From 0eec985a6288512f349774be866d507728093710 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:38:09 +0900 Subject: [PATCH] [bugfix/Refactor] Checkbox Component. Fix to disabled when it's loading(it was clickable continuously) --- .../_components/checkbox/Checkbox.jsx | 24 -------- .../_components/checkbox/Checkbox.module.scss | 60 ------------------- .../setting_box/_components/index.js | 1 - .../setting_box/_templates/Templates.jsx | 2 +- .../setting_box/others/Others.jsx | 2 +- .../common_components/checkbox/Checkbox.jsx | 11 ++-- .../checkbox/Checkbox.module.scss | 6 ++ 7 files changed, 15 insertions(+), 91 deletions(-) delete mode 100644 src-ui/app/config_page/setting_section/setting_box/_components/checkbox/Checkbox.jsx delete mode 100644 src-ui/app/config_page/setting_section/setting_box/_components/checkbox/Checkbox.module.scss diff --git a/src-ui/app/config_page/setting_section/setting_box/_components/checkbox/Checkbox.jsx b/src-ui/app/config_page/setting_section/setting_box/_components/checkbox/Checkbox.jsx deleted file mode 100644 index 752597f5..00000000 --- a/src-ui/app/config_page/setting_section/setting_box/_components/checkbox/Checkbox.jsx +++ /dev/null @@ -1,24 +0,0 @@ -import styles from "./Checkbox.module.scss"; - -export const Checkbox = (props) => { - return ( -
- -
- ); -}; diff --git a/src-ui/app/config_page/setting_section/setting_box/_components/checkbox/Checkbox.module.scss b/src-ui/app/config_page/setting_section/setting_box/_components/checkbox/Checkbox.module.scss deleted file mode 100644 index a4364962..00000000 --- a/src-ui/app/config_page/setting_section/setting_box/_components/checkbox/Checkbox.module.scss +++ /dev/null @@ -1,60 +0,0 @@ -@import "@scss_mixins"; - -.checkbox_container { - // width: 100%; - height: 100%; - display: flex; - justify-content: end; - align-items: center; -} - -.checkbox_wrapper { - display: inline-block; - cursor: pointer; - padding: 2rem; - position: relative; - &:hover { - & .cbx { - border: var(--primary_600_color) solid 0.2rem; - } - } -} - -.checkbox_wrapper .cbx { - display: block; - width: 2.8rem; - height: 2.8rem; - border-radius: 0.4rem; - border: var(--dark_700_color) solid 0.2rem; - transition: all 0.15s ease; - padding: 0.4rem; -} - -.checkbox_wrapper .cbx svg { - fill: none; - stroke-linecap: round; - stroke-linejoin: round; - stroke: var(--dark_basic_text_color); - stroke-width: 0.2rem; - 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(--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); -} \ No newline at end of file diff --git a/src-ui/app/config_page/setting_section/setting_box/_components/index.js b/src-ui/app/config_page/setting_section/setting_box/_components/index.js index d702c1ee..7ead1049 100644 --- a/src-ui/app/config_page/setting_section/setting_box/_components/index.js +++ b/src-ui/app/config_page/setting_section/setting_box/_components/index.js @@ -1,5 +1,4 @@ export { ActionButton } from "./action_button/ActionButton"; -export { Checkbox } from "./checkbox/Checkbox"; export { DeeplAuthKey, OpenWebpage_DeeplAuthKey } from "./deepl_auth_key/DeeplAuthKey"; export { DropdownMenu } from "./dropdown_menu/DropdownMenu"; export { Entry } from "./entry/Entry"; diff --git a/src-ui/app/config_page/setting_section/setting_box/_templates/Templates.jsx b/src-ui/app/config_page/setting_section/setting_box/_templates/Templates.jsx index 7051ee17..96e42d30 100644 --- a/src-ui/app/config_page/setting_section/setting_box/_templates/Templates.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/_templates/Templates.jsx @@ -6,7 +6,6 @@ import { LabelComponent, DropdownMenu, Slider, - Checkbox, SwitchBox, Entry, RadioButton, @@ -17,6 +16,7 @@ import { WordFilterListToggleComponent, DownloadModels, } from "../_components/"; +import { Checkbox } from "@common_components"; const LabeledContainer = ({ children, label, desc, custom_class_name }) => (
diff --git a/src-ui/app/config_page/setting_section/setting_box/others/Others.jsx b/src-ui/app/config_page/setting_section/setting_box/others/Others.jsx index ed3e88fd..f1e9a251 100644 --- a/src-ui/app/config_page/setting_section/setting_box/others/Others.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/others/Others.jsx @@ -17,10 +17,10 @@ import { import { LabelComponent, - Checkbox, ActionButton, SectionLabelComponent, } from "../_components/"; +import { Checkbox } from "@common_components"; import OpenFolderSvg from "@images/open_folder.svg?react"; diff --git a/src-ui/common_components/checkbox/Checkbox.jsx b/src-ui/common_components/checkbox/Checkbox.jsx index ac291f65..b9cdd7d3 100644 --- a/src-ui/common_components/checkbox/Checkbox.jsx +++ b/src-ui/common_components/checkbox/Checkbox.jsx @@ -1,20 +1,23 @@ +import { clsx } from "clsx"; import styles from "./Checkbox.module.scss"; - export const Checkbox = ({ checkboxId, variable, toggleFunction, - state = "idle", size = "2.8rem", color = "var(--primary_600_color)", borderWidth = "0.2rem", padding = "2rem", }) => { + const wrapper_class_names = clsx(styles.checkbox_wrapper, { + [styles.is_disabled]: variable.state === "pending", + }); + return (