From 7b73e822379772fc4a85d3c12b7a28fafe8c0a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Ramos?= Date: Mon, 9 Jan 2017 18:58:30 +0000 Subject: [PATCH] headed list item ui component --- ui/src/components/list/collapsed.js | 18 -------- ui/src/components/list/description.js | 4 +- ui/src/components/list/header.js | 55 ++++++++++++++++++++++ ui/src/components/list/index.js | 11 +++-- ui/src/components/list/item.js | 20 ++++++-- ui/src/components/list/meta.js | 39 ++++++++++------ ui/src/components/list/options.js | 26 ++++++++--- ui/src/components/list/outlet.js | 38 ++++++++------- ui/src/components/list/subtitle.js | 18 ++++++-- ui/src/components/list/title.js | 6 ++- ui/src/components/list/transfer-props.js | 29 ++++++++++++ ui/src/components/list/view.js | 23 ++++++++- ui/src/shared/constants/boxes.js | 1 + ui/stories/index.js | 59 ++++++++++++++++++++++-- 14 files changed, 272 insertions(+), 75 deletions(-) delete mode 100644 ui/src/components/list/collapsed.js create mode 100644 ui/src/components/list/header.js create mode 100644 ui/src/components/list/transfer-props.js diff --git a/ui/src/components/list/collapsed.js b/ui/src/components/list/collapsed.js deleted file mode 100644 index c5824212..00000000 --- a/ui/src/components/list/collapsed.js +++ /dev/null @@ -1,18 +0,0 @@ -const React = require('react'); - -module.exports = (Component) => (props) => { - // eslint-disable-next-line react/prop-types - const _children = React.Children.map(props.children, (c) => { - return React.cloneElement(c, { - ...c.props, - // eslint-disable-next-line react/prop-types - collapsed: props.collapsed - }); - }); - - return ( - - {_children} - - ); -}; diff --git a/ui/src/components/list/description.js b/ui/src/components/list/description.js index 35ba6cf8..80240ff2 100644 --- a/ui/src/components/list/description.js +++ b/ui/src/components/list/description.js @@ -1,6 +1,6 @@ -const Title = require('./title'); -const Styled = require('styled-components'); const React = require('react'); +const Styled = require('styled-components'); +const Title = require('./title'); const { default: styled diff --git a/ui/src/components/list/header.js b/ui/src/components/list/header.js new file mode 100644 index 00000000..3d022475 --- /dev/null +++ b/ui/src/components/list/header.js @@ -0,0 +1,55 @@ +const constants = require('../../shared/constants'); +const fns = require('../../shared/functions'); +const Item = require('./item'); +const React = require('react'); +const Styled = require('styled-components'); + +const { + colors +} = constants; + +const { + remcalc +} = fns; + +const { + default: styled +} = Styled; + +const StyledItem = styled(Item)` + position: absolute; + + background-color: ${colors.brandPrimary}; + border: solid 1px ${colors.borderPrimary}; + box-shadow: none; + + width: calc(100% + ${remcalc(2)}); + margin: 0; + + top: ${remcalc(-1)}; + left: ${remcalc(-1)}; + right: ${remcalc(-1)}; +`; + +const addFromHeader = (children) => React.Children.map(children, (c) => { + return React.cloneElement(c, { + ...c.props, + fromHeader: true + }); +}); + +const Header = (props) => ( + + {addFromHeader(props.children)} + +); + +Header.propTypes = { + children: React.PropTypes.node +}; + +module.exports = Header; diff --git a/ui/src/components/list/index.js b/ui/src/components/list/index.js index 0d79549b..cfb4ab13 100644 --- a/ui/src/components/list/index.js +++ b/ui/src/components/list/index.js @@ -1,10 +1,11 @@ module.exports = { - ListItem: require('./item'), - ListItemView: require('./view'), - ListItemTitle: require('./title'), - ListItemSubTitle: require('./subtitle'), ListItemDescription: require('./description'), + ListItemHeader: require('./header'), + ListItem: require('./item'), ListItemMeta: require('./meta'), + ListItemOptions: require('./options'), ListItemOutlet: require('./outlet'), - ListItemOptions: require('./options') + ListItemSubTitle: require('./subtitle'), + ListItemTitle: require('./title'), + ListItemView: require('./view') }; diff --git a/ui/src/components/list/item.js b/ui/src/components/list/item.js index e6c11391..bf6670f5 100644 --- a/ui/src/components/list/item.js +++ b/ui/src/components/list/item.js @@ -1,9 +1,9 @@ -const Collapsed = require('./collapsed'); const constants = require('../../shared/constants'); const fns = require('../../shared/functions'); const React = require('react'); const Row = require('../row'); const Styled = require('styled-components'); +const transferProps = require('./transfer-props'); const { boxes, @@ -18,16 +18,28 @@ const { default: styled } = Styled; -const height = (props) => props.collapsed ? remcalc(48) : remcalc(126); +const height = (props) => props.collapsed + ? remcalc(48) + : remcalc(126); + +const shadow = (props) => props.collapsed && props.headed + ? boxes.bottomShaddowDarker + : boxes.bottomShaddow; const Item = styled(Row)` + position: relative; + height: ${height} - box-shadow: ${boxes.bottomShaddow}; + box-shadow: ${shadow}; border: 1px solid ${colors.borderSecondary}; background-color: ${colors.brandSecondary}; + margin-bottom: ${remcalc(10)}; `; -module.exports = Collapsed((props) => ( +module.exports = transferProps([ + 'collapsed', + 'headed' +], (props) => ( {props.children} diff --git a/ui/src/components/list/meta.js b/ui/src/components/list/meta.js index 1a2bfda6..df41aa5b 100644 --- a/ui/src/components/list/meta.js +++ b/ui/src/components/list/meta.js @@ -1,8 +1,9 @@ -const Collapsed = require('./collapsed'); const Column = require('../column'); -const Styled = require('styled-components'); const React = require('react'); const Row = require('../row'); +const Styled = require('styled-components'); +const transferProps = require('./transfer-props'); +const View = require('./view'); const { default: styled @@ -14,14 +15,26 @@ const InnerRow = styled(Row)` height: 100%; `; -module.exports = Collapsed((props) => ( - - - {props.children} - - -)); +module.exports = transferProps([ + 'collapsed', + 'headed', + 'fromHeader' +], (props) => { + const meta = ( + + + {props.children} + + + ); + + return !props.fromHeader ? meta : ( + + {meta} + + ); +}); diff --git a/ui/src/components/list/options.js b/ui/src/components/list/options.js index a04c3303..6f8f0f90 100644 --- a/ui/src/components/list/options.js +++ b/ui/src/components/list/options.js @@ -2,6 +2,7 @@ const Button = require('../button'); const constants = require('../../shared/constants'); const fns = require('../../shared/functions'); const React = require('react'); +const transferProps = require('./transfer-props'); const Styled = require('styled-components'); const { @@ -16,11 +17,17 @@ const { default: styled } = Styled; -const height = (props) => props.collapsed ? remcalc(46) : remcalc(124); +const height = (props) => props.collapsed + ? remcalc(46) + : remcalc(124); + +const borderLeftColor = (props) => !props.fromHeader + ? colors.borderSecondary + : colors.borderPrimary; const Nav = styled.nav` flex: 0 0 ${remcalc(47)}; - border-left: 1px solid ${colors.borderSecondary}; + border-left: 1px solid ${borderLeftColor}; `; const StyledButton = styled(Button)` @@ -44,17 +51,24 @@ const StyledButton = styled(Button)` } `; -const Options = (props) => ( -