Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
style(Sidebar): move sidebar collpase button to topbar
Browse files Browse the repository at this point in the history
Signed-off-by: reslene <reslene@numary.com>
  • Loading branch information
reslene committed Dec 16, 2022
1 parent 5ee8b49 commit 6ed40e6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 41 deletions.
8 changes: 2 additions & 6 deletions app/src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@ const Layout: FunctionComponent<LayoutProps> = ({ children }) => {
</animated.div>
) : (
<animated.div style={{ height: '100%' }}>
<Topbar />
<Topbar resized={showMiniSidebar} onResize={handleMiniSidebar} />
<Box id="layout" sx={{ minHeight: '100%', display: 'flex' }}>
<Sidebar
width={sideBarWidth}
onResize={handleMiniSidebar}
resized={showMiniSidebar}
/>
<Sidebar width={sideBarWidth} resized={showMiniSidebar} />
<Box
sx={{ width: { sm: `calc(100% - ${sideBarWidth}px)` } }}
mt={8}
Expand Down
33 changes: 2 additions & 31 deletions app/src/components/Layout/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import { FunctionComponent } from 'react';

import { NavigateBefore, NavigateNext } from '@mui/icons-material';
import { Box, Button, IconButton, Typography, useTheme } from '@mui/material';
import { useLocation } from '@remix-run/react';
import { isArray } from 'lodash';
Expand All @@ -11,11 +10,7 @@ import { SidebarProps } from '~/src/components/Layout/components/Sidebar/types';
import { routerConfig } from '~/src/components/Navbar/routes';
import LinkWrapper from '~/src/components/Wrappers/LinkWrapper';

const Sidebar: FunctionComponent<SidebarProps> = ({
width,
onResize,
resized,
}) => {
const Sidebar: FunctionComponent<SidebarProps> = ({ width, resized }) => {
const { palette } = useTheme();
const location = useLocation();
const { t } = useTranslation();
Expand Down Expand Up @@ -43,31 +38,7 @@ const Sidebar: FunctionComponent<SidebarProps> = ({
transition: 'all 0.25s',
}}
>
<Box
sx={{
display: 'flex',
justifyContent: resized ? 'center' : 'flex-end',
mt: 8,
pr: resized ? 0 : 1,
}}
>
<IconButton
sx={{
...buttonSx,
width: 'auto',
transition: 'all 0.85s',
':hover': {
transform: 'rotate(360deg)',
transition: 'all 0.85s',
background: 'transparent',
},
}}
onClick={onResize}
>
{resized ? <NavigateNext /> : <NavigateBefore />}
</IconButton>
</Box>
<Box>
<Box mt={9}>
{routerConfig.map(({ label: groupLabel, children }, index) => (
<Box key={index} sx={{ marginTop: resized ? '24px' : 'initial' }}>
{groupLabel && !resized && (
Expand Down
1 change: 0 additions & 1 deletion app/src/components/Layout/components/Sidebar/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export type SidebarProps = {
width: number;
onResize: () => void;
resized: boolean;
};
26 changes: 23 additions & 3 deletions app/src/components/Layout/components/Topbar/Topbar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { FunctionComponent, useEffect } from 'react';

import { ArrowDropDown, Person } from '@mui/icons-material';
import { ArrowDropDown, MenuOpen, Person } from '@mui/icons-material';
import {
Avatar,
Box,
Expand All @@ -13,11 +13,12 @@ import {
} from '@mui/material';
import { useTranslation } from 'react-i18next';

import { TopbarProps } from '~/src/components/Layout/components/Topbar/types';
import Search from '~/src/components/Search';
import { useService } from '~/src/hooks/useService';
import { CurrentUser } from '~/src/utils/api';

const Topbar: FunctionComponent = () => {
const Topbar: FunctionComponent<TopbarProps> = ({ resized, onResize }) => {
const { palette } = useTheme();
const { t } = useTranslation();
const { api, setCurrentUser, currentUser, metas } = useService();
Expand Down Expand Up @@ -82,9 +83,28 @@ const Topbar: FunctionComponent = () => {
}}
id="topbar"
>
<Box ml={2}>
<Box display="flex">
<IconButton
sx={{
transition: 'all 0.85s',
color: ({ palette }) => palette.neutral[500],
background: 'transparent',
ml: 2,
mr: 2,
':hover': {
transform: `rotate(${resized ? '-180deg' : '180deg'})`,
color: ({ palette }) => palette.neutral[300],
transition: 'all 0.85s',
background: 'transparent',
},
}}
onClick={onResize}
>
<MenuOpen />
</IconButton>
<Search />
</Box>

{currentUser && (
<Box mr={1}>
<IconButton sx={{ p: 0 }}>
Expand Down
4 changes: 4 additions & 0 deletions app/src/components/Layout/components/Topbar/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type TopbarProps = {
onResize: () => void;
resized: boolean;
};

0 comments on commit 6ed40e6

Please sign in to comment.