diff --git a/ui/src/components/widget/index.js b/ui/src/components/widget/index.js index a24af2c0..20e8b06d 100644 --- a/ui/src/components/widget/index.js +++ b/ui/src/components/widget/index.js @@ -1,6 +1,44 @@ -const classNames = require('classnames'); const React = require('react'); -const styles = require('./style.css'); +const constants = require('../../shared/constants'); +const Styled = require('styled-components'); + +const { + boxes +} = constants; + +const { + default: styled, +} = Styled; + +const StyledInput = styled.input` + display: none; + visibility: hidden; + + &:checked { + & ~ .content { + border: ${boxes.border.checked}; + } + } + + &:disabled { + & ~ .content { + cursor: not-allowed; + filter: grayscale(80%); + opacity: 0.4; + } + } +`; + +const StyledContent = styled.div` + border: ${boxes.border.unchecked}; + border-radius: 4px; + cursor: pointer; + padding: remcalc(36); + + & img { + max-width: 100%; + } +`; const Widget = ({ checked = false, @@ -12,28 +50,21 @@ const Widget = ({ style, value = name }) => { - - const cn = classNames( - className, - styles.widget - ); - const type = selectable === 'single' ? 'radio' : 'checkbox'; return ( - ); }; diff --git a/ui/src/components/widget/style.css b/ui/src/components/widget/style.css deleted file mode 100644 index 1f48c1f0..00000000 --- a/ui/src/components/widget/style.css +++ /dev/null @@ -1,36 +0,0 @@ -~boxes: "../../shared/constants.js"; - -:root { - --border-checked: ~boxes.border.checked; - --border-unchecked: ~boxes.border.unchecked; -} - -.content { - border: var(--border-unchecked); - border-radius: 4px; - cursor: pointer; - padding: remcalc(36); - - & img { - max-width: 100%; - } -} - -.input { - display: none; - visibility: hidden; - - &:checked { - & ~ .content { - border: var(--border-checked); - } - } - - &:disabled { - & ~ .content { - cursor: not-allowed; - filter: grayscale(80%); - opacity: 0.4; - } - } -} diff --git a/ui/src/index.js b/ui/src/index.js index f822d1d2..0066cece 100644 --- a/ui/src/index.js +++ b/ui/src/index.js @@ -17,7 +17,7 @@ module.exports = { // Radio: require('./components/radio'), // RadioGroup: require('./components/radio-group'), // Select: require('./components/select'), - // Widget: require('./components/widget'), + Widget: require('./components/widget'), // Pagination: require('./components/pagination'), // Modal: require('./components/modal') }; diff --git a/ui/stories/index.js b/ui/stories/index.js index 12b4d2e0..9488ec3f 100644 --- a/ui/stories/index.js +++ b/ui/stories/index.js @@ -12,7 +12,8 @@ const { Checkbox, Row, Column, - Avatar + Avatar, + Widget } = require('../src/'); const styles = { @@ -123,3 +124,11 @@ storiesOf('Checkbox', module) .add('Disabled', () => ( )); + +storiesOf('Widget', module) + .add('single', () => ( + + +

Some text

+
+ ))