From 848450e0231c6e2c8429e28184755eb4b3a05df9 Mon Sep 17 00:00:00 2001 From: Alex Windett Date: Tue, 10 Jan 2017 16:52:08 +0000 Subject: [PATCH] reworking notification component --- ui/src/components/close/index.js | 39 +++++++++++++++ ui/src/components/close/readme.md | 65 +++++++++++++++++++++++++ ui/src/components/notification/index.js | 44 +++++++++-------- ui/src/shared/constants/colors.js | 1 + ui/stories/index.js | 28 ++++++----- 5 files changed, 145 insertions(+), 32 deletions(-) create mode 100644 ui/src/components/close/index.js create mode 100644 ui/src/components/close/readme.md diff --git a/ui/src/components/close/index.js b/ui/src/components/close/index.js new file mode 100644 index 00000000..2f1c6aec --- /dev/null +++ b/ui/src/components/close/index.js @@ -0,0 +1,39 @@ +const constants = require('../../shared/constants'); +const fns = require('../../shared/functions'); +const composers = require('../../shared/composers'); +const React = require('react'); +const Styled = require('styled-components'); +const closeIcon = require('../../shared/assets/close'); + +const { + colors +} = constants; + +const { + remcalc +} = fns; + +const { + default: styled +} = Styled; + +const Close = ({ + style, + onClick +}) => { + return ( + + Close + + ); +}; + +Close.propTypes = { + style: React.PropTypes.object, + onClick: React.PropTypes.func +}; + +module.exports = Close; diff --git a/ui/src/components/close/readme.md b/ui/src/components/close/readme.md new file mode 100644 index 00000000..a114f555 --- /dev/null +++ b/ui/src/components/close/readme.md @@ -0,0 +1,65 @@ +# `` + +## demo + +```embed +const React = require('react'); +const ReactDOM = require('react-dom/server'); +const Base = require('../base'); +const Container = require('../container'); +const Row = require('../row'); +const Column = require('../column'); +const Notificaton = require('./index.js'); +const styles = require('./style.css'); + +const style = { + marginBottom: 0 +} + +nmodule.exports = ReactDOM.renderToString( + + + + +

This is the warning content

+
+
+
+ + + +

This is the question content

+
+
+
+ + + +

This is the alert content

+
+
+
+ +); +``` + +## usage + +```js +const React = require('react'); +const Notificaton = require('ui/avatar'); + +module.exports = () => { + return ( + +

This is the warning content

+
+ +

This is the question content

+
+ +

This is the alert content

+
+ ); +} +``` diff --git a/ui/src/components/notification/index.js b/ui/src/components/notification/index.js index dc1125d9..88e3258c 100644 --- a/ui/src/components/notification/index.js +++ b/ui/src/components/notification/index.js @@ -1,6 +1,6 @@ const constants = require('../../shared/constants'); const fns = require('../../shared/functions'); -const match = require('../../shared/match'); +const composers = require('../../shared/composers'); const React = require('react'); const Styled = require('styled-components'); @@ -12,44 +12,46 @@ const { remcalc } = fns; -const { - prop: matchProp -} = match; - const { default: styled } = Styled; -const background = matchProp({ - warning: colors.warningLight, - alert: colors.alertLight, -}, 'transparent'); +const { + baseBox, + pseudoEl +} = composers; -const border = matchProp({ - warning: colors.warning, - alert: 'red', -}, 'none'); +const decorationWidth = remcalc(108); const StyledNotification = styled.div` - border-radius: 4px; - box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.05); display: inline-block; - height: 100%; + min-height: 100%; + position: relative; + width: 100%; - background-color: ${background('type')}; - border: ${border('type')}; + ${baseBox(0)} + + &::before { + background-color: ${props => colors[props.type] || colors.brandPrimary} + width: ${decorationWidth}; + height: 100%; + + ${pseudoEl()} + } `; const StyledContent = styled.div` float: left; - padding: ${remcalc(20)}; + padding: ${remcalc(18)} 20% ${remcalc(18)} ${remcalc(18)}; + margin-left: ${decorationWidth}; + width: 100%; `; const Notificaton = ({ children, className, style, - type = '' + type }) => { return ( ( - - This is the default content - + + + This is the default content + + )) - .add('warning', () => ( - - This is the warning content - + .add('Success', () => ( + + + This is the success content + + )) - .add('alert', () => ( - - This is the alert content - + .add('Alert', () => ( + + + This is the alert content + + )); storiesOf('Pagination', module)