Author SHA1 Message Date
chight 60f71485da Refactor CSS on mydashboard started needs completed 2026-09-02 12:45:40 -07:00
chight 8e9b17f6dd Refactor, cleaned up header file 2026-08-26 13:10:02 -07:00
chight c45bc778ec Refactor, cleaned up sidebar and theme 2026-08-26 13:04:17 -07:00
chight 816046d05a Fix the color mode button was highlighting odd. removed highlight 2026-08-24 10:58:09 -07:00
chight 12e540b61b Fix adjustment to VDAP logo and emoji 2026-08-24 08:58:31 -07:00
chight 1e1130f965 Update widget library will now open to a percentage of screen 2026-08-21 14:39:57 -07:00
chight 8ddf9ff393 Update chevrons are updated for better UI 2026-08-21 13:30:02 -07:00
chight 9abcb78327 Refactor only formatting of file 2026-08-21 12:58:28 -07:00
chight f5f09e31fe Update added chevrons to scrollbar - bug in size of chevrons 2026-08-21 12:55:54 -07:00
chight 510c63e7b0 Update tabs in widget library now scroll and look nice 2026-08-21 11:41:08 -07:00
chight 3017535d02 Update to buttons on widget choices 2026-08-20 14:45:13 -07:00
chight 9b1ddf6dcc Refactor widget library UI code 2026-08-20 12:51:58 -07:00
chight 2b0300b075 Refactor continued of UI. changes to theme to make baselines 2026-08-04 09:05:30 -07:00
chight a6ebe5af1e Refactor recipe adjustment 2026-07-29 14:18:10 -07:00
chight 6d0af310ae Refactor continuing to work on UI 2026-07-29 13:48:38 -07:00
chight 2283d156ea Refactoring some theme colors 2026-07-24 14:11:17 -07:00
chight 3697575f54 Refactor the UI for light mode is at an acceptable point 2026-07-23 15:47:51 -07:00
chight 9fbf22bc32 Refactor still working on UI changes 2026-07-22 14:58:59 -07:00
chight 7568d0dba4 Merge remote-tracking branch 'origin/20260721_0845_Venessa_addingWidgets' into 20260715_UI_update 2026-07-22 10:37:09 -07:00
chight 022d4169b5 Reformat starting changes on layout for better UI visuals 2026-07-22 10:37:01 -07:00
vkuchenik 35eea905a3 Fixed the tabs in the canvas not transitioning colors to black when active and Updated canvas coloring in 'coming soon' pages 2026-07-22 09:40:41 -07:00
vkuchenik 764bf07ac8 Fixed weird menu positioning on open, now opens below settings button 2026-07-22 08:46:58 -07:00
vkuchenik 9ee41c9b8a Added an Alert Level Change Quad Plot Widget 2026-07-21 16:07:59 -07:00
21 changed files with 1127 additions and 904 deletions
+7 -7
View File
@@ -33,12 +33,12 @@ function AppFoundation() {
height="100vh" height="100vh"
width="100vw" width="100vw"
> >
<GridItem rowSpan={1} colSpan={2}> <GridItem rowSpan={2} colSpan={1}>
<Header />
</GridItem>
<GridItem colSpan={1}>
<Sidebar /> <Sidebar />
</GridItem> </GridItem>
<GridItem rowSpan={1} colSpan={1}>
<Header />
</GridItem>
<GridItem colSpan={1} width="100%" overflow="auto"> <GridItem colSpan={1} width="100%" overflow="auto">
<Outlet /> <Outlet />
</GridItem> </GridItem>
@@ -48,8 +48,8 @@ function AppFoundation() {
} }
const Placeholder = ({ name }) => ( const Placeholder = ({ name }) => (
<Flex width="100%" height="100%" align="center" justify="center" bg="gray.50" _dark={{ bg: "gray.900" }}> <Flex width="100%" height="100%" align="center" justify="center">
<Heading color="gray.400" _dark={{ bg: "gray.600" }} size="md">{name} Dashboard - Coming Soon</Heading> <Heading color="gray.500" _dark={{ color: "gray.200" }} size="lg">{name} Dashboard - Coming Soon</Heading>
</Flex> </Flex>
); );
@@ -75,7 +75,7 @@ function App() {
<Route path="/home" element={<Home />}> <Route path="/home" element={<Home />}>
<Route index element={<MyDashboard />} /> <Route index element={<MyDashboard />} />
<Route path="gas" element={<MyDashboard />} /> <Route path="gas" element={<Placeholder name="Gas" />} />
<Route path="seismic" element={<Placeholder name="Seismic" />} /> <Route path="seismic" element={<Placeholder name="Seismic" />} />
<Route path="remote" element={<Placeholder name="Remote Sensing" />} /> <Route path="remote" element={<Placeholder name="Remote Sensing" />} />
<Route path="daily" element={<Placeholder name="Daily Activity" />} /> <Route path="daily" element={<Placeholder name="Daily Activity" />} />
@@ -0,0 +1,84 @@
import VdapApi from '../../hooks/useVdapApi.js';
import {Flex, Spinner, Text, Box, Center} from "@chakra-ui/react"; // Adjust path as needed
export default function LlmAlChangesQuadPlot(props) {
console.log("3. Quad Plot loaded");
let tp_percent = 0;
let tn_percent = 0;
let fp_percent = 0;
let fn_percent = 0;
// Clean, single-line data fetching
const { data: apiData, isLoading, error } = VdapApi('/api/v2/llm_quadrant_plot');
if (isLoading) return (
<Flex w="100%" h="100%" bg="gray.800" borderRadius="md" align="center" justify="center">
<Spinner size="xl" color="blue.400" thickness="4px" />
</Flex>
);
if (error) return (
<Flex w="100%" h="100%" bg="gray.800" borderRadius="md" align="center" justify="center" p={4}>
<Text color="red.400">{error}</Text>
</Flex>
);
if (apiData.length === 0) return (
<Flex height="100%" width="100%" align="center" justify="center" bg="gray.800" borderRadius="md">
<Text color="gray.400">No alert level quad plot data available.</Text>
</Flex>
);
if (apiData) {
console.log(apiData);
tp_percent = ((apiData[0]['tp_count']/apiData[0]['tot_count'])*100).toFixed(2);
tn_percent = ((apiData[0]['tn_count']/apiData[0]['tot_count'])*100).toFixed(2);
fp_percent = ((apiData[0]['fp_count']/apiData[0]['tot_count'])*100).toFixed(2);
fn_percent = ((apiData[0]['fn_count']/apiData[0]['tot_count'])*100).toFixed(2);
}
return (
<Flex direction="column" w="100%" h="100%" borderRadius="lg">
<Flex direction="row" w="100%" bg="gray.800" borderTopRadius="lg" justifyItems="center" alignItems="start" p={2} pb={0} pl={4} justifyContent="end">
{/*<Text fontWeight="bold" fontSize="lg" color="white">Alert Level Changes Quad Plot</Text>*/}
<Text bg="cyan.200/5" borderRadius="sm" padding="1" fontWeight="normal" fontSize="sm" color="white">All time</Text>
</Flex>
<Flex direction="column" w="100%" h="100%" bg="gray.800" gap="2" padding="2" borderBottomRadius="lg">
<Flex direction="row" w="100%" h="100%" gap="2">
<Center bg={`blue.200/${tp_percent % 50}`} w="100%" h="100%" borderRadius="lg" color="white" fontSize="sm" fontWeight="bold">
<Flex direction="column" w="100%" h="100%" justifyContent="center" alignItems="center">
<Text>True Positive</Text>
<Text fontSize="lg"> {tp_percent}% </Text>
<Text color="gray.400" fontSize="xs" fontWeight="normal"> {apiData[0]['tp_count']}/{apiData[0]['tot_count']} </Text>
</Flex>
</Center>
<Center bg={`blue.200/${tn_percent % 50}`} w="100%" h="100%" borderRadius="lg" color="white" fontSize="sm" fontWeight="bold">
<Flex direction="column" w="100%" h="100%" justifyContent="center" alignItems="center">
<Text>True Negative</Text>
<Text fontSize="lg"> {tn_percent}% </Text>
<Text color="gray.400" fontSize="xs" fontWeight="normal"> {apiData[0]['tn_count']}/{apiData[0]['tot_count']} </Text>
</Flex>
</Center>
</Flex>
<Flex direction="row" w="100%" h="100%" gap="2">
<Center bg={`blue.200/${fp_percent % 50}`} w="100%" h="100%" borderRadius="lg" color="white" fontSize="sm" fontWeight="bold">
<Flex direction="column" w="100%" h="100%" justifyContent="center" alignItems="center">
<Text>False Positive</Text>
<Text fontSize="lg"> {fp_percent}% </Text>
<Text color="gray.400" fontSize="xs" fontWeight="normal"> {apiData[0]['fp_count']}/{apiData[0]['tot_count']} </Text>
</Flex>
</Center>
<Center bg={`blue.200/${fn_percent % 50}`} w="100%" h="100%" borderRadius="lg" color="white" fontSize="sm" fontWeight="bold">
<Flex direction="column" w="100%" h="100%" justifyContent="center" alignItems="center">
<Text>False Negative</Text>
<Text fontSize="lg"> {fn_percent}% </Text>
<Text color="gray.400" fontSize="xs" fontWeight="normal"> {apiData[0]['fn_count']}/{apiData[0]['tot_count']} </Text>
</Flex>
</Center>
</Flex>
</Flex>
</Flex>
)
}
@@ -0,0 +1,73 @@
import React from 'react';
import { Box } from '@chakra-ui/react';
import { http, HttpResponse } from 'msw'; // Import MSW
import LlmAlChangesQuadPlot from './LlmAlChangesQuadPlot';
export default {
title: 'Dashboard Widgets/LLM AL Changes Quad Plot',
component: LlmAlChangesQuadPlot,
decorators: [
(Story) => (
<Box
w="100%" maxW="1800px" h="400px"
border="2px dashed" borderColor="gray.600" p={2}
resize="both" overflow="auto"
>
<Story />
</Box>
),
],
};
const mockData = [
{ tp: 50 },
{ tn: 250 },
{ fp: 10 },
{ fn: 5 },
{ tot_count: 315}
];
// Scenario LIVE: call our API for real
export const LivePopulated = {};
// Scenario 1: Successful API Call
export const Populated = {
parameters: {
msw: {
handlers: [
// Intercept the exact URL your component is trying to fetch
http.get('*/api/v2/llm_quadrant_plot', () => {
// Return a 200 OK with the mock JSON
return HttpResponse.json(mockData);
}),
],
},
},
};
// Scenario 2: The 500 Server Crash
export const ServerCrash = {
parameters: {
msw: {
handlers: [
http.get('*/api/v2/llm_quad_plot', () => {
// Return a 500 Error
return new HttpResponse(null, { status: 500 });
}),
],
},
},
};
// Scenario 3: Empty State (API works, but no data returned)
export const EmptyData = {
parameters: {
msw: {
handlers: [
http.get('*/api/v2/llm_quad_plot', () => {
return HttpResponse.json([]);
}),
],
},
},
};
@@ -1,7 +1,6 @@
import { useState, useMemo } from "react"; import {useState, useMemo, useRef, useEffect, useCallback} from "react";
import { import {
Button, Button,
IconButton,
Box, Box,
Text, Text,
Flex, Flex,
@@ -10,25 +9,61 @@ import {
Tabs, Tabs,
Badge, Badge,
Menu, Menu,
HStack HStack,
useRecipe,
useSlotRecipe
} from "@chakra-ui/react"; } from "@chakra-ui/react";
import { Settings, Plus, LayoutGrid, Move, Save, X } from 'lucide-react'; import {Settings, LayoutGrid, Move, Save, X, ChevronRight, ChevronLeft} from 'lucide-react';
import {useDashboardStore} from "../../store/useDashboardStore.jsx"; import {useDashboardStore} from "../../store/useDashboardStore.jsx";
import {WIDGET_REGISTRY} from "../../constants/widgetRegistry.jsx"; 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"};
return mapping[key.toLowerCase()] || key.charAt(0).toUpperCase();
};
export function SettingsButton() { export function SettingsButton() {
// 1. ☁Store connections // 1. ☁Store connections
const isEditing = useDashboardStore(state => state.isEditing); const isEditing = useDashboardStore(state => state.isEditing);
const enterEditMode = useDashboardStore(state => state.enterEditMode); const enterEditMode = useDashboardStore(state => state.enterEditMode);
// This now handles both local UI lock AND database saving!
const saveEdit = useDashboardStore(state => state.saveEdit); const saveEdit = useDashboardStore(state => state.saveEdit);
const cancelEdit = useDashboardStore(state => state.cancelEdit); const cancelEdit = useDashboardStore(state => state.cancelEdit);
const addWidget = useDashboardStore(state => state.addWidget); const addWidget = useDashboardStore(state => state.addWidget);
const recipe = useRecipe({key: "glassTab"});
const tabStyles = recipe();
// Pull the glass container styles for the dropdown and modal
const panelRecipe = useSlotRecipe({key: "glassPanel"});
const panelStyles = panelRecipe({layout: "dropdown"});
const modalStyles = panelRecipe({layout: "popover"});
const [isLibraryOpen, setIsLibraryOpen] = useState(false); const [isLibraryOpen, setIsLibraryOpen] = useState(false);
// ⬅️ ➡️ This is the callbacks and scroll control to add the chevron arrows in the tab list
const tabsRef = useRef(null);
const [canScrollLeft, setCanScrollLeft] = useState(false);
const [canScrollRight, setCanScrollRight] = useState(false);
const checkScroll = useCallback(() => {
if (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);
}
}, []);
useEffect(() => {
if (isLibraryOpen) {
// Small timeout ensures the DOM has rendered the tabs before measuring
setTimeout(checkScroll, 50);
window.addEventListener('resize', checkScroll);
return () => window.removeEventListener('resize', checkScroll);
}
}, [isLibraryOpen, checkScroll]);
// Smart Add Handler // Smart Add Handler
const handleAddWidget = (widgetId, sizeKey) => { const handleAddWidget = (widgetId, sizeKey) => {
enterEditMode(); enterEditMode();
@@ -46,94 +81,280 @@ export function SettingsButton() {
const categories = Object.keys(categorizedWidgets); const categories = Object.keys(categorizedWidgets);
// use ref to capture html node for placing menu accordingly
const menuRef = useRef(null);
const getAnchorRect = () => {
if (!menuRef.current) return null;
return menuRef.current.getBoundingClientRect();
};
return ( return (
<> <>
{/* THE STATIC DROPDOWN MENU */} {isEditing ? (
<Menu.Root> // 📝 EDIT MODE: The 3-Pill Layout
<Menu.Trigger asChild> <HStack gap={2}>
<IconButton {/* 1. The Add Widget Button */}
aria-label="Settings" <Box
bg="vdap.darkGreen" as="button"
color="white" css={tabStyles}
size="sm" data-state="open"
borderRadius="md" onClick={() => setIsLibraryOpen(true)}
_hover={{ bg: "vdap.darkGreenHover" }} color={{base: "blue.500", _dark: "blue.300"}}
_hover={{bg: "rgba(66, 153, 225, 0.1)"}}
> >
<Settings size={18} /> <LayoutGrid size={20} style={{flexShrink: 0}}/>
</IconButton> <Box as="span">Widget Library</Box>
</Box>
{/* 2. The Save Button */}
<Box
as="button"
css={tabStyles}
data-state="open"
onClick={saveEdit}
color={{base: "green.600", _dark: "green.400"}}
_hover={{bg: "rgba(72, 187, 120, 0.1)"}}
>
<Save size={20} style={{flexShrink: 0}}/>
<Box as="span">Save Layout</Box>
</Box>
{/* 3. The Discard Button */}
<Box
as="button"
css={tabStyles}
data-state="open"
onClick={cancelEdit}
color={{base: "red.500", _dark: "red.400"}}
_hover={{bg: "rgba(245, 101, 101, 0.1)"}}
>
<X size={20} style={{flexShrink: 0}}/>
<Box as="span">Discard</Box>
</Box>
</HStack>
) : (
// 👀 VIEW MODE: The Static Dropdown Menu
<Menu.Root positioning={{getAnchorRect}}>
<Menu.Trigger asChild>
<Box ref={menuRef} as="button" css={tabStyles}>
{/* size increased to 24 to match tabs. flexShrink: 0 is CRITICAL */}
<Settings size={24} style={{flexShrink: 0}}/>
<Box as="span">Dashboard Settings</Box>
</Box>
</Menu.Trigger> </Menu.Trigger>
<Menu.Content bg="white" boxShadow="lg" borderRadius="md" p={1} zIndex="dropdown"> <Menu.Positioner>
{isEditing ? ( <Menu.Content css={panelStyles.root} zIndex="dropdown" minW="200px">
<> <Menu.Item
{/* WIRE DIRECTLY TO saveEdit */} onClick={enterEditMode}
<Menu.Item onClick={saveEdit} color="green.600" fontWeight="bold" cursor="pointer" _hover={{ bg: "green.50" }}> cursor="pointer"
<Save size={16} style={{ marginRight: '8px' }} /> Save Layout _hover={{WebkitTextStroke: "0.5px currentColor"}}
</Menu.Item> >
<Menu.Item onClick={cancelEdit} color="red.500" cursor="pointer" _hover={{ bg: "red.50" }}>
<X size={16} style={{ marginRight: '8px' }} /> Discard Changes
</Menu.Item>
</>
) : (
<Menu.Item onClick={enterEditMode} cursor="pointer" _hover={{ bg: "gray.100" }}>
<Move size={16} style={{marginRight: '8px'}}/> Edit Layout <Move size={16} style={{marginRight: '8px'}}/> Edit Layout
</Menu.Item> </Menu.Item>
)}
<Menu.Separator my={1} borderColor="gray.200" /> <Menu.Separator my={1} borderColor={{base: "gray.200", _dark: "whiteAlpha.200"}}/>
<Menu.Item onClick={() => setIsLibraryOpen(true)} cursor="pointer" _hover={{ bg: "gray.100" }}> <Menu.Item
onClick={() => setIsLibraryOpen(true)}
cursor="pointer"
_hover={{
bg: {base: "rgba(0, 0, 0, 0.05)", _dark: "rgba(255, 255, 255, 0.1)"},
WebkitTextStroke: "0.5px currentColor"
}}
>
<LayoutGrid size={16} style={{marginRight: '8px'}}/> Widget Library <LayoutGrid size={16} style={{marginRight: '8px'}}/> Widget Library
</Menu.Item> </Menu.Item>
</Menu.Content> </Menu.Content>
</Menu.Positioner>
</Menu.Root> </Menu.Root>
)}
{/* THE WIDGET LIBRARY MODAL (Controlled by isLibraryOpen) */} {/* 📚📚📚 THE WIDGET LIBRARY MODAL (Controlled by isLibraryOpen) */}
<Dialog.Root open={isLibraryOpen} onOpenChange={(e) => setIsLibraryOpen(e.open)} size="xl" placement="center"> <Dialog.Root
<Dialog.Backdrop bg="blackAlpha.600" /> open={isLibraryOpen}
onOpenChange={(e) => setIsLibraryOpen(e.open)}
size="xl"
placement="center"
closeOnInteractOutside={true}
closeOnEscapeKeyDown={true}
>
{/* Soft blur can be added to the background behind the modal */}
{/*<Dialog.Backdrop bg="blackAlpha.100" backdropFilter="blur(2px)"/>*/}
<Dialog.Positioner> <Dialog.Positioner>
<Dialog.Content bg="gray.50" borderRadius="xl" overflow="hidden" boxShadow="xl" maxW="800px">
<Dialog.Header bg="vdap.darkGreen" color="white" py={4}> <Dialog.Content css={modalStyles.root} overflow="hidden" maxW="60%" minH="80%" p={0}>
<Dialog.Title fontSize="xl" fontWeight="bold">Add Dashboard Widgets</Dialog.Title>
<Dialog.Header bg="transparent" color={{base: "gray.800", _dark: "white"}} py={4}
borderColor={{base: "gray.200", _dark: "whiteAlpha.200"}}>
<Dialog.Title fontSize="xl" fontWeight="bold">Widgets Shop</Dialog.Title>
</Dialog.Header> </Dialog.Header>
<Dialog.Body p={0}> <Dialog.Body p={0}>
<Tabs.Root defaultValue={categories[0]} variant="enclosed" colorScheme="blue"> <Tabs.Root defaultValue={categories[0]} variant="unstyled">
<Tabs.List bg="white" px={4} pt={4} borderBottom="1px solid" borderColor="gray.200"> <Box position="relative" display="flex" mx="auto" maxWidth="100%" mx={5} mt={4} mb={6}>
{/* LEFT GLASS CRESCENT */}
{canScrollLeft && (
<Flex
position="absolute"
left="0" top="0" bottom="0"
w="50px"
align="center" justify="center"
zIndex={2}
cursor="pointer"
onClick={() => tabsRef.current.scrollBy({left: -200, behavior: 'smooth'})}
bg={{base: "rgba(255, 255, 255, 0.7)", _dark: "rgba(30, 30, 30, 0.8)"}}
backdropFilter="blur(1px)"
borderTopLeftRadius="full"
borderBottomLeftRadius="full"
// THE MAGIC: Bites a transparent circle out of the flat right side!
WebkitMaskImage="radial-gradient(circle at 100% 50%, transparent 30px, black 19px)"
maskImage="radial-gradient(circle at 100% 50%, transparent 30px, black 35px)"
color={{base: "gray.600", _dark: "gray.300"}}
transition="background-color 0.2s"
_hover={{
color: {base: "blue.500", _dark: "blue.300"},
bg: {base: "rgba(255, 255, 255, 0.9)", _dark: "rgba(40, 40, 40, 0.95)"}
}}
>
{/* Shifted slightly left to optically center it in the crescent mass */}
<ChevronLeft size={18} style={{ marginLeft: "-30px" }}/>
</Flex>
)}
<Tabs.List
ref={tabsRef}
onScroll={checkScroll}
bg={{base: "rgba(0, 0, 0, 0.04)", _dark: "rgba(255, 255, 255, 0.05)"}}
p={1}
borderRadius="full"
display="flex"
flexWrap="nowrap"
overflowX="auto"
maxWidth="100%"
border="1px solid"
borderColor={{base: "blackAlpha.50", _dark: "whiteAlpha.100"}}
css={{
scrollbarWidth: "none",
"&::-webkit-scrollbar": {display: "none"},
}}
// This is for desktop users not on trackpad to scroll the
onWheel={(e) => {
if (e.currentTarget) {
e.currentTarget.scrollLeft += e.deltaY;
}
}}
>
{categories.map(cat => ( {categories.map(cat => (
<Tabs.Trigger key={cat} value={cat} pb={2}>{cat}</Tabs.Trigger> <Tabs.Trigger
key={cat}
value={cat}
px={5}
py={2}
borderRadius="full"
whiteSpace="nowrap"
flexShrink={0}
color={{base: "gray.500", _dark: "gray.400"}}
fontWeight="medium"
transition="background-color 0.2s, color 0.2s, box-shadow 0.2s"
_hover={{
color: {base: "gray.800", _dark: "gray.200"}
}}
_selected={{
bg: {base: "white", _dark: "rgba(255, 255, 255, 0.12)"},
color: {base: "blue.600", _dark: "blue.200"},
boxShadow: "sm",
fontWeight: "bold",
}}
>
{cat}
</Tabs.Trigger>
))} ))}
</Tabs.List> </Tabs.List>
{canScrollRight && (
<Flex
position="absolute"
right="0" top="0" bottom="0"
w="50px"
align="center" justify="center"
zIndex={2}
cursor="pointer"
onClick={() => tabsRef.current.scrollBy({left: 200, behavior: 'smooth'})}
bg={{base: "rgba(255, 255, 255, 0.7)", _dark: "rgba(30, 30, 30, 0.8)"}}
backdropFilter="blur(1px)"
borderTopRightRadius="full"
borderBottomRightRadius="full"
// THE MAGIC: Bites a transparent circle out of the flat left side!
WebkitMaskImage="radial-gradient(circle at 0% 50%, transparent 30px, black 19px)"
maskImage="radial-gradient(circle at 0% 50%, transparent 30px, black 35px)"
color={{base: "gray.600", _dark: "gray.300"}}
transition="background-color 0.2s"
_hover={{
color: {base: "blue.500", _dark: "blue.300"},
bg: {base: "rgba(255, 255, 255, 0.9)", _dark: "rgba(40, 40, 40, 0.95)"}
}}
>
{/* Shifted slightly right to optically center it in the crescent mass */}
<ChevronRight size={18} style={{ marginRight: "-30px" }}/>
</Flex>
)}
</Box>
{categories.map(cat => ( {categories.map(cat => (
<Tabs.Content key={cat} value={cat} p={6}> <Tabs.Content key={cat} value={cat} p={6}>
<Grid templateColumns="repeat(auto-fill, minmax(300px, 1fr))" gap={4}> <Grid templateColumns="repeat(auto-fill, minmax(300px, 1fr))" gap={4}>
{categorizedWidgets[cat].map(widget => ( {categorizedWidgets[cat].map(widget => (
<Flex key={widget.id} direction="column" bg="white" p={4} borderRadius="md" border="1px solid" borderColor="gray.200" boxShadow="sm"> <Flex
key={widget.id}
direction="column"
bg={{base: "rgba(255, 255, 255, 0.6)", _dark: "rgba(0, 0, 0, 0.2)"}}
p={4}
borderRadius="xl"
border="1px solid"
borderColor={{base: "rgba(255, 255, 255, 0.9)", _dark: "whiteAlpha.200"}}
boxShadow="sm"
>
<Text fontWeight="bold" fontSize="md" mb={1}>{widget.name}</Text> <Text fontWeight="bold" fontSize="md" mb={1}>{widget.name}</Text>
<Text fontSize="sm" color="gray.500" mb={4} flex="1">{widget.description}</Text> <Text fontSize="sm" color="gray.500" mb={4} flex="1">{widget.description}</Text>
<Box borderTop="1px solid" borderColor="gray.100" pt={3}> <Box borderTop="1px solid" borderColor={{base: "gray.200", _dark: "whiteAlpha.200"}}
<Text fontSize="xs" fontWeight="bold" color="gray.400" textTransform="uppercase" mb={2}>Add to Grid:</Text> pt={3}>
<Text fontSize="xs" fontWeight="bold" color="gray.400" textTransform="uppercase"
mb={2}>
Add to Dashboard:
</Text>
<HStack gap={2} flexWrap="wrap"> <HStack gap={2} flexWrap="wrap">
{Object.keys(widget.allowedSizes).map(sizeKey => ( {Object.keys(widget.allowedSizes).map(sizeKey => (
<Badge <Box
key={sizeKey} key={sizeKey}
as="button" as="button"
css={tabStyles}
onClick={() => handleAddWidget(widget.id, sizeKey)} onClick={() => handleAddWidget(widget.id, sizeKey)}
colorScheme="gray" color={{base: "blue.600", _dark: "blue.300"}}
variant="subtle"
px={3}
py={1}
borderRadius="full"
cursor="pointer"
_hover={{ bg: "blue.50", color: "blue.600", transform: "scale(1.05)" }}
transition="all 0.2s"
> >
<Plus size={12} style={{ display: 'inline', marginRight: '4px' }}/> {/* THE ABBREVIATION ICON: Always visible */}
{sizeKey.charAt(0).toUpperCase() + sizeKey.slice(1)} <Flex
</Badge> align="center"
justify="center"
w="24px"
h="24px"
flexShrink={0}
borderRadius="full"
bg={{base: "blue.50", _dark: "whiteAlpha.200"}}
fontWeight="black"
fontSize="xs"
bg='transparent'
>
{getSizeAbbreviation(sizeKey)}
</Flex>
{/* THE EXPANDED TEXT: Only visible on hover */}
<Box as="span">Add Widget</Box>
</Box>
))} ))}
</HStack> </HStack>
</Box> </Box>
@@ -144,7 +365,8 @@ export function SettingsButton() {
))} ))}
</Tabs.Root> </Tabs.Root>
</Dialog.Body> </Dialog.Body>
<Dialog.CloseTrigger position="absolute" top={3} right={3} color="white" /> <Dialog.CloseTrigger position="absolute" top={3} right={3}
color={{base: "gray.500", _dark: "whiteAlpha.800"}} _hover={{color: "red.400"}}/>
</Dialog.Content> </Dialog.Content>
</Dialog.Positioner> </Dialog.Positioner>
</Dialog.Root> </Dialog.Root>
@@ -1,79 +0,0 @@
import Widget from "./Widget.jsx";
import { Fieldset, NativeSelect, For, Box, Field, Input, Button, Text, Flex } from "@chakra-ui/react";
import { useForm } from "react-hook-form";
import { useState } from "react";
import { Asterisk } from 'lucide-react';
export default function AlertLevel({id, isEditable, isDelete, DeleteWidget}) {
const { register, handleSubmit, reset, formState: {errors} } = useForm();
const [isSubmit, setIsSubmit] = useState(false);
const onSubmit = (data) => {
setIsSubmit(true);
reset();
}
// Prop Forwarding
const widgetProps = { id, isEditable, isDelete, DeleteWidget, isSubmit, setIsSubmit }
return (
<Widget title="Alert Level" {...widgetProps} >
{!isSubmit ? (
// DISPLAYING INPUT FIElDS AND LABELS
<Box
as="form"
onSubmit={handleSubmit(onSubmit)}
width="100%"
p={3}
display="flex"
flexDir="column"
>
<Fieldset.Root size="md" maxW="md">
<Fieldset.Content>
<Field.Root>
<Field.Label fontWeight="semibold">Volcano</Field.Label>
<Input name="volcanoname" />
</Field.Root>
<Field.Root>
<Field.Label fontWeight="semibold">Country</Field.Label>
<NativeSelect.Root>
<NativeSelect.Field name="country">
<For each={["United Kingdom", "Canada", "United States"]}>
{(item) => (
<option key={item} value={item}>
{item}
</option>
)}
</For>
</NativeSelect.Field>
<NativeSelect.Indicator />
</NativeSelect.Root>
</Field.Root>
</Fieldset.Content>
<Button type="submit" size="sm">Submit</Button>
</Fieldset.Root>
</Box>
):(
// DISPLAYING ALERT LEVEL DATA
<Box p={1} mt={1} ml="auto" mr="auto" width="200px">
<Box
bg="bg"
shadow="md"
borderRadius="md"
p={8}
width="200px"
height="10px"
textAlign="center"
display="flex"
alignItems="center"
justifyContent="center"
>
<Text fontsize="2xl" fontWeight="bold" color="gray.700">Alert Level Data Coming Soon.</Text>
</Box>
</Box>
)}
</Widget>
);
}
@@ -1,7 +0,0 @@
import { Button } from "@chakra-ui/react";
export function CancelButton ({onCancel}) {
return (
<Button onClick={onCancel} borderRadius="md">Cancel</Button>
)
}
@@ -1,39 +0,0 @@
// DEPRECATED
// import GlobalMap from "./views/GlobalMap";
// import RegionalMap from "./views/RegionalMap";
// import Volcano from "./views/Volcano";
// import Admin from "./views/Admin";
// import Account from "./views/Account"
// import Home from "./views/Home";
// import { DASHBOARD_VIEWS, ADMIN_VIEWS, VOLCANO_VIEWS } from "@/constants/viewKeys";
// import { chakra } from "@chakra-ui/react";
// import Personal from "./views/Personal";
// import Security from "./views/Security";
//
// export default function Canvas(props) {
// const { view } = props;
//
// return (
// <chakra.div width="100%" height="100%">
// {/* Check if view is a tab inside the Home Header */}
// { DASHBOARD_VIEWS.includes(view) && (
// <Home {...props}/>
// )}
// {/* Check if view is a tab inside the Volcano Header */}
// { VOLCANO_VIEWS.includes(view) && (
// <Volcano {...props}/>
// )}
// {/* Check if view is a tab inside the Admin Header */}
// { ADMIN_VIEWS.includes(view) && (
// <Admin {...props}/>
// )}
// {view === "global" && <GlobalMap />}
// {view === "regional" && <RegionalMap />}
// {view === "account" && <Account />}
// {view === "settings" && <Personal />}
// {view === "personal" && <Personal />}
// {view === "security" && <Security />}
// </chakra.div>
// );
// }
@@ -1,27 +0,0 @@
import { MoveDiagonal2 } from 'lucide-react';
import React from "react";
const CustomResizeHandle = React.forwardRef((props, ref) => {
const { handleAxis, isVisable, ...restProps } = props;
if (!isVisable) return null;
return (
<div
ref={ref}
{...restProps}
className={`resize-hande-${handleAxis}`}
style={{
position: 'absolute',
bottom: 0,
right: 0,
cursor: "pointer",
width: "20px",
height: "20px",
zIndex: "1",
}}
>
<MoveDiagonal2 />
</div>
);
});
export default CustomResizeHandle;
@@ -1,95 +0,0 @@
// DEPRECATED
// import Header from './Header/Header.jsx';
// import Sidebar from './Sidebar/Sidebar.jsx';
// import Canvas from './Canvas/Canvas.jsx';
// import { Grid, GridItem, useRecipe, useDialog } from '@chakra-ui/react';
// import { useState } from 'react';
// import DialogPopup from './Canvas/CanvasComponents/DialogPopup.jsx';
//
// export default function Dashboard() {
// const recipe = useRecipe({ key: "dashboard" });
// const styles = recipe();
//
// const [darkMode, setDarkMode] = useState(false);
// const [isEditable, setIsEditable] = useState(false); // editable=true means static=false (vice versa)
// const [isDelete, setIsDelete] = useState(false);
// const [originalLayout, setOriginalLayout] = useState([]);
// const [originalWidgets, setOriginalWidgets] = useState([]);
// const [view, setView] = useState("mydashboard");
// const [layout, setLayout] = useState([]);
// const [widgetArray, setWidgetArray] = useState([]);
// const dialog = useDialog();
//
// const beginEditIfNeeded = () => {
// if ( !isEditable ) {
// setOriginalLayout(layout);
// setOriginalWidgets(widgetArray);
// }
// };
//
// const onCancel = () => {
// console.log("canceling changes...");
// console.log(originalWidgets);
// if (originalLayout.length) {
// setLayout(originalLayout.map(item => ({
// ...item,
// static: true
// })));
// };
// setWidgetArray(originalWidgets);
// setIsEditable(false);
// setIsDelete(false);
// setOriginalLayout([]);
// setOriginalWidgets([]);
// }
//
// // Prevent navigation while in Edit mode without saving or cancelling
// const handleViewChange = (nextView) => {
// console.log("1. handling view change")
// if (view === "mydashboard" && isEditable) {
// console.log("2. currently editing");
// dialog.setOpen(true);
// return;
//
// // const confirmed = window.confirm(
// // "You have unsaved changes. Discard them and continue?"
// // );
// // if (!confirmed) return;
// // onCancel();
// }
// setView(nextView);
// };
//
// const onLayoutChange = (newLayout) => setLayout(newLayout);
//
// // Prop Forwarding
// const canvasProps = { view, layout, setLayout, setOriginalLayout, onLayoutChange, onChangeView: handleViewChange,
// onCancel, isEditable, setIsEditable, isDelete, setIsDelete, widgetArray, setWidgetArray, originalWidgets, setOriginalWidgets, beginEditIfNeeded
// };
// const sidebarProps = { view, onChangeView: handleViewChange, darkMode, setDarkMode };
// const headerProps = { onChangeView: handleViewChange };
//
// return (
// <>
// <DialogPopup dialog={dialog} />
// <Grid css={styles}
// templateRows="1fr 11fr"
// // templateColumns="1fr 20fr"
// templateColumns="auto 1fr"
// height="100vh"
// width="100vw"
// >
// <GridItem rowSpan={1} colSpan={2}>
// <Header {...headerProps}/>
// </GridItem>
// <GridItem colSpan={1}>
// <Sidebar {...sidebarProps}/>
// </GridItem>
// <GridItem colSpan={1} width="100%" overflow="auto">
// <Canvas {...canvasProps}/>
// </GridItem>
// </Grid>
// </>
// );
// }
@@ -1,9 +0,0 @@
import { Button } from "@chakra-ui/react";
export default function DeleteAllButton ({onDeleteAll}) {
return (
<Button onClick={onDeleteAll} color="#FFFFFF" bg="#EF4444" _hover={{ bg: "bg.error", color: "#EF4444"}}>
Delete All
</Button>
)
}
@@ -1,57 +0,0 @@
import { Box, Menu, Portal } from '@chakra-ui/react'
import AlertLevel from "@/components/deprecated/AlertLevelWidget.jsx";
export default function FirstWidgetButton({ appendWidget }) {
const triggerItem = (
<>
<Menu.Trigger asChild>
<Box
p={6}
m="auto"
mt={6}
align="center"
textAlign="center"
justify="center"
width="400px"
borderRadius="md"
boxShadow="md"
border="2px dashed"
borderColor="gray.300"
bg="gray.50"
cursor="pointer"
_hover = {{
bg: "gray.100",
borderColor: "gray.400",
boxShadow: "lg",
}}
>
Add Your First Widget
</Box>
</Menu.Trigger>
</>
);
const positioning = { placement: "bottom-middle" };
// const WidgetMenuProps = { appendWidget, triggerItem, positioning };
return (
// <WidgetMenu {...WidgetMenuProps} />
<Menu.Root positioning={positioning}>
{triggerItem}
<Portal>
<Menu.Positioner>
<Menu.Content>
<Menu.Item
value="AlertLevel"
onClick={() => appendWidget(AlertLevel, 4, 7, 4, 7, 8, 14)} // width and height are passed through here for each widget
>
Alert Level
</Menu.Item>
<Menu.Item value="CO2">CO2</Menu.Item>
<Menu.Item value="Ivans">IVANS</Menu.Item>
<Menu.Item value="PlumeHeights">Plume Heights</Menu.Item>
<Menu.Item value="AlertLevelChanges">Alert Level Changes</Menu.Item>
</Menu.Content>
</Menu.Positioner>
</Portal>
</Menu.Root>
);
}
@@ -1,7 +0,0 @@
import { Button } from "@chakra-ui/react";
export function SaveButton ({onSave}) {
return (
<Button onClick={onSave} borderRadius="md" bg="primary" _hover={{bg: "primaryLt"}}>Save</Button>
)
}
@@ -1,32 +0,0 @@
import { useSlotRecipe, chakra, Flex, CloseButton, Text, IconButton } from "@chakra-ui/react"
import { Undo } from 'lucide-react';
export default function Widget(props) {
// deconstructing props
const { id, title, isEditable, isDelete, DeleteWidget, isSubmit, setIsSubmit, children } = props;
const recipe = useSlotRecipe({ key: "widget" });
const styles = recipe();
return (
<Flex flexDirection="column" w="100%" h="auto">
{/* HEADER */}
<Flex css={styles.header} cursor={isEditable ? "move":"default"} flexDirection="row" w="100%" h="auto" justifyContent="space-between" alignItems="center">
<Text className="widget-handle" w="100%" display="flex" alignItems="center" height="32px" fontWeight="bold">{title}</Text>
{isDelete ? (
<CloseButton onClick={() => DeleteWidget(id)} size="xs" _hover={{bg: "tomato", color: "white"}}/>
):(
isSubmit ? (
<IconButton onClick={() => setIsSubmit(false)} size="xs" bg="base300" cursor="pointer"><Undo fill="text" /></IconButton>
):null
)}
</Flex>
{/* CHILDREN */}
<Flex w="100%" h="auto">
{children}
</Flex>
</Flex>
);
}
@@ -1,26 +0,0 @@
import { Menu, Portal } from "@chakra-ui/react";
import AlertLevel from "./AlertLevelWidget.jsx";
export default function WidgetMenu({appendWidget, triggerItem, positioning}) {
return (
<Menu.Root positioning={positioning}>
{triggerItem}
<Portal>
<Menu.Positioner>
<Menu.Content>
<Menu.Item
value="AlertLevel"
onClick={() => appendWidget(AlertLevel, 4, 7, 4, 7, 8, 14)} // width and height are passed through here for each widget
>
Alert Level
</Menu.Item>
<Menu.Item value="CO2">CO2</Menu.Item>
<Menu.Item value="Ivans">IVANS</Menu.Item>
<Menu.Item value="PlumeHeights">Plume Heights</Menu.Item>
<Menu.Item value="AlertLevelChanges">Alert Level Changes</Menu.Item>
</Menu.Content>
</Menu.Positioner>
</Portal>
</Menu.Root>
)
}
@@ -1,35 +0,0 @@
import { Tooltip as ChakraTooltip, Portal } from '@chakra-ui/react'
import * as React from 'react'
export const Tooltip = React.forwardRef(function Tooltip(props, ref) {
const {
showArrow,
children,
disabled,
portalled = true,
content,
contentProps,
portalRef,
...rest
} = props
if (disabled) return children
return (
<ChakraTooltip.Root {...rest}>
<ChakraTooltip.Trigger asChild>{children}</ChakraTooltip.Trigger>
<Portal disabled={!portalled} container={portalRef}>
<ChakraTooltip.Positioner>
<ChakraTooltip.Content ref={ref} {...contentProps}>
{showArrow && (
<ChakraTooltip.Arrow>
<ChakraTooltip.ArrowTip />
</ChakraTooltip.Arrow>
)}
{content}
</ChakraTooltip.Content>
</ChakraTooltip.Positioner>
</Portal>
</ChakraTooltip.Root>
)
})
+7 -12
View File
@@ -2,6 +2,7 @@ import { useRecipe, Button, Stack, Text, Flex } from "@chakra-ui/react"
import UserAvatarMenu from "./UserAvatarMenu.jsx"; import UserAvatarMenu from "./UserAvatarMenu.jsx";
import { NavLink } from "react-router-dom"; import { NavLink } from "react-router-dom";
import useAuthStore from "@/store/authStore"; import useAuthStore from "@/store/authStore";
import {SearchBar} from "@/components/dashboard/SearchBar.jsx";
// Import the asset properly so Vite can bundle it for any server // Import the asset properly so Vite can bundle it for any server
// import defaultAvatar from "@/assets/user_profile.svg"; // import defaultAvatar from "@/assets/user_profile.svg";
@@ -13,25 +14,19 @@ export default function Header() {
const { user } = useAuthStore(); const { user } = useAuthStore();
console.log(user); console.log(user);
const displayName = user ? (user.fullName || user.username) : "Loading..."; const displayName = user ? (user.firstName || user.username) : "Loading...";
const avatarname = user ? (user.fullName || user.username) : "Loading...";
const displayEmail = user?.email || "LDAP User"; const displayEmail = user?.email || "LDAP User";
return ( return (
<Flex css={styles} justify="space-between" align="center" width="100%"> <Flex css={styles} >
{/* Home Link Logo */} <SearchBar placeholder="Enter a volcano to search" size="sm" width="410px" />
<Button as={NavLink} to="/home" color="color" variant="plain" textStyle="5xl" fontWeight="bold">
VDAP
</Button>
{/* User Profile Section */} {/* User Profile Section */}
<Flex align="center" gap={3} pr={6}> <Flex align="center" gap={3} pr={6}>
<Stack gap="0" textAlign="right" cursor="default"> <Text fontWeight="bold" textStyle="md" >{displayName}</Text>
<Text color="color" fontWeight="bold" textStyle="lg">{displayName}</Text>
<Text color="fg.muted" textStyle="sm">{displayEmail}</Text>
</Stack>
<UserAvatarMenu <UserAvatarMenu
name={displayName} name={avatarname}
// avatar={user.avatar} // avatar={user.avatar}
/> />
</Flex> </Flex>
+30 -29
View File
@@ -3,7 +3,7 @@ import { ColorModeButton } from "@/components/ui/color-mode.jsx";
import {useState} from "react"; import {useState} from "react";
import {NavLink} from "react-router-dom"; import {NavLink} from "react-router-dom";
import Tooltip from "../ui/Tooltip.jsx"; import Tooltip from "../ui/Tooltip.jsx";
import { Mountain, House, Earth, MapPin, ShieldUser, Menu } from 'lucide-react'; import {Mountain, House, Earth, MapPin, ShieldUser, Menu, PanelLeftClose, PanelLeftOpen} from 'lucide-react';
const SIDEBAR_DEFAULT_BUTTONS = [ const SIDEBAR_DEFAULT_BUTTONS = [
{icon: House, name: "Home", url: "/home"}, {icon: House, name: "Home", url: "/home"},
@@ -14,9 +14,11 @@ const SIDEBAR_DEFAULT_BUTTONS = [
]; ];
export default function Sidebar() { export default function Sidebar() {
const [isOpen, setIsOpen] = useState(true); const [isOpen, setIsOpen] = useState(true);
const recipe = useSlotRecipe({key: "sidebar"}); const recipe = useSlotRecipe({key: "sidebar"});
const styles = recipe(); const styles = recipe({state: isOpen ? "open" : "closed"});
// TODO we will need to call buttons here by authorized user, for now we update the visible buttons as simply the default buttons // TODO we will need to call buttons here by authorized user, for now we update the visible buttons as simply the default buttons
const visibleButtons = SIDEBAR_DEFAULT_BUTTONS; const visibleButtons = SIDEBAR_DEFAULT_BUTTONS;
@@ -24,51 +26,50 @@ export default function Sidebar() {
const toggleSidebar = () => setIsOpen((prev) => !prev); const toggleSidebar = () => setIsOpen((prev) => !prev);
return ( return (
<Box css={styles.root} width={isOpen ? "210px" : "71px"} transition="width 0.4s ease" position="relative" display="flex" flexDirection="column" gap={2} <Box css={styles.root}>
{/* Home Link Logo */}
<Button
as={NavLink}
to="/home"
css={styles.logo}
variant="plain"
> >
{/* Menu Trigger */} {isOpen ? "🌋 VDAP" : "🌋"}
<IconButton aria-label="Toggle Sidebar" variant="plain" size="md" onClick={toggleSidebar} width="54px" alignSelf="flex-start" </Button>
>
<Menu />
</IconButton>
{/* Navigation Buttons */} {/* Navigation Buttons */}
{visibleButtons.map((button) => { {visibleButtons.map((button) => {
const Icon = button.icon; const Icon = button.icon;
return ( return (
<Tooltip key={button.name} content={button.name} sidebarIsOpen={isOpen}>
<Button <Button
as={NavLink} as={NavLink}
to={button.url} to={button.url}
css={styles.buttons} css={styles.buttons}
justifyContent="flex-start"
width="100%"
overflow="hidden" // Prevents text popout on collapse
>
<Icon style={{ flexShrink: 0 }} /> {/* Prevents icon from squishing */}
{/* Cleaned conditional transition styling */}
<Box
as="span"
ml={isOpen ? 3 : 0}
opacity={isOpen ? 1 : 0}
visibility={isOpen ? "visible" : "hidden"} // Prevents phantom width calculations and overflow into canvas
transition="opacity 0.3s ease, visibility 0.3s ease, margin 0.3s ease"
whiteSpace="nowrap"
> >
{/* Navigation buttons are [icon text] */}
<Icon/>
<Box as="span" css={styles.button_text}>
{button.name} {button.name}
</Box> </Box>
</Button> </Button>
</Tooltip>
); );
})} })}
<Box css={styles.footer}>
{/* Menu Trigger */}
<IconButton
aria-label="Toggle Sidebar"
variant="plain"
size="md"
onClick={toggleSidebar}
css={styles.collapse_button}
>
{isOpen ? <PanelLeftClose /> : <PanelLeftOpen />}
</IconButton>
{/* Theme Toggler */} {/* Theme Toggler */}
<ColorModeButton <ColorModeButton _hover={{ bg: "transparent" }} />
position="absolute" </Box>
bottom="4"
left="4"
/>
</Box> </Box>
); );
} }
+12 -1
View File
@@ -78,11 +78,22 @@ export const WIDGET_REGISTRY = {
// The baseline data every new VAA widget starts with // The baseline data every new VAA widget starts with
defaultSettings: { defaultSettings: {
yAxisScale: 'normal' // Options: 'normal' | 'symlog' yAxisScale: 'log' // Options: 'normal' | 'symlog'
}, },
allowedSizes: { allowedSizes: {
medium: { w: 6, h: 12 } medium: { w: 6, h: 12 }
} }
}, },
"llm_al_changes_quad_plot": {
name: "Alert Level Changes Quad Plot",
category: "Computer Science",
description: "Percentage of True-Positive, True-Negative, False-Positive, and False-Negative changes in all " +
"alert levels.",
component: lazy(() => import('../components/Widgets/LlmAlChangesQuadPlot.jsx')),
allowedSizes: {
small: { w: 3, h: 12 }
}
}
}; };
+42 -37
View File
@@ -1,60 +1,65 @@
import { HStack, Flex, Box } from "@chakra-ui/react"; import {HStack, Flex, Box, useRecipe} from "@chakra-ui/react";
import {NavLink, Outlet, useLocation} from "react-router-dom"; import {NavLink, Outlet, useLocation} from "react-router-dom";
import {SearchBar} from "../../components/dashboard/SearchBar.jsx"; import {SearchBar} from "../../components/dashboard/SearchBar.jsx";
import {SettingsButton} from "../../components/dashboard/SettingsButton.jsx"; import {SettingsButton} from "../../components/dashboard/SettingsButton.jsx";
// 1. Import your icons (Swap these for whichever you prefer!)
import {LayoutDashboard, CalendarDays, Cloud, Satellite, Activity} from "lucide-react";
// 2. Define the tabs array
const HOME_TABS = [
{name: "My Dashboard", url: "/home", icon: LayoutDashboard, exact: true},
{name: "Daily Activity", url: "/home/daily", icon: CalendarDays},
{name: "Gas", url: "/home/gas", icon: Cloud},
{name: "Remote Sensing", url: "/home/remote", icon: Satellite},
{name: "Seismic", url: "/home/seismic", icon: Activity},
];
export default function Home() { export default function Home() {
const recipe = useRecipe({key: "glassTab"});
const tabStyles = recipe();
const location = useLocation(); const location = useLocation();
const isPersonalDashboard = location.pathname === "/home" || location.pathname === "/home/"; const isPersonalDashboard = location.pathname === "/home" || location.pathname === "/home/";
// 1. CSS making this look like how we want it, TODO turn to theme?
const tabStyles = {
fontSize: "lg",
fontWeight: "normal",
color: "fg.muted",
px: 4, // Horizontal padding
py: 2, // Vertical padding
borderBottom: "2px solid transparent",
mb: "-2px", // 🔥 The trick: Pulls the active border down to overlap the container's line
transition: "all 0.2s",
_hover: { color: "fg" },
_activeLink: {
color: "color", // Or whatever your primary text color is
borderColor: "currentColor", // The active underline
}
};
return ( return (
<Flex direction="column" height="100%" width="100%"> <Flex direction="column" height="100%" width="100%">
{/* 2. 🛠️ SUB HEADER: Matches your original padding and background */} <Flex as="header" position="sticky" top="0" zIndex="dropdown" bg="transparent" p={5} align="center"
<Flex as="header" position="sticky" top="0" zIndex="dropdown" bg="base200" p={5} align="center" justify="space-between" width="100%"> justify="space-between" width="100%">
{/* TABS CONTAINER */}
<Flex gap={2} alignItems="center">
{HOME_TABS.map((tab) => {
const Icon = tab.icon;
return (
<Box
key={tab.name}
as={NavLink}
to={tab.url}
end={tab.exact} // CRITICAL: Forces exact match so "/home" deactivates on sub-routes
css={tabStyles}
>
{/* flexShrink: 0 ensures the icon never squishes during the gooey animation */}
<Icon size={24} style={{flexShrink: 0}}/>
<Box as="span">{tab.name}</Box>
</Box>
);
})}
{/* The Settings button is now inline with the tabs and only renders on the personal dashboard */}
{isPersonalDashboard && <SettingsButton/>}
{/* TABS CONTAINER - Replicates the Tabs.List line container */}
<Flex borderBottom="2px solid" borderColor="border.muted" gap={2}>
<Box as={NavLink} to="/home" end css={tabStyles}>My Dashboard</Box>
<Box as={NavLink} to="/home/gas" css={tabStyles}>Gas</Box>
<Box as={NavLink} to="/home/seismic" css={tabStyles}>Seismic</Box>
<Box as={NavLink} to="/home/remote" css={tabStyles}>Remote Sensing</Box>
<Box as={NavLink} to="/home/daily" css={tabStyles}>Daily Activity</Box>
</Flex> </Flex>
{/* EDIT MODE BUTTONS & CONTROLS */} {/* EDIT MODE BUTTONS & CONTROLS */}
{/* Leaving this HStack here in case you plan to put the SearchBar or other global tools back on the right side */}
<HStack width="258px" justifyContent="flex-end"> <HStack width="258px" justifyContent="flex-end">
{isPersonalDashboard ? ( {/* Future global controls go here */}
<>
<SearchBar placeholder="Enter a volcano to search" size="sm" width="210px" />
{/* This will eventually trigger your Zustand store's edit mode! */}
<SettingsButton />
</>
) : (
<SearchBar placeholder="Enter a volcano to search" size="sm" width="210px" />
)}
</HStack> </HStack>
</Flex> </Flex>
{/* 3. 🛠️ CANVAS AREA */}
<Flex flex="1" overflow="auto"> <Flex flex="1" overflow="auto">
<Outlet/> <Outlet/>
</Flex> </Flex>
+26 -40
View File
@@ -1,9 +1,9 @@
import { Box, Text, Flex, IconButton, Spinner, Popover } from "@chakra-ui/react"; import {Box, Text, Flex, IconButton, Spinner, Popover, useSlotRecipe} from "@chakra-ui/react";
import {X, MoreVertical} from "lucide-react"; import {X, MoreVertical} from "lucide-react";
import {Responsive, WidthProvider} from "react-grid-layout"; import {Responsive, WidthProvider} from "react-grid-layout";
import {useDashboardStore} from "@/store/useDashboardStore.jsx"; import {useDashboardStore} from "@/store/useDashboardStore.jsx";
import {Suspense, useEffect, useRef} from 'react'; import {Suspense, useEffect, useRef} from 'react';
import { useColorModeValue } from "@/components/ui/color-mode";
// 1. Import database messenger // 1. Import database messenger
import useAuthStore from "@/store/authStore"; import useAuthStore from "@/store/authStore";
@@ -14,11 +14,6 @@ import { WIDGET_REGISTRY } from '@/constants/widgetRegistry.jsx';
const ResponsiveGridLayout = WidthProvider(Responsive); const ResponsiveGridLayout = WidthProvider(Responsive);
export default function MyDashboard() { export default function MyDashboard() {
// 🌗 Let's adjust for our light and dark mode
const frameBg = useColorModeValue("gray.100", "gray.800");
const titleColor = useColorModeValue("gray.800", "gray.100");
const iconColor = useColorModeValue("gray.600", "gray.400");
const iconHoverBg = useColorModeValue("gray.100", "gray.700");
// ☁️ Database Connection // ☁️ Database Connection
const {user} = useAuthStore(); const {user} = useAuthStore();
@@ -33,9 +28,11 @@ export default function MyDashboard() {
// 🔒 Safety lock to prevent infinite re-renders // 🔒 Safety lock to prevent infinite re-renders
const hasHydrated = useRef(false); const hasHydrated = useRef(false);
// ========================================== // 1. Pull the new global slot recipe
// INITIAL LOAD: Grab data from Django const recipe = useSlotRecipe({key: "glassPanel"});
// ========================================== const styles = recipe({ layout: "widget" });
const popoverStyles = recipe({ layout: "popover" });
useEffect(() => { useEffect(() => {
if (user?.preferences?.dashboard_layout && !hasHydrated.current) { if (user?.preferences?.dashboard_layout && !hasHydrated.current) {
const savedLayout = user.preferences.dashboard_layout; const savedLayout = user.preferences.dashboard_layout;
@@ -45,7 +42,6 @@ export default function MyDashboard() {
if (Array.isArray(savedLayout)) { if (Array.isArray(savedLayout)) {
setWidgets(savedLayout); setWidgets(savedLayout);
} }
hasHydrated.current = true; hasHydrated.current = true;
} }
}, [user, setWidgets]); }, [user, setWidgets]);
@@ -72,17 +68,9 @@ export default function MyDashboard() {
const SettingsUI = registryEntry.settingsComponent; const SettingsUI = registryEntry.settingsComponent;
return ( return (
// The "Frame" that holds both the Title and the Chart <>
<Flex direction="column" height="100%" width="100%" bg={frameBg}> <Box css={styles.header}>
<Text color="titleColor" fontWeight="semibold" fontSize="md" isTruncated>
{/* THE TITLE BAR */}
<Flex
justify="space-between"
align="center"
px={3}
py={2}
>
<Text color={titleColor} fontWeight="semibold" fontSize="md" isTruncated>
{registryEntry.name} {registryEntry.name}
</Text> </Text>
@@ -94,6 +82,7 @@ export default function MyDashboard() {
size="xs" size="xs"
variant="ghost" variant="ghost"
color="gray.400" color="gray.400"
borderRadius="xl"
_hover={{color: "white", bg: "gray.700"}} _hover={{color: "white", bg: "gray.700"}}
aria-label="Widget Settings" aria-label="Widget Settings"
> >
@@ -103,7 +92,7 @@ export default function MyDashboard() {
{/* NEW: The Positioner lifts the content out of the Flexbox flow */} {/* NEW: The Positioner lifts the content out of the Flexbox flow */}
<Popover.Positioner zIndex={10}> <Popover.Positioner zIndex={10}>
<Popover.Content bg="gray.50" p={4} boxShadow="xl" borderRadius="md"> <Popover.Content css={popoverStyles.root}>
<Suspense fallback={<Spinner size="sm"/>}> <Suspense fallback={<Spinner size="sm"/>}>
<SettingsUI <SettingsUI
widgetId={widget.id} widgetId={widget.id}
@@ -116,21 +105,18 @@ export default function MyDashboard() {
) : ( ) : (
<Box w="20px" h="20px"/> <Box w="20px" h="20px"/>
)} )}
</Flex>
{/* THE CHART CANVAS */}
<Box flex="1" overflow="hidden" position="relative" p={1}>
{/* Pass the settings object into the actual chart component */}
<Component settings={widget.settings || {}} />
</Box> </Box>
</Flex> <Box css={styles.body}>
<Component settings={widget.settings || {}}/>
</Box>
</>
); );
} }
// Fallback if someone asks for a widget that doesn't exist // Fallback if someone asks for a widget that doesn't exist
return ( return (
<Flex width="100%" height="100%" align="center" justify="center" direction="column" bg="gray.800"> <Flex css={styles.body} align="center" justify="center" direction="column">
<Text fontWeight="bold" color="red.400">Error</Text> <Text fontWeight="bold" color="red.400">Error</Text>
<Text fontSize="sm" color="gray.400">Widget '{widget.type}' not found.</Text> <Text fontSize="sm" color="gray.400">Widget '{widget.type}' not found.</Text>
</Flex> </Flex>
@@ -154,12 +140,12 @@ export default function MyDashboard() {
{widgets.map(widget => ( {widgets.map(widget => (
<Box <Box
key={widget.id} key={widget.id}
bg="white" css={styles.root}
borderRadius="md" // 3. Grid-specific state overrides remain inline
boxShadow={isEditing ? "outline" : "sm"} // Visual cue when editing boxShadow={isEditing ? "outline" : styles.root.boxShadow}
border={isEditing ? "2px dashed gray" : "1px solid"} borderStyle={isEditing ? "dashed" : "solid"}
borderColor={isEditing ? "gray.400" : "gray.200"} borderWidth={isEditing ? "2px" : "1px"}
overflow="hidden" borderColor={isEditing ? "orange.300" : styles.root.borderColor}
cursor={isEditing ? "grab" : "default"} cursor={isEditing ? "grab" : "default"}
position="relative" // 3. REQUIRED so the absolute button stays inside this box position="relative" // 3. REQUIRED so the absolute button stays inside this box
> >
@@ -172,8 +158,9 @@ export default function MyDashboard() {
right={2} right={2}
size="xs" size="xs"
bg="white" bg="white"
color={iconColor} color="black"
border="1px solid" border="1px solid"
borderRadius="xl"
borderColor="gray.200" borderColor="gray.200"
_hover={{bg: "red.50", color: "red.500", borderColor: "red.200"}} _hover={{bg: "red.50", color: "red.500", borderColor: "red.200"}}
zIndex={2} zIndex={2}
@@ -187,13 +174,12 @@ export default function MyDashboard() {
{/* 4. SUSPENSE BOUNDARY wrapping the render function */} {/* 4. SUSPENSE BOUNDARY wrapping the render function */}
<Suspense fallback={ <Suspense fallback={
<Flex w="100%" h="100%" align="center" justify="center" bg="gray.800"> <Flex css={styles.body} align="center" justify="center">
<Spinner size="md" color="blue.400" thickness="3px"/> <Spinner size="md" color="blue.400" thickness="3px"/>
</Flex> </Flex>
}> }>
{renderWidget(widget)} {renderWidget(widget)}
</Suspense> </Suspense>
</Box> </Box>
))} ))}
</ResponsiveGridLayout> </ResponsiveGridLayout>
+295 -36
View File
@@ -3,12 +3,10 @@ import { defineSlotRecipe, createSystem, defaultConfig, defineConfig, defineReci
// RECIPES // RECIPES
const headerRecipe = defineRecipe({ const headerRecipe = defineRecipe({
base: { base: {
bg: "{base200}", bg: "{transparent}",
color: "text", color: "text",
width: "100%", width: "100%",
height: "100%", height: "100%",
borderBottom: "1px solid",
borderBottomColor:"{border}",
display: "flex", display: "flex",
flexDirection: "row", flexDirection: "row",
justifyContent: "space-between", justifyContent: "space-between",
@@ -16,48 +14,177 @@ const headerRecipe = defineRecipe({
} }
}); });
const sidebarRecipe = defineSlotRecipe({
slots: ["root", "logo", "footer", "button_text","buttons", "collapse_button"],
base: {
root: {
// 1. Semi-transparent backgrounds
bg: {
base: "linear-gradient(to bottom right, #99000040 20%, #FF660040 60%, #EEEE0040 100%)",
_dark: "linear-gradient(to bottom right, #9900003C 20%, #FF66003C 60%, #FFC0003C 100%)"
},
// 2. The glass blur effect
backdropFilter: "blur(12px)",
WebkitBackdropFilter: "blur(12px)",
// 3. Subtle semi-transparent borders
border: "1px solid",
borderColor: {base: "rgba(255, 255, 255, 0.8)", _dark: "rgba(255, 255, 255, 0.1)"},
// CRITICAL: Remove the right border so it doesn't draw a line through your cutout
borderRight: "none",
borderRadius: "2xl",
// boxShadow: "0 4px 30px rgba(0, 0, 0, 0.1)",
// boxShadow: "-10px 4px 30px rgba(0, 0, 0, 0.1)",
width: "100%",
height: "calc(100% - 16px)",
margin: "8px",
display: "flex",
flexDirection: "column",
position: "relative",
justifyContent: "start",
alignItems: "stretch",
gap: 4,
transition: "width 0.4s ease",
// CRITICAL: Adjust padding and overflow to allow the button to touch the right edge
pl: 2, // Keep left padding
py: 2, // Keep top/bottom padding
pr: 0, // Remove right padding
pt: 4, // Added top padding to give the logo room to breathe
overflow: "visible", // Allows the curved corner patches to render outside the button
zIndex: 10,
},
buttons: {
position: "relative", // Required to anchor the corner patches
bg: "transparent",
justifyContent: "flex-start",
transition: "background-color 0.4s ease, color 0.4s ease",
"& svg": {
transition: "stroke-width 0.4s ease",
flexShrink: "0"
},
_hover: {
bg: "rgba(255, 255, 255, 0.1)",
color: "{text}",
fontWeight: "semibold",
"& svg": {
strokeWidth: "3"
}
},
fontSize: "l",
color: {base: "{text}"},
variant: "ghost",
width: "100%",
// Flat on the right, rounded on the left
borderRightRadius: "0",
borderLeftRadius: "4xl",
"&.active": {
bg: "{MainBackground}",
color: "{textInverted}",
_hover: {
bg: "{MainBackground}",
color: "{textInverted}",
fontWeight: "normal",
"& svg": {
strokeWidth: "2" // Keeps the active icon at normal thickness on hover
}
},
// The Top Inverted Curve
_before: {
content: '""',
position: "absolute",
right: "-1px",
top: "-25px",
width: "25px",
height: "25px",
bg: "inherit",
WebkitMaskImage: "radial-gradient(circle at top left, transparent 25px, black 25.5px)",
maskImage: "radial-gradient(circle at top left, transparent 25px, black 25.5px)",
pointerEvents: "none",
},
// The Bottom Inverted Curve
_after: {
content: '""',
position: "absolute",
right: "-1px",
bottom: "-25px",
width: "25px",
height: "25px",
bg: "inherit",
WebkitMaskImage: "radial-gradient(circle at bottom left, transparent 25px, black 25.5px)",
maskImage: "radial-gradient(circle at bottom left, transparent 25px, black 25.5px)",
pointerEvents: "none",
}
},
},
logo: {
width: "100%",
height: "auto",
overflow: "hidden",
fontWeight: "bold",
px: 0,
},
footer: {
mt: "auto",
display: "flex",
justifyContent: "center",
alignItems: "center",
pb: 4,
pr: 2,
transition: "opacity 0.3s ease, visibility 0.3s ease, margin 0.3s ease"
},
button_text: {
transition: "opacity 0.3s ease, visibility 0.3s ease, margin 0.3s ease",
whiteSpace: "nowrap"
},
collapse_button: {
"& svg": { flexShrink: "0" },
},
},
variants: {
state: {
open: {
root: { width: "190px" },
logo: { justifyContent: "flex-start", ml: 2, textStyle: "4xl" },
footer: { gap: 16, flexDirection: "row" },
button_text: {ml: 3, opacity: 1, visibility: "visible"},
},
closed: {
root: { width: "71px" },
logo: { justifyContent: "center", ml: -1, textStyle: "3xl" },
footer: { gap: 2, flexDirection: "column-reverse" },
button_text: {ml: 0, opacity: 0, visibility: "hidden"},
}
}
}
});
const dashboardRecipe = defineRecipe({ const dashboardRecipe = defineRecipe({
base: { base: {
bg: "{base200}" bg: "{MainBackground}"
} }
}); });
const canvasRecipe = defineRecipe({ const canvasRecipe = defineRecipe({
base: { base: {
bg: "{base200}", bg: "{transparent}",
zIndex: "-1", zIndex: "-1",
color: "{text}" color: "{text}"
} }
}); });
const sidebarRecipe = defineSlotRecipe({
slots: ["root", "close_button", "buttons", "dark_mode_button"],
base: {
root: {
bg: "{base200}",
borderRight: "1px solid",
borderColor: "{border}",
width: "100%",
height: "100%",
display: "flex",
flexDirection: "column",
justifyContent: "start",
alignItems: "start",
gap: 2,
p: 2,
},
buttons: {
bg: "transparent",
_hover: {bg: "{primaryLt}", color: "{textInverted}"},
"&.active": {bg: "{primary}", color: "{textInverted}"},
fontSize: "xl",
color: {base: "{text}"},
variant: "ghost",
width: "100%",
},
}
});
const widgetRecipe = defineSlotRecipe({ const widgetRecipe = defineSlotRecipe({
slots: ["root", "header", "canvas"], slots: ["root", "header", "canvas"],
base: { base: {
@@ -96,6 +223,131 @@ const widgetRecipe = defineSlotRecipe({
} }
}); });
const glassPanelRecipe = defineSlotRecipe({
slots: ["root", "header", "body"],
// 🧊 THE GLASS MATH (Applies to everything)
base: {
root: {
display: "flex",
flexDirection: "column",
position: "relative",
overflow: "hidden",
bg: {base: "rgba(255, 255, 255, 0.4)", _dark: "rgba(255, 255, 255, 0.04)"},
backdropFilter: "blur(12px)",
WebkitBackdropFilter: "blur(12px)",
border: "1px solid",
borderColor: {base: "gray.200", _dark: "whiteAlpha.200"},
boxShadow: "sm",
}
},
// 📏 THE LAYOUTS (Applies selectively)
variants: {
layout: {
widget: {
root: {width: "100%", height: "100%", borderRadius: "3xl"},
header: {display: "flex", justifyContent: "space-between", alignItems: "center", px: 3, pt: 2, pb: 0},
body: {flex: "1", overflow: "hidden", position: "relative", px: 1, pb: 1, pt: 0}
},
dropdown: {
root: {borderRadius: "xl", p: 1}
// (Header and body slots are ignored here because dropdowns don't use them)
},
popover: {
root: {
borderRadius: "2xl",
p: 4,
boxShadow: "xl",
minW: "240px",
// OVERRIDES: Make the background 85-90% opaque instead of 40%
bg: { base: "rgba(255, 255, 255, 0.75)", _dark: "rgba(20, 22, 25, 0.8)" },
// OVERRIDES: Increase the blur just to smooth out any stubborn gridlines
backdropFilter: "blur(15px)",
WebkitBackdropFilter: "blur(15px)",
}
}
},
mode: {
editing: {
root: {
boxShadow: "outline",
borderStyle: "dashed",
borderWidth: "2px",
borderColor: "orange.300",
cursor: "grab",
}
}
}
},
defaultVariants: {
layout: "widget"
}
});
const glassTabRecipe = defineRecipe({
base: {
display: "flex",
alignItems: "center",
height: "40px",
// The Circle State (Inactive)
maxWidth: "40px",
minWidth: "40px",
px: "8px",
gap: 2,
// CRITICAL: Locks the shape to a perfect circle/pill
borderRadius: "full",
overflow: "hidden",
whiteSpace: "nowrap",
textDecoration: "none",
fontWeight: "bold",
color: "fg.muted",
// --- THE GLASS EFFECT (Inactive) ---
// Uses a highly transparent white/black depending on mode
bg: {base: "rgba(255, 255, 255, 0.4)", _dark: "rgba(255, 255, 255, 0.03)"},
backdropFilter: "blur(12px)",
WebkitBackdropFilter: "blur(12px)",
border: "1px solid",
borderColor: {base: "rgba(0, 0, 0, 0.05)", _dark: "rgba(255, 255, 255, 0.08)"},
boxShadow: "0 4px 6px rgba(0, 0, 0, 0.02)", // Tiny shadow to lift it off the canvas
transition: "all 0.85s cubic-bezier(0.34, 1.56, 0.64, 1)",
"&:hover, &[data-state='open'], &[aria-expanded='true']": {
maxWidth: "250px",
pr: "16px",
// --- THE GLASS EFFECT (Hover) ---
// Becomes slightly more opaque when you mouse over
bg: {base: "rgba(255, 255, 255, 0.8)", _dark: "rgba(255, 255, 255, 0.1)"},
borderColor: {base: "rgba(0, 0, 0, 0.1)", _dark: "rgba(255, 255, 255, 0.15)"},
color: "fg",
textDecoration: "none",
},
"&.active": {
maxWidth: "250px",
pr: "16px",
bg: "{gooeyButtonBackground}",
borderColor: "transparent",
color: "{textInverted}",
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.1)", // Stronger shadow for the active tab
_hover: {
bg: "{gooeyButtonBackground}",
cursor: "default",
textDecoration: "none",
}
}
}
});
const config = defineConfig({ const config = defineConfig({
globalCss: { globalCss: {
".react-grid-placeholder": { ".react-grid-placeholder": {
@@ -178,9 +430,14 @@ const config = defineConfig({
primaryLt: {value: {base: "#98cdffff", _dark: "#98cdffff"}}, primaryLt: {value: {base: "#98cdffff", _dark: "#98cdffff"}},
secondaryBG: {value: {base: "#EDF1F1", _dark: "#121212"}}, secondaryBG: {value: {base: "#EDF1F1", _dark: "#121212"}},
border: {value: {base: "#000000", _dark: "#cbcbcb84"}}, border: {value: {base: "#000000", _dark: "#cbcbcb84"}},
text: {value: {base: "#000000", _dark: "lightgrey"}}, text: {value: {base: "#000000", _dark: "#FFFFFF"}},
textInverted: {value: "white"}, textInverted: {value: {base: "#000000", _dark: "#FFFFFF"}},
icon: {value: {base: "#000000", _dark: "lightgrey"}}, icon: {value: {base: "#000000", _dark: "#FFFFFF"}},
gooeyButtonBackground: {value: {base: "rgba(255, 255, 255, 0.1)", _dark: "rgba(255, 255, 255, 0.1)"}},
MainBackground: {value: {base: "#F9F9F9", _dark: "#141414"}},
titleColor: {value: {base: "gray.800", _dark: "#FFFFFF"}},
iconColor: {value: {base: "gray.600", _dark: "#000000"}},
glassSeperator: {value: {base: "#0000001A", _dark: "#FFFFFF3F"}},
}, },
}, },
tokens: { tokens: {
@@ -192,10 +449,12 @@ const config = defineConfig({
header: headerRecipe, header: headerRecipe,
dashboard: dashboardRecipe, dashboard: dashboardRecipe,
canvas: canvasRecipe, canvas: canvasRecipe,
glassTab: glassTabRecipe
}, },
slotRecipes: { slotRecipes: {
sidebar: sidebarRecipe, sidebar: sidebarRecipe,
widget: widgetRecipe, widget: widgetRecipe,
glassPanel: glassPanelRecipe,
}, },
}, },
}); });