1
0
mirror of https://github.com/yldio/copilot.git synced 2024-09-21 22:03:54 +03:00

Update Button and Checkbox

This commit is contained in:
Tom Gallacher 2016-12-08 12:41:37 +00:00 committed by Sérgio Ramos
parent 0f6169ca5d
commit 8f675e7911
5 changed files with 89 additions and 30 deletions

View File

@ -19,39 +19,40 @@ const {
// TODO: this should come from constants // TODO: this should come from constants
// and be calculated accordingly // and be calculated accordingly
const colors = { const styles = {
primaryBackground: colors.brandPrimary; primaryBackground: colors.brandPrimary,
primaryBorder: '#2532BB'; primaryBorder: '#2532BB',
primaryColor: '#FFFFFF'; primaryColor: '#FFFFFF',
secondaryBackgroud: '#FFFFFF'; secondaryBackgroud: '#FFFFFF',
secondaryBorder: '#D8D8D8'; secondaryBorder: '#D8D8D8',
secondaryColor: '#646464'; secondaryColor: '#646464',
inactiveBackground: '#F9F9F9'; inactiveBackground: '#F9F9F9',
inactiveBorder: '#D8D8D8'; inactiveBorder: '#D8D8D8',
inactiveColor: '#737373'; inactiveColor: '#737373',
...colors
}; };
const background = match({ const background = match({
secondary: colors.secondaryBackgroud, secondary: styles.secondaryBackgroud,
inactive: colors.inactiveBackground inactive: styles.inactiveBackground
}, colors.primaryBackground); }, styles.primaryBackground);
const border = match({ const border = match({
secondary: colors.secondaryBorder, secondary: styles.secondaryBorder,
inactive: colors.inactiveBorder inactive: styles.inactiveBorder
}, colors.primaryBorder); }, styles.primaryBorder);
const color = match({ const color = match({
secondary: colors.secondaryColor, secondary: styles.secondaryColor,
inactive: colors.inactiveColor inactive: styles.inactiveColor
}, colors.primaryColor); }, styles.primaryColor);
module.exports = styled.button` module.exports = styled.button`
border-radius: ${remcalc(boxes.borderRadius)}; border-radius: ${remcalc(boxes.borderRadius)};
box-shadow: ${boxes.bottomShaddow}; box-shadow: ${boxes.bottomShaddow};
font-size: ${remcalc(16)}; font-size: ${remcalc(16)};
min-width: ${remcalc(120)}; min-width: ${remcalc(120)};
padding: ${remcalc(18 24)}; padding: ${remcalc('18 24')};
background: ${background}; background: ${background};
border: 1px solid ${border}; border: 1px solid ${border};

View File

@ -1,6 +1,34 @@
const classNames = require('classnames'); const classNames = require('classnames');
const React = require('react'); const React = require('react');
const styles = require('./style.css'); const constants = require('../../shared/constants');
const fns = require('../../shared/functions');
const match = require('../../shared/match');
const Styled = require('styled-components');
const {
colors,
boxes
} = constants;
const {
remcalc
} = fns;
const {
default: styled,
css
} = Styled;
const styles = {
...colors
};
const StyledInput = styled.input`
`;
const StyledLabel = styled.label`
color: #646464;
`;
const Checkbox = ({ const Checkbox = ({
checked = false, checked = false,
@ -25,8 +53,8 @@ const Checkbox = ({
); );
return ( return (
<label className={styles.label} htmlFor={id}> <StyledLabel className={styles.label} htmlFor={id}>
<input <StyledInput
checked={checked} checked={checked}
className={cn} className={cn}
disabled={disabled} disabled={disabled}
@ -36,13 +64,12 @@ const Checkbox = ({
onChange={onChange} onChange={onChange}
readOnly={readOnly} readOnly={readOnly}
required={required} required={required}
selectionDirection={selectionDirection}
style={style} style={style}
tabIndex={tabIndex} tabIndex={tabIndex}
type='checkbox' type='checkbox'
/> />
<span>{children}</span> <span>{children}</span>
</label> </StyledLabel>
); );
}; };

View File

@ -1,3 +0,0 @@
.label {
color: #646464;
}

View File

@ -1,9 +1,9 @@
module.exports = { module.exports = {
Avatar: require('./components/avatar'), Avatar: require('./components/avatar'),
Base: require('./components/base'), Base: require('./components/base'),
// Button: require('./components/button'), Button: require('./components/button'),
// ButtonIcon: require('./components/button-icon'), // ButtonIcon: require('./components/button-icon'),
// Checkbox: require('./components/checkbox'), Checkbox: require('./components/checkbox'),
Column: require('./components/column'), Column: require('./components/column'),
Container: require('./components/container'), Container: require('./components/container'),
Row: require('./components/row'), Row: require('./components/row'),

View File

@ -7,7 +7,9 @@ const {
const { const {
Base, Base,
Button,
Container, Container,
Checkbox,
Row, Row,
Column, Column,
Avatar Avatar
@ -91,3 +93,35 @@ storiesOf('Avatar', module)
/> />
</Base> </Base>
)); ));
storiesOf('Button', module)
.add('With text', () => (
<Button>
Inspire the lazy
</Button>
)).add('Secondary', () => (
<Button secondary>
Inspire the brave
</Button>
)).add('Disabled', () => (
<Button disabled>
Inspire the liars
</Button>
));
storiesOf('Checkbox', module)
.add('Default', () => (
<Checkbox>
Checkbox
</Checkbox>
))
.add('Checked', () => (
<Checkbox checked onChange={function noop() {}}>
Checkbox Checked
</Checkbox>
))
.add('Disabled', () => (
<Checkbox disabled>
Checkbox Disabled
</Checkbox>
));