From c027a30b3f6b9f12720a4169a08b3784f053009a Mon Sep 17 00:00:00 2001 From: Christopher Hight Date: Tue, 20 Oct 2026 14:05:52 -0700 Subject: [PATCH] Refactor widgets to use theme better. Alert change and 7day vaa --- .../src/components/Widgets/AlertChanges.jsx | 75 +++++++++--------- .../components/Widgets/VaaActivity7Day.jsx | 79 ++++++++----------- client/src/theme.js | 12 +++ 3 files changed, 83 insertions(+), 83 deletions(-) diff --git a/client/src/components/Widgets/AlertChanges.jsx b/client/src/components/Widgets/AlertChanges.jsx index 9f6dbd2..42eea0d 100644 --- a/client/src/components/Widgets/AlertChanges.jsx +++ b/client/src/components/Widgets/AlertChanges.jsx @@ -60,38 +60,38 @@ export default function AlertChanges({ settings, widgetID}) { return sorted_entries; }, [apiData, thisWidget]); - // list of alert colors used for coloring text below + // Alert colors are now light/dark mode responsive const alertColors = { - Red: "red.400", - Orange: "orange.400", - Yellow: "yellow.400", - Green: "green.400", + Red: "alertRed", + Orange: "alertOrange", + Yellow: "alertYellow", + Green: "alertGreen", }; if (isLoading) return ( - + ); if (error) return ( - + {error} ); if (data.length === 0) return ( - - No flight level data available for the selected dates. + + No flight level data available for the selected dates. ); return ( - + // bg="transparent" to let the glass panel show through + {data.map((volcano, index) => { if (thisWidget?.size === "large") return ( - {/* Using context to dynamically change the border radii of the triggers */} {(collapsible) => ( <> @@ -102,57 +102,58 @@ export default function AlertChanges({ settings, widgetID}) { p={1} pl={3} pr={3} borderTopRadius="lg" borderBottomRadius={collapsible.open ? "0" : "lg"} - bg="gray.600" + bg="widgetItemBg" > - - {volcano[0]} {/* volcano name */} - {volcano[1][0]?.alert_start_date_local} + + {volcano[0]} + {volcano[1][0]?.alert_start_date_local} - {volcano[1][0]?.alert_level_name} + + {volcano[1][0]?.alert_level_name} + - + + {volcano[1]?.map((object, index) => ( - {/**/} - + {object?.alert_scheme_domain === "terrestrial" && } {object?.alert_scheme_domain === "aviation" && } {object?.alert_scheme_domain === "maritime" && } - + {object?.change_type === "increase" ? : } - {/*{object?.volcano}*/} - {object?.alert_start_date_local} + {object?.alert_start_date_local} {object?.alert_level_name} - Alert Scale: + Alert Scale: {(Array.from({ length: Number(object?.alert_scheme_highest) - Number(object?.alert_scheme_lowest) + 1}, (v, i) => Number(object?.alert_scheme_lowest) + i)) .map((num) => (
{num}
@@ -181,30 +182,30 @@ export default function AlertChanges({ settings, widgetID}) { justify="space-between" align="center" p={1} pl={3} pr={3} borderRadius="lg" - bg="gray.600" + bg="widgetItemBg" > - + - + {domain[0] === "aviation" && } {domain[0] === "terrestrial" && } {domain[0] === "maritime" && } - {volcano[0] || ""} {/* volcano name */} + {volcano[0] || ""} - {domain[1]?.[0]?.alert_start_date_local || ""} + {domain[1]?.[0]?.alert_start_date_local || ""} - - + + {domain[1]?.[0]?.change_type === "increase" ? : } {domain[1]?.[0]?.alert_level_name} diff --git a/client/src/components/Widgets/VaaActivity7Day.jsx b/client/src/components/Widgets/VaaActivity7Day.jsx index a6bb48c..d33b667 100644 --- a/client/src/components/Widgets/VaaActivity7Day.jsx +++ b/client/src/components/Widgets/VaaActivity7Day.jsx @@ -23,7 +23,6 @@ export default function VaaActivity7Day({ settings, widgetID }) { 'hexagon', 'octagon', 'cross', 'x' ]; - // Sort data descending by flight level (matching Observable behavior) const sortedData = [...apiData].sort((a, b) => b.obs_fl - a.obs_fl); // Efficiently group into Plotly traces by volcano @@ -44,102 +43,90 @@ export default function VaaActivity7Day({ settings, widgetID }) { mode: 'markers', marker: { size: 7, - line: { width: .5, color: 'rgba(255, 255, 255, 0.7)' }, + line: { width: 0.5, color: 'var(--chakra-colors-textInverted)' }, symbol: Symbolway[index % Symbolway.length], }, // Replicating the clean Observable tooltip hovertemplate: - `${volcanoName}
` + - 'Date: %{x|%b %d %Y %H:%M}
' + - 'Flight Level: %{y}' + `${volcanoName}
` + + 'Date: %{x|%b %d %Y %H:%M}
' + + 'Flight Level: %{y}' })); }, [apiData]); // 2. Build the Layout (Styling and Grid) const layout = useMemo(() => { - return { autosize: true, paper_bgcolor: 'transparent', // Let Chakra UI background show through plot_bgcolor: 'transparent', - font: { color: '#d1d5db' }, // gray.300 + font: { color: 'var(--chakra-colors-widgetTextMuted)' }, margin: { t: 40, r: 20, l: 20, b: 20 }, - // title: { - // text: '7 Day Consolidated Flight Levels', - // font: { size: 16, color: 'white' }, - // x: 0.05 - // }, xaxis: { title: { text: 'Date (UTC)', - font: { color: 'white', size: 12 } + font: { color: 'var(--chakra-colors-text)', size: 12 } }, type: 'date', - tickformat: '%b %d
%Y %H:%M', // Multiline ticks from Observable - gridcolor: '#4b5563', - zerolinecolor: '#4b5563', + tickformat: '%b %d
%Y %H:%M', + gridcolor: 'var(--chakra-colors-glassSeperator)', + zerolinecolor: 'var(--chakra-colors-glassSeperator)', automargin: true, }, yaxis: { title: { text: 'Flight Level', - font: { color: 'white', size: 12 } + font: { color: 'var(--chakra-colors-text)', size: 12 } }, type: plotYAxisType, - gridcolor: '#4b5563', - zerolinecolor: '#ffffff', + gridcolor: 'var(--chakra-colors-glassSeperator)', + zerolinecolor: 'var(--chakra-colors-text)', automargin: true, }, - // legend: { - // orientation: 'h', - // y: -0.2, - // x: 0.5, - // xanchor: 'center' - // }, hovermode: 'closest', shapes: [ { type: 'line', x0: 0, x1: 1, - xref: 'paper', // Spans entire chart width + xref: 'paper', y0: 0, y1: 0, yref: 'y', - line: { color: 'white', width: 1 } + line: { color: 'var(--chakra-colors-text)', width: 1 } } ], }; }, [apiData, plotYAxisType]); if (isLoading) return ( - - - + + + ); if (error) return ( - - {error} - + + {error} + ); if (plotTraces.length === 0) return ( - - No flight level data available. - + + No flight level data available. + ); return ( - - - + + + ); } \ No newline at end of file diff --git a/client/src/theme.js b/client/src/theme.js index 2865f1f..052037b 100644 --- a/client/src/theme.js +++ b/client/src/theme.js @@ -572,6 +572,18 @@ const config = defineConfig({ iconColor: { value: { base: "gray.600", _dark: "gray.300" } }, // Fixed: Visible in dark mode glassSeperator: { value: { base: "#0000001A", _dark: "#FFFFFF3F" } }, gooeyButtonBackground: {value: {base: "rgba(255, 255, 255, 0.1)", _dark: "rgba(255, 255, 255, 0.1)"}}, + + // WIDGET SPECIFIC VALUES + widgetItemBg: { value: { base: "rgba(0, 0, 0, 0.04)", _dark: "rgba(255, 255, 255, 0.05)" } }, + widgetItemExpandedBg: { value: { base: "rgba(0, 0, 0, 0.08)", _dark: "rgba(0, 0, 0, 0.3)" } }, + widgetBadgeBg: { value: { base: "rgba(255, 255, 255, 0.6)", _dark: "rgba(0, 0, 0, 0.5)" } }, + widgetTextMuted: { value: { base: "gray.600", _dark: "gray.400" } }, + + // ALERT COLORS + alertRed: { value: { base: "red.600", _dark: "red.400" } }, + alertOrange: { value: { base: "orange.600", _dark: "orange.400" } }, + alertYellow: { value: { base: "yellow.600", _dark: "yellow.400" } }, + alertGreen: { value: { base: "green.600", _dark: "green.400" } }, }, }, tokens: {