diff --git a/frontend/components/basic/Toggle.tsx b/frontend/components/basic/Toggle.tsx new file mode 100644 index 000000000..fa69e4419 --- /dev/null +++ b/frontend/components/basic/Toggle.tsx @@ -0,0 +1,81 @@ +import React from "react"; +import { Switch } from "@headlessui/react"; + + +interface OverrideProps { + id: string; + keyName: string; + value: string; + pos: number; +} + +interface ToggleProps { + enabled: boolean; + setEnabled: (value: boolean) => void; + addOverride: (value: OverrideProps) => void; + keyName: string; + value: string; + pos: number; + id: string; + deleteOverride: (id: string) => void; + sharedToHide: string[]; + setSharedToHide: (values: string[]) => void; +} + +/** + * This is a typical 'iPhone' toggle (e.g., user for overriding secrets with personal values) + * @param obj + * @param {boolean} obj.enabled - whether the toggle is turned on or off + * @param {function} obj.setEnabled - change the state of the toggle + * @param {function} obj.addOverride - a function that adds an override to a certain secret + * @param {string} obj.keyName - key of a certain secret + * @param {string} obj.value - value of a certain secret + * @param {number} obj.pos - position of a certain secret + #TODO: make the secret id persistent? + * @param {string} obj.id - id of a certain secret + * @param {function} obj.deleteOverride - a function that deleted an override for a certain secret + * @param {string[]} obj.sharedToHide - an array of shared secrets that we want to hide visually because they are overriden. + * @param {function} obj.setSharedToHide - a function that updates the array of secrets that we want to hide visually + * @returns + */ +export default function Toggle ({ + enabled, + setEnabled, + addOverride, + keyName, + value, + pos, + id, + deleteOverride, + sharedToHide, + setSharedToHide +}: ToggleProps): JSX.Element { + return ( + { + if (enabled == false) { + addOverride({ id, keyName, value, pos }); + setSharedToHide([ + ...sharedToHide!, + id + ]) + } else { + setSharedToHide(sharedToHide!.filter(tempId => tempId != id)) + deleteOverride(id); + } + setEnabled(!enabled); + }} + className={`${ + enabled ? 'bg-primary' : 'bg-bunker-400' + } relative inline-flex h-5 w-9 items-center rounded-full`} + > + Enable notifications + + + ) +} diff --git a/frontend/components/basic/buttons/Button.tsx b/frontend/components/basic/buttons/Button.tsx index 81672adc1..9197ccf13 100644 --- a/frontend/components/basic/buttons/Button.tsx +++ b/frontend/components/basic/buttons/Button.tsx @@ -16,7 +16,7 @@ type ButtonProps = { size: string; icon?: IconProp; active?: boolean; - iconDisabled?: string; + iconDisabled?: IconProp; textDisabled?: string; type?: ButtonHTMLAttributes['type']; }; @@ -73,15 +73,16 @@ export default function Button(props: ButtonProps): JSX.Element { // Setting the text color for the text and icon props.color == "mineshaft" && "text-gray-400", - props.color != "mineshaft" && props.color != "red" && "text-black", + props.color != "mineshaft" && props.color != "red" && props.color != "none" && "text-black", props.color == "red" && "text-gray-200", - activityStatus && props.color != "red" ? "group-hover:text-black" : "", + props.color == "none" && "text-gray-200 text-xl", + activityStatus && props.color != "red" && props.color != "none" ? "group-hover:text-black" : "", props.size == "icon" && "flex items-center justify-center" ); const textStyle = classNames( - "relative duration-200", + "relative duration-200 text-center w-full", // Show the loading sign if the loading indicator is on props.loading ? "opacity-0" : "opacity-100", diff --git a/frontend/components/basic/popups/BottomRightPopup.js b/frontend/components/basic/popups/BottomRightPopup.tsx similarity index 71% rename from frontend/components/basic/popups/BottomRightPopup.js rename to frontend/components/basic/popups/BottomRightPopup.tsx index 85aaba725..e6ea60f92 100644 --- a/frontend/components/basic/popups/BottomRightPopup.js +++ b/frontend/components/basic/popups/BottomRightPopup.tsx @@ -3,6 +3,16 @@ import { faXmark } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +interface PopupProps { + buttonText: string; + buttonLink: string; + titleText: string; + emoji: string; + textLine1: string; + textLine2: string; + setCheckDocsPopUpVisible: (value: boolean) => void; +} + /** * This is the notification that pops up at the bottom right when a user performs a certain action * @param {object} org @@ -23,16 +33,16 @@ export default function BottonRightPopup({ textLine1, textLine2, setCheckDocsPopUpVisible, -}) { +}: PopupProps): JSX.Element { return (