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-ui][docs] Open Material UI template with CodeSandbox/StackBlitz #43604

Merged
merged 43 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b48eb9e
poc AppTheme + TemplateFrame
siriwatknp Sep 4, 2024
c982bbf
add codesandbox button
siriwatknp Sep 4, 2024
033443d
move AppTheme to
siriwatknp Sep 5, 2024
0e236e1
update TemplateFrame to use button
siriwatknp Sep 5, 2024
52ee07e
fix dark mode flicker issue
siriwatknp Sep 5, 2024
f2ef7f2
switch back to TemplateName
siriwatknp Sep 5, 2024
63baeff
use branding theme
siriwatknp Sep 5, 2024
e6eb4a1
replace file with module
siriwatknp Sep 5, 2024
b12cbf6
run docs:format
siriwatknp Sep 5, 2024
411a832
Merge branch 'master' of https://github.com/mui/material-ui into poc/…
siriwatknp Sep 6, 2024
8b59da7
add StackBlitz
siriwatknp Sep 6, 2024
0e98e5c
move ToggleColorMode to shared-theme
siriwatknp Sep 6, 2024
39ed005
fix tests
siriwatknp Sep 6, 2024
fa891f7
fix typo
siriwatknp Sep 6, 2024
eefecad
remove updateTemplates check
siriwatknp Sep 6, 2024
7b8a931
fix dark mode flicker at the toolbar
siriwatknp Sep 6, 2024
20cfc8e
remove unnecessary comment
siriwatknp Sep 6, 2024
bfc116a
Merge branch 'master' of https://github.com/mui/material-ui into poc/…
siriwatknp Sep 9, 2024
1c377a9
fix the toolbar
siriwatknp Sep 9, 2024
ad00393
comment commitRef
siriwatknp Sep 9, 2024
0385f86
make Dashboard work with new structure
siriwatknp Sep 9, 2024
16b2e23
remove unused files
siriwatknp Sep 9, 2024
2d0ce45
add contributing guide
siriwatknp Sep 9, 2024
cb7823e
typescript format
siriwatknp Sep 9, 2024
d080e3f
fix experiment dashboard
siriwatknp Sep 9, 2024
a269533
fix non-breaking space
siriwatknp Sep 9, 2024
bb3e39f
Merge branch 'master' of https://github.com/mui/material-ui into poc/…
siriwatknp Sep 9, 2024
494bc92
Add visual separator between items
zanivan Sep 9, 2024
f3a1537
Fix layout shift
zanivan Sep 9, 2024
8dd2969
wip
siriwatknp Sep 10, 2024
3cb513f
Merge branch 'master' of https://github.com/mui/material-ui into poc/…
siriwatknp Sep 10, 2024
469338c
make the generateTemplate works with the new structure
siriwatknp Sep 10, 2024
eac95f9
Merge branch 'poc/template-theme' of github.com:siriwatknp/material-u…
siriwatknp Sep 10, 2024
63778ad
switch back to headless mode
siriwatknp Sep 10, 2024
185cbfd
move contributing to faq
siriwatknp Sep 10, 2024
f4e1ae9
Merge branch 'master' of https://github.com/mui/material-ui into poc/…
siriwatknp Sep 10, 2024
046339e
add disableTransitionOnChange
siriwatknp Sep 10, 2024
5f501ea
docs:ts format
siriwatknp Sep 10, 2024
3361f4a
Add link to contribution guide
zanivan Sep 10, 2024
dd74af9
Merge branch 'poc/template-theme' of https://github.com/siriwatknp/ma…
zanivan Sep 10, 2024
b01d202
Tweaks to the text
zanivan Sep 10, 2024
9dd82c4
fix non-breaking space
siriwatknp Sep 11, 2024
8c64407
fix data-screenshot="toggle-mode"
siriwatknp Sep 11, 2024
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
6 changes: 0 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,6 @@ jobs:
command: |
pnpm docs:link-check
git add -A && git diff --exit-code --staged
- run:
name: Update the templates shared themes
command: pnpm template:update-theme
- run:
name: '`pnpm template:update-theme` changes committed?'
command: git add -A && git diff --exit-code --staged
Comment on lines -302 to -307
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer need to run the script. The shared theme is the source of truth and it will be bundled with the template when users open CodeSandbox or StackBlitz.

