-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1451 from cozy/cozy-theme-button
- Loading branch information
Showing
12 changed files
with
139 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
@require 'tools/mixins' | ||
|
||
.c-bar-btn { | ||
.BarButton | ||
display flex | ||
align-items center | ||
justify-content center | ||
width rem(48) | ||
height rem(48) | ||
} | ||
|
||
:root | ||
--barIconColor var(--coolGrey) | ||
--barIconColorDisabled var(--silver) | ||
|
||
.BarButtonIcon | ||
color var(--barIconColor) | ||
|
||
.BarButton--disabled | ||
.BarButtonIcon | ||
color var(--barIconColorDisabled) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
An area of a page can have a different CozyTheme and components inside | ||
will be automatically styled. | ||
|
||
- At the moment only some Buttons support this. | ||
|
||
|
||
``` | ||
import CozyTheme from 'cozy-ui/transpiled/react/CozyTheme'; | ||
import { Title, SubTitle } from 'cozy-ui/transpiled/react/Text'; | ||
import Button from 'cozy-ui/transpiled/react/Button'; | ||
import BarButton from 'cozy-ui/transpiled/react/BarButton'; | ||
const props = [{}, { disabled: true}, { busy: true }]; | ||
const themesSupportingContext = [ | ||
'regular', | ||
'secondary' | ||
]; | ||
<CozyTheme variant='inverted' className='u-p-1'> | ||
<Title className='u-white'>Inverted theme</Title> | ||
<SubTitle className='u-white'>Buttons</SubTitle> | ||
{themesSupportingContext.map(theme => | ||
<p key={theme}>{ | ||
props.map( | ||
props => <Button key={theme + JSON.stringify(props)} label={theme} theme={theme} {...props} /> | ||
) | ||
}</p> | ||
)} | ||
<SubTitle className='u-white'>BarButton</SubTitle> | ||
<BarButton icon='dots' /> | ||
</CozyTheme> | ||
``` | ||
|
||
`MuiCozyTheme` is used under the hood so that MaterialUI components are | ||
also styled. | ||
|
||
``` | ||
import MuiButton from '@material-ui/core/Button'; | ||
<div className='u-bg-primaryColor u-p-1'> | ||
<CozyTheme variant='inverted'> | ||
<MuiButton>Default button with Cozy theme</MuiButton> | ||
</CozyTheme> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React, { createContext, useContext } from 'react' | ||
import MuiCozyTheme from '../MuiCozyTheme' | ||
import styles from './styles.styl' | ||
import cx from 'classnames' | ||
|
||
export const CozyThemeContext = createContext() | ||
|
||
const CozyTheme = ({ variant, children, className }) => ( | ||
<CozyThemeContext.Provider value={variant}> | ||
<MuiCozyTheme variant={variant}> | ||
<div className={cx(className, styles[`CozyTheme--${variant}`])}> | ||
{children} | ||
</div> | ||
</MuiCozyTheme> | ||
</CozyThemeContext.Provider> | ||
) | ||
|
||
export const useCozyTheme = () => useContext(CozyThemeContext) | ||
|
||
export default CozyTheme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
$translucentWhite1=rgba(255, 255, 255, 0.24) | ||
$translucentWhite2=rgba(255, 255, 255, 0.88) | ||
|
||
.CozyTheme--inverted | ||
background: var(--primaryColor) | ||
--barIconColor var(--primaryContrastTextColor) | ||
--barIconColorDisabled $translucentWhite2 | ||
|
||
--regularButtonPrimaryColor: var(--primaryContrastTextColor) | ||
--regularButtonSecondaryColor: var(--primaryContrastTextColor) | ||
--regularButtonActiveColor: $translucentWhite2 | ||
--regularButtonConstrastColor: var(--primaryColor) | ||
|
||
--secondaryButtonPrimaryColor: var(--primaryColor) | ||
--secondaryButtonSecondaryColor: var(--white) | ||
--secondaryButtonActiveColor: $translucentWhite1 | ||
--secondaryButtonContrastColor: var(--white) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters