From ef774b44f29859621859161151d2a13efa9a64c4 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Feb 2026 18:10:43 +0000 Subject: [PATCH] remove v1 theme and components --- client/src/App.tsx | 8 +- client/src/Components/v1/ArrowRight/index.jsx | 29 - .../src/Components/v1/Breadcrumbs/index.css | 21 - .../src/Components/v1/Breadcrumbs/index.jsx | 78 -- client/src/Components/v1/ConfigBox/index.jsx | 39 - .../Components/v1/Dialog/genericDialog.jsx | 73 -- client/src/Components/v1/Dialog/index.jsx | 63 -- client/src/Components/v1/Icon/iconMap.js | 120 --- client/src/Components/v1/Icon/index.jsx | 198 ----- .../Components/v1/Inputs/Checkbox/index.jsx | 116 --- .../v1/Inputs/ColorPicker/index.jsx | 63 -- .../v1/Inputs/FieldWrapper/index.jsx | 51 -- .../v1/Inputs/ImageUpload/index.jsx | 249 ------ .../src/Components/v1/Inputs/Radio/index.css | 0 .../src/Components/v1/Inputs/Radio/index.jsx | 117 --- .../src/Components/v1/Inputs/Search/index.jsx | 315 ------- .../src/Components/v1/Inputs/Select/index.css | 7 - .../src/Components/v1/Inputs/Select/index.jsx | 213 ----- .../v1/Inputs/TextInput/Adornments/index.jsx | 74 -- .../Components/v1/Inputs/TextInput/index.jsx | 181 ---- client/src/Components/v1/Link/index.jsx | 73 -- client/src/Components/v1/Link/link.css | 0 client/src/Components/v1/TextLink/index.jsx | 38 - client/src/Components/v1/Toast/body.jsx | 34 - client/src/Components/v1/Toast/index.jsx | 114 --- .../v2/design-elements/Fallback.tsx | 7 +- .../v2/design-elements/MonitorStatus.tsx | 3 +- .../Components/v2/design-elements/StatBox.tsx | 2 +- .../src/Components/v2/inputs/ColorPicker.tsx | 2 +- client/src/Components/v2/inputs/Dialog.tsx | 2 +- client/src/Components/v2/inputs/TextInput.tsx | 2 +- client/src/Components/v2/layout/AppLayout.tsx | 1 - client/src/Utils/MonitorUtils.ts | 2 +- .../Utils/Theme/{v2Palette.ts => Palette.ts} | 0 .../src/Utils/Theme/{v2Theme.ts => Theme.ts} | 2 +- client/src/Utils/Theme/constants.js | 291 ------- client/src/Utils/Theme/darkTheme.js | 13 - client/src/Utils/Theme/extractColorObject.js | 25 - client/src/Utils/Theme/globalTheme.js | 793 ------------------ client/src/Utils/Theme/lightTheme.js | 12 - 40 files changed, 12 insertions(+), 3419 deletions(-) delete mode 100644 client/src/Components/v1/ArrowRight/index.jsx delete mode 100644 client/src/Components/v1/Breadcrumbs/index.css delete mode 100644 client/src/Components/v1/Breadcrumbs/index.jsx delete mode 100644 client/src/Components/v1/ConfigBox/index.jsx delete mode 100644 client/src/Components/v1/Dialog/genericDialog.jsx delete mode 100644 client/src/Components/v1/Dialog/index.jsx delete mode 100644 client/src/Components/v1/Icon/iconMap.js delete mode 100644 client/src/Components/v1/Icon/index.jsx delete mode 100644 client/src/Components/v1/Inputs/Checkbox/index.jsx delete mode 100644 client/src/Components/v1/Inputs/ColorPicker/index.jsx delete mode 100644 client/src/Components/v1/Inputs/FieldWrapper/index.jsx delete mode 100644 client/src/Components/v1/Inputs/ImageUpload/index.jsx delete mode 100644 client/src/Components/v1/Inputs/Radio/index.css delete mode 100644 client/src/Components/v1/Inputs/Radio/index.jsx delete mode 100644 client/src/Components/v1/Inputs/Search/index.jsx delete mode 100644 client/src/Components/v1/Inputs/Select/index.css delete mode 100644 client/src/Components/v1/Inputs/Select/index.jsx delete mode 100644 client/src/Components/v1/Inputs/TextInput/Adornments/index.jsx delete mode 100644 client/src/Components/v1/Inputs/TextInput/index.jsx delete mode 100644 client/src/Components/v1/Link/index.jsx delete mode 100644 client/src/Components/v1/Link/link.css delete mode 100644 client/src/Components/v1/TextLink/index.jsx delete mode 100644 client/src/Components/v1/Toast/body.jsx delete mode 100644 client/src/Components/v1/Toast/index.jsx rename client/src/Utils/Theme/{v2Palette.ts => Palette.ts} (100%) rename client/src/Utils/Theme/{v2Theme.ts => Theme.ts} (99%) delete mode 100644 client/src/Utils/Theme/constants.js delete mode 100644 client/src/Utils/Theme/darkTheme.js delete mode 100644 client/src/Utils/Theme/extractColorObject.js delete mode 100644 client/src/Utils/Theme/globalTheme.js delete mode 100644 client/src/Utils/Theme/lightTheme.js diff --git a/client/src/App.tsx b/client/src/App.tsx index cbf8ecb3d..148978521 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -7,19 +7,19 @@ import { CssBaseline, GlobalStyles } from "@mui/material"; import { Routes } from "./Routes"; import AppLayout from "@/Components/v2/layout/AppLayout"; import type { RootState } from "@/Types/state"; -import { lightTheme, darkTheme } from "@/Utils/Theme/v2Theme"; +import { lightTheme, darkTheme } from "@/Utils/Theme/Theme"; function App() { const mode = useSelector((state: RootState) => state.ui.mode); - const v2theme = mode === "light" ? lightTheme : darkTheme; + const theme = mode === "light" ? lightTheme : darkTheme; return ( - + diff --git a/client/src/Components/v1/ArrowRight/index.jsx b/client/src/Components/v1/ArrowRight/index.jsx deleted file mode 100644 index 3ae64a580..000000000 --- a/client/src/Components/v1/ArrowRight/index.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import Icon from "../Icon"; -import PropTypes from "prop-types"; - -const ArrowRight = ({ type, color = "#667085", ...props }) => { - if (type === "double") { - return ( - - ); - } else { - return ( - - ); - } -}; - -ArrowRight.propTypes = { - type: PropTypes.oneOf(["double", "default"]), - color: PropTypes.string, -}; - -export default ArrowRight; diff --git a/client/src/Components/v1/Breadcrumbs/index.css b/client/src/Components/v1/Breadcrumbs/index.css deleted file mode 100644 index 022db9a83..000000000 --- a/client/src/Components/v1/Breadcrumbs/index.css +++ /dev/null @@ -1,21 +0,0 @@ -.MuiBreadcrumbs-root { - min-height: 34px; -} -.MuiBreadcrumbs-root svg { - width: 16px; - min-height: 16px; -} -.MuiBreadcrumbs-root .MuiBreadcrumbs-li a { - font-weight: 400; -} -.MuiBreadcrumbs-root .MuiBreadcrumbs-li:not(:last-child) { - cursor: pointer; -} -.MuiBreadcrumbs-root .MuiBreadcrumbs-li:last-child a { - font-weight: 500; - opacity: 1; - cursor: default; -} -.MuiBreadcrumbs-root .MuiBreadcrumbs-separator { - margin: 0; -} diff --git a/client/src/Components/v1/Breadcrumbs/index.jsx b/client/src/Components/v1/Breadcrumbs/index.jsx deleted file mode 100644 index 34e5d5e95..000000000 --- a/client/src/Components/v1/Breadcrumbs/index.jsx +++ /dev/null @@ -1,78 +0,0 @@ -import PropTypes from "prop-types"; -import { Box, Breadcrumbs as MUIBreadcrumbs } from "@mui/material"; -import { useTheme } from "@emotion/react"; -import { useNavigate } from "react-router-dom"; -import ArrowRight from "../ArrowRight/index.jsx"; -import "./index.css"; - -/** - * Breadcrumbs component that displays a list of breadcrumb items. - * - * @param {Object} props - * @param {Array} props.list - Array of breadcrumb items. Each item should have `name` and `path` properties. - * @param {string} props.list.name - The name to display for the breadcrumb. - * @param {string} props.list.path - The path to navigate to when the breadcrumb is clicked. - * - * @returns {JSX.Element} The rendered Breadcrumbs component. - */ - -const Breadcrumbs = ({ list }) => { - const theme = useTheme(); - const navigate = useNavigate(); - - return ( - } - aria-label="breadcrumb" - px={theme.spacing(2)} - py={theme.spacing(3.5)} - width="fit-content" - backgroundColor={theme.palette.secondary.main} - borderRadius={theme.shape.borderRadius} - lineHeight="18px" - sx={{ - "& .MuiBreadcrumbs-li a": { - transition: "background-color 0.2s ease-in-out, color 0.2s ease-in-out", - }, - "& .MuiBreadcrumbs-li:not(:last-of-type):hover a": { - backgroundColor: theme.palette.secondary.contrastText, - color: theme.palette.secondary.main, - }, - }} - > - {list.map((item, index) => { - return ( - navigate(item.path)} - sx={{ - opacity: 0.8, - textTransform: "capitalize", - "&, &:hover": { - color: theme.palette.secondary.contrastText, - }, - }} - > - {item.name} - - ); - })} - - ); -}; - -Breadcrumbs.propTypes = { - list: PropTypes.arrayOf( - PropTypes.shape({ - name: PropTypes.string.isRequired, - path: PropTypes.string.isRequired, - }).isRequired - ).isRequired, -}; - -export default Breadcrumbs; diff --git a/client/src/Components/v1/ConfigBox/index.jsx b/client/src/Components/v1/ConfigBox/index.jsx deleted file mode 100644 index 01b35729e..000000000 --- a/client/src/Components/v1/ConfigBox/index.jsx +++ /dev/null @@ -1,39 +0,0 @@ -import { Stack, styled } from "@mui/material"; - -const ConfigBox = styled(Stack)(({ theme }) => ({ - display: "flex", - flexDirection: "row", - justifyContent: "space-between", - backgroundColor: theme.palette.primary.main, - border: 1, - borderStyle: "solid", - borderColor: theme.palette.primary.lowContrast, - borderRadius: theme.spacing(2), - "& > *": { - paddingTop: theme.spacing(15), - paddingBottom: theme.spacing(15), - }, - "& > div:first-of-type": { - flex: 0.7, - borderRight: 1, - borderRightStyle: "solid", - borderRightColor: theme.palette.primary.lowContrast, - paddingRight: theme.spacing(15), - paddingLeft: theme.spacing(15), - backgroundColor: theme.palette.tertiary.background, - "& :is(h1, h2):first-of-type": { - fontWeight: 600, - marginBottom: theme.spacing(4), - }, - }, - "& > div:last-of-type": { - flex: 1, - paddingRight: theme.spacing(20), - paddingLeft: theme.spacing(20), - }, - "& h1, & h2": { - color: theme.palette.primary.contrastTextSecondary, - }, -})); - -export default ConfigBox; diff --git a/client/src/Components/v1/Dialog/genericDialog.jsx b/client/src/Components/v1/Dialog/genericDialog.jsx deleted file mode 100644 index a13eba849..000000000 --- a/client/src/Components/v1/Dialog/genericDialog.jsx +++ /dev/null @@ -1,73 +0,0 @@ -import { useId } from "react"; -import PropTypes from "prop-types"; -import { Modal, Stack, Typography } from "@mui/material"; - -const GenericDialog = ({ title, description, open, onClose, theme, children, width }) => { - const titleId = useId(); - const descriptionId = useId(); - const ariaDescribedBy = description?.length > 0 ? descriptionId : ""; - return ( - e.stopPropagation()} - > - - - {title} - - {description && ( - - {description} - - )} - {children} - - - ); -}; - -GenericDialog.propTypes = { - title: PropTypes.string.isRequired, - description: PropTypes.string, - open: PropTypes.bool.isRequired, - onClose: PropTypes.func.isRequired, - theme: PropTypes.object.isRequired, - children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]) - .isRequired, - width: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]), -}; - -export { GenericDialog }; diff --git a/client/src/Components/v1/Dialog/index.jsx b/client/src/Components/v1/Dialog/index.jsx deleted file mode 100644 index b8cf07439..000000000 --- a/client/src/Components/v1/Dialog/index.jsx +++ /dev/null @@ -1,63 +0,0 @@ -import PropTypes from "prop-types"; -import { Button, Stack } from "@mui/material"; -import { GenericDialog } from "./genericDialog.jsx"; -import { useTheme } from "@emotion/react"; -import { useTranslation } from "react-i18next"; - -const Dialog = ({ - title, - description, - open, - onCancel, - confirmationButtonLabel, - onConfirm, - isLoading, -}) => { - const theme = useTheme(); - const { t } = useTranslation(); - - return ( - - - - - - - ); -}; - -Dialog.propTypes = { - title: PropTypes.string.isRequired, - description: PropTypes.string, - open: PropTypes.bool.isRequired, - onCancel: PropTypes.func.isRequired, - confirmationButtonLabel: PropTypes.string.isRequired, - onConfirm: PropTypes.func.isRequired, - isLoading: PropTypes.bool, -}; - -export default Dialog; diff --git a/client/src/Components/v1/Icon/iconMap.js b/client/src/Components/v1/Icon/iconMap.js deleted file mode 100644 index 58da7304b..000000000 --- a/client/src/Components/v1/Icon/iconMap.js +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Maps legacy icon names to Lucide icon names - * Use: import { iconMap } from './iconMap'; LucideIcons[iconMap['monitors']] - */ -export const iconMap = { - // Navigation/Sidebar icons - monitors: "Globe", - incidents: "AlertTriangle", - integrations: "Link", - "page-speed": "Gauge", - settings: "Settings", - notifications: "Bell", - maintenance: "Wrench", - "status-pages": "Wifi", - docs: "FileText", - discussions: "MessageCircle", - support: "HelpCircle", - changeLog: "Code", - logs: "Database", - - // User icons - user: "User", - "user-two": "Users", - "user-edit": "UserPen", - groups: "Users", - lock: "Lock", - key: "Key", - logout: "LogOut", - - // Action icons - edit: "Pencil", - "trash-bin": "Trash2", - search: "Search", - "close-icon": "X", - check: "Check", - "check-icon": "CheckCircle", - "check-outlined": "CheckCircle", - - // Arrow icons - "left-arrow": "ChevronLeft", - "right-arrow": "ChevronRight", - "up-arrow": "ChevronUp", - "down-arrow": "ChevronDown", - "left-arrow-double": "ChevronsLeft", - "right-arrow-double": "ChevronsRight", - "left-arrow-long": "ArrowLeft", - "top-right-arrow": "ArrowUpRight", - "open-in-new-page": "ExternalLink", - "selector-vertical": "ChevronsUpDown", - - // Status/Alert icons - "alert-icon": "Bell", - "warning-icon": "AlertCircle", - "history-icon": "History", - - // Data/Chart icons - dashboard: "LayoutGrid", - "monitor-graph-line": "TrendingUp", - "response-time-icon": "TrendingUp", - "uptime-icon": "Activity", - "speedometer-icon": "Gauge", - "spedometer-icon": "Gauge", - "ruler-icon": "Ruler", - "performance-report": "Layers", - "average-response-icon": "BarChart3", - "distributed-uptime": "Network", - - // Misc icons - calendar: "Calendar", - "calendar-check": "CalendarCheck", - "clock-snooze": "Clock", - mail: "Mail", - email: "Mail", - folder: "Folder", - "dots-vertical": "MoreVertical", - "pause-icon": "PauseCircle", - "resume-icon": "PlayCircle", - "checkbox-filled": "CheckSquare", - "checkbox-outline": "Square", - "radio-checked": "Circle", - "cpu-chip": "Cpu", - certificate: "Award", - "interval-check": "RefreshCw", -}; - -/** - * MUI icon to Lucide mapping - */ -export const muiToLucideMap = { - AddCircleOutline: "PlusCircle", - ArrowDownwardRounded: "ArrowDown", - ArrowUpwardRounded: "ArrowUp", - ArrowDropDown: "ChevronDown", - ArrowOutward: "ExternalLink", - CheckCircle: "CheckCircle2", - Clear: "X", - Close: "X", - CloseRounded: "X", - CloudUpload: "Upload", - Delete: "Trash2", - DeleteOutlineRounded: "Trash2", - Email: "Mail", - ErrorOutline: "AlertTriangle", - ErrorOutlineOutlined: "AlertTriangle", - Image: "ImageIcon", - InfoOutlined: "Info", - KeyboardArrowDown: "ChevronDown", - Menu: "Menu", - PauseCircleOutline: "PauseCircle", - PauseOutlined: "Pause", - PlayArrowOutlined: "Play", - PlayCircleOutlineRounded: "PlayCircle", - RadioButtonChecked: "Circle", - ReorderRounded: "GripVertical", - SettingsOutlined: "Settings", - Share: "Share2", - Visibility: "Eye", - VisibilityOff: "EyeOff", - WarningAmberOutlined: "AlertTriangle", -}; diff --git a/client/src/Components/v1/Icon/index.jsx b/client/src/Components/v1/Icon/index.jsx deleted file mode 100644 index 9f7c61585..000000000 --- a/client/src/Components/v1/Icon/index.jsx +++ /dev/null @@ -1,198 +0,0 @@ -import { useTheme } from "@mui/material"; -import PropTypes from "prop-types"; -import { - Activity, - AlertCircle, - AlertTriangle, - ArrowDown, - ArrowLeft, - ArrowUp, - ArrowUpRight, - Bell, - Calendar, - Check, - CheckCircle, - CheckCircle2, - CheckSquare, - ChevronDown, - ChevronLeft, - ChevronRight, - ChevronsLeft, - ChevronsRight, - ChevronsUpDown, - Circle, - CircleDot, - Clock, - Code, - Cpu, - Database, - ExternalLink, - Eye, - EyeOff, - FileText, - Gauge, - Globe, - GripVertical, - HelpCircle, - History, - Image as ImageIcon, - Info, - Key, - Layers, - Link, - Lock, - LogOut, - Mail, - Menu, - MessageCircle, - MoreVertical, - Pause, - PauseCircle, - Play, - PlayCircle, - PlusCircle, - RefreshCw, - Ruler, - Search, - Settings, - Square, - Trash2, - TrendingUp, - Upload, - User, - Users, - Wifi, - Wrench, - X, -} from "lucide-react"; - -/** - * Map of icon names to Lucide icon components. - * Only icons explicitly imported here will be included in the bundle (tree-shaking). - * To add a new icon: import it above and add it to this object. - */ -const iconComponents = { - Activity, - AlertCircle, - AlertTriangle, - ArrowDown, - ArrowLeft, - ArrowUp, - ArrowUpRight, - Bell, - Calendar, - Check, - CheckCircle, - CheckCircle2, - CheckSquare, - ChevronDown, - ChevronLeft, - ChevronRight, - ChevronsLeft, - ChevronsRight, - ChevronsUpDown, - Circle, - CircleDot, - Clock, - Code, - Cpu, - Database, - ExternalLink, - Eye, - EyeOff, - FileText, - Gauge, - Globe, - GripVertical, - HelpCircle, - History, - Image: ImageIcon, - Info, - Key, - Layers, - Link, - Lock, - LogOut, - Mail, - Menu, - MessageCircle, - MoreVertical, - Pause, - PauseCircle, - Play, - PlayCircle, - PlusCircle, - RefreshCw, - Ruler, - Search, - Settings, - Square, - Trash2, - TrendingUp, - Upload, - User, - Users, - Wifi, - Wrench, - X, -}; - -/** - * Theme-aware icon component wrapping Lucide icons - * - * @param {string} name - Lucide icon name (e.g., "Bell", "Check", "ArrowLeft") - * @param {number} size - Icon size in pixels (default: 20) - * @param {string} color - Direct color value OR theme path like "primary.contrastText" - * @param {number} strokeWidth - Stroke width (default: 1.5) - * @param {string} fill - Fill color (default: "none") - */ -const Icon = ({ name, size = 20, color, strokeWidth = 1.5, fill = "none", ...props }) => { - const theme = useTheme(); - - // Resolve color from theme path or use direct value - const resolveColor = (colorValue) => { - if (!colorValue) { - return theme.palette.primary.contrastTextTertiary; // Default icon color - } - - // If it's a theme path like "primary.contrastText" - if (typeof colorValue === "string" && colorValue.includes(".")) { - const parts = colorValue.split("."); - let resolved = theme.palette; - for (const part of parts) { - resolved = resolved?.[part]; - } - return resolved || colorValue; - } - - // Direct color value - return colorValue; - }; - - const LucideIcon = iconComponents[name]; - - if (!LucideIcon) { - console.warn(`Icon "${name}" not found in Icon component`); - return null; - } - - return ( - - ); -}; - -Icon.propTypes = { - name: PropTypes.string.isRequired, - size: PropTypes.number, - color: PropTypes.string, - strokeWidth: PropTypes.number, - fill: PropTypes.string, -}; - -export default Icon; diff --git a/client/src/Components/v1/Inputs/Checkbox/index.jsx b/client/src/Components/v1/Inputs/Checkbox/index.jsx deleted file mode 100644 index caa6830e7..000000000 --- a/client/src/Components/v1/Inputs/Checkbox/index.jsx +++ /dev/null @@ -1,116 +0,0 @@ -import PropTypes from "prop-types"; -import { FormControlLabel, Checkbox as MuiCheckbox } from "@mui/material"; -import { useTheme } from "@emotion/react"; -import Icon from "../../Icon"; - -/** - * Checkbox Component - * - * A customized checkbox component using Material-UI that supports custom sizing, - * disabled states, and custom icons. - * - * @component - * @param {Object} props - Component properties - * @param {string} props.id - Unique identifier for the checkbox input - * @param {string} [props.name] - Optional name attribute for the checkbox - * @param {(string|React.ReactNode)} props.label - Label text or node for the checkbox - * @param {('small'|'medium'|'large')} [props.size='medium'] - Size of the checkbox icon - * @param {boolean} props.isChecked - Current checked state of the checkbox - * @param {string} [props.value] - Optional value associated with the checkbox - * @param {Function} [props.onChange] - Callback function triggered when checkbox state changes - * @param {boolean} [props.isDisabled] - Determines if the checkbox is disabled - * - * @returns {React.ReactElement} Rendered Checkbox component - * - * @example - * // Basic usage - * - * - * @example - * // With custom size and disabled state - * - */ -const Checkbox = ({ - id, - name, - label, - size = "medium", - isChecked, - value, - onChange, - isDisabled, -}) => { - /* TODO move sizes to theme */ - const sizes = { small: "14px", medium: "16px", large: "18px" }; - const theme = useTheme(); - return ( - } - checkedIcon={} - inputProps={{ - "aria-label": "controlled checkbox", - id: id, - }} - sx={{ - "&:hover": { backgroundColor: "transparent" }, - "& svg": { width: sizes[size], height: sizes[size] }, - }} - /> - } - label={label} - disabled={isDisabled} - sx={{ - borderRadius: theme.shape.borderRadius, - p: theme.spacing(2.5), - "& .MuiButtonBase-root": { - width: theme.spacing(10), - p: 0, - mr: theme.spacing(6), - }, - "&:not(:has(.Mui-disabled)):hover": { - backgroundColor: theme.palette.tertiary.main, - }, - "& span.MuiTypography-root": { - fontSize: 13, - color: theme.palette.primary.contrastTextTertiary, - }, - ".MuiFormControlLabel-label.Mui-disabled": { - color: theme.palette.primary.contrastTextTertiary, - opacity: 0.25, - }, - }} - /> - ); -}; - -Checkbox.propTypes = { - id: PropTypes.string, - name: PropTypes.string, - label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired, - size: PropTypes.oneOf(["small", "medium", "large"]), - isChecked: PropTypes.bool.isRequired, - value: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), - onChange: PropTypes.func, - isDisabled: PropTypes.bool, -}; - -export default Checkbox; diff --git a/client/src/Components/v1/Inputs/ColorPicker/index.jsx b/client/src/Components/v1/Inputs/ColorPicker/index.jsx deleted file mode 100644 index e64c936fc..000000000 --- a/client/src/Components/v1/Inputs/ColorPicker/index.jsx +++ /dev/null @@ -1,63 +0,0 @@ -import PropTypes from "prop-types"; -import { Stack, Typography } from "@mui/material"; -import { useTheme } from "@emotion/react"; -import { MuiColorInput } from "mui-color-input"; - -/** - * - * @param {*} id The ID of the component - * @param {*} value The color value of the component - * @param {*} error The error of the component - * @param {*} onChange The Change handler function - * @param {*} onBlur The Blur handler function - * @returns The ColorPicker component - * Example usage: - * - * - */ -const ColorPicker = ({ id, name, value, error, onChange, onBlur }) => { - const theme = useTheme(); - return ( - - onChange({ target: { name, value: color } })} - onBlur={onBlur} - /> - {error && ( - - {error} - - )} - - ); -}; - -ColorPicker.propTypes = { - id: PropTypes.string.isRequired, - value: PropTypes.string, - error: PropTypes.string, - onChange: PropTypes.func.isRequired, - onBlur: PropTypes.func, - name: PropTypes.string, -}; - -export default ColorPicker; diff --git a/client/src/Components/v1/Inputs/FieldWrapper/index.jsx b/client/src/Components/v1/Inputs/FieldWrapper/index.jsx deleted file mode 100644 index cc5061af8..000000000 --- a/client/src/Components/v1/Inputs/FieldWrapper/index.jsx +++ /dev/null @@ -1,51 +0,0 @@ -import { Stack, Typography } from "@mui/material"; -import PropTypes from "prop-types"; -import { useTheme } from "@emotion/react"; - -const DEFAULT_GAP = 6; -const FieldWrapper = ({ - label, - children, - gap, - labelMb, - labelFontWeight = 500, - labelVariant = "h3", - labelSx = {}, - sx = {}, -}) => { - const theme = useTheme(); - return ( - - {label && ( - - {label} - - )} - {children} - - ); -}; - -FieldWrapper.propTypes = { - label: PropTypes.node, - children: PropTypes.node.isRequired, - gap: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]), - labelMb: PropTypes.number, - labelFontWeight: PropTypes.number, - labelVariant: PropTypes.string, - labelSx: PropTypes.object, - sx: PropTypes.object, -}; - -export default FieldWrapper; diff --git a/client/src/Components/v1/Inputs/ImageUpload/index.jsx b/client/src/Components/v1/Inputs/ImageUpload/index.jsx deleted file mode 100644 index d224418e0..000000000 --- a/client/src/Components/v1/Inputs/ImageUpload/index.jsx +++ /dev/null @@ -1,249 +0,0 @@ -// Components -import { Box, Stack, Typography } from "@mui/material"; -import Icon from "../../Icon"; -import Image from "../../Image/index.jsx"; -import TextField from "@mui/material/TextField"; -import IconButton from "@mui/material/IconButton"; -import ProgressUpload from "../../ProgressBars/index.jsx"; - -// Utils -import PropTypes from "prop-types"; -import { useCallback, useState, useRef, useEffect } from "react"; -import { useTheme } from "@emotion/react"; -import { useTranslation } from "react-i18next"; - -/** - * ImageUpload component allows users to upload images with drag-and-drop functionality. - * It supports file size and format validation. - * - * @component - * @param {Object} props - Component props - * @param {boolean} [props.previewIsRound=false] - Determines if the image preview should be round - * @param {string} [props.src] - Source URL of the image to display - * @param {function} props.onChange - Callback function to handle file change, takes a file as an argument - * @param {number} [props.maxSize=3145728] - Maximum file size allowed in bytes (default is 3MB) - * @param {Array} [props.accept=['jpg', 'jpeg', 'png']] - Array of accepted file formats - * @param {Object} [props.errors] - Object containing error messages - * @returns {JSX.Element} The rendered component - */ -const ImageUpload = ({ - previewIsRound = false, - src, - onChange, - maxSize = 3 * 1024 * 1024, - accept = ["jpg", "jpeg", "png"], - error, -}) => { - const theme = useTheme(); - const { t } = useTranslation(); - const [uploadComplete, setUploadComplete] = useState(false); - const [completedFile, setCompletedFile] = useState(null); - const [file, setFile] = useState(null); - const [progress, setProgress] = useState({ value: 0, isLoading: false }); - const intervalRef = useRef(null); - const [localError, setLocalError] = useState(null); - const [isDragging, setIsDragging] = useState(false); - - const roundStyle = previewIsRound ? { borderRadius: "50%" } : {}; - - const handleImageChange = useCallback( - (file) => { - if (!file) return; - - const isValidType = accept.some((type) => file.type.includes(type)); - const isValidSize = file.size <= maxSize; - - if (!isValidType) { - setLocalError(t("invalidFileFormat")); - return; - } - if (!isValidSize) { - setLocalError(t("invalidFileSize")); - return; - } - - setLocalError(null); - - const previewFile = { - src: URL.createObjectURL(file), - name: file.name, - file, - }; - - setFile(previewFile); - setProgress({ value: 0, isLoading: true }); - - intervalRef.current = setInterval(() => { - setProgress((prev) => { - const buffer = 12; - if (prev.value + buffer >= 100) { - clearInterval(intervalRef.current); - setUploadComplete(true); - setCompletedFile(previewFile); - return { value: 100, isLoading: false }; - } - return { value: prev.value + buffer, isLoading: true }; - }); - }, 120); - }, - [maxSize, accept] - ); - - useEffect(() => { - if (uploadComplete && completedFile) { - onChange?.(completedFile); - setUploadComplete(false); - setCompletedFile(null); - } - }, [uploadComplete, completedFile, onChange]); - - return ( - <> - {src ? ( - - Uploaded preview - - ) : ( - <> - setIsDragging(true)} - onDragLeave={() => setIsDragging(false)} - onDrop={() => setIsDragging(false)} - sx={{ - position: "relative", - height: "fit-content", - border: "dashed", - borderRadius: theme.shape.borderRadius, - borderColor: isDragging - ? theme.palette.primary.main - : theme.palette.primary.lowContrast, - backgroundColor: isDragging ? "hsl(215, 87%, 51%, 0.05)" : "transparent", - borderWidth: "2px", - transition: "0.2s", - "&:hover": { - borderColor: theme.palette.primary.main, - backgroundColor: "hsl(215, 87%, 51%, 0.05)", - }, - }} - > - handleImageChange(e?.target?.files?.[0])} - sx={{ - width: "100%", - "& .MuiInputBase-input[type='file']": { - opacity: 0, - cursor: "pointer", - maxWidth: "500px", - minHeight: "175px", - zIndex: 1, - }, - "& fieldset": { - padding: 0, - border: "none", - }, - }} - /> - - - - - - - {t("ClickUpload")} - {" "} - or {t("DragandDrop")} - - - ({t("MaxSize")}: {Math.round(maxSize / 1024 / 1024)}MB) - - - - {(localError || progress.isLoading || progress.value !== 0) && ( - - } - label={file?.name || "Upload failed"} - size={file?.size} - progress={progress.value} - onClick={() => { - clearInterval(intervalRef.current); - setFile(null); - setProgress({ value: 0, isLoading: false }); - setLocalError(null); - onChange(undefined); - }} - error={localError || error} - /> - )} - - {t("SupportedFormats")}: {accept.join(", ").toUpperCase()} - - - )} - - ); -}; - -ImageUpload.propTypes = { - previewIsRound: PropTypes.bool, - src: PropTypes.string, - onChange: PropTypes.func, - maxSize: PropTypes.number, - accept: PropTypes.array, - error: PropTypes.string, -}; - -export default ImageUpload; diff --git a/client/src/Components/v1/Inputs/Radio/index.css b/client/src/Components/v1/Inputs/Radio/index.css deleted file mode 100644 index e69de29bb..000000000 diff --git a/client/src/Components/v1/Inputs/Radio/index.jsx b/client/src/Components/v1/Inputs/Radio/index.jsx deleted file mode 100644 index b6bd4e69c..000000000 --- a/client/src/Components/v1/Inputs/Radio/index.jsx +++ /dev/null @@ -1,117 +0,0 @@ -import PropTypes from "prop-types"; -import { FormControlLabel, Radio as MUIRadio, Typography } from "@mui/material"; -import { useTheme } from "@emotion/react"; -import Icon from "../../Icon"; -import "./index.css"; - -/** - * Radio component. - * - * @component - * @example - * // Usage: - * - * - * @param {Object} props - The component - * @param {string} id - The id of the radio button. - * @param {string} title - The title of the radio button. - * @param {string} [desc] - The description of the radio button. - * @param {string} [size="small"] - The size of the radio button. - * @returns {JSX.Element} - The rendered Radio component. - */ - -const Radio = ({ - name, - checked, - value, - id, - size, - title, - desc, - onChange, - labelSpacing, -}) => { - const theme = useTheme(); - - return ( - - } - sx={{ - color: "transparent", - width: 16, - height: 16, - boxShadow: `inset 0 0 0 1px ${theme.palette.secondary.main}`, - "&:not(.Mui-checked)": { - boxShadow: `inset 0 0 0 1px ${theme.palette.primary.contrastText}70`, // Use theme text color for the outline - }, - mt: theme.spacing(0.5), - }} - /> - } - onChange={onChange} - label={ - <> - - {title} - - - {desc} - - - } - labelPlacement="end" - sx={{ - alignItems: "flex-start", - p: theme.spacing(2.5), - m: theme.spacing(-2.5), - borderRadius: theme.shape.borderRadius, - "&:hover": { - backgroundColor: theme.palette.tertiary.main, - }, - "& .MuiButtonBase-root": { - p: 0, - mr: theme.spacing(6), - }, - }} - /> - ); -}; - -Radio.propTypes = { - title: PropTypes.string, - desc: PropTypes.string, - size: PropTypes.string, - name: PropTypes.string, - checked: PropTypes.bool, - value: PropTypes.string, - id: PropTypes.string, - onChange: PropTypes.func, -}; - -export default Radio; diff --git a/client/src/Components/v1/Inputs/Search/index.jsx b/client/src/Components/v1/Inputs/Search/index.jsx deleted file mode 100644 index 4371ef971..000000000 --- a/client/src/Components/v1/Inputs/Search/index.jsx +++ /dev/null @@ -1,315 +0,0 @@ -import PropTypes from "prop-types"; -import { - Box, - ListItem, - Autocomplete, - TextField, - Typography, - Checkbox, -} from "@mui/material"; -import { useTheme } from "@emotion/react"; -import Icon from "../../Icon"; -import React, { useEffect } from "react"; -import { useTranslation } from "react-i18next"; -import FieldWrapper from "../FieldWrapper/index.jsx"; - -/** - * Search component using Material UI's Autocomplete. - * - * @param {Object} props - * @param {string} props.id - Unique identifier for the Autocomplete component - * @param {Array} props.options - Options to display in the Autocomplete dropdown - * @param {string} props.filteredBy - Key to access the option label from the options - * @param {string} props.value - Current input value for the Autocomplete - * @param {Function} props.handleChange - Function to call when the input changes - * @param {Function} Prop.onBlur - Function to call when the input is blured - * @param {Object} props.sx - Additional styles to apply to the component - * @param {string} props.unit - Label to identify type of options - * @returns {JSX.Element} The rendered Search component - */ - -const SearchAdornment = () => { - const theme = useTheme(); - return ( - - - - ); -}; - -//TODO keep search state inside of component. -const Search = ({ - label, - id, - options, - filteredBy, - secondaryLabel, - value, - inputValue, - handleInputChange, - handleChange, - sx, - multiple = false, - isAdorned = true, - error, - disabled, - startAdornment, - endAdornment, - onBlur, - //FieldWrapper's props - gap, - labelMb, - labelFontWeight, - labelVariant, - labelSx = {}, - unit = "option", - maxWidth = "100%", -}) => { - const theme = useTheme(); - const { t } = useTranslation(); - const [selectAll, setSelectAll] = React.useState(false); - - const [open, setOpen] = React.useState(false); - const enhancedOptions = React.useMemo(() => { - return multiple && isAdorned - ? [ - { - [filteredBy]: t("selectAll"), - isSelectAll: true, - _id: "select_all", - id: "select_all", - }, - ...options, - ] - : options; - }, [multiple, isAdorned, options, filteredBy]); - const isOptionSelected = (option) => { - if (!multiple && !isAdorned) return false; - if (Array.isArray(value)) { - return value.some((item) => (item._id ?? item.id) === (option._id ?? option.id)); - } - return false; - }; - const handleSelectAll = (isSelectAll) => { - const newValue = isSelectAll ? [...options] : []; - handleChange(newValue); - setSelectAll(isSelectAll); - }; - useEffect(() => { - const allSelected = - Array.isArray(value) && Array.isArray(options) && value.length === options.length; - if (selectAll !== allSelected) setSelectAll(allSelected); - }, [value, options]); - return ( - setOpen(true)} - onClose={(event, reason) => { - if (reason === "blur" || reason === "escape") { - setOpen(false); - } - }} - inputValue={inputValue} - onInputChange={(_, newValue) => { - handleInputChange(newValue); - }} - onChange={(_, newValue) => { - if (multiple && isAdorned) { - const hasSelectAllSelected = - Array.isArray(newValue) && newValue.some((item) => item.isSelectAll); - if (hasSelectAllSelected) { - handleSelectAll(!selectAll); - } else { - handleChange(newValue); - setSelectAll(Array.isArray(newValue) && newValue.length === options.length); - } - } else { - handleChange(newValue); - setOpen(false); - } - }} - fullWidth - freeSolo - disabled={disabled} - disableClearable - options={enhancedOptions} - getOptionLabel={(option) => option[filteredBy]} - isOptionEqualToValue={(option, value) => - (option._id ?? option.id) === (value?._id ?? value?.id) - } // Compare by unique identifier - renderInput={(params) => ( - - }), - ...(startAdornment && { startAdornment: startAdornment }), - ...(endAdornment && { endAdornment: endAdornment }), - }, - }} - sx={{}} - /> - {error && ( - - {error} - - )} - - )} - filterOptions={(options, { inputValue }) => { - if (inputValue.trim() === "" && multiple && isAdorned) { - return enhancedOptions; - } - const filtered = options.filter((option) => - option[filteredBy].toLowerCase().includes(inputValue.toLowerCase()) - ); - - if (filtered.length === 0) { - return [ - { - [filteredBy]: t("general.noOptionsFound", { unit: unit }), - noOptions: true, - }, - ]; - } - return filtered; - }} - getOptionKey={(option) => { - return option._id ?? option.id; - }} - renderOption={(props, option) => { - const { key, ...optionProps } = props; - const hasSecondaryLabel = secondaryLabel && option[secondaryLabel] !== undefined; - const port = option["port"]; - const selected = isOptionSelected(option); - return ( - - {multiple && isAdorned && !option.noOptions && ( - - )} - {option[filteredBy] + - (hasSecondaryLabel - ? ` (${option[secondaryLabel]}${port ? `: ${port}` : ""})` - : "")} - - ); - }} - slotProps={{ - popper: { - keepMounted: true, - sx: { - "& ul": { p: 2, backgroundColor: theme.palette.primary.main }, - "& li.MuiAutocomplete-option": { - color: theme.palette.primary.contrastTextSecondary, - px: 4, - borderRadius: theme.shape.borderRadius, - }, - - "& .MuiAutocomplete-listbox .MuiAutocomplete-option[aria-selected='true'], & .MuiAutocomplete-listbox .MuiAutocomplete-option[aria-selected='true'].Mui-focused, & .MuiAutocomplete-listbox .MuiAutocomplete-option[aria-selected='true']:hover": - { - backgroundColor: theme.palette.primary.lowContrast, - color: "red", - }, - "& li.MuiAutocomplete-option:hover:not([aria-selected='true'])": { - color: theme.palette.secondary.contrastText, - backgroundColor: theme.palette.secondary.main, - }, - "& .MuiAutocomplete-noOptions": { - px: theme.spacing(6), - py: theme.spacing(5), - }, - }, - }, - }} - sx={{ - /* height: 34,*/ - "&.MuiAutocomplete-root .MuiAutocomplete-input": { - padding: `0 ${theme.spacing(5)}`, - }, - ...sx, - }} - /> - ); -}; - -Search.propTypes = { - label: PropTypes.string, - id: PropTypes.string, - multiple: PropTypes.bool, - options: PropTypes.array.isRequired, - filteredBy: PropTypes.string.isRequired, - secondaryLabel: PropTypes.string, - value: PropTypes.oneOfType([PropTypes.array, PropTypes.object]), - inputValue: PropTypes.string.isRequired, - handleInputChange: PropTypes.func.isRequired, - handleChange: PropTypes.func, - isAdorned: PropTypes.bool, - sx: PropTypes.object, - error: PropTypes.string, - disabled: PropTypes.bool, - startAdornment: PropTypes.object, - endAdornment: PropTypes.object, - onBlur: PropTypes.func, - unit: PropTypes.string, -}; - -export default Search; diff --git a/client/src/Components/v1/Inputs/Select/index.css b/client/src/Components/v1/Inputs/Select/index.css deleted file mode 100644 index b40cf8564..000000000 --- a/client/src/Components/v1/Inputs/Select/index.css +++ /dev/null @@ -1,7 +0,0 @@ -.select-wrapper .select-component > .MuiSelect-select { - padding: 0 10px; - min-height: 34px; - display: flex; - align-items: center; - line-height: 1; -} diff --git a/client/src/Components/v1/Inputs/Select/index.jsx b/client/src/Components/v1/Inputs/Select/index.jsx deleted file mode 100644 index ec2522d17..000000000 --- a/client/src/Components/v1/Inputs/Select/index.jsx +++ /dev/null @@ -1,213 +0,0 @@ -import PropTypes from "prop-types"; -import { useTheme } from "@emotion/react"; -import { MenuItem, Select as MuiSelect, Stack, Typography } from "@mui/material"; -import Icon from "../../Icon"; -import FieldWrapper from "../FieldWrapper/index.jsx"; - -import "./index.css"; - -/** - * @component - * @param {object} props - * @param {string} props.id - The ID attribute for the select element. - * @param {string} props.placeholder - The label of the select element. - * @param {string} props.placeholder - The placeholder text when no option is selected. - * @param {boolean} props.isHidden - Whether the placeholder should be hidden. - * @param {(string | number | boolean)} props.value - The currently selected value. - * @param {object[]} props.items - The array of items to populate in the select dropdown. - * @param {(string | number | boolean)} props.items._id - The unique identifier of each item. - * @param {string} props.items.name - The display name of each item. - * @param {function} props.onChange - The function to handle onChange event. - * @param {object} props.sx - The custom styles object for MUI Select component. - * @param {number} props.maxWidth - Maximum width in pixels for the select component. Enables responsive text truncation. - * @returns {JSX.Element} - * - * @example - * const frequencies = [ - * { _id: 1, name: "1 minute" }, - * { _id: 2, name: "2 minutes" }, - * { _id: 3, name: "3 minutes" }, - * ]; - * - *