diff --git a/src/demo/Sidebar.tsx b/src/demo/Sidebar.tsx index c408c2f07..1ff219ee4 100644 --- a/src/demo/Sidebar.tsx +++ b/src/demo/Sidebar.tsx @@ -1,15 +1,18 @@ -/** @jsxImportSource @emotion/react */ - -import { css } from '@emotion/react'; +import styled from '@emotion/styled'; import Menu from 'rc-menu'; import { memo, useMemo } from 'react'; import { FaBars } from 'react-icons/fa'; import { createSearchParams, useNavigate } from 'react-router-dom'; + import 'rc-menu/assets/index.css'; import { buildMenu, getKey } from './utility/menu.js'; -const sidebarCss = css` +interface MenuStatus { + isMenuClosed: boolean; +} + +const SideBarContainer = styled.div` background: #2ca8ff; position: fixed; top: 0; @@ -17,17 +20,10 @@ const sidebarCss = css` bottom: 0; left: 0; z-index: 19; + width: ${({ isMenuClosed }) => (isMenuClosed ? '3%' : '260px')}; `; -const sidebarOpenCss = css` - width: 260px; -`; - -const sidebarClosedCss = css` - width: 3%; -`; - -const menuBtCss = css` +const MenuButton = styled.button` margin: 2px 4px; z-index: 7; font-size: 18px; @@ -56,7 +52,7 @@ const menuBtCss = css` } `; -const logoCss = css` +const SideBarHeader = styled.div` display: flex; justify-content: space-between; align-items: center; @@ -64,7 +60,12 @@ const logoCss = css` border-bottom: 1px solid #eee; `; -const simpleTextCss = css` +const TitleContainer = styled.div` + display: ${({ isMenuClosed }) => (isMenuClosed ? 'none' : 'block')}; + padding: 0.5rem 0.7rem; +`; + +const Title = styled.a` text-transform: uppercase; padding: 0.5rem 0; display: block; @@ -75,21 +76,18 @@ const simpleTextCss = css` font-weight: 400; line-height: 30px; overflow: hidden; -`; - -const logoNormalCss = css` - display: block; opacity: 1; transform: translateZ(0); `; -const sidebarWrapperCss = css` +const SideBarWrapper = styled.div` position: relative; height: calc(100vh - 75px); overflow: hidden auto; width: 260px; z-index: 4; padding-bottom: 100px; + display: ${({ isMenuClosed }) => (isMenuClosed ? 'none' : 'block')}; `; function Sidebar(props) { @@ -98,25 +96,19 @@ function Sidebar(props) { return buildMenu(props.routes); }, [props.routes]); - const subDisplay = props.menuIsClosed ? 'none' : 'block'; + const { menuIsClosed } = props; return ( -
-
-
- NMRium -
- -
-
+ + + {/* @ts-expect-error menu typings are wrong */} { @@ -135,8 +127,8 @@ function Sidebar(props) { > {routes} -
-
+ + ); } diff --git a/src/demo/layouts/Admin.tsx b/src/demo/layouts/Admin.tsx index cb7a914cc..f557448b0 100644 --- a/src/demo/layouts/Admin.tsx +++ b/src/demo/layouts/Admin.tsx @@ -1,6 +1,4 @@ -/** @jsxImportSource @emotion/react */ - -import { css } from '@emotion/react'; +import styled from '@emotion/styled'; import type { ReactElement } from 'react'; import { Suspense, useCallback, useMemo, useState } from 'react'; import { Route, Routes, useLocation } from 'react-router-dom'; @@ -9,20 +7,13 @@ import Sidebar from '../Sidebar.js'; import { getKey, mapTreeToFlatArray } from '../utility/menu.js'; import { possibleViews } from '../views/index.js'; -const mainPanelCss = css` +const Container = styled.div<{ isMenuClosed: boolean }>` position: relative; float: right; height: 100%; background-color: #ebecf1; -`; - -const mainPanelOpenCss = css` - width: calc(100% - 260px); -`; - -const mainPanelClosedCss = css` - width: 98%; - margin-left: 20px !important; + width: ${({ isMenuClosed }) => (isMenuClosed ? '98%' : 'calc(100% - 260px)')}; + margin-left: ${({ isMenuClosed }) => (isMenuClosed ? '20px' : '0px')}; `; interface DashboardProps { @@ -71,13 +62,7 @@ export function Dashboard(props: DashboardProps) { menuIsClosed={menuIsClosed} onMenuToggle={toggleMenu} /> -
+ {/**/} Loading...
}> @@ -97,7 +82,7 @@ export function Dashboard(props: DashboardProps) { {/**/} - + ); }