diff --git a/src/components/UserCheckBoxes/UserCheckBoxes.css b/src/components/UserCheckBoxes/UserCheckBoxes.css deleted file mode 100644 index 980c0fe3..00000000 --- a/src/components/UserCheckBoxes/UserCheckBoxes.css +++ /dev/null @@ -1,113 +0,0 @@ -/* Checkbox Container */ - -.rcb-checkbox-container { - display: flex; - flex-direction: column; - padding-top: 12px; - margin-left: 16px; - flex-wrap: wrap; - gap: 10px; -} - -.rcb-checkbox-offset { - margin-left: 50px; -} - -/* Checkbox Row Container */ - -.rcb-checkbox-row-container { - display: flex; - align-items: center; - gap: 5px; - border-width: 0.5px; - border-style: solid; - border-radius: 10px; - min-height: 30px; - max-height: 32px; - width: 80%; - cursor: pointer; - background-color: #fff; - animation: checkboxes-entry 0.5s ease-out -} - -.rcb-checkbox-row-container:hover { - box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); -} - -@keyframes checkboxes-entry { - 0% { - transform: translateX(-100%); - opacity: 0; - } - 100% { - transform: translateX(0); - opacity: 1; - } -} - -/* Checkbox Row */ - -.rcb-checkbox-row { - display: inline-flex; - margin-left: 10px; - align-items: center; - cursor: pointer; -} - -/* Checkbox Mark */ - -.rcb-checkbox-mark { - width: 20px; - height: 20px; - background-color: #f2f2f2; - border-radius: 50%; - border: none; - display: flex; - align-items: center; - justify-content: center; - transition: all 0.3s ease; - margin-right: 10px; - cursor: pointer; -} - -.rcb-checkbox-mark:hover { - background-color: #c2c2c2; -} - -.rcb-checkbox-mark:before { - content: "\2713"; - transition: all 0.3s ease; -} - -/* Checkbox Label */ - -.rcb-checkbox-label { - font-size: 14px; - text-overflow: ellipsis; -} - -/* Checkbox Next Button */ - -.rcb-checkbox-next-button { - text-align: center; - display: inline-block; - align-items: center; - border-width: 0.5px; - border-style: solid; - border-radius: 10px; - font-size: 24px; - min-height: 30px; - max-height: 32px; - width: 80%; - cursor: pointer; - background-color: #fff; - animation: checkboxes-entry 0.5s ease-out; -} - -.rcb-checkbox-next-button::before { - content: "\2192"; -} - -.rcb-checkbox-next-button:hover { - box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); -} \ No newline at end of file diff --git a/src/components/UserCheckBoxes/UserCheckBoxes.tsx b/src/components/UserCheckBoxes/UserCheckBoxes.tsx deleted file mode 100644 index 82de2e1d..00000000 --- a/src/components/UserCheckBoxes/UserCheckBoxes.tsx +++ /dev/null @@ -1,142 +0,0 @@ - -import { useEffect, useState, MouseEvent } from "react"; - -import { useBotOptions } from "../../context/BotOptionsContext"; -import { usePaths } from "../../context/PathsContext"; - -import "./UserCheckboxes.css"; - -/** - * Supports showing of checkboxes for user to mark. - * - * @param checkboxes object representing checkboxes to show and min/max number of selections - * @param checkedItems set representing items marked - * @param path path associated with the current block - * @param handleActionInput handles input (marked checkboxes) from user - */ -const UserCheckboxes = ({ - checkboxes, - checkedItems, - path, - handleActionInput, -}: { - checkboxes: {items: Array, max?: number, min?: number}; - checkedItems: Set; - path: string; - handleActionInput: (path: string, userInput: string, sendUserInput: boolean) => void; -}) => { - - // handles options for bot - const { botOptions } = useBotOptions() - - // handles paths of the user - const { paths } = usePaths(); - - // tracks which checkboxes have been marked - const [checkedBoxes, setCheckedBoxes] = useState>(new Set()); - - // handles state of checkboxes - const [disabled, setDisabled] = useState(false); - - // styles for bot checkbox row items - const botCheckboxRowStyle = { - cursor: disabled ? `url(${botOptions.theme?.actionDisabledIcon}), auto` : "pointer", - color: botOptions.theme?.primaryColor, - borderColor: botOptions.theme?.primaryColor, - ...botOptions.botCheckboxRowStyle - }; - - // styles for bot checkbox next button - const botCheckboxNextStyle = { - cursor: disabled || checkedBoxes.size < (checkboxes.min as number) - ? `url(${botOptions.theme?.actionDisabledIcon}), auto` : "pointer", - color: botOptions.theme?.primaryColor, - borderColor: botOptions.theme?.primaryColor, - ...botOptions.botCheckboxNextStyle - }; - - // styles for bot checkmark - const botCheckMarkStyle = { - cursor: disabled ? `url(${botOptions.theme?.actionDisabledIcon}), auto` : "pointer", - color: "transparent", - ...botOptions.botCheckMarkStyle - }; - - // styles for bot selected checkmark - const botCheckMarkSelectedStyle = { - cursor: disabled ? `url(${botOptions.theme?.actionDisabledIcon}), auto` : "pointer", - color: "#fff", - borderColor: botOptions.theme?.primaryColor, - backgroundColor: botOptions.theme?.primaryColor, - ...botOptions.botCheckMarkSelectedStyle - }; - - // disables checkboxes when moving on from current path - useEffect(() => { - if (paths.length > 0 && paths[paths.length - 1] !== path) { - setDisabled(true); - } - }, [paths]); - - // handles marking/unmarking of checkboxes - const handleCheckItems = (label: string) => { - if (disabled) { - return; - } - - setCheckedBoxes((prevCheckedBoxes) => { - const updatedCheckboxes = new Set(prevCheckedBoxes); - if (updatedCheckboxes.has(label)) { - checkedItems.delete(label); - updatedCheckboxes.delete(label); - } else { - if (checkedBoxes.size == checkboxes.max) { - return prevCheckedBoxes; - } - checkedItems.add(label); - updatedCheckboxes.add(label); - } - return updatedCheckboxes; - }); - }; - - return ( -
- {checkboxes.items.map((key) => { - - return ( -
{ - event.preventDefault(); - handleCheckItems(key) - }} - style={botCheckboxRowStyle} - key={key} - className="rcb-checkbox-row-container" - > -
-
-
{key}
-
-
- ); - })} - -
- ); -}; - -export default UserCheckboxes; \ No newline at end of file