Skip to content

Commit bc168f5

Browse files
Merge pull request #72 from commitd/sh-develop
Theme changes
2 parents 3d4c3a8 + b1416d1 commit bc168f5

30 files changed

+1770
-1716
lines changed

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"github.vscode-pull-request-github",
1616
"ms-vsliveshare.vsliveshare",
1717
"eamodio.gitlens",
18-
"streetsidesoftware.code-spell-checker"
18+
"streetsidesoftware.code-spell-checker",
19+
"ryanluker.vscode-coverage-gutters"
1920
],
2021
"postCreateCommand": "yarn install",
2122
"remoteUser": "node"

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "4.1.1",
2+
"version": "4.2.0",
33
"name": "@committed/components",
44
"description": "Committed Component Library",
55
"author": "Committed",
@@ -75,7 +75,6 @@
7575
},
7676
"devDependencies": {
7777
"@babel/core": "^7.12.3",
78-
"@compositor/kit": "^1.0.47",
7978
"@material-ui/core": "^4.11.0",
8079
"@material-ui/icons": "^4.9.1",
8180
"@material-ui/lab": "^4.0.0-alpha.56",

src/components/appbar/AppBar.tsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,27 @@ import { Theme } from '../../theme'
88
export type AppBarProps = MaterialAppBarProps
99

1010
export const AppBar: React.ComponentType<AppBarProps> = styled(MaterialAppBar)(
11-
({ theme }: { theme: Theme }) => ({
12-
'& h1, h2, h3, h4, h5, h6': {
13-
fontSize: theme.fontSizing(1),
14-
fontWeight: theme.typography.fontWeightMedium,
15-
},
16-
})
11+
({ theme, color = 'primary' }: { theme: Theme } & AppBarProps) => {
12+
let colorStyles = {}
13+
if (theme.palette.type === 'dark' && color === 'primary') {
14+
colorStyles = {
15+
backgroundColor: theme.palette.secondary.main,
16+
color: theme.palette.secondary.contrastText,
17+
}
18+
}
19+
if (theme.palette.type === 'dark' && color === 'secondary') {
20+
colorStyles = {
21+
backgroundColor: theme.palette.primary.main,
22+
color: theme.palette.primary.contrastText,
23+
}
24+
}
25+
26+
return {
27+
...colorStyles,
28+
'& h1, h2, h3, h4, h5, h6': {
29+
fontSize: theme.fontSizing(1),
30+
fontWeight: theme.typography.fontWeightMedium,
31+
},
32+
}
33+
}
1734
)

src/components/checkbox/CheckMark.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,24 @@ import { Theme } from '../../theme'
55

66
export type CheckMarkProps = SvgIconProps
77

8-
const useStyles = makeStyles((theme: Theme) => ({
8+
const useStyles = makeStyles(({ palette }: Theme) => ({
99
tick: {
1010
fill: ({ color }: SvgIconProps) => {
1111
let bgcolor = 'transparent'
1212
if (color === 'primary') {
13-
const primaryColor = theme.palette.primary.main
14-
const brandColor = theme.palette.brand.main
15-
bgcolor =
16-
brandColor === primaryColor
17-
? theme.palette.primary.contrastText
18-
: brandColor
13+
if (palette.type === 'dark') {
14+
bgcolor = palette.secondary.main
15+
} else {
16+
const primaryColor = palette.secondary.main
17+
const brandColor = palette.brand.main
18+
bgcolor =
19+
brandColor === primaryColor
20+
? palette.primary.contrastText
21+
: brandColor
22+
}
1923
}
2024
if (color === 'secondary') {
21-
bgcolor = theme.palette.getContrastText(theme.palette.secondary.main)
25+
bgcolor = palette.getContrastText(palette.secondary.main)
2226
}
2327
return bgcolor
2428
},

src/components/textfield/TextField.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import MaterialTextField, {
55
} from '@material-ui/core/TextField'
66
import { makeStyles } from '../../styles'
77

8-
export type CommittedTextFieldProps = Omit<MaterialTextFieldProps, 'variant'>
8+
export type CommittedTextFieldProps = Omit<
9+
MaterialTextFieldProps,
10+
'variant' | 'margin'
11+
>
912
export type TextFieldProps = CommittedTextFieldProps & BoxProps
1013

1114
const useStyles = makeStyles((theme) => {
@@ -93,4 +96,4 @@ const CommittedTextField: React.FC<CommittedTextFieldProps> = React.forwardRef(
9396

9497
export const TextField = withBoxProps<CommittedTextFieldProps>(
9598
CommittedTextField
96-
) as React.ForwardRefExoticComponent<CommittedTextFieldProps>
99+
) as React.ForwardRefExoticComponent<TextFieldProps>

src/theme/commonTheme.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ export const committedOverrides = (
118118
},
119119
textPrimary: {
120120
color: palette.primary.main,
121-
'&:hover': {
122-
backgroundColor: fade(
123-
palette.brand.main,
124-
palette.action.hoverOpacity
125-
),
126-
},
127121
'&$disabled': {},
128122
},
129123
textSecondary: {},

src/theme/darkTheme.ts

Lines changed: 14 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
import { darken, fade, lighten } from '../styles'
21
import { deepmerge } from '@material-ui/utils'
2+
import { fade, lighten } from '../styles'
33
import * as allColors from './colors'
4-
import { addTransparency } from './commonTheme'
5-
import { OverrideOptionsFunction, PaletteColor, PaletteOptions } from './types'
4+
import { OverrideOptionsFunction, PaletteOptions } from './types'
65

76
export type DarkPaletteColors = typeof committedDarkPaletteColors
87

98
export const committedDarkPaletteColors = {
109
...allColors,
11-
brand: allColors.committedGrey,
10+
brand: allColors.committedYellow,
1211
primary: allColors.committedYellow,
13-
secondary: {
14-
'300': allColors.committedGrey[50],
15-
'500': allColors.committedGrey[200],
16-
'700': allColors.committedGrey[400],
17-
},
12+
secondary: allColors.committedGrey,
1813
success: allColors.teal,
1914
warning: allColors.orange,
2015
error: allColors.red,
@@ -59,10 +54,10 @@ export const committedDarkPalette: PaletteOptions = {
5954
contrastText: textColor,
6055
},
6156
primary: {
62-
light: paletteColors.primary[300],
63-
main: paletteColors.primary[500],
64-
dark: paletteColors.primary[700],
65-
contrastText: paletteColors.brand[500],
57+
light: paletteColors.primary[500],
58+
main: paletteColors.primary[700],
59+
dark: paletteColors.primary[900],
60+
contrastText: paletteColors.secondary[500],
6661
},
6762
secondary: {
6863
light: paletteColors.secondary[300],
@@ -91,29 +86,14 @@ export const committedDarkPalette: PaletteOptions = {
9186
},
9287
background: {
9388
default: 'black',
94-
paper: paletteColors.grey[800],
89+
paper: paletteColors.grey[900],
9590
},
9691
text,
9792
grey: paletteColors.grey,
9893
action,
9994
divider: 'rgba(255, 255, 255, 0.8)',
10095
}
10196

102-
// eqiv to color[400]
103-
const mainLight = (color: PaletteColor): string => {
104-
return lighten(color.main, 0.25)
105-
}
106-
107-
// color[200]
108-
const lightLight = (color: PaletteColor): string => {
109-
return lighten(color.light, 0.25)
110-
}
111-
112-
// color[100]
113-
const lightLightVery = (color: PaletteColor): string => {
114-
return lighten(color.light, 0.5)
115-
}
116-
11797
export const committedDarkOverrides: OverrideOptionsFunction = (
11898
defaultOverrides,
11999
helpers
@@ -150,49 +130,18 @@ export const committedDarkOverrides: OverrideOptionsFunction = (
150130
},
151131
},
152132
textSecondary: {
153-
color: palette.secondary.main,
154-
'&:hover': {
155-
backgroundColor: fade(palette.primary.main, action.hoverOpacity),
156-
},
157-
},
158-
outlinedPrimary: {
159-
color: palette.getContrastText(palette.primary.light),
160-
borderColor: palette.getContrastText(palette.primary.light),
161-
backgroundColor: palette.primary.light,
162-
'&:hover': {
163-
backgroundColor: lighten(
164-
lightLight(palette.primary),
165-
action.hoverOpacity
166-
),
167-
borderColor: darken(
168-
palette.getContrastText(palette.primary.light),
169-
0.25
170-
),
171-
},
172-
'&$disabled': {
173-
backgroundColor: addTransparency(mainLight(palette.primary)),
174-
borderColor: addTransparency(palette.secondary.light),
175-
},
133+
color: palette.secondary.light,
176134
},
177135
outlinedSecondary: {
178-
color: palette.primary.dark,
179-
borderColor: palette.primary.dark,
180-
backgroundColor: palette.brand.light,
181-
'&:hover': {
182-
backgroundColor: lightLight(palette.brand),
183-
borderColor: darken(palette.primary.dark, 0.25),
184-
},
185-
'&$disabled': {
186-
backgroundColor: addTransparency(lightLightVery(palette.brand)),
187-
borderColor: addTransparency(palette.primary.main),
188-
},
136+
color: palette.secondary.light,
137+
borderColor: palette.secondary.light,
189138
},
190139
},
191140
MuiCheckbox: {
192141
colorSecondary: {
193-
color: palette.secondary.main,
142+
color: palette.secondary.light,
194143
'&$checked': {
195-
color: palette.secondary.main,
144+
color: palette.secondary.light,
196145
'&:hover': {
197146
backgroundColor: fade(palette.primary.main, action.hoverOpacity),
198147
},

src/theme/lightTheme.ts

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import * as allColors from './colors'
44
import { addTransparency } from './commonTheme'
55
import {
66
OverrideOptionsFunction,
7-
PaletteColor,
87
PaletteOptions,
98
TypeAction,
109
TypeText,
@@ -14,11 +13,7 @@ export const committedLightPaletteColors = {
1413
...allColors,
1514
brand: allColors.committedYellow,
1615
primary: allColors.committedGrey,
17-
secondary: {
18-
'300': allColors.committedYellow[50],
19-
'500': allColors.committedYellow[200],
20-
'700': allColors.committedYellow[400],
21-
},
16+
secondary: allColors.committedYellow,
2217
success: allColors.teal,
2318
warning: allColors.orange,
2419
error: allColors.red,
@@ -104,21 +99,6 @@ export const committedLightPalette: PaletteOptions = {
10499
divider: 'rgba(0, 0, 0, 0.12)',
105100
}
106101

107-
// eqiv to color[400]
108-
const mainLight = (color: PaletteColor): string => {
109-
return lighten(color.main, 0.25)
110-
}
111-
112-
// color[200]
113-
const lightLight = (color: PaletteColor): string => {
114-
return lighten(color.light, 0.25)
115-
}
116-
117-
// color[100]
118-
const lightLightVery = (color: PaletteColor): string => {
119-
return lighten(color.light, 0.5)
120-
}
121-
122102
export const committedLightOverrides: OverrideOptionsFunction = (
123103
defaultOverrides,
124104
helpers
@@ -138,41 +118,16 @@ export const committedLightOverrides: OverrideOptionsFunction = (
138118
},
139119
containedSecondary: {
140120
'&$disabled': {
141-
backgroundColor: addTransparency(lightLight(palette.secondary)),
121+
backgroundColor: addTransparency(
122+
lighten(palette.secondary.light, 0.25)
123+
),
142124
},
143125
},
144126
textSecondary: {
145-
color: palette.brand.dark,
146-
'&:hover': {
147-
backgroundColor: fade(palette.primary.main, action.hoverOpacity),
148-
},
149-
},
150-
outlinedPrimary: {
151-
color: palette.secondary.dark,
152-
backgroundColor: palette.primary.light,
153-
borderColor: palette.primary.main,
154-
'&:hover': {
155-
backgroundColor: darken(palette.primary.main, action.hoverOpacity),
156-
borderColor: palette.primary.main,
157-
},
158-
'&$disabled': {
159-
backgroundColor: addTransparency(mainLight(palette.primary)),
160-
borderColor: addTransparency(palette.secondary.main),
161-
},
127+
color: darken(palette.secondary.dark, 0.2),
162128
},
163129
outlinedSecondary: {
164-
color: palette.primary.dark,
165-
borderColor: palette.primary.main,
166-
backgroundColor: lightLightVery(palette.brand),
167-
'&:hover': {
168-
backgroundColor: lightLight(palette.brand),
169-
borderColor: palette.primary.main,
170-
},
171-
'&$disabled': {
172-
color: addTransparency(palette.primary.dark),
173-
backgroundColor: addTransparency(lightLightVery(palette.brand)),
174-
borderColor: addTransparency(palette.primary.main),
175-
},
130+
color: darken(palette.secondary.dark, 0.2),
176131
},
177132
},
178133
MuiCheckbox: {

stories/colour.stories.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ The main light theme colours. They can be referred to in palette based props usi
1212
We use the brand colour for accents and highlights, not as the primary colour.
1313

1414
<ThemeProvider choice="light">
15-
<Flex flexWrap="wrap">
15+
<Flex p={3} bgcolor="background.default" flexWrap="wrap">
1616
<Palette key="brand" name="brand" width={1} />
1717
<Palette key="primary" name="primary" />
1818
<Palette key="secondary" name="secondary" />
1919
<Palette key="error" name="error" />
2020
<Palette key="warning" name="warning" />
2121
<Palette key="success" name="success" />
2222
<Palette key="info" name="info" />
23+
<Surfaces />
2324
</Flex>
24-
<Surfaces />
2525
</ThemeProvider>
2626

2727
## Main Dark
@@ -30,16 +30,16 @@ The main dark theme colours. They can be referred to in palette based props usin
3030
We use the brand colour for accents and highlights, not as the primary colour.
3131

3232
<ThemeProvider choice="dark">
33-
<Flex flexWrap="wrap">
33+
<Flex p={3} bgcolor="background.default" flexWrap="wrap">
3434
<Palette key="brand" name="brand" width={1} />
3535
<Palette key="primary" name="primary" />
3636
<Palette key="secondary" name="secondary" />
3737
<Palette key="error" name="error" />
3838
<Palette key="warning" name="warning" />
3939
<Palette key="success" name="success" />
4040
<Palette key="info" name="info" />
41+
<Surfaces />
4142
</Flex>
42-
<Surfaces />
4343
</ThemeProvider>
4444

4545
## Colours

0 commit comments

Comments
 (0)