Spaces:
Sleeping
Sleeping
File size: 3,254 Bytes
3d701d8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
import React, { useState, useEffect } from "react";
import {
ChakraProvider,
extendTheme,
Tabs,
TabList,
TabPanels,
Tab,
TabPanel,
Container,
Box,
Text,
} from "@chakra-ui/react";
import Header from "./components/Header";
import Dashboard from "./components/Dashboard";
import ProjectExplorer from "./components/ProjectExplorer";
import ProjectDetails from "./components/ProjectDetails";
import { useAppState } from "./hooks/useAppState";
const theme = extendTheme({
fonts: {
heading: `'Segoe UI', sans-serif`,
body: `'Segoe UI', sans-serif`,
},
colors: {
brand: {
blue: "#003399",
yellow: "#FFCC00",
gray: "#f5f5f5",
},
},
styles: {
global: {
html: {
bg: "white", // ✅ add this
},
body: {
bg: "white",
color: "gray.800",
},
},
},
components: {
Tabs: {
baseStyle: {
tab: {
_selected: {
bg: "brand.yellow",
color: "brand.blue",
fontWeight: "bold",
borderColor: "brand.blue",
borderTopWidth: "4px",
},
},
tabpanel: {
borderTopWidth: "0px",
},
},
},
Button: {
variants: {
solid: {
bg: "brand.blue",
color: "white",
_hover: { bg: "#002080" },
},
},
},
},
radii: {
md: "12px",
lg: "16px",
xl: "24px",
},
});
export default function App() {
const [tabIndex, setTabIndex] = useState(0);
const {
selectedProject,
dashboardProps,
explorerProps,
detailsProps,
} = useAppState();
// If they deselect, never stay on “Details”
useEffect(() => {
if (!selectedProject && tabIndex === 2) {
setTabIndex(1);
}
}, [selectedProject, tabIndex]);
// If they just selected a project, jump to details
useEffect(() => {
if (selectedProject) {
setTabIndex(2);
}
}, [selectedProject]);
return (
<ChakraProvider theme={theme}>
<Header />
<Container maxW="9xl" mt="90px" px={{ base: 4, md: 8 }}>
<Box bg="white" borderRadius="xl" boxShadow="lg" p={6}>
<Tabs
variant="enclosed-colored"
colorScheme="yellow"
index={tabIndex}
onChange={setTabIndex}
isFitted
aria-label="Main Navigation Tabs"
>
<TabList role="tablist">
<Tab>Dashboard</Tab>
<Tab>Projects</Tab>
<Tab isDisabled={!selectedProject}>Project Details</Tab>
</TabList>
<TabPanels>
<TabPanel>
<Dashboard {...dashboardProps} />
</TabPanel>
<TabPanel>
<ProjectExplorer {...explorerProps} />
</TabPanel>
<TabPanel>
{selectedProject
? <ProjectDetails {...detailsProps} />
: <Text color="gray.500" textAlign="center" py={10}>
Select a project to see its details
</Text>
}
</TabPanel>
</TabPanels>
</Tabs>
</Box>
</Container>
</ChakraProvider>
);
} |