test_types:
<<: *default-job
resource_class: 'medium+'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* TODO: need to update the `updateTemplatesTheme.ts` script to include the components that are used in the template.
* Generated by a script.
*/
import * as React from 'react';
import PropTypes from 'prop-types';
import { ThemeProvider, createTheme } from '@mui/material/styles';

import { inputsCustomizations } from './customizations/inputs';
import { dataDisplayCustomizations } from './customizations/dataDisplay';
import { feedbackCustomizations } from './customizations/feedback';
import { navigationCustomizations } from './customizations/navigation';
import { surfacesCustomizations } from './customizations/surfaces';
import { colorSchemes, typography, shadows, shape } from './themePrimitives';

function AppTheme({ children, disableCustomTheme, themeComponents }) {
const theme = React.useMemo(() => {
return disableCustomTheme
? {}
: createTheme({
// For more details about CSS variables configuration, see https://mui.com/material-ui/customization/css-theme-variables/configuration/
cssVariables: {
colorSchemeSelector: 'data-mui-color-scheme',
cssVarPrefix: 'template',
},
colorSchemes, // Recently added in v6 for building light & dark mode app, see https://mui.com/material-ui/customization/palette/#color-schemes
typography,
shadows,
shape,
components: {
...inputsCustomizations,
...dataDisplayCustomizations,
...feedbackCustomizations,
...navigationCustomizations,
...surfacesCustomizations,
...themeComponents,
},
});
}, [disableCustomTheme, themeComponents]);
if (disableCustomTheme) {
return <React.Fragment>{children}</React.Fragment>;
}
return (
<ThemeProvider theme={theme} disableTransitionOnChange>
{children}
</ThemeProvider>
);
}

AppTheme.propTypes = {
children: PropTypes.node,
/**
* This is for the docs site. You can ignore it or remove it.
*/
disableCustomTheme: PropTypes.bool,
themeComponents: PropTypes.object,
};

export default AppTheme;
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* TODO: need to update the `updateTemplatesTheme.ts` script to include the components that are used in the template.
* Generated by a script.
*/
import * as React from 'react';
import { ThemeProvider, createTheme } from '@mui/material/styles';
import type { ThemeOptions } from '@mui/material/styles';
import { inputsCustomizations } from './customizations/inputs';
import { dataDisplayCustomizations } from './customizations/dataDisplay';
import { feedbackCustomizations } from './customizations/feedback';
import { navigationCustomizations } from './customizations/navigation';
import { surfacesCustomizations } from './customizations/surfaces';
import { colorSchemes, typography, shadows, shape } from './themePrimitives';

interface AppThemeProps {
children: React.ReactNode;
/**
* This is for the docs site. You can ignore it or remove it.
*/
disableCustomTheme?: boolean;
themeComponents?: ThemeOptions['components'];
}

