[Refactor] Move to src-ui/views and src-ui/logics structure.
This commit is contained in:
52
src-ui/views/common_components/checkbox/Checkbox.jsx
Normal file
52
src-ui/views/common_components/checkbox/Checkbox.jsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import clsx from "clsx";
|
||||
import styles from "./Checkbox.module.scss";
|
||||
export const Checkbox = ({
|
||||
checkboxId,
|
||||
variable,
|
||||
is_available = true,
|
||||
toggleFunction,
|
||||
size = "2.8rem",
|
||||
borderWidth = "0.2rem",
|
||||
padding = "2rem",
|
||||
}) => {
|
||||
|
||||
const wrapper_class_names = clsx(styles.checkbox_wrapper, {
|
||||
[styles.is_disabled]: !is_available,
|
||||
[styles.is_pending]: variable.state === "pending",
|
||||
});
|
||||
|
||||
return (
|
||||
<div className={styles.checkbox_container}>
|
||||
<label
|
||||
className={wrapper_class_names}
|
||||
htmlFor={checkboxId}
|
||||
style={{
|
||||
"--checkbox-size": size,
|
||||
"--checkbox-border-width": borderWidth,
|
||||
"--checkbox-padding": padding,
|
||||
}}
|
||||
>
|
||||
{variable.state === "pending" ? (
|
||||
<span className={styles.loader}></span>
|
||||
) : (
|
||||
<input
|
||||
type="checkbox"
|
||||
id={checkboxId}
|
||||
checked={variable.data}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onChange={() => {
|
||||
if (toggleFunction) {
|
||||
toggleFunction();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<span className={styles.cbx}>
|
||||
<svg viewBox="0 0 12 12">
|
||||
<polyline points="1 6.29411765 4.5 10 11 1"></polyline>
|
||||
</svg>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
73
src-ui/views/common_components/checkbox/Checkbox.module.scss
Normal file
73
src-ui/views/common_components/checkbox/Checkbox.module.scss
Normal file
@@ -0,0 +1,73 @@
|
||||
@import "@scss_mixins";
|
||||
|
||||
.checkbox_container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: end;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.checkbox_wrapper {
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
padding: var(--checkbox-padding, 2rem);
|
||||
position: relative;
|
||||
|
||||
&:hover {
|
||||
& .cbx {
|
||||
border: var(--checkbox-color, var(--primary_600_color)) solid var(--checkbox-border-width, 0.2rem);
|
||||
}
|
||||
}
|
||||
&.is_pending {
|
||||
pointer-events: none;
|
||||
& .cbx {
|
||||
border-color: var(--primary_800_color);
|
||||
}
|
||||
}
|
||||
&.is_disabled {
|
||||
pointer-events: none;
|
||||
& .cbx {
|
||||
filter: grayscale(100%);
|
||||
border-color: var(--dark_800_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.checkbox_wrapper .cbx {
|
||||
display: block;
|
||||
width: var(--checkbox-size, 2.8rem);
|
||||
height: var(--checkbox-size, 2.8rem);
|
||||
border-radius: 0.4rem;
|
||||
border: var(--dark_700_color) solid var(--checkbox-border-width, 0.2rem);
|
||||
transition: all 0.15s ease;
|
||||
padding: calc(var(--checkbox-size, 2.8rem) / 7);
|
||||
}
|
||||
|
||||
.checkbox_wrapper .cbx svg {
|
||||
fill: none;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
stroke: var(--dark_basic_text_color);
|
||||
stroke-width: calc(var(--checkbox-border-width, 0.2rem) / 2);
|
||||
stroke-dasharray: 1.7rem;
|
||||
stroke-dashoffset: 1.7rem;
|
||||
}
|
||||
|
||||
.checkbox_wrapper input[type="checkbox"] {
|
||||
display: none;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.checkbox_wrapper input[type="checkbox"]:checked + .cbx {
|
||||
background-color: var(--checkbox-color, var(--primary_600_color));
|
||||
border: none;
|
||||
}
|
||||
|
||||
.checkbox_wrapper input[type="checkbox"]:checked + .cbx svg {
|
||||
stroke-dashoffset: 0;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
.loader {
|
||||
@include loader(2rem, 0.2rem, right, -2rem);
|
||||
}
|
||||
Reference in New Issue
Block a user