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] Refine and unify custom template themes #43220

Merged
merged 67 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
f81b154
Clean up landing page template theme
zanivan Aug 5, 2024
946cc5f
Add missing components to theme
zanivan Aug 5, 2024
eed2a8f
Standardize theme folder across all templates
zanivan Aug 5, 2024
ab81559
Run docs:typescript
zanivan Aug 5, 2024
a2d4b26
Stray visual tweaks
zanivan Aug 7, 2024
88a11ea
Merge branch 'next' into refine-custom-theme
zanivan Aug 7, 2024
eca042e
Stray design tweaks
zanivan Aug 7, 2024
8dd2aae
Stray tweaks on marketing-page template
zanivan Aug 7, 2024
41a3106
Merge branch 'next' into refine-custom-theme
zanivan Aug 7, 2024
607ddc4
Run docs:typescript:formatted
zanivan Aug 7, 2024
3a1d012
Fix imports
zanivan Aug 8, 2024
cccb5d1
Fix input padding
zanivan Aug 8, 2024
10746f8
Test screenshots
zanivan Aug 8, 2024
9118043
Tweaks to sign-in and sign-up
zanivan Aug 8, 2024
2bc6df6
Standardizing colors
zanivan Aug 9, 2024
edf8702
Merge branch 'next' into refine-custom-theme
zanivan Aug 9, 2024
cee9709
Merge branch 'next' into refine-custom-theme
zanivan Aug 12, 2024
4cdf224
Clean up dashboard theme
zanivan Aug 13, 2024
594126e
Fix lint
zanivan Aug 13, 2024
488f125
Remove outdated pricing imports
zanivan Aug 13, 2024
4f5be73
Clean up test regressions
zanivan Aug 13, 2024
fdecca2
Fix tests
zanivan Aug 13, 2024
f84f057
Fix regression tests
zanivan Aug 13, 2024
7da8ba0
Add missing test
zanivan Aug 13, 2024
2db4070
Add update tempaltes theme script and CI check
DiegoAndai Aug 14, 2024
80462ed
Add shared theme files
DiegoAndai Aug 14, 2024
f2404cb
Improve CI check
DiegoAndai Aug 14, 2024
46f5aa0
Commit incorrect edit of shared theme file to test CI check
DiegoAndai Aug 14, 2024
4b10844
Revert "Commit incorrect edit of shared theme file to test CI check"
DiegoAndai Aug 14, 2024
59fa3e4
Improve script
DiegoAndai Aug 14, 2024
049dfab
Make the templates respect the user's system color mode
zanivan Aug 15, 2024
f9edd82
Make selected color mode persist between reload
zanivan Aug 15, 2024
4454144
Clean up landing page template theme
zanivan Aug 5, 2024
3506ced
Add missing components to theme
zanivan Aug 5, 2024
38c5294
Standardize theme folder across all templates
zanivan Aug 5, 2024
ebed551
Run docs:typescript
zanivan Aug 5, 2024
9afc729
Stray visual tweaks
zanivan Aug 7, 2024
a90bfdf
Stray design tweaks
zanivan Aug 7, 2024
d674b4f
Stray tweaks on marketing-page template
zanivan Aug 7, 2024
a8494b0
Run docs:typescript:formatted
zanivan Aug 7, 2024
2422ad1
Fix imports
zanivan Aug 8, 2024
b0e94a1
Fix input padding
zanivan Aug 8, 2024
8b935c6
Test screenshots
zanivan Aug 8, 2024
bc04345
Tweaks to sign-in and sign-up
zanivan Aug 8, 2024
b51591a
Standardizing colors
zanivan Aug 9, 2024
7a02484
Clean up dashboard theme
zanivan Aug 13, 2024
923bbe5
Fix lint
zanivan Aug 13, 2024
fe5d32c
Remove outdated pricing imports
zanivan Aug 13, 2024
218f25e
Clean up test regressions
zanivan Aug 13, 2024
c637a27
Fix tests
zanivan Aug 13, 2024
bed2833
Fix regression tests
zanivan Aug 13, 2024
6980a0c
Add missing test
zanivan Aug 13, 2024
0e88852
Add update tempaltes theme script and CI check
DiegoAndai Aug 14, 2024
4979d7e
Add shared theme files
DiegoAndai Aug 14, 2024
672299b
Improve CI check
DiegoAndai Aug 14, 2024
a389b9d
Commit incorrect edit of shared theme file to test CI check
DiegoAndai Aug 14, 2024
c3fd74a
Revert "Commit incorrect edit of shared theme file to test CI check"
DiegoAndai Aug 14, 2024
9b639e5
Improve script
DiegoAndai Aug 14, 2024
5793f69
Make the templates respect the user's system color mode
zanivan Aug 15, 2024
56ea32d
Make selected color mode persist between reload
zanivan Aug 15, 2024
1c81f6d
Fix imports
aarongarciah Aug 16, 2024
156f24a
Update theme
aarongarciah Aug 16, 2024
f755c42
Merge branch 'refine-custom-theme' of https://github.com/mui/material…
zanivan Aug 16, 2024
7a2a1df
Remove outdated theme files
zanivan Aug 16, 2024
b5d29e0
Merge branch 'next' into refine-custom-theme
zanivan Aug 16, 2024
a94c233
Run scripts
zanivan Aug 16, 2024
3e5adcd
Small fix
zanivan Aug 16, 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: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ 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
test_types:
<<: *default-job
resource_class: 'medium+'
Expand Down
19 changes: 0 additions & 19 deletions benchmark/server/scenarios/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
createGenerateClassName,
} from '@mui/styles';
import { green, red } from '@mui/material/colors';
import Pricing from 'docs/data/material/getting-started/templates/pricing/Pricing';
import { spacing, palette, unstable_styleFunctionSx as styleFunction } from '@mui/system';
import Avatar from '@mui/material/Avatar';
import Box from '@mui/material/Box';
Expand Down Expand Up @@ -42,23 +41,6 @@ const theme = createTheme({
},
});

