Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Material You] Add theme structure & Button component #34650

Merged
merged 66 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
5f1c550
[POC] Add `createMD3Theme` creator v2
mnajdova Oct 7, 2022
81fd0cf
More styles
mnajdova Oct 11, 2022
4be5c86
More progress
mnajdova Oct 18, 2022
9be7ed0
vars fixes
mnajdova Oct 18, 2022
eb71487
Make sizes work
mnajdova Oct 18, 2022
995e5c0
Convert component to ts
mnajdova Oct 19, 2022
dca1c60
fix import
mnajdova Oct 19, 2022
61ebd28
Fix lint & prettier
mnajdova Oct 19, 2022
e81a363
Fix tsx issues
mnajdova Oct 20, 2022
545b646
Fix regression tests
mnajdova Oct 20, 2022
1a45e91
Refactor to only use CSS vars, added default theme, add custom styled…
mnajdova Oct 20, 2022
f916db3
Merge pull request #35 from mnajdova/poc/support-css-vars-provider-only
mnajdova Oct 20, 2022
9fd9092
Fix some CI issues
mnajdova Oct 20, 2022
c70d8dc
Fix build
mnajdova Oct 20, 2022
72b7375
Cleanup docs experiments page
mnajdova Oct 20, 2022
1ea8e95
Make it able to coexist with MD2
mnajdova Oct 20, 2022
755bb6f
Fix defaultTheme
mnajdova Oct 20, 2022
775bd0c
lint fix
mnajdova Oct 20, 2022
fb1e07c
Use imports from @mui/material-next
mnajdova Oct 21, 2022
4c03b3b
SxProps type
mnajdova Oct 21, 2022
2ea93a3
Don't export types just yet
mnajdova Oct 21, 2022
5c16e1f
Remove component's CSS vars
mnajdova Oct 27, 2022
0cdc39b
Change the theme structure
mnajdova Oct 27, 2022
db6ddd9
Some fixed and types issues
mnajdova Oct 28, 2022
03b455c
More ts fixes
mnajdova Oct 28, 2022
346fe69
Default theme fixes
mnajdova Oct 28, 2022
da2361d
Add basic styleFunctionSx
mnajdova Oct 28, 2022
843f358
Merge branch 'master' into poc/material-you-new-component
mnajdova Oct 28, 2022
18cddd1
Fixes after rebase
mnajdova Oct 28, 2022
11afa92
Merge branch 'master' into poc/material-you-new-component
mnajdova Oct 28, 2022
d416262
[release] v5.10.12
mnajdova Oct 31, 2022
a4ac85f
Remove autogenerated text
mnajdova Oct 31, 2022
9d0d4f3
Merge branch 'master' into release/5.10.12
mnajdova Oct 31, 2022
7e1815a
Updated changelog
mnajdova Oct 31, 2022
4a6bafb
Merge branch 'master' into release/5.10.12
mnajdova Oct 31, 2022
1e556dc
Updated changelog
mnajdova Oct 31, 2022
bf55df5
Merge branch 'release/5.10.12' of https://github.com/mnajdova/materia…
mnajdova Oct 31, 2022
a0ea0e3
Improve classes
mnajdova Nov 1, 2022
225f5cc
Update packages/mui-material-next/src/Button/Button.types.ts
mnajdova Nov 3, 2022
2f2c1a3
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 4, 2022
696baf0
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 9, 2022
ba3ff09
Merge branch 'master' into poc/material-you-new-component
mnajdova Nov 9, 2022
f019d2b
Merge branch 'poc/material-you-new-component' of https://github.com/m…
mnajdova Nov 9, 2022
449d93a
address Jun's feedback
mnajdova Nov 9, 2022
1eefc63
adjust demo colors
mnajdova Nov 9, 2022
a5b0735
Add css vars
mnajdova Nov 9, 2022
12ee941
Fix the border radius
mnajdova Nov 9, 2022
78638b8
Fix border radius
mnajdova Nov 10, 2022
92c0735
Fix in all cases
mnajdova Nov 10, 2022
41216b6
Fix lint issue
mnajdova Nov 10, 2022
00a3cd9
prettier
mnajdova Nov 10, 2022
150fab6
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 14, 2022
6205b27
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 15, 2022
90bb1dd
Merge branch 'master' into poc/material-you-new-component
mnajdova Nov 16, 2022
909f466
Jun's reviewmerge
mnajdova Nov 16, 2022
5ffb6cf
lint fix
mnajdova Nov 16, 2022
2812dea
Fix the sx palette mappings
mnajdova Nov 16, 2022
62c80e3
Fix lint issue
mnajdova Nov 16, 2022
d418b4a
Fix ts issues
mnajdova Nov 16, 2022
1bb3f11
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 18, 2022
02fb061
Merge branch 'master' into poc/material-you-new-component
mnajdova Nov 18, 2022
4aef1c6
Resolve Michal's review
mnajdova Nov 18, 2022
702bf5e
Fix lint issues
mnajdova Nov 18, 2022
0c1f512
Apply suggestions from code review
mnajdova Nov 21, 2022
bcf632c
Merge branch 'master' of https://github.com/mui-org/material-ui into …
mnajdova Nov 21, 2022
b9dd876
Merge branch 'master' into poc/material-you-new-component
mnajdova Nov 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 171 additions & 0 deletions docs/pages/experiments/md3/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
import * as React from 'react';
import Tooltip from '@mui/material/Tooltip';
import IconButton from '@mui/material/IconButton';
import Stack from '@mui/material/Stack';
import MD2Button, { ButtonProps as MD2ButtonProps } from '@mui/material/Button';
import { unstable_capitalize as capitalize } from '@mui/utils';
import DeleteIcon from '@mui/icons-material/Delete';
import SendIcon from '@mui/icons-material/Send';
import Button, { ButtonProps } from '@mui/material-next/Button';
import { CssVarsProvider, useColorScheme, extendTheme } from '@mui/material-next/styles';
import DarkIcon from '@mui/icons-material/DarkModeOutlined';
import LightIcon from '@mui/icons-material/LightModeOutlined';

