joyent-portal/packages/ui-toolkit/src/form/checkbox.js

47 lines
857 B
JavaScript
Raw Normal View History

2017-09-25 16:47:00 +03:00
import styled from 'styled-components';
import React from 'react';
2017-09-25 16:47:00 +03:00
import typography from '../typography';
import BaseInput from './base/input';
import BaseToggle from './base/toggle';
import Baseline from '../baseline';
2017-09-25 16:47:00 +03:00
const Li = styled.li`
list-style-type: none;
display: flex;
align-items: center;
2017-09-25 16:47:00 +03:00
${typography.fontFamily};
${typography.normal};
label {
font-weight: 400;
}
2017-09-25 16:47:00 +03:00
`;
const Ul = styled.ul`
margin: 0;
padding: 0;
`;
const CheckboxItem = BaseInput(({ children, id, ...rest }) => (
<Li {...rest}>{children}</Li>
));
const Checkbox = Baseline(
BaseInput(
BaseToggle({
2017-09-25 16:47:00 +03:00
container: CheckboxItem,
type: 'checkbox'
})
)
);
/**
* @example ./usage-checkbox.md
*/
2017-08-28 22:21:08 +03:00
export default ({ children, ...rest }) => (
<Checkbox {...rest}>{children}</Checkbox>
);
2017-09-25 16:47:00 +03:00
export const CheckboxList = Baseline(Ul);