feat: design my apps along with app layout
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
3785c705ff
commit
6da8557219
30
packages/web/src/components/ConditionalIconButton/index.tsx
Normal file
30
packages/web/src/components/ConditionalIconButton/index.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import * as React from 'react';
|
||||
import { useTheme } from '@mui/material/styles';
|
||||
import useMediaQuery from '@mui/material/useMediaQuery';
|
||||
import Button from '@mui/material/Button';
|
||||
|
||||
import { IconButton } from './style';
|
||||
|
||||
export default function ConditionalIconButton(props: any) {
|
||||
const { Icon, ...buttonProps } = props;
|
||||
const theme = useTheme();
|
||||
const matchSmallScreens = useMediaQuery(theme.breakpoints.down('md'), { noSsr: true });
|
||||
|
||||
if (matchSmallScreens) {
|
||||
return (
|
||||
<IconButton
|
||||
color={buttonProps.color}
|
||||
type={buttonProps.type}
|
||||
size={buttonProps.size}
|
||||
component={buttonProps.component}
|
||||
to={buttonProps.to}
|
||||
>
|
||||
<Icon />
|
||||
</IconButton>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Button {...buttonProps} />
|
||||
);
|
||||
}
|
13
packages/web/src/components/ConditionalIconButton/style.ts
Normal file
13
packages/web/src/components/ConditionalIconButton/style.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { styled } from '@mui/material/styles';
|
||||
import MuiIconButton, { iconButtonClasses } from '@mui/material/IconButton';
|
||||
|
||||
export const IconButton = styled(MuiIconButton)`
|
||||
&.${iconButtonClasses.colorPrimary} {
|
||||
background: ${({ theme }) => theme.palette.primary.main};
|
||||
color: ${({ theme }) => theme.palette.primary.contrastText};
|
||||
|
||||
&:hover {
|
||||
background: ${({ theme }) => theme.palette.primary.dark};
|
||||
}
|
||||
}
|
||||
` as typeof MuiIconButton;
|
Reference in New Issue
Block a user