Skip to content

Commit

Permalink
fix(css): Avoid importing palette.styl and utils.styl in each css of
Browse files Browse the repository at this point in the history
legacy component. Prefer to import palette.styl in utils.styl to avoid
duplication, and to use not hashed css.
  • Loading branch information
JF-Cozy committed Jun 19, 2023
1 parent ee6553a commit 311644b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 24 deletions.
12 changes: 5 additions & 7 deletions react/CozyTheme/index.jsx
Expand Up @@ -2,19 +2,17 @@ import React, { createContext, useContext } from 'react'
import cx from 'classnames'

import MuiCozyTheme from '../MuiCozyTheme'
import themesStyles from '../../stylus/settings/palette.styl'

export const CozyThemeContext = createContext()

const allStyles = {
'CozyTheme--normal': themesStyles['CozyTheme--normal'],
'CozyTheme--inverted': themesStyles['CozyTheme--inverted']
}

const CozyTheme = ({ variant, children, className }) => (
<CozyThemeContext.Provider value={variant}>
<MuiCozyTheme variant={variant}>
<div className={cx(className, allStyles[`CozyTheme--${variant}`])}>
<div
className={cx(className, {
[`CozyTheme--${variant}`]: Boolean(variant)
})}
>
{children}
</div>
</MuiCozyTheme>
Expand Down
6 changes: 1 addition & 5 deletions react/Dialog/index.jsx
Expand Up @@ -2,7 +2,6 @@ import React from 'react'
import { RemoveScroll } from 'react-remove-scroll'
import { default as MUIDialog } from '@material-ui/core/Dialog'

import themesStyles from '../../stylus/settings/palette.styl'
import useBreakpoints from '../hooks/useBreakpoints'
import { useCozyTheme } from '../CozyTheme'
import { useDialogEffects } from './DialogEffects'
Expand All @@ -29,10 +28,7 @@ const Dialog = props => {

return (
<Wrapper>
<MUIDialog
className={themesStyles[`CozyTheme--${cozyTheme}`]}
{...props}
/>
<MUIDialog className={`CozyTheme--${cozyTheme}`} {...props} />
</Wrapper>
)
}
Expand Down
14 changes: 7 additions & 7 deletions react/SquareAppIcon/__snapshots__/SquareAppIcon.spec.js.snap
Expand Up @@ -6,7 +6,7 @@ exports[`SquareAppIcon component should render an app correctly with the app nam
data-testid="square-app-icon"
>
<div
class="palette__CozyTheme--normal___3UmMb"
class="CozyTheme--normal"
>
<span
class="MuiBadge-root-40"
Expand Down Expand Up @@ -55,7 +55,7 @@ exports[`SquareAppIcon component should render an app correctly with the given n
data-testid="square-app-icon"
>
<div
class="palette__CozyTheme--normal___3UmMb"
class="CozyTheme--normal"
>
<span
class="MuiBadge-root-9"
Expand Down Expand Up @@ -104,7 +104,7 @@ exports[`SquareAppIcon component should render an app with the app slug if no na
data-testid="square-app-icon"
>
<div
class="palette__CozyTheme--normal___3UmMb"
class="CozyTheme--normal"
>
<span
class="MuiBadge-root-71"
Expand Down Expand Up @@ -207,7 +207,7 @@ exports[`SquareAppIcon component should render correctly an app in error state 1
data-testid="square-app-icon"
>
<div
class="palette__CozyTheme--normal___3UmMb"
class="CozyTheme--normal"
>
<span
class="MuiBadge-root-164"
Expand Down Expand Up @@ -317,7 +317,7 @@ exports[`SquareAppIcon component should render correctly an app in maintenance s
data-testid="square-app-icon"
>
<div
class="palette__CozyTheme--normal___3UmMb"
class="CozyTheme--normal"
>
<span
class="MuiBadge-root-102"
Expand Down Expand Up @@ -366,7 +366,7 @@ exports[`SquareAppIcon component should render correctly an app in shortcut stat
data-testid="square-app-icon"
>
<div
class="palette__CozyTheme--normal___3UmMb"
class="CozyTheme--normal"
>
<span
class="MuiBadge-root-226"
Expand Down Expand Up @@ -415,7 +415,7 @@ exports[`SquareAppIcon component should render correctly an app with custom cont
data-testid="square-app-icon"
>
<div
class="palette__CozyTheme--normal___3UmMb"
class="CozyTheme--normal"
>
<span
class="MuiBadge-root-318"
Expand Down
5 changes: 0 additions & 5 deletions react/utilities.js

This file was deleted.

1 change: 1 addition & 0 deletions stylus/cozy-ui/utils.styl
Expand Up @@ -2,3 +2,4 @@
CSS utility classes only
\*------------------------------------*/
@require '../utilities/*'
@require '../settings/palette.styl'

0 comments on commit 311644b

Please sign in to comment.