const ModeSwitcher = () => {
const { mode, setMode } = useColorScheme();
const [mounted, setMounted] = React.useState(false);

React.useEffect(() => {
setMounted(true);
}, []);

if (!mounted) {
return null;
}

return (
<Tooltip title={`Change to ${mode === 'light' ? 'dark' : 'light'} mode`}>
<IconButton
onClick={() => {
if (mode === 'light') {
setMode('dark');
} else {
setMode('light');
}
}}
>
{mode === 'light' ? <DarkIcon /> : <LightIcon />}
</IconButton>
</Tooltip>
);
};

const variants: ButtonProps['variant'][] = [
'elevated',
'filled',
'filledTonal',
'outlined',
'text',
];
const colors: ButtonProps['color'][] = ['primary', 'secondary', 'tertiary'];
const sizes: ButtonProps['size'][] = ['small', 'medium', 'large'];

const md2Variants: MD2ButtonProps['variant'][] = ['contained', 'outlined', 'text'];
const md2Colors: MD2ButtonProps['color'][] = [
'primary',
'secondary',
'success',
'error',
'info',
'warning',
];

const DemoComponents = () => {
return (
<Stack direction="column" gap={1}>
<h4>Enabled</h4>
<Stack direction="row" gap={1}>
{variants.map((variant) => (
<Button key={`${variant}-enabled`} variant={variant}>
{capitalize(variant as string)}
</Button>
))}
</Stack>
<h4>Disabled</h4>
<Stack direction="row" gap={1}>
{variants.map((variant) => (
<Button key={`${variant}-disabled`} variant={variant} disabled>
{capitalize(variant as string)}
</Button>
))}
</Stack>
<h4>Colors</h4>
<Stack direction="row" gap={1}>
{colors.map((color) => (
<Button key={color} variant="filled" color={color}>
{capitalize(color as string)}
</Button>
))}
</Stack>
<Stack direction="row" gap={1}>
{colors.map((color) => (
<Button key={color} variant="outlined" color={color}>
{capitalize(color as string)}
</Button>
))}
</Stack>
<Stack direction="row" gap={1}>
{colors.map((color) => (
<Button key={color} variant="text" color={color}>
{capitalize(color as string)}
</Button>
))}
</Stack>
<h4>Extended buttons</h4>
<Stack direction="row" gap={1}>
{colors.map((color) => (
<Button key={color} variant="filled" color={color} endIcon={<SendIcon />}>
Send
</Button>
))}
<Button variant="filled" disabled endIcon={<SendIcon />}>
Send
</Button>
</Stack>
<Stack direction="row" gap={1}>
{colors.map((color) => (
<Button key={color} variant="outlined" color={color} startIcon={<DeleteIcon />}>
Delete
</Button>
))}
<Button variant="outlined" disabled startIcon={<DeleteIcon />}>
Delete
</Button>
</Stack>
<h4>Sizes</h4>
<Stack direction="row" gap={1} alignItems="end">
{sizes.map((size) => (
<Button key={size} variant="filled" size={size} endIcon={<SendIcon />}>
{capitalize(size as string)}
</Button>
))}
</Stack>
<Stack direction="row" gap={1} alignItems="end">
{sizes.map((size) => (
<Button key={size} variant="outlined" size={size} startIcon={<DeleteIcon />}>
{capitalize(size as string)}
</Button>
))}
</Stack>
<h4>Material Design 2 Buttons</h4>
<Stack direction="row" gap={1} alignItems="end">
{md2Variants.map((variant) => (
<MD2Button key={variant} variant={variant}>
{capitalize(variant as string)}
</MD2Button>
))}
</Stack>
<Stack direction="row" gap={1} alignItems="end">
{md2Colors.map((color) => (
<MD2Button key={color} variant="contained" color={color}>
{capitalize(color as string)}
</MD2Button>
))}
</Stack>
</Stack>
);
};

// default MD3 theme
const cssVarsTheme = extendTheme();

export default function App() {
return (
<React.Fragment>
<CssVarsProvider theme={cssVarsTheme}>
<ModeSwitcher />
<DemoComponents />
</CssVarsProvider>
</React.Fragment>
);
}
Loading