Skip to content

Commit

Permalink
Merge pull request #1727 from cozy/buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
ptbrowne authored Feb 1, 2021
2 parents ac68d82 + a06724a commit 4661fd1
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 18 deletions.
10 changes: 9 additions & 1 deletion react/Field/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ import Field from 'cozy-ui/transpiled/react/Field';
import MuiButton from 'cozy-ui/transpiled/react/MuiCozyTheme/Buttons';
<form>
<br/>
<Field
label="I'm a label"
labelProps={{
Expand All @@ -255,7 +256,14 @@ import MuiButton from 'cozy-ui/transpiled/react/MuiCozyTheme/Buttons';
}}
type="password"
secondaryComponent={({visible}) => {
return <MuiButton size='small' color='secondary'>{visible ? 'Hide' : 'Show' }</MuiButton>
return (
/* Need to cancel the paddingTop of the button */
<div style={{ marginTop: '-0.5rem'}}>
<MuiButton size='small' color='secondary'>
{visible ? 'Hide' : 'Show' }
</MuiButton>
</div>
)
}}
/>
</form>
Expand Down
84 changes: 73 additions & 11 deletions react/MuiCozyTheme/Buttons/Readme.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,83 @@
```
import Button from 'cozy-ui/transpiled/react/MuiCozyTheme/Buttons';
import Typography from 'cozy-ui/transpiled/react/Typography';
import Icon from 'cozy-ui/transpiled/react/Icon'
import Stack from 'cozy-ui/transpiled/react/Stack'
import WrenchCircleIcon from 'cozy-ui/transpiled/react/Icons/WrenchCircle'
const ButtonsVariant = ({variant}) => {
const ButtonsVariant = ({variant, size }) => {
return (
<div>
<Button variant={variant} className='u-m-1'>Default</Button>
<Button variant={variant} color="primary" className='u-m-1'>Primary</Button>
<Button variant={variant} color="secondary" className='u-m-1'>Secondary</Button>
<Button variant={variant} disabled className='u-m-1'>Disabled</Button>
<Button variant={variant} href="#text-buttons" className='u-m-1'>Link</Button>
<input accept="image/*" className='u-hide' id="flat-button-file" multiple type="file" />
<label htmlFor="flat-button-file">
<Button variant={variant} component="span" className='u-m-1'>Upload</Button>
</label>
<Button variant={variant} size={size}>
<Icon icon={WrenchCircleIcon} className='u-mr-half' />
Default
</Button>
<Button variant={variant} size={size} color="primary" className='u-ml-half'>
<Icon icon={WrenchCircleIcon} className='u-mr-half' />
Primary
</Button>
<Button variant={variant} size={size} color="secondary" className='u-ml-half'>Secondary</Button>
<Button variant={variant} size={size} disabled className='u-ml-half'>Disabled</Button>
<Button variant={variant} size={size} href="#text-buttons" className='u-ml-half'>Link</Button>
</div>
)
}
<>Text Buttons:<ButtonsVariant />Outlined Buttons:<ButtonsVariant variant='outlined' />Contained Buttons:<ButtonsVariant variant='contained' /></>
const StateRadio = ({ name, ...props }) => {
return <input
type='radio'
name={name}
checked={state[name] == props.value}
onChange={() => setState({ [name]: props.value })}
{...props}
/>
}
const Example = ({ size, className }) => {
return (
<Stack spacing='s'>
<div>
<Typography variant='subtitle1' gutterBottom>Text Buttons</Typography>
<ButtonsVariant size={size} />
</div>
<div>
<Typography variant='subtitle1' gutterBottom>Outlined Buttons</Typography>
<ButtonsVariant variant='outlined' size={size}/>
</div>
<div>
<Typography variant='subtitle1' gutterBottom>Contained buttons</Typography>
<ButtonsVariant variant='contained' size={size} />
</div>
</Stack>
)
}
initialState = {
size: 'medium'
};
<>
{true || isTesting()
?
<Stack spacing='l'>
{['small', 'medium', 'large'].map(size => (
<Stack spacing='xs'>
<Typography variant='h3'>{ size }</Typography>
<Example size={size} />
</Stack>
))}
</Stack> :
<Stack spacing='m'>
<div>
<StateRadio value='small' name='size' /> small{' '}
<StateRadio value='medium' name='size' /> medium{' '}
<StateRadio value='large' name='size' /> large
</div>
<div>
<Example size={state.size} />
</div>
</Stack>
}
</>
```
14 changes: 12 additions & 2 deletions react/MuiCozyTheme/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,25 @@ const makeOverrides = theme => ({
}
},
MuiButton: {
root: {
height: '2.5rem',
padding: '0px 1rem'
},
sizeSmall: {
height: '2rem',
padding: '0px 0.75rem'
},
sizeLarge: {
padding: '0px 1.25rem',
height: '3rem'
},
outlined: {
borderRadius: 2,
height: 40,
minWidth: 112
},
contained: {
borderRadius: 2,
boxShadow: 0,
height: 40,
minWidth: 112
},
containedSecondary: {
Expand Down
3 changes: 1 addition & 2 deletions react/UploadQueue/styles.styl
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ progress.upload-queue-progress
.upload-queue-header
background 0
text-transform uppercase
padding-left 0
padding-right 0
padding 0

.upload-queue-content
display none
Expand Down
6 changes: 4 additions & 2 deletions react/__snapshots__/examples.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2329,10 +2329,12 @@ exports[`Field should render examples: Field 13`] = `

exports[`Field should render examples: Field 14`] = `
"<div>
<form>
<form><br>
<div class=\\"styles__o-field___3n5HM\\"><label for=\\"\\" class=\\"styles__c-label___o4ozG styles__c-label--block___2ZV_7\\" style=\\"color: teal;\\">I'm a label</label>
<div class=\\"styles__o-field-input___vCqdV\\">
<div class=\\"styles__o-field-input-action___2k7a8\\"><button class=\\"MuiButtonBase-root-88 MuiButton-root-161 MuiButton-text-163 MuiButton-textSecondary-165 MuiButton-flat-166 MuiButton-flatSecondary-168 MuiButton-sizeSmall-184\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiButton-label-162\\">Show</span><span class=\\"MuiTouchRipple-root-100\\"></span></button></div><input type=\\"password\\" id=\\"\\" class=\\"styles__c-input-text___3TAv1 styles__c-input-text--large___28EaR\\" placeholder=\\"\\" style=\\"border-color: teal;\\" value=\\"\\">
<div class=\\"styles__o-field-input-action___2k7a8\\">
<div style=\\"margin-top: -0.5rem;\\"><button class=\\"MuiButtonBase-root-88 MuiButton-root-161 MuiButton-text-163 MuiButton-textSecondary-165 MuiButton-flat-166 MuiButton-flatSecondary-168 MuiButton-sizeSmall-184\\" tabindex=\\"0\\" type=\\"button\\"><span class=\\"MuiButton-label-162\\">Show</span><span class=\\"MuiTouchRipple-root-100\\"></span></button></div>
</div><input type=\\"password\\" id=\\"\\" class=\\"styles__c-input-text___3TAv1 styles__c-input-text--large___28EaR\\" placeholder=\\"\\" style=\\"border-color: teal;\\" value=\\"\\">
</div>
</div>
</form>
Expand Down

0 comments on commit 4661fd1

Please sign in to comment.