Skip to content

Commit 9ed2537

Browse files
authored
Merge pull request #10960 from marmelab/fix-toolbar-default-theme
Fix `<Toolbar>` design
2 parents dce7fcf + 3ba2ad0 commit 9ed2537

File tree

10 files changed

+99
-2
lines changed

10 files changed

+99
-2
lines changed

examples/demo/src/themes/chiptuneTheme.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { grey } from '@mui/material/colors';
12
import { RaThemeOptions } from 'react-admin';
23

34
/** Just for fun */
@@ -21,5 +22,12 @@ export const chiptuneTheme: RaThemeOptions = {
2122
MuiFormControl: { defaultProps: { fullWidth: true } },
2223
MuiTextField: { defaultProps: { fullWidth: true } },
2324
RaSimpleFormIterator: { defaultProps: { fullWidth: true } },
25+
RaToolbar: {
26+
styleOverrides: {
27+
root: {
28+
backgroundColor: grey[900],
29+
},
30+
},
31+
},
2432
},
2533
};

examples/demo/src/themes/cssVariablesTheme.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,30 @@ const lightTheme: RaThemeOptions = {
1010
0.8
1111
),
1212
},
13+
components: {
14+
RaToolbar: {
15+
styleOverrides: {
16+
root: {
17+
backgroundColor: `color-mix(in oklab, var(--mui-palette-background-paper) 80%, light-dark(black, white))`,
18+
},
19+
},
20+
},
21+
},
1322
};
1423
const darkTheme: RaThemeOptions = {
1524
palette: {
1625
mode: 'dark',
1726
bulkActionsToolbarBackgroundColor: defaultTheme.palette.primary.dark,
1827
},
28+
components: {
29+
RaToolbar: {
30+
styleOverrides: {
31+
root: {
32+
backgroundColor: `color-mix(in oklab, var(--mui-palette-background-paper) 80%, light-dark(black, white))`,
33+
},
34+
},
35+
},
36+
},
1937
};
2038

2139
export const cssVariablesTheme = createTheme({

examples/demo/src/themes/softTheme.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { grey } from '@mui/material/colors';
12
import { defaultTheme } from 'react-admin';
23

34
/**
@@ -45,6 +46,13 @@ export const softDarkTheme = {
4546
elevation: 1,
4647
},
4748
},
49+
RaToolbar: {
50+
styleOverrides: {
51+
root: {
52+
backgroundColor: grey[800],
53+
},
54+
},
55+
},
4856
},
4957
};
5058

@@ -121,5 +129,12 @@ export const softLightTheme = {
121129
},
122130
},
123131
},
132+
RaToolbar: {
133+
styleOverrides: {
134+
root: {
135+
backgroundColor: grey[300],
136+
},
137+
},
138+
},
124139
},
125140
};

examples/demo/src/themes/themes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@ export const themes: Theme[] = [
7373
{ name: 'nano', light: nanoLightTheme, dark: nanoDarkTheme },
7474
{ name: 'radiant', light: radiantLightTheme, dark: radiantDarkTheme },
7575
{ name: 'house', light: houseLightTheme, dark: houseDarkTheme },
76-
{ name: 'chiptune', light: chiptuneTheme },
76+
{ name: 'chiptune', single: chiptuneTheme },
7777
];

packages/ra-ui-materialui/src/form/Toolbar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ const StyledToolbar = styled(MuiToolbar, {
108108
name: PREFIX,
109109
overridesResolver: (props, styles) => styles.root,
110110
})(({ theme }) => ({
111-
backgroundColor: (theme.vars || theme).palette.divider,
111+
backgroundColor: (theme.vars || theme).palette.background.paper,
112+
backgroundImage: theme.vars != null ? 'var(--Paper-overlay);' : 'none',
112113

113114
[`&.${ToolbarClasses.desktopToolbar}`]: {},
114115

packages/ra-ui-materialui/src/theme/bwTheme.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,13 @@ const createBWTheme = (mode: 'light' | 'dark'): ThemeOptions => {
414414
},
415415
},
416416
},
417+
RaToolbar: {
418+
styleOverrides: {
419+
root: {
420+
backgroundColor: GREY,
421+
},
422+
},
423+
},
417424
},
418425
sidebar: {
419426
width: 195,

packages/ra-ui-materialui/src/theme/defaultTheme.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ThemeOptions } from '@mui/material';
2+
import { grey } from '@mui/material/colors';
23
import { deepmerge } from '@mui/utils';
34

45
const defaultThemeInvariants: ThemeOptions = {
@@ -96,6 +97,13 @@ export const defaultLightTheme: ThemeOptions = deepmerge(
9697
},
9798
},
9899
},
100+
RaToolbar: {
101+
styleOverrides: {
102+
root: {
103+
backgroundColor: grey[300],
104+
},
105+
},
106+
},
99107
},
100108
}
101109
);
@@ -112,6 +120,15 @@ export const defaultDarkTheme: ThemeOptions = deepmerge(
112120
default: '#313131',
113121
},
114122
},
123+
components: {
124+
RaToolbar: {
125+
styleOverrides: {
126+
root: {
127+
backgroundColor: grey[800],
128+
},
129+
},
130+
},
131+
},
115132
}
116133
);
117134

packages/ra-ui-materialui/src/theme/houseTheme.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
PaletteOptions,
77
ThemeOptions,
88
} from '@mui/material';
9+
import { grey } from '@mui/material/colors';
910

1011
/**
1112
* House: A young and joyful theme.
@@ -172,6 +173,16 @@ const componentsOverrides = (theme: Theme): ThemeOptions['components'] => ({
172173
},
173174
},
174175
},
176+
RaToolbar: {
177+
styleOverrides: {
178+
root: {
179+
backgroundColor:
180+
theme.palette.mode === 'dark'
181+
? `color-mix(in oklab, ${theme.palette.background.paper} 80%, white)`
182+
: grey[300],
183+
},
184+
},
185+
},
175186
});
176187

177188
const alert = {

packages/ra-ui-materialui/src/theme/nanoTheme.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
Theme,
55
ThemeOptions,
66
} from '@mui/material';
7+
import { grey } from '@mui/material/colors';
78

89
/**
910
* Nano: A dense theme with minimal chrome, ideal for complex apps.
@@ -326,6 +327,14 @@ const componentsOverrides = (theme: Theme): ThemeOptions['components'] => ({
326327
fullWidth: true,
327328
},
328329
},
330+
RaToolbar: {
331+
styleOverrides: {
332+
root: {
333+
backgroundColor:
334+
theme.palette.mode === 'dark' ? grey[900] : grey[100],
335+
},
336+
},
337+
},
329338
});
330339

331340
const alert = {

packages/ra-ui-materialui/src/theme/radiantTheme.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Theme,
66
ThemeOptions,
77
} from '@mui/material';
8+
import { grey } from '@mui/material/colors';
89

910
/**
1011
* Radiant: A theme emphasizing clarity and ease of use.
@@ -151,6 +152,16 @@ const componentsOverrides = (theme: Theme): ThemeOptions['components'] => {
151152
},
152153
},
153154
},
155+
RaToolbar: {
156+
styleOverrides: {
157+
root: {
158+
backgroundColor:
159+
theme.palette.mode === 'dark'
160+
? `color-mix(in oklab, ${theme.palette.background.paper} 80%, white)`
161+
: grey[300],
162+
},
163+
},
164+
},
154165
};
155166
};
156167

0 commit comments

Comments
 (0)