Skip to content

Commit

Permalink
add test and prevent all errors
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed May 14, 2024
1 parent 9b370e8 commit c6f3d6c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 30 deletions.
10 changes: 3 additions & 7 deletions packages/mui-material/src/AppBar/AppBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,9 @@ const AppBarRoot = styled(Paper, {
}),
},
},
...Object.keys((theme.vars ?? theme).palette)
.filter(
(key) =>
(theme.vars ?? theme).palette[key].main &&
(theme.vars ?? theme).palette[key].contrastText,
)
.map((color) => ({
...Object.entries(theme.palette)
.filter(([, palette]) => palette && palette.main && palette.contrastText)
.map(([color]) => ({
props: { color },
style: {
'--AppBar-background': (theme.vars ?? theme).palette[color].main,
Expand Down
10 changes: 3 additions & 7 deletions packages/mui-material/src/Badge/Badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,9 @@ const BadgeBadge = styled('span', {
duration: theme.transitions.duration.enteringScreen,
}),
variants: [
...Object.keys((theme.vars ?? theme).palette)
.filter(
(key) =>
(theme.vars ?? theme).palette[key].main &&
(theme.vars ?? theme).palette[key].contrastText,
)
.map((color) => ({
...Object.entries(theme.palette)
.filter(([, palette]) => palette && palette.main && palette.contrastText)
.map(([color]) => ({
props: { color },
style: {
backgroundColor: (theme.vars || theme).palette[color].main,
Expand Down
18 changes: 9 additions & 9 deletions packages/mui-material/src/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export const SliderRoot = styled('span', {
},
},
variants: [
...Object.keys((theme.vars ?? theme).palette)
.filter((key) => (theme.vars ?? theme).palette[key].main)
.map((color) => ({
...Object.entries(theme.palette)
.filter(([, palette]) => palette && palette.main)
.map(([color]) => ({
props: { color },
style: {
color: (theme.vars || theme).palette[color].main,
Expand Down Expand Up @@ -201,9 +201,9 @@ export const SliderTrack = styled('span', {
display: 'none',
},
},
...Object.keys((theme.vars ?? theme).palette)
.filter((key) => (theme.vars ?? theme).palette[key].main)
.map((color) => ({
...Object.entries(theme.palette)
.filter(([, palette]) => palette && palette.main)
.map(([color]) => ({
props: { color, track: 'inverted' },
style: {
...(theme.vars
Expand Down Expand Up @@ -301,9 +301,9 @@ export const SliderThumb = styled('span', {
transform: 'translate(-50%, 50%)',
},
},
...Object.keys((theme.vars ?? theme).palette)
.filter((key) => (theme.vars ?? theme).palette[key].main)
.map((color) => ({
...Object.entries(theme.palette)
.filter(([, palette]) => palette && palette.main)
.map(([color]) => ({
props: { color },
style: {
[`&:hover, &.${sliderClasses.focusVisible}`]: {
Expand Down
10 changes: 3 additions & 7 deletions packages/mui-material/src/ToggleButton/ToggleButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,9 @@ const ToggleButtonRoot = styled(ButtonBase, {
},
},
},
...Object.keys((theme.vars || theme).palette)
.filter((key) =>
theme.vars
? theme.vars.palette[key].main && theme.vars.palette[key].mainChannel
: theme.palette[key].main,
)
.map((color) => ({
...Object.entries(theme.palette)
.filter(([, palette]) => palette && palette.main)
.map(([color]) => ({
props: { color },
style: {
[`&.${toggleButtonClasses.selected}`]: {
Expand Down
1 change: 1 addition & 0 deletions packages/test-utils/src/describeConformance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,7 @@ function testThemeCustomPalette(element: React.ReactElement, getOptions: () => C
custom: {
main: '#ff5252',
},
unknown: null,
},
});

Expand Down

0 comments on commit c6f3d6c

Please sign in to comment.