export default function AppTheme({
children,
disableCustomTheme,
themeComponents,
}: AppThemeProps) {
const theme = React.useMemo(() => {
return disableCustomTheme
? {}
: createTheme({
// For more details about CSS variables configuration, see https://mui.com/material-ui/customization/css-theme-variables/configuration/
cssVariables: {
colorSchemeSelector: 'data-mui-color-scheme',
cssVarPrefix: 'template',
},
colorSchemes, // Recently added in v6 for building light & dark mode app, see https://mui.com/material-ui/customization/palette/#color-schemes
typography,
shadows,
shape,
components: {
...inputsCustomizations,
...dataDisplayCustomizations,
...feedbackCustomizations,
...navigationCustomizations,
...surfacesCustomizations,
...themeComponents,
},
});
}, [disableCustomTheme, themeComponents]);
if (disableCustomTheme) {
return <React.Fragment>{children}</React.Fragment>;
}
return (
<ThemeProvider theme={theme} disableTransitionOnChange>
{children}
</ThemeProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import { useColorScheme } from '@mui/material/styles';
import MenuItem from '@mui/material/MenuItem';
import Select from '@mui/material/Select';

export default function ToggleColorMode() {
const { mode, setMode } = useColorScheme();
if (!mode) {
return null;
}
return (
<Select
data-template-mode-trigger=""
value={mode}
onChange={(e) => setMode(e.target.value)}
sx={{ position: 'fixed', top: '1rem', right: '1rem' }}
>
<MenuItem value="system">System</MenuItem>
<MenuItem value="light">Light</MenuItem>
<MenuItem value="dark">Dark</MenuItem>
</Select>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import { useColorScheme } from '@mui/material/styles';
import MenuItem from '@mui/material/MenuItem';
import Select from '@mui/material/Select';

export default function ToggleColorMode() {
const { mode, setMode } = useColorScheme();
if (!mode) {
return null;
}
return (
<Select
data-template-mode-trigger=""
value={mode}
onChange={(e) => setMode(e.target.value as 'system' | 'light' | 'dark')}
sx={{ position: 'fixed', top: '1rem', right: '1rem' }}
>
<MenuItem value="system">System</MenuItem>
<MenuItem value="light">Light</MenuItem>
<MenuItem value="dark">Dark</MenuItem>
</Select>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const dataDisplayCustomizations = {
[`& .${svgIconClasses.root}`]: {
width: '1rem',
height: '1rem',
color: theme.palette.text.secondary,
color: (theme.vars || theme).palette.text.secondary,
},
[`& .${typographyClasses.root}`]: {
fontWeight: 500,
Expand All @@ -33,13 +33,13 @@ export const dataDisplayCustomizations = {
display: 'flex',
gap: 8,
padding: '2px 8px',
borderRadius: theme.shape.borderRadius,
borderRadius: (theme.vars || theme).shape.borderRadius,
opacity: 0.7,
'&.Mui-selected': {
opacity: 1,
backgroundColor: alpha(theme.palette.action.selected, 0.3),
[`& .${svgIconClasses.root}`]: {
color: theme.palette.text.primary,
color: (theme.vars || theme).palette.text.primary,
},
'&:focus-visible': {
backgroundColor: alpha(theme.palette.action.selected, 0.3),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const dataDisplayCustomizations: Components<Theme> = {
[`& .${svgIconClasses.root}`]: {
width: '1rem',
height: '1rem',
color: theme.palette.text.secondary,
color: (theme.vars || theme).palette.text.secondary,
},
[`& .${typographyClasses.root}`]: {
fontWeight: 500,
Expand All @@ -33,13 +33,13 @@ export const dataDisplayCustomizations: Components<Theme> = {
display: 'flex',
gap: 8,
padding: '2px 8px',
borderRadius: theme.shape.borderRadius,
borderRadius: (theme.vars || theme).shape.borderRadius,
opacity: 0.7,
'&.Mui-selected': {
opacity: 1,
backgroundColor: alpha(theme.palette.action.selected, 0.3),
[`& .${svgIconClasses.root}`]: {
color: theme.palette.text.primary,
color: (theme.vars || theme).palette.text.primary,
},
'&:focus-visible': {
backgroundColor: alpha(theme.palette.action.selected, 0.3),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const feedbackCustomizations = {
root: ({ theme }) => ({
borderRadius: 10,
backgroundColor: orange[100],
color: theme.palette.text.primary,
color: (theme.vars || theme).palette.text.primary,
border: `1px solid ${alpha(orange[300], 0.5)}`,
'& .MuiAlert-icon': {
color: orange[500],
Expand All @@ -26,7 +26,7 @@ export const feedbackCustomizations = {
'& .MuiDialog-paper': {
borderRadius: '10px',
border: '1px solid',
borderColor: theme.palette.divider,
borderColor: (theme.vars || theme).palette.divider,
},
}),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const feedbackCustomizations: Components<Theme> = {
root: ({ theme }) => ({
borderRadius: 10,
backgroundColor: orange[100],
color: theme.palette.text.primary,
color: (theme.vars || theme).palette.text.primary,
border: `1px solid ${alpha(orange[300], 0.5)}`,
'& .MuiAlert-icon': {
color: orange[500],
Expand All @@ -26,7 +26,7 @@ export const feedbackCustomizations: Components<Theme> = {
'& .MuiDialog-paper': {
borderRadius: '10px',
border: '1px solid',
borderColor: theme.palette.divider,
borderColor: (theme.vars || theme).palette.divider,
},
}),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const inputsCustomizations = {
styleOverrides: {
root: ({ theme }) => ({
boxShadow: 'none',
borderRadius: theme.shape.borderRadius,
borderRadius: (theme.vars || theme).shape.borderRadius,
textTransform: 'none',
variants: [
{
Expand Down Expand Up @@ -113,7 +113,7 @@ export const inputsCustomizations = {
variant: 'outlined',
},
style: {
color: theme.palette.text.primary,
color: (theme.vars || theme).palette.text.primary,
border: '1px solid',
borderColor: gray[200],
backgroundColor: alpha(gray[50], 0.3),
Expand Down Expand Up @@ -224,11 +224,11 @@ export const inputsCustomizations = {
styleOverrides: {
root: ({ theme }) => ({
boxShadow: 'none',
borderRadius: theme.shape.borderRadius,
borderRadius: (theme.vars || theme).shape.borderRadius,
textTransform: 'none',
fontWeight: theme.typography.fontWeightMedium,
letterSpacing: 0,
color: theme.palette.text.primary,
color: (theme.vars || theme).palette.text.primary,
border: '1px solid ',
borderColor: gray[200],
backgroundColor: alpha(gray[50], 0.3),
Expand Down Expand Up @@ -382,10 +382,10 @@ export const inputsCustomizations = {
},
root: ({ theme }) => ({
padding: '8px 12px',
color: theme.palette.text.primary,
borderRadius: theme.shape.borderRadius,
border: `1px solid ${theme.palette.divider}`,
backgroundColor: theme.palette.background.default,
color: (theme.vars || theme).palette.text.primary,
borderRadius: (theme.vars || theme).shape.borderRadius,
border: `1px solid ${(theme.vars || theme).palette.divider}`,
backgroundColor: (theme.vars || theme).palette.background.default,
transition: 'border 120ms ease-in',
'&:hover': {
borderColor: gray[400],
Expand Down Expand Up @@ -426,9 +426,9 @@ export const inputsCustomizations = {
MuiInputAdornment: {
styleOverrides: {
root: ({ theme }) => ({
color: theme.palette.grey[500],
color: (theme.vars || theme).palette.grey[500],
...theme.applyStyles('dark', {
color: theme.palette.grey[400],
color: (theme.vars || theme).palette.grey[400],
}),
}),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const inputsCustomizations: Components<Theme> = {
styleOverrides: {
root: ({ theme }) => ({
boxShadow: 'none',
borderRadius: theme.shape.borderRadius,
borderRadius: (theme.vars || theme).shape.borderRadius,
textTransform: 'none',
variants: [
{
Expand Down Expand Up @@ -113,7 +113,7 @@ export const inputsCustomizations: Components<Theme> = {
variant: 'outlined',
},
style: {
color: theme.palette.text.primary,
color: (theme.vars || theme).palette.text.primary,
border: '1px solid',
borderColor: gray[200],
backgroundColor: alpha(gray[50], 0.3),
Expand Down Expand Up @@ -225,11 +225,11 @@ export const inputsCustomizations: Components<Theme> = {
styleOverrides: {
root: ({ theme }) => ({
boxShadow: 'none',
borderRadius: theme.shape.borderRadius,
borderRadius: (theme.vars || theme).shape.borderRadius,
textTransform: 'none',
fontWeight: theme.typography.fontWeightMedium,
letterSpacing: 0,
color: theme.palette.text.primary,
color: (theme.vars || theme).palette.text.primary,
border: '1px solid ',
borderColor: gray[200],
backgroundColor: alpha(gray[50], 0.3),
Expand Down Expand Up @@ -383,10 +383,10 @@ export const inputsCustomizations: Components<Theme> = {
},
root: ({ theme }) => ({
padding: '8px 12px',
color: theme.palette.text.primary,
borderRadius: theme.shape.borderRadius,
border: `1px solid ${theme.palette.divider}`,
backgroundColor: theme.palette.background.default,
color: (theme.vars || theme).palette.text.primary,
borderRadius: (theme.vars || theme).shape.borderRadius,
border: `1px solid ${(theme.vars || theme).palette.divider}`,
backgroundColor: (theme.vars || theme).palette.background.default,
transition: 'border 120ms ease-in',
'&:hover': {
borderColor: gray[400],
Expand Down Expand Up @@ -427,9 +427,9 @@ export const inputsCustomizations: Components<Theme> = {
MuiInputAdornment: {
styleOverrides: {
root: ({ theme }) => ({
color: theme.palette.grey[500],
color: (theme.vars || theme).palette.grey[500],
...theme.applyStyles('dark', {
color: theme.palette.grey[400],
color: (theme.vars || theme).palette.grey[400],
}),
}),
},
Expand Down
Loading