From 95f01e88543ea92dc727ae2a61fd64906d9998db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Ramos?= Date: Fri, 9 Dec 2016 15:34:10 +0000 Subject: [PATCH] convert select --- ui/src/components/select/index.js | 53 ++++++++++++++++++++++------- ui/src/components/select/style.css | 28 --------------- ui/src/components/tabs/tab/index.js | 3 +- ui/src/index.js | 2 +- ui/stories/index.js | 40 +++++++++++++++++++--- 5 files changed, 77 insertions(+), 49 deletions(-) delete mode 100644 ui/src/components/select/style.css diff --git a/ui/src/components/select/index.js b/ui/src/components/select/index.js index 2942df65..abe8b35a 100644 --- a/ui/src/components/select/index.js +++ b/ui/src/components/select/index.js @@ -1,6 +1,37 @@ -const classNames = require('classnames'); +const fns = require('../../shared/functions'); const React = require('react'); -const styles = require('./style.css'); +const Styled = require('styled-components'); + +const { + rndId +} = fns; + +const { + default: styled +} = Styled; + +// TODO: this should be a constant +const StyledLabel = styled.div` + color: #464646; +`; + +const StyledSelect = styled.select` + color: #464646; + + /* select[multiple] is valid CSS syntax - not added to lint library yet */ + /* stylelint-disable */ + &[multiple] { + /* stylelint-enable */ + padding-left: 0; + padding-right: 0; + + & :global option { + padding-left: 15px; + padding-right: 15px; + width: 100%; + } + } +`; const Select = ({ autoFocus, @@ -8,24 +39,20 @@ const Select = ({ className, disabled, form, - id, + id = rndId(), label, multiple, name, required, selected }) => { - const cn = classNames( - className, - styles['select-group'] - ); - return ( -
- - +
); }; diff --git a/ui/src/components/select/style.css b/ui/src/components/select/style.css deleted file mode 100644 index c7e6ec6f..00000000 --- a/ui/src/components/select/style.css +++ /dev/null @@ -1,28 +0,0 @@ -.select { - composes: input from "../input/style.css"; - - /* select[multiple] is valid CSS syntax - not added to lint library yet */ - /* stylelint-disable */ - &[multiple] { - /* stylelint-enable */ - padding-left: 0; - padding-right: 0; - - & :global option { - padding-left: 15px; - padding-right: 15px; - width: 100%; - } - - /* this doesn't seem to work, research further - &:-internal-list-box :global option:checked, - & :global option:checked { - background-color: white; - } - */ - } -} - -.label { - composes: label from "../input/style.css"; -} diff --git a/ui/src/components/tabs/tab/index.js b/ui/src/components/tabs/tab/index.js index 15df2714..cd464b83 100644 --- a/ui/src/components/tabs/tab/index.js +++ b/ui/src/components/tabs/tab/index.js @@ -10,8 +10,7 @@ const { } = composers; const { - boxes, - colors + boxes } = constants; const { diff --git a/ui/src/index.js b/ui/src/index.js index a42b0e55..3a6bb750 100644 --- a/ui/src/index.js +++ b/ui/src/index.js @@ -16,7 +16,7 @@ module.exports = { // RangeSlider: require('./components/range-slider'), Radio: require('./components/radio'), // RadioGroup: require('./components/radio-group'), - // Select: require('./components/select'), + Select: require('./components/select'), 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 7d9abc87..3d15e09f 100644 --- a/ui/stories/index.js +++ b/ui/stories/index.js @@ -13,6 +13,7 @@ const { Row, Column, Avatar, + Select, Tabs, Tab, Toggle, @@ -142,6 +143,26 @@ storiesOf('Radio', module) )); +storiesOf('Select', module) + .add('Default', () => ( + + )) + .add('multiple', () => ( + + )); + storiesOf('Tabs', module) .add('Default', () => ( @@ -152,7 +173,7 @@ storiesOf('Tabs', module)

User

- )) + )); storiesOf('Toggle', module) .add('checked', () => ( @@ -166,12 +187,21 @@ storiesOf('Toggle', module) )) .add('no props', () => ( - )) + )); storiesOf('Widget', module) .add('single', () => ( - - + + england flag

Some text

- )) + ));