updated themes file to further reduce styling in sidebar component page
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
|
import {Mountain, House, Earth, MapPin, ShieldUser, PanelLeftClose, PanelLeftOpen} from 'lucide-react';
|
||||||
import {useSlotRecipe, Box, Button, IconButton, Text, Flex} from "@chakra-ui/react";
|
import {useSlotRecipe, Box, Button, IconButton, Text, Flex} from "@chakra-ui/react";
|
||||||
import {ColorModeButton} from "@/components/ui/color-mode.jsx";
|
import {ColorModeButton} from "@/components/ui/color-mode.jsx";
|
||||||
import {useState} from "react";
|
|
||||||
import {NavLink} from "react-router-dom";
|
import {NavLink} from "react-router-dom";
|
||||||
import {Mountain, House, Earth, MapPin, ShieldUser, PanelLeftClose, PanelLeftOpen} from 'lucide-react';
|
import {useState} from "react";
|
||||||
|
|
||||||
const SIDEBAR_DEFAULT_BUTTONS = [
|
const SIDEBAR_DEFAULT_BUTTONS = [
|
||||||
{icon: House, name: "Home", url: "/home"},
|
{icon: House, name: "Home", url: "/home"},
|
||||||
@@ -13,27 +13,18 @@ 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({state: isOpen ? "open" : "closed"});
|
const styles = recipe({state: isOpen ? "open" : "closed"});
|
||||||
|
const visibleButtons = SIDEBAR_DEFAULT_BUTTONS; // TODO: call btns here according to users authorization
|
||||||
// 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 toggleSidebar = () => setIsOpen((prev) => !prev);
|
const toggleSidebar = () => setIsOpen((prev) => !prev);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box css={styles.root}>
|
<Box css={styles.root}>
|
||||||
{/* Logo Navigates to Home Page */}
|
{/* Logo Navigates to Home Page */}
|
||||||
<Button
|
<Button as={NavLink} to="/home" variant="plain" css={styles.logo}>
|
||||||
as={NavLink}
|
<Flex>
|
||||||
to="/home"
|
|
||||||
css={styles.logo}
|
|
||||||
variant="plain"
|
|
||||||
>
|
|
||||||
<Flex direction="row" justify="space-between">
|
|
||||||
<Text>🌋</Text>
|
<Text>🌋</Text>
|
||||||
<Text css={styles.logo_text}>VDAP</Text>
|
<Text css={styles.logo_text}>VDAP</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
@@ -43,12 +34,7 @@ export default function Sidebar() {
|
|||||||
{visibleButtons.map((button) => {
|
{visibleButtons.map((button) => {
|
||||||
const Icon = button.icon;
|
const Icon = button.icon;
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button as={NavLink} to={button.url} css={styles.buttons}> {/* Navigation buttons are [icon text] */}
|
||||||
as={NavLink}
|
|
||||||
to={button.url}
|
|
||||||
css={styles.buttons}
|
|
||||||
>
|
|
||||||
{/* Navigation buttons are [icon text] */}
|
|
||||||
<Icon/>
|
<Icon/>
|
||||||
<Box as="span" css={styles.button_text}>
|
<Box as="span" css={styles.button_text}>
|
||||||
{button.name}
|
{button.name}
|
||||||
@@ -57,22 +43,17 @@ export default function Sidebar() {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
|
{/* Collapse Sidebar and Theme Footer Buttons */}
|
||||||
<Flex css={styles.footer}>
|
<Flex css={styles.footer}>
|
||||||
<Flex css={styles.closed_theme_button}>
|
<Flex css={styles.closed_theme_button}>
|
||||||
<ColorModeButton _hover={{ bg: "transparent" }} />
|
<ColorModeButton />
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex direction="row" justify="space-between">
|
<Flex>
|
||||||
<IconButton
|
<IconButton aria-label="Toggle Sidebar" variant="plain" onClick={toggleSidebar} css={styles.collapse_button}>
|
||||||
aria-label="Toggle Sidebar"
|
|
||||||
variant="plain"
|
|
||||||
size="md"
|
|
||||||
onClick={toggleSidebar}
|
|
||||||
css={styles.collapse_button}
|
|
||||||
>
|
|
||||||
{isOpen ? <PanelLeftClose /> : <PanelLeftOpen />}
|
{isOpen ? <PanelLeftClose /> : <PanelLeftOpen />}
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<Flex css={styles.opened_theme_button}>
|
<Flex css={styles.opened_theme_button}>
|
||||||
<ColorModeButton _hover={{ bg: "transparent" }} />
|
<ColorModeButton />
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
+11
-2
@@ -136,9 +136,8 @@ const sidebarRecipe = defineSlotRecipe({
|
|||||||
justifyContent: "flex-start",
|
justifyContent: "flex-start",
|
||||||
ml: 2,
|
ml: 2,
|
||||||
textStyle: "4xl",
|
textStyle: "4xl",
|
||||||
overflow: "hidden",
|
|
||||||
fontWeight: "bold",
|
fontWeight: "bold",
|
||||||
fontSize: "2rem",
|
overflow: "hidden",
|
||||||
px: 0,
|
px: 0,
|
||||||
},
|
},
|
||||||
logo_text: {
|
logo_text: {
|
||||||
@@ -167,6 +166,11 @@ const sidebarRecipe = defineSlotRecipe({
|
|||||||
align: "center",
|
align: "center",
|
||||||
justifyContent: "right",
|
justifyContent: "right",
|
||||||
mr: 6,
|
mr: 6,
|
||||||
|
"& .chakra-button": { // targets the chakra button class in ColorModeButton component to set bg transparency
|
||||||
|
"&:hover": {
|
||||||
|
bg: "transparent",
|
||||||
|
}
|
||||||
|
},
|
||||||
"& button": {
|
"& button": {
|
||||||
alignSelf: "center",
|
alignSelf: "center",
|
||||||
transition: "opacity 0.3s ease, visibility 0.3s ease, margin 0.3s ease",
|
transition: "opacity 0.3s ease, visibility 0.3s ease, margin 0.3s ease",
|
||||||
@@ -174,6 +178,11 @@ const sidebarRecipe = defineSlotRecipe({
|
|||||||
},
|
},
|
||||||
closed_theme_button: {
|
closed_theme_button: {
|
||||||
ml: 0.9,
|
ml: 0.9,
|
||||||
|
"& .chakra-button": { // targets the chakra button class to set bg transparency
|
||||||
|
"&:hover": {
|
||||||
|
bg: "transparent",
|
||||||
|
}
|
||||||
|
},
|
||||||
"& button": {
|
"& button": {
|
||||||
transition: "opacity 0.3s ease, visibility 0.3s ease, margin 0.3s ease",
|
transition: "opacity 0.3s ease, visibility 0.3s ease, margin 0.3s ease",
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user