Spaces:
Runtime error
Runtime error
Download src/components/Layout.tsx from Vignesh5656/transformation-ui: direct link, hf CLI and curl.
- Browser
- Download file 15.3 kB
-
https://huggingface.co/spaces/Vignesh5656/transformation-ui/resolve/main/src/components/Layout.tsx
- Command line
-
hf download hf://spaces/Vignesh5656/transformation-ui/src/components/Layout.tsx
-
curl -L -o Layout.tsx https://huggingface.co/spaces/Vignesh5656/transformation-ui/resolve/main/src/components/Layout.tsx
15.3 kB
| import React, { useState } from 'react'; | |
| import { | |
| AppBar, | |
| Box, | |
| CssBaseline, | |
| Drawer, | |
| IconButton, | |
| List, | |
| ListItem, | |
| ListItemButton, | |
| ListItemIcon, | |
| ListItemText, | |
| Toolbar, | |
| Typography, | |
| useTheme as useMuiTheme, | |
| useMediaQuery, | |
| Avatar, | |
| Chip, | |
| Divider, | |
| Badge, | |
| Tooltip, | |
| } from '@mui/material'; | |
| import { | |
| Menu as MenuIcon, | |
| Dashboard as DashboardIcon, | |
| Settings as SettingsIcon, | |
| Build as BuildIcon, | |
| History as HistoryIcon, | |
| AccountCircle as AccountCircleIcon, | |
| Notifications as NotificationsIcon, | |
| BusinessCenter as BusinessCenterIcon, | |
| Chat as ChatIcon, | |
| AutoAwesome as AutoAwesomeIcon, | |
| Compare as CompareIcon | |
| } from '@mui/icons-material'; | |
| import { Routes, Route, useNavigate, useLocation } from 'react-router-dom'; | |
| import MainPage from '../pages/MainPage'; | |
| import ConfigurationPage from '../pages/ConfigurationPageNew'; | |
| import HistoryPage from '../pages/HistoryPage'; | |
| import SettingsPage from '../pages/SettingsPage'; | |
| import ChatPage from '../pages/ChatPage'; | |
| import DIYGeneratorPage from '../pages/DIYGeneratorPage'; | |
| import AnomalyPage from '../pages/AnomalyPage'; | |
| const drawerWidth = 240; | |
| interface NavItem { | |
| text: string; | |
| icon: React.ReactElement; | |
| path: string; | |
| } | |
| const navigationItems: NavItem[] = [ | |
| { text: 'Dashboard', icon: <DashboardIcon />, path: '/' }, | |
| { text: 'DIY Generator', icon: <AutoAwesomeIcon />, path: '/diy-generator' }, | |
| { text: 'Configuration', icon: <BuildIcon />, path: '/configuration' }, | |
| { text: 'Anomaly', icon: <CompareIcon />, path: '/anomaly' }, | |
| { text: 'Chat', icon: <ChatIcon />, path: '/chat' }, | |
| // { text: 'History', icon: <HistoryIcon />, path: '/history' }, | |
| { text: 'Settings', icon: <SettingsIcon />, path: '/settings' }, | |
| ]; | |
| const Layout: React.FC = () => { | |
| const theme = useMuiTheme(); | |
| const isMobile = useMediaQuery(theme.breakpoints.down('md')); | |
| const [mobileOpen, setMobileOpen] = useState(false); | |
| const navigate = useNavigate(); | |
| const location = useLocation(); | |
| // Add keyframes for pulse animation | |
| React.useEffect(() => { | |
| const style = document.createElement('style'); | |
| style.textContent = ` | |
| @keyframes pulse { | |
| 0% { | |
| transform: scale(0.95); | |
| box-shadow: 0 0 0 0 rgba(77, 196, 212, 0.7); | |
| } | |
| 70% { | |
| transform: scale(1); | |
| box-shadow: 0 0 0 6px rgba(77, 196, 212, 0); | |
| } | |
| 100% { | |
| transform: scale(0.95); | |
| box-shadow: 0 0 0 0 rgba(77, 196, 212, 0); | |
| } | |
| } | |
| `; | |
| document.head.appendChild(style); | |
| return () => { | |
| document.head.removeChild(style); | |
| }; | |
| }, []); | |
| const handleDrawerToggle = () => { | |
| setMobileOpen(!mobileOpen); | |
| }; | |
| const handleNavigate = (path: string) => { | |
| navigate(path); | |
| if (isMobile) { | |
| setMobileOpen(false); | |
| } | |
| }; | |
| const drawer = ( | |
| <Box sx={{ | |
| height: '100vh', | |
| background: 'linear-gradient(180deg, #5009b5 0%, #2b1b49 100%)', // Carelon purple gradient | |
| display: 'flex', | |
| flexDirection: 'column', | |
| position: 'relative' | |
| }}> | |
| {/* Header Section */} | |
| <Box sx={{ | |
| p: 3, | |
| textAlign: 'center', | |
| borderBottom: '1px solid rgba(0, 0, 0, 0.1)', | |
| flexShrink: 0, | |
| backgroundColor: '#f7f7f7', // Light grey background | |
| borderTopLeftRadius: 0, | |
| borderTopRightRadius: 0 | |
| }}> | |
| {/* Carelon Logo */} | |
| <Box sx={{ mb: 2 }}> | |
| <img | |
| src="/carelon.svg" | |
| alt="Carelon" | |
| style={{ | |
| height: '40px', | |
| width: 'auto' | |
| // Removed filter to show original logo colors | |
| }} | |
| /> | |
| </Box> | |
| <Typography | |
| variant="h6" | |
| sx={{ | |
| color: '#5009b5', // Carelon primary purple | |
| fontWeight: 700, | |
| fontSize: '1.1rem', | |
| mb: 0.5 | |
| }} | |
| > | |
| Benefit Agent Portal | |
| </Typography> | |
| <Typography | |
| variant="body2" | |
| sx={{ | |
| color: '#2b1b49', // Darker purple for secondary text | |
| fontSize: '0.875rem' | |
| }} | |
| > | |
| Behavioral Health Platform | |
| </Typography> | |
| </Box> | |
| {/* User Info Section */} | |
| <Box sx={{ | |
| p: 2, | |
| borderBottom: '1px solid rgba(255, 255, 255, 0.1)', | |
| mb: 1, | |
| flexShrink: 0 | |
| }}> | |
| <Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}> | |
| <Avatar sx={{ width: 40, height: 40, backgroundColor: 'rgba(255, 255, 255, 0.2)' }}> | |
| <AccountCircleIcon /> | |
| </Avatar> | |
| <Box sx={{ flex: 1 }}> | |
| <Typography | |
| variant="body2" | |
| sx={{ | |
| color: 'white', | |
| fontWeight: 600, | |
| fontSize: '0.875rem' | |
| }} | |
| > | |
| Benefit Agent | |
| </Typography> | |
| <Chip | |
| label="Benefits Analyst" | |
| size="small" | |
| sx={{ | |
| height: 20, | |
| fontSize: '0.75rem', | |
| backgroundColor: 'rgba(255, 255, 255, 0.15)', | |
| color: 'white', | |
| '& .MuiChip-label': { | |
| px: 1 | |
| } | |
| }} | |
| /> | |
| </Box> | |
| </Box> | |
| </Box> | |
| {/* Navigation Items */} | |
| <List sx={{ | |
| px: 2, | |
| py: 1, | |
| flex: 1, | |
| overflow: 'auto' | |
| }}> | |
| {navigationItems.map((item, index) => ( | |
| <ListItem key={item.text} disablePadding sx={{ mb: 0.5 }}> | |
| <ListItemButton | |
| selected={location.pathname === item.path} | |
| onClick={() => handleNavigate(item.path)} | |
| sx={{ | |
| borderRadius: '12px', | |
| py: 1.5, | |
| px: 2, | |
| '&.Mui-selected': { | |
| backgroundColor: 'rgba(255, 255, 255, 0.15)', | |
| backdropFilter: 'blur(10px)', | |
| border: '1px solid rgba(255, 255, 255, 0.2)', | |
| '&:hover': { | |
| backgroundColor: 'rgba(255, 255, 255, 0.2)', | |
| }, | |
| }, | |
| '&:hover': { | |
| backgroundColor: 'rgba(255, 255, 255, 0.1)', | |
| }, | |
| transition: 'all 0.3s ease', | |
| }} | |
| > | |
| <ListItemIcon | |
| sx={{ | |
| color: 'white', | |
| minWidth: 40, | |
| }} | |
| > | |
| {item.icon} | |
| </ListItemIcon> | |
| <ListItemText | |
| primary={item.text} | |
| sx={{ | |
| '& .MuiListItemText-primary': { | |
| fontWeight: location.pathname === item.path ? 600 : 500, | |
| color: 'white', | |
| fontSize: '0.875rem', | |
| }, | |
| }} | |
| /> | |
| {location.pathname === item.path && ( | |
| <Box | |
| sx={{ | |
| width: 4, | |
| height: 20, | |
| backgroundColor: 'white', | |
| borderRadius: '2px', | |
| opacity: 0.8 | |
| }} | |
| /> | |
| )} | |
| </ListItemButton> | |
| </ListItem> | |
| ))} | |
| </List> | |
| {/* Bottom Status */} | |
| <Box sx={{ | |
| p: 2, | |
| borderTop: '1px solid rgba(255, 255, 255, 0.1)', | |
| flexShrink: 0, | |
| mt: 'auto' | |
| }}> | |
| <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 1 }}> | |
| <Box | |
| sx={{ | |
| width: 8, | |
| height: 8, | |
| borderRadius: '50%', | |
| backgroundColor: '#4DC4D4', // Carelon light teal | |
| animation: 'pulse 2s infinite' | |
| }} | |
| /> | |
| <Typography | |
| variant="caption" | |
| sx={{ | |
| color: 'rgba(255, 255, 255, 0.8)', | |
| fontSize: '0.75rem' | |
| }} | |
| > | |
| System Online | |
| </Typography> | |
| </Box> | |
| </Box> | |
| </Box> | |
| ); | |
| return ( | |
| <Box sx={{ display: 'flex' }}> | |
| <CssBaseline /> | |
| <AppBar | |
| position="fixed" | |
| elevation={0} | |
| sx={{ | |
| width: { md: `calc(100% - ${drawerWidth}px)` }, | |
| ml: { md: `${drawerWidth}px` }, | |
| background: 'linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%)', | |
| backdropFilter: 'blur(20px)', | |
| borderBottom: '1px solid rgba(0, 0, 0, 0.06)', | |
| color: theme.palette.text.primary, | |
| }} | |
| > | |
| <Toolbar sx={{ justifyContent: 'space-between' }}> | |
| <Box sx={{ display: 'flex', alignItems: 'center' }}> | |
| <IconButton | |
| color="inherit" | |
| aria-label="open drawer" | |
| edge="start" | |
| onClick={handleDrawerToggle} | |
| sx={{ | |
| mr: 2, | |
| display: { md: 'none' }, | |
| backgroundColor: 'rgba(0, 0, 0, 0.04)', | |
| '&:hover': { | |
| backgroundColor: 'rgba(0, 0, 0, 0.08)', | |
| } | |
| }} | |
| > | |
| <MenuIcon /> | |
| </IconButton> | |
| <Box> | |
| <Typography | |
| variant="h5" | |
| component="div" | |
| sx={{ | |
| fontWeight: 700, | |
| background: 'linear-gradient(135deg, #5009b5 0%, #2b1b49 100%)', // Carelon purple gradient | |
| backgroundClip: 'text', | |
| WebkitBackgroundClip: 'text', | |
| color: 'transparent', | |
| fontSize: '1.25rem' | |
| }} | |
| > | |
| {navigationItems.find(item => item.path === location.pathname)?.text || 'Dashboard'} | |
| </Typography> | |
| <Typography | |
| variant="body2" | |
| sx={{ | |
| color: 'text.secondary', | |
| fontSize: '0.875rem', | |
| mt: -0.5 | |
| }} | |
| > | |
| {location.pathname === '/' && 'Use Benefit AI Agent to perform Domain functions'} | |
| {location.pathname === '/diy-generator' && 'Create custom benefit plans step by step'} | |
| {location.pathname === '/configuration' && 'Configure processing parameters'} | |
| {location.pathname === '/chat' && 'AI-powered health insurance benefits assistant'} | |
| {location.pathname === '/history' && 'View processing history and reports'} | |
| {location.pathname === '/settings' && 'Manage application settings'} | |
| </Typography> | |
| </Box> | |
| </Box> | |
| {/* Right side of AppBar */} | |
| <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}> | |
| <Tooltip title="Notifications"> | |
| <IconButton | |
| sx={{ | |
| backgroundColor: 'rgba(0, 0, 0, 0.04)', | |
| '&:hover': { | |
| backgroundColor: 'rgba(0, 0, 0, 0.08)', | |
| } | |
| }} | |
| > | |
| <Badge badgeContent={3} color="error"> | |
| <NotificationsIcon /> | |
| </Badge> | |
| </IconButton> | |
| </Tooltip> | |
| <Divider orientation="vertical" flexItem sx={{ mx: 1 }} /> | |
| <Chip | |
| avatar={ | |
| <Avatar sx={{ | |
| width: 24, | |
| height: 24, | |
| backgroundColor: 'primary.main' | |
| }}> | |
| JD | |
| </Avatar> | |
| } | |
| label="Benefit Agent" | |
| variant="outlined" | |
| sx={{ | |
| backgroundColor: 'rgba(0, 0, 0, 0.02)', | |
| border: '1px solid rgba(0, 0, 0, 0.08)', | |
| '&:hover': { | |
| backgroundColor: 'rgba(0, 0, 0, 0.04)', | |
| } | |
| }} | |
| /> | |
| </Box> | |
| </Toolbar> | |
| </AppBar> | |
| <Box | |
| component="nav" | |
| sx={{ width: { md: drawerWidth }, flexShrink: { md: 0 } }} | |
| > | |
| <Drawer | |
| variant="temporary" | |
| open={mobileOpen} | |
| onClose={handleDrawerToggle} | |
| ModalProps={{ | |
| keepMounted: true, | |
| }} | |
| sx={{ | |
| display: { xs: 'block', md: 'none' }, | |
| '& .MuiDrawer-paper': { | |
| boxSizing: 'border-box', | |
| width: drawerWidth, | |
| border: 'none', | |
| boxShadow: '0 10px 30px rgba(0, 0, 0, 0.3)', | |
| }, | |
| }} | |
| > | |
| {drawer} | |
| </Drawer> | |
| <Drawer | |
| variant="permanent" | |
| sx={{ | |
| display: { xs: 'none', md: 'block' }, | |
| '& .MuiDrawer-paper': { | |
| boxSizing: 'border-box', | |
| width: drawerWidth, | |
| border: 'none', | |
| boxShadow: '4px 0 20px rgba(0, 0, 0, 0.1)', | |
| position: 'fixed', | |
| top: 0, | |
| left: 0, | |
| height: '100vh', | |
| overflow: 'hidden', | |
| }, | |
| }} | |
| open | |
| > | |
| {drawer} | |
| </Drawer> | |
| </Box> | |
| <Box | |
| component="main" | |
| sx={{ | |
| flexGrow: 1, | |
| p: { xs: 1, md: 0 }, | |
| width: { md: `calc(100% - ${drawerWidth}px)` }, | |
| // ml: { md: `${drawerWidth}px` }, | |
| background: theme.palette.mode === 'dark' | |
| ? 'linear-gradient(135deg, #121212 0%, #1E1E1E 100%)' // Standard dark theme | |
| : 'linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%)', // Clean white like Carelon | |
| minHeight: '100vh', | |
| height: '100vh', | |
| overflow: 'hidden', | |
| position: 'relative', | |
| '&::before': { | |
| content: '""', | |
| position: 'absolute', | |
| top: 0, | |
| left: 0, | |
| right: 0, | |
| bottom: 0, | |
| background: theme.palette.mode === 'dark' | |
| ? 'radial-gradient(circle at 20% 80%, rgba(77, 196, 212, 0.1) 0%, transparent 50%), radial-gradient(circle at 80% 20%, rgba(46, 95, 126, 0.1) 0%, transparent 50%)' | |
| : 'radial-gradient(circle at 20% 80%, rgba(0, 163, 181, 0.05) 0%, transparent 50%), radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.8) 0%, transparent 50%)', | |
| pointerEvents: 'none', | |
| } | |
| }} | |
| > | |
| <Toolbar /> | |
| <Box sx={{ | |
| position: 'relative', | |
| zIndex: 1, | |
| height: 'calc(100vh - 64px)', | |
| overflow: 'auto', | |
| px: { xs: 1, md: 3 }, | |
| py: { xs: 1, md: 2 } | |
| }}> | |
| <Routes> | |
| <Route path="/" element={<MainPage />} /> | |
| <Route path="/index.html" element={<MainPage />} /> | |
| <Route path="/diy-generator" element={<DIYGeneratorPage />} /> | |
| <Route path="/configuration" element={<ConfigurationPage />} /> | |
| <Route path="/anomaly" element={<AnomalyPage />} /> | |
| <Route path="/chat" element={<ChatPage />} /> | |
| <Route path="/history" element={<HistoryPage />} /> | |
| <Route path="/settings" element={<SettingsPage />} /> | |
| </Routes> | |
| </Box> | |
| </Box> | |
| </Box> | |
| ); | |
| }; | |
| export default Layout; |