refactor(web): remove typescript
This commit is contained in:
@@ -1,46 +1,26 @@
|
||||
import * as React from 'react';
|
||||
import { useTheme } from '@mui/material/styles';
|
||||
import { SwipeableDrawerProps } from '@mui/material/SwipeableDrawer';
|
||||
import Toolbar from '@mui/material/Toolbar';
|
||||
import List from '@mui/material/List';
|
||||
import Divider from '@mui/material/Divider';
|
||||
import useMediaQuery from '@mui/material/useMediaQuery';
|
||||
import Badge from '@mui/material/Badge';
|
||||
|
||||
import ListItemLink from 'components/ListItemLink';
|
||||
import useFormatMessage from 'hooks/useFormatMessage';
|
||||
import { Drawer as BaseDrawer } from './style';
|
||||
|
||||
const iOS =
|
||||
typeof navigator !== 'undefined' &&
|
||||
/iPad|iPhone|iPod/.test(navigator.userAgent);
|
||||
|
||||
type DrawerLink = {
|
||||
Icon: React.ElementType;
|
||||
primary: string;
|
||||
to: string;
|
||||
target?: '_blank';
|
||||
badgeContent?: React.ReactNode;
|
||||
dataTest?: string;
|
||||
};
|
||||
|
||||
type DrawerProps = {
|
||||
links: DrawerLink[];
|
||||
bottomLinks?: DrawerLink[];
|
||||
} & SwipeableDrawerProps;
|
||||
|
||||
export default function Drawer(props: DrawerProps): React.ReactElement {
|
||||
export default function Drawer(props) {
|
||||
const { links = [], bottomLinks = [], ...drawerProps } = props;
|
||||
const theme = useTheme();
|
||||
const matchSmallScreens = useMediaQuery(theme.breakpoints.down('md'));
|
||||
const formatMessage = useFormatMessage();
|
||||
|
||||
const closeOnClick = (event: React.SyntheticEvent) => {
|
||||
const closeOnClick = (event) => {
|
||||
if (matchSmallScreens) {
|
||||
props.onClose(event);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<BaseDrawer
|
||||
{...drawerProps}
|
||||
@@ -84,7 +64,7 @@ export default function Drawer(props: DrawerProps): React.ReactElement {
|
||||
target={target}
|
||||
data-test={dataTest}
|
||||
/>
|
||||
)
|
||||
),
|
||||
)}
|
||||
</List>
|
||||
</BaseDrawer>
|
@@ -1,10 +1,8 @@
|
||||
import { styled, Theme, CSSObject } from '@mui/material/styles';
|
||||
import { styled } from '@mui/material/styles';
|
||||
import { drawerClasses } from '@mui/material/Drawer';
|
||||
import MuiSwipeableDrawer from '@mui/material/SwipeableDrawer';
|
||||
|
||||
const drawerWidth = 300;
|
||||
|
||||
const openedMixin = (theme: Theme): CSSObject => ({
|
||||
const openedMixin = (theme) => ({
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
@@ -15,8 +13,7 @@ const openedMixin = (theme: Theme): CSSObject => ({
|
||||
width: drawerWidth,
|
||||
},
|
||||
});
|
||||
|
||||
const closedMixin = (theme: Theme): CSSObject => ({
|
||||
const closedMixin = (theme) => ({
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.leavingScreen,
|
||||
@@ -27,7 +24,6 @@ const closedMixin = (theme: Theme): CSSObject => ({
|
||||
width: `calc(${theme.spacing(9)} + 1px)`,
|
||||
},
|
||||
});
|
||||
|
||||
export const Drawer = styled(MuiSwipeableDrawer)(({ theme, open }) => ({
|
||||
width: drawerWidth,
|
||||
flexShrink: 0,
|
Reference in New Issue
Block a user