Skip to content

Commit 79f403d

Browse files
committed
feat: Remove light inverted and dark inverted theme
BREAKING CHANGE: You no longer can select inverted variant for CozyTheme
1 parent 76bb14e commit 79f403d

23 files changed

+150
-553
lines changed

docs/components/DemoProvider.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import React from 'react'
22

3-
import { useCozyTheme } from 'cozy-ui/transpiled/react/providers/CozyTheme'
43
import TranspiledDemoProvider from 'cozy-ui/transpiled/react/providers/DemoProvider'
54

65
// Provider used in readme.md files, because we must
76
// use transpiled files inside readme.
87
const DemoProvider = props => {
9-
const { variant } = useCozyTheme()
10-
11-
return <TranspiledDemoProvider variant={variant} {...props} />
8+
return <TranspiledDemoProvider {...props} />
129
}
1310

1411
export default DemoProvider

docs/components/TableOfContentsRenderer.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const TableOfContents = props => {
2727
busy: false
2828
})
2929
const [themeType, SetThemeType] = useState({
30-
value: localStorage.getItem('ui-theme-type') || deviceThemeType || 'light',
30+
value: localStorage.getItem('ui-theme') || deviceThemeType || 'light',
3131
busy: false
3232
})
3333

@@ -51,7 +51,7 @@ const TableOfContents = props => {
5151
onClick={() => {
5252
const newThemeType = themeType.value === 'light' ? 'dark' : 'light'
5353
SetThemeType({ value: newThemeType, busy: true })
54-
localStorage.setItem('ui-theme-type', newThemeType)
54+
localStorage.setItem('ui-theme', newThemeType)
5555
window.location.reload()
5656
}}
5757
/>

docs/components/Wrapper.jsx

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import React, { useState } from 'react'
22

33
import Divider from '../../react/Divider'
44
import Paper from '../../react/Paper'
5-
import Typography from '../../react/Typography'
65
import Button from '../../react/deprecated/Button' // TODO: should remove deprecated
7-
import isTesting from '../../react/helpers/isTesting'
86
import CozyTheme from '../../react/providers/CozyTheme'
97
import { isUsingDevStyleguidist } from '../../scripts/build-utils'
108

@@ -30,25 +28,16 @@ const styles = {
3028
}
3129

3230
export default ({ children }) => {
33-
const [variant, setVariant] = useState(
34-
localStorage.getItem('ui-theme-variant') || 'normal'
35-
)
3631
const [lang, setLang] = useState(localStorage.getItem('lang') || 'en')
3732

38-
const otherVariant = variant === 'normal' ? 'inverted' : 'normal'
39-
40-
const handleVariantClick = () => {
41-
setVariant(otherVariant)
42-
}
43-
4433
const handleLangClick = () => {
4534
const newLang = lang === 'fr' ? 'en' : 'fr'
4635
setLang(newLang)
4736
localStorage.setItem('lang', newLang)
4837
}
4938
return (
5039
<CozyTheme>
51-
<CozyTheme variant={variant}>
40+
<CozyTheme>
5241
<Paper className="u-pos-relative u-p-1" elevation={0} square>
5342
<Button
5443
size="tiny"
@@ -57,31 +46,14 @@ export default ({ children }) => {
5746
style={styles.buttonLang}
5847
onClick={handleLangClick}
5948
/>
60-
{isTesting() || isUsingDevStyleguidist() ? null : (
61-
<Button
62-
size="tiny"
63-
theme="secondary"
64-
label={variant}
65-
style={styles.button}
66-
onClick={handleVariantClick}
67-
/>
68-
)}
69-
{isUsingDevStyleguidist() && (
70-
<Typography component="div" className="u-db u-mb-1" variant="h5">
71-
Variant: {variant}
72-
</Typography>
73-
)}
7449
{children}
7550
</Paper>
7651
</CozyTheme>
7752
{isUsingDevStyleguidist() && (
7853
<>
7954
<Divider />
80-
<CozyTheme variant={otherVariant}>
55+
<CozyTheme>
8156
<Paper className="u-pos-relative u-p-1" elevation={0} square>
82-
<Typography component="div" className="u-db u-mb-1" variant="h5">
83-
Variant: {otherVariant}
84-
</Typography>
8557
{children}
8658
</Paper>
8759
</CozyTheme>

react/MuiCozyTheme/helpers.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,5 @@ export const getFlagshipCssVar = position =>
210210
* @param {string} variant - Variant of the theme
211211
* @returns {array} Array of Mui shadows
212212
*/
213-
export const makeShadows = (type, variant) =>
214-
[...Array(26)].map((_, index) =>
215-
getCssVariableValue(`shadow${index}`, type, variant)
216-
)
213+
export const makeShadows = type =>
214+
[...Array(26)].map((_, index) => getCssVariableValue(`shadow${index}`, type))

react/MuiCozyTheme/index.jsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@ import React from 'react'
44
import { getTheme } from './theme'
55
import { ThemeProvider } from '../styles'
66

7-
const MuiCozyTheme = ({ type, variant, children }) => {
8-
const theme = getTheme(type, variant)
7+
const MuiCozyTheme = ({ type, children }) => {
8+
const theme = getTheme(type)
99

1010
return <ThemeProvider theme={theme}>{children}</ThemeProvider>
1111
}
1212

1313
MuiCozyTheme.propTypes = {
14-
type: PropTypes.oneOf(['light', 'dark']),
15-
variant: PropTypes.oneOf(['normal', 'inverted'])
14+
type: PropTypes.oneOf(['light', 'dark'])
1615
}
1716

1817
MuiCozyTheme.defaultProps = {
19-
type: 'light',
20-
variant: 'normal'
18+
type: 'light'
2119
}
2220

2321
export default MuiCozyTheme

0 commit comments

Comments
 (0)