import React from "react"; import { styled, useStyletron } from "styletron-react"; import Button from "../button/Button"; export interface SideBarProps {} /** * This is the component * Used to navigate the user trough the app */ const SideBar: React.FC = () => { const [css] = useStyletron(); const [isCollapsed, setIsCollapsed] = React.useState(true); // TODO: implement React Spring for animations // Usage of tenaries causes memory leaks // https://stackoverflow.com/questions/61882182/react-spring-cant-perform-a-react-state-update-on-an-unmounted-component#:~:text=Warning%3A%20Can't%20perform%20a,in%20a%20useEffect%20cleanup%20function. // // import { useSpring, animated } from 'react-spring'; // small : large // const { width, opacity } = useSpring({ // from: { width: '0px', opacity: '0%' }, // width: isCollapsed ? '69px' : '271px', // opacity: isCollapsed ? '0%' : '100%', // }); const BreakLine = styled("div", { height: "1px", backgroundColor: "#E9E9E9", width: "100%", marginBottom: "8px", }); const Sidebar = isCollapsed ? styled("div", { backgroundColor: "white", // boxShadow: 'none', boxShadow: "0 2px 12px 0 rgb(166 166 166 / 50%)", position: "fixed", minWidth: "69px", top: 0, zIndex: 2, }) : styled("div", { backgroundColor: "white", boxShadow: "0 2px 12px 0 rgb(166 166 166 / 50%)", position: "fixed", minWidth: "271px", top: 0, zIndex: 2, }); return (
<> {isCollapsed ? ( ) : ( )} <> {isCollapsed ? ( ) : ( )} <> {isCollapsed ? ( ) : ( )} <> {isCollapsed ? ( ) : ( )} <> {isCollapsed ? ( ) : ( )} <> {isCollapsed ? ( ) : ( )}
<> {isCollapsed ? ( ) : ( )} <> {isCollapsed ? ( ) : ( )} <> {isCollapsed ? ( ) : ( )}
); }; export default SideBar;