Skip to content

Commit

Permalink
create new object everytime
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Jun 7, 2022
1 parent dae84e7 commit 37fd682
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions packages/mui-material/src/styles/createPalette.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import blue from '../colors/blue';
import lightBlue from '../colors/lightBlue';
import green from '../colors/green';

export const light = {
const getLightTokens = () => ({
// The colors used to style the text.
text: {
// The most important text.
Expand Down Expand Up @@ -47,9 +47,11 @@ export const light = {
focusOpacity: 0.12,
activatedOpacity: 0.12,
},
};
});

export const dark = {
export const light = getLightTokens();

const getDarkTokens = () => ({
text: {
primary: common.white,
secondary: 'rgba(255, 255, 255, 0.7)',
Expand All @@ -74,7 +76,9 @@ export const dark = {
focusOpacity: 0.12,
activatedOpacity: 0.24,
},
};
});

export const dark = getDarkTokens();

function addLightOrDark(intent, direction, shade, tonalOffset) {
const tonalOffsetLight = tonalOffset.light || tonalOffset;
Expand Down Expand Up @@ -261,7 +265,7 @@ export default function createPalette(palette) {
return color;
};

const modes = { dark, light };
const modes = { dark: getDarkTokens(), light: getLightTokens() };

if (process.env.NODE_ENV !== 'production') {
if (!modes[mode]) {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/styles/createPalette.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('createPalette()', () => {
expect(palette.secondary.main, 'should use purple as the default secondary color').to.equal(
purple[200],
);
expect(palette.text, 'should use dark theme text').to.equal(dark.text);
expect(palette.text, 'should use dark theme text').to.deep.equal(dark.text);
});

describe('augmentColor', () => {
Expand Down

0 comments on commit 37fd682

Please sign in to comment.