Skip to content

Commit

Permalink
Clean up SvgIcon demo
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj committed Apr 4, 2022
1 parent 78b8819 commit 55bbcdc
Showing 1 changed file with 2 additions and 36 deletions.
38 changes: 2 additions & 36 deletions docs/pages/experiments/joy/svg-icon.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,11 @@
import Moon from '@mui/icons-material/DarkMode';
import Sun from '@mui/icons-material/LightMode';
import Box from '@mui/joy/Box';
import Button from '@mui/joy/Button';
import { CssVarsProvider, useColorScheme } from '@mui/joy/styles';
import SvgIcon from '@mui/joy/SvgIcon';
import Typography from '@mui/joy/Typography';
import * as React from 'react';
// @ts-ignore
import { jsx as _jsx } from 'react/jsx-runtime';

function createSvgIcon(path: any, displayName: any, initialProps?: any) {
const Component = (props: any, ref: any) =>
(
<SvgIcon
data-testid={`${displayName}Icon`}
ref={ref}
viewBox="0 0 24 24"
fontSize="extraLarge"
{...initialProps}
{...props}
sx={{ ...initialProps?.sx, ...props.sx }}
>
{path}
</SvgIcon>
) as unknown as typeof SvgIcon;

// @ts-ignore
return React.memo(React.forwardRef(Component));
}

export const Moon = createSvgIcon(
_jsx('path', {
d: 'M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9 9-4.03 9-9c0-.46-.04-.92-.1-1.36-.98 1.37-2.58 2.26-4.4 2.26-2.98 0-5.4-2.42-5.4-5.4 0-1.81.89-3.42 2.26-4.4-.44-.06-.9-.1-1.36-.1z',
}),
'DarkMode',
);

export const Sun = createSvgIcon(
_jsx('path', {
d: 'M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zM2 13h2c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1s.45 1 1 1zm18 0h2c.55 0 1-.45 1-1s-.45-1-1-1h-2c-.55 0-1 .45-1 1s.45 1 1 1zM11 2v2c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1zm0 18v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1s-1 .45-1 1zM5.99 4.58c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0s.39-1.03 0-1.41L5.99 4.58zm12.37 12.37c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0 .39-.39.39-1.03 0-1.41l-1.06-1.06zm1.06-10.96c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0l1.06-1.06zM7.05 18.36c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0l1.06-1.06z',
}),
'LightMode',
);

const ColorSchemePicker = () => {
const { mode, setMode } = useColorScheme();
Expand Down

0 comments on commit 55bbcdc

Please sign in to comment.