From 9abcb783273fd45c5b7b5860d34b22d1fb1c89e7 Mon Sep 17 00:00:00 2001 From: Christopher Hight Date: Fri, 21 Aug 2026 12:58:28 -0700 Subject: [PATCH] Refactor only formatting of file --- .../components/dashboard/SettingsButton.jsx | 425 +++++++++--------- 1 file changed, 216 insertions(+), 209 deletions(-) diff --git a/client/src/components/dashboard/SettingsButton.jsx b/client/src/components/dashboard/SettingsButton.jsx index 436fc6b..8038b94 100644 --- a/client/src/components/dashboard/SettingsButton.jsx +++ b/client/src/components/dashboard/SettingsButton.jsx @@ -19,7 +19,7 @@ import {WIDGET_REGISTRY} from "../../constants/widgetRegistry.jsx"; // 🚨 NEW: Tiny helper to convert size keys into abbreviations const getSizeAbbreviation = (key) => { - const mapping = { small: "S", medium: "M", large: "L", xlarge: "XL" }; + const mapping = {small: "S", medium: "M", large: "L", xlarge: "XL"}; return mapping[key.toLowerCase()] || key.charAt(0).toUpperCase(); }; @@ -48,7 +48,7 @@ export function SettingsButton() { const checkScroll = useCallback(() => { if (tabsRef.current) { - const { scrollLeft, scrollWidth, clientWidth } = tabsRef.current; + const {scrollLeft, scrollWidth, clientWidth} = tabsRef.current; setCanScrollLeft(scrollLeft > 0); // We use -1 here to account for sub-pixel rendering in some browsers setCanScrollRight(Math.ceil(scrollLeft + clientWidth) < scrollWidth - 1); @@ -99,10 +99,10 @@ export function SettingsButton() { css={tabStyles} data-state="open" onClick={() => setIsLibraryOpen(true)} - color={{ base: "blue.500", _dark: "blue.300" }} - _hover={{ bg: "rgba(66, 153, 225, 0.1)" }} + color={{base: "blue.500", _dark: "blue.300"}} + _hover={{bg: "rgba(66, 153, 225, 0.1)"}} > - + Widget Library @@ -112,10 +112,10 @@ export function SettingsButton() { css={tabStyles} data-state="open" onClick={saveEdit} - color={{ base: "green.600", _dark: "green.400" }} - _hover={{ bg: "rgba(72, 187, 120, 0.1)" }} + color={{base: "green.600", _dark: "green.400"}} + _hover={{bg: "rgba(72, 187, 120, 0.1)"}} > - + Save Layout @@ -125,20 +125,20 @@ export function SettingsButton() { css={tabStyles} data-state="open" onClick={cancelEdit} - color={{ base: "red.500", _dark: "red.400" }} - _hover={{ bg: "rgba(245, 101, 101, 0.1)" }} + color={{base: "red.500", _dark: "red.400"}} + _hover={{bg: "rgba(245, 101, 101, 0.1)"}} > - + Discard ) : ( // 👀 VIEW MODE: The Static Dropdown Menu - + {/* size increased to 24 to match tabs. flexShrink: 0 is CRITICAL */} - + Dashboard Settings @@ -148,215 +148,222 @@ export function SettingsButton() { - Edit Layout + Edit Layout - + - setIsLibraryOpen(true)} - cursor="pointer" - _hover={{ - bg: {base: "rgba(0, 0, 0, 0.05)", _dark: "rgba(255, 255, 255, 0.1)"}, - WebkitTextStroke: "0.5px currentColor" - }} - > - Widget Library - - - - - )} - - {/* 📚📚📚 THE WIDGET LIBRARY MODAL (Controlled by isLibraryOpen) */} - setIsLibraryOpen(e.open)} - size="xl" - placement="center" - closeOnInteractOutside={true} - closeOnEscapeKeyDown={true} + setIsLibraryOpen(true)} + cursor="pointer" + _hover={{ + bg: {base: "rgba(0, 0, 0, 0.05)", _dark: "rgba(255, 255, 255, 0.1)"}, + WebkitTextStroke: "0.5px currentColor" + }} > - {/* Soft blur can be added to the background behind the modal */} - {/**/} - + Widget Library + + + + + )} - + {/* 📚📚📚 THE WIDGET LIBRARY MODAL (Controlled by isLibraryOpen) */} + setIsLibraryOpen(e.open)} + size="xl" + placement="center" + closeOnInteractOutside={true} + closeOnEscapeKeyDown={true} + > + {/* Soft blur can be added to the background behind the modal */} + {/**/} + - - Widgets Shop - + - - - + + Widgets Shop + - {/* LEFT GLASS CRESCENT */} - {canScrollLeft && ( - tabsRef.current.scrollBy({ left: -200, behavior: 'smooth' })} - // The Glass Look hugging the left pill edge - bg={{ base: "rgba(255, 255, 255, 0.7)", _dark: "rgba(30, 30, 30, 0.8)" }} - backdropFilter="blur(8px)" - borderTopLeftRadius="full" - borderBottomLeftRadius="full" - // Fades the inner edge so it blends into the track - boxShadow={{ base: "10px 0 15px -5px rgba(255,255,255,0.8)", _dark: "10px 0 15px -5px rgba(30,30,30,0.9)" }} - color={{ base: "gray.600", _dark: "gray.300" }} - _hover={{ color: { base: "blue.500", _dark: "blue.300" } }} - > - - - )} - { - if (e.currentTarget) { - e.currentTarget.scrollLeft += e.deltaY; - } - }} - > - {categories.map(cat => ( - - {cat} - - ))} - - {canScrollRight && ( - tabsRef.current.scrollBy({ left: 200, behavior: 'smooth' })} - // The Glass Look hugging the right pill edge - bg={{ base: "rgba(255, 255, 255, 0.7)", _dark: "rgba(30, 30, 30, 0.8)" }} - backdropFilter="blur(8px)" - borderTopRightRadius="full" - borderBottomRightRadius="full" - boxShadow={{ base: "-10px 0 15px -5px rgba(255,255,255,0.8)", _dark: "-10px 0 15px -5px rgba(30,30,30,0.9)" }} - color={{ base: "gray.600", _dark: "gray.300" }} - _hover={{ color: { base: "blue.500", _dark: "blue.300" } }} - > - - - )} + + + - - {categories.map(cat => ( - - - {categorizedWidgets[cat].map(widget => ( - tabsRef.current.scrollBy({left: -200, behavior: 'smooth'})} + // The Glass Look hugging the left pill edge + bg={{base: "rgba(255, 255, 255, 0.7)", _dark: "rgba(30, 30, 30, 0.8)"}} + backdropFilter="blur(8px)" + borderTopLeftRadius="full" + borderBottomLeftRadius="full" + // Fades the inner edge so it blends into the track + boxShadow={{ + base: "10px 0 15px -5px rgba(255,255,255,0.8)", + _dark: "10px 0 15px -5px rgba(30,30,30,0.9)" + }} + color={{base: "gray.600", _dark: "gray.300"}} + _hover={{color: {base: "blue.500", _dark: "blue.300"}}} + > + + + )} + { + if (e.currentTarget) { + e.currentTarget.scrollLeft += e.deltaY; + } + }} + > + {categories.map(cat => ( + + {cat} + + ))} + + {canScrollRight && ( + tabsRef.current.scrollBy({left: 200, behavior: 'smooth'})} + // The Glass Look hugging the right pill edge + bg={{base: "rgba(255, 255, 255, 0.7)", _dark: "rgba(30, 30, 30, 0.8)"}} + backdropFilter="blur(8px)" + borderTopRightRadius="full" + borderBottomRightRadius="full" + boxShadow={{ + base: "-10px 0 15px -5px rgba(255,255,255,0.8)", + _dark: "-10px 0 15px -5px rgba(30,30,30,0.9)" + }} + color={{base: "gray.600", _dark: "gray.300"}} + _hover={{color: {base: "blue.500", _dark: "blue.300"}}} + > + + + )} + + + {categories.map(cat => ( + + + {categorizedWidgets[cat].map(widget => ( + + {widget.name} + {widget.description} + + + + Add to Dashboard: + + + {Object.keys(widget.allowedSizes).map(sizeKey => ( + handleAddWidget(widget.id, sizeKey)} + color={{base: "blue.600", _dark: "blue.300"}} > - {widget.name} - {widget.description} + {/* 🚨 THE ABBREVIATION ICON: Always visible */} + + {getSizeAbbreviation(sizeKey)} + - - - Add to Dashboard: - - - {Object.keys(widget.allowedSizes).map(sizeKey => ( - handleAddWidget(widget.id, sizeKey)} - color={{base: "blue.600", _dark: "blue.300"}} - > - {/* 🚨 THE ABBREVIATION ICON: Always visible */} - - {getSizeAbbreviation(sizeKey)} - - - {/* 🚨 THE EXPANDED TEXT: Only visible on hover */} - Add Widget - - ))} - - - + {/* 🚨 THE EXPANDED TEXT: Only visible on hover */} + Add Widget + ))} - - - ))} - - - - - - + + + + ))} + + + ))} + + + + + + ); } \ No newline at end of file