Skip to content

Commit

Permalink
fix: shape and color theme inconsistency
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed Jul 27, 2022
1 parent f8dd729 commit 2701476
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/widget-embedded/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ body {
-moz-osx-font-smoothing: grayscale;
}

a, a:hover {
color: red;
}

@media (prefers-color-scheme: dark) {
body {
background-color: #000;
Expand Down
24 changes: 21 additions & 3 deletions packages/widget/src/config/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import {
alpha,
createTheme as createMuiTheme,
darken,
getContrastRatio,
lighten,
} from '@mui/material/styles';
import { dark, light } from '@mui/material/styles/createPalette';
import { ThemeConfig } from '../types';

// https://mui.com/customization/palette/
Expand Down Expand Up @@ -68,6 +70,11 @@ const palette = {
},
};

const shape = {
borderRadius: 12,
borderRadiusSecondary: 6,
};

export const createTheme = (mode: PaletteMode, theme: ThemeConfig = {}) =>
createMuiTheme({
typography: {
Expand Down Expand Up @@ -130,8 +137,7 @@ export const createTheme = (mode: PaletteMode, theme: ThemeConfig = {}) =>
}),
},
shape: {
borderRadius: 12,
borderRadiusSecondary: 6,
...shape,
...theme.shape,
},
breakpoints: {
Expand Down Expand Up @@ -181,7 +187,8 @@ export const createTheme = (mode: PaletteMode, theme: ThemeConfig = {}) =>
}
: {}),
root: {
borderRadius: theme.shape?.borderRadiusSecondary,
borderRadius:
theme.shape?.borderRadiusSecondary ?? shape.borderRadiusSecondary,
textTransform: 'none',
fontSize: '1rem',
padding: '10px 16px',
Expand All @@ -197,12 +204,23 @@ export const createTheme = (mode: PaletteMode, theme: ThemeConfig = {}) =>
pointerEvents: 'auto',
},
},
contained: {
'&:hover': {
color:
getContrastRatio(palette.primary.main, dark.text.primary) >= 3
? dark.text.primary
: light.text.primary,
},
},
},
},
MuiIconButton: {
styleOverrides: {
root: {
color: 'inherit',
'&:hover': {
color: 'inherit',
},
},
},
},
Expand Down

0 comments on commit 2701476

Please sign in to comment.