function renderPricing(req, res) {
const sheetsRegistry = new SheetsRegistry();
const html = ReactDOMServer.renderToString(
<StylesProvider
sheetsRegistry={sheetsRegistry}
generateClassName={createGenerateClassName()}
sheetsManager={new Map()}
>
<ThemeProvider theme={theme}>
<Pricing />
</ThemeProvider>
</StylesProvider>,
);
const css = sheetsRegistry.toString();
res.send(renderFullPage(html, css));
}

function renderBox(req, res) {
const sheetsRegistry = new SheetsRegistry();
const html = ReactDOMServer.renderToString(
Expand Down Expand Up @@ -156,7 +138,6 @@ function renderSystem(req, res) {
}

const app = express();
app.get('/', renderPricing);
app.get('/spacing', renderSpacing);
app.get('/palette', renderPalette);
app.get('/system', renderSystem);
Expand Down
19 changes: 17 additions & 2 deletions docs/data/material/getting-started/templates/blog/Blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,26 @@ export default function Blog() {
const [showCustomTheme, setShowCustomTheme] = React.useState(true);
const blogTheme = createTheme(getBlogTheme(mode));
const defaultTheme = createTheme({ palette: { mode } });
// This code only runs on the client side, to determine the system color preference
React.useEffect(() => {
// Check if there is a preferred mode in localStorage
const savedMode = localStorage.getItem('themeMode');
if (savedMode) {
setMode(savedMode);
} else {
// If no preference is found, it uses system preference
const systemPrefersDark = window.matchMedia(
'(prefers-color-scheme: dark)',
).matches;
setMode(systemPrefersDark ? 'dark' : 'light');
}
}, []);

const toggleColorMode = () => {
setMode((prev) => (prev === 'dark' ? 'light' : 'dark'));
const newMode = mode === 'dark' ? 'light' : 'dark';
setMode(newMode);
localStorage.setItem('themeMode', newMode); // Save the selected mode to localStorage
};

const toggleCustomTheme = () => {
setShowCustomTheme((prev) => !prev);
};
Expand Down
19 changes: 17 additions & 2 deletions docs/data/material/getting-started/templates/blog/Blog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,26 @@ export default function Blog() {
const [showCustomTheme, setShowCustomTheme] = React.useState(true);
const blogTheme = createTheme(getBlogTheme(mode));
const defaultTheme = createTheme({ palette: { mode } });
// This code only runs on the client side, to determine the system color preference
React.useEffect(() => {
// Check if there is a preferred mode in localStorage
const savedMode = localStorage.getItem('themeMode') as PaletteMode | null;
if (savedMode) {
setMode(savedMode);
} else {
// If no preference is found, it uses system preference
const systemPrefersDark = window.matchMedia(
'(prefers-color-scheme: dark)',
).matches;
setMode(systemPrefersDark ? 'dark' : 'light');
}
}, []);

const toggleColorMode = () => {
setMode((prev) => (prev === 'dark' ? 'light' : 'dark'));
const newMode = mode === 'dark' ? 'light' : 'dark';
setMode(newMode);
localStorage.setItem('themeMode', newMode); // Save the selected mode to localStorage
};

const toggleCustomTheme = () => {
setShowCustomTheme((prev) => !prev);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import { styled } from '@mui/material/styles';
import { alpha, styled } from '@mui/material/styles';
import Box from '@mui/material/Box';
import AppBar from '@mui/material/AppBar';
import Toolbar from '@mui/material/Toolbar';
Expand All @@ -24,7 +24,7 @@ const StyledToolbar = styled(Toolbar)(({ theme }) => ({
backdropFilter: 'blur(24px)',
border: '1px solid',
borderColor: theme.palette.divider,
backgroundColor: theme.palette.background.default,
backgroundColor: alpha(theme.palette.background.default, 0.4),
boxShadow: theme.shadows[1],
padding: '8px 12px',
}));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { PaletteMode, styled } from '@mui/material/styles';
import { PaletteMode, alpha, styled } from '@mui/material/styles';
import Box from '@mui/material/Box';
import AppBar from '@mui/material/AppBar';
import Toolbar from '@mui/material/Toolbar';
Expand All @@ -23,7 +23,7 @@ const StyledToolbar = styled(Toolbar)(({ theme }) => ({
backdropFilter: 'blur(24px)',
border: '1px solid',
borderColor: theme.palette.divider,
backgroundColor: theme.palette.background.default,
backgroundColor: alpha(theme.palette.background.default, 0.4),
boxShadow: theme.shadows[1],
padding: '8px 12px',
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,11 @@ export default function MainContent() {
gap: 4,
}}
>
<Box sx={{ display: 'flex', flexDirection: 'row', gap: 1 }}>
<Chip onClick={handleClick} label="All categories" />
<Box sx={{ display: 'flex', flexDirection: 'row', gap: 3 }}>
<Chip onClick={handleClick} size="medium" label="All categories" />
<Chip
onClick={handleClick}
size="medium"
label="Company"
sx={{
backgroundColor: 'transparent',
Expand All @@ -219,6 +220,7 @@ export default function MainContent() {
/>
<Chip
onClick={handleClick}
size="medium"
label="Product"
sx={{
backgroundColor: 'transparent',
Expand All @@ -227,6 +229,7 @@ export default function MainContent() {
/>
<Chip
onClick={handleClick}
size="medium"
label="Design"
sx={{
backgroundColor: 'transparent',
Expand All @@ -235,6 +238,7 @@ export default function MainContent() {
/>
<Chip
onClick={handleClick}
size="medium"
label="Engineering"
sx={{
backgroundColor: 'transparent',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,11 @@ export default function MainContent() {
gap: 4,
}}
>
<Box sx={{ display: 'flex', flexDirection: 'row', gap: 1 }}>
<Chip onClick={handleClick} label="All categories" />
<Box sx={{ display: 'flex', flexDirection: 'row', gap: 3 }}>
<Chip onClick={handleClick} size="medium" label="All categories" />
<Chip
onClick={handleClick}
size="medium"
label="Company"
sx={{
backgroundColor: 'transparent',
Expand All @@ -211,6 +212,7 @@ export default function MainContent() {
/>
<Chip
onClick={handleClick}
size="medium"
label="Product"
sx={{
backgroundColor: 'transparent',
Expand All @@ -219,6 +221,7 @@ export default function MainContent() {
/>
<Chip
onClick={handleClick}
size="medium"
label="Design"
sx={{
backgroundColor: 'transparent',
Expand All @@ -227,6 +230,7 @@ export default function MainContent() {
/>
<Chip
onClick={handleClick}
size="medium"
label="Engineering"
sx={{
backgroundColor: 'transparent',
Expand Down
Loading
Loading