{
- if (!props.active) {
- return null;
- }
-
- return (
-
-
-
- {props.children}
-
-
- );
-};
+const Modal = (props) => !props.active ? null : (
+
+
+
+ {props.children}
+
+
+);
Modal.propTypes = {
active: React.PropTypes.bool,
@@ -68,4 +66,6 @@ Modal.propTypes = {
handleDismiss: React.PropTypes.func
};
-module.exports = Modal;
+module.exports = Baseline(
+ Modal
+);
diff --git a/ui/src/components/notification/index.js b/ui/src/components/notification/index.js
index 619b559f..8ff158ce 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 composers = require('../../shared/composers');
+const fns = require('../../shared/functions');
const React = require('react');
const Styled = require('styled-components');
const Close = require('../close');
@@ -19,7 +19,8 @@ const {
const {
baseBox,
- pseudoEl
+ pseudoEl,
+ Baseline
} = composers;
const decorationWidth = remcalc(108);
@@ -31,12 +32,12 @@ const StyledNotification = styled.div`
width: 100%;
${baseBox(0)}
-
+
&::before {
background-color: ${props => colors[props.type] || colors.brandPrimary}
width: ${decorationWidth};
height: 100%;
-
+
${pseudoEl()}
}
`;
@@ -55,7 +56,9 @@ const Notificaton = ({
type,
close
}) => {
- const renderClose = close ? () : null;
+ const renderClose = !close ? null : (
+
+ );
return (
- { renderClose }
-
+ {renderClose}
{children}
@@ -80,4 +82,6 @@ Notificaton.propTypes = {
type: React.PropTypes.string
};
-module.exports = Notificaton;
+module.exports = Baseline(
+ Notificaton
+);
diff --git a/ui/src/components/pagination/index.js b/ui/src/components/pagination/index.js
index ca69b1fb..bb7e8888 100644
--- a/ui/src/components/pagination/index.js
+++ b/ui/src/components/pagination/index.js
@@ -5,7 +5,8 @@ const React = require('react');
const Styled = require('styled-components');
const {
- baseBox
+ baseBox,
+ Baseline
} = composers;
const {
@@ -64,7 +65,6 @@ const StyledLi = styled.li`
}
`;
-
const Pagination = ({
children,
className,
@@ -104,4 +104,6 @@ Pagination.propTypes = {
style: React.PropTypes.object
};
-module.exports = Pagination;
+module.exports = Baseline(
+ Pagination
+);
diff --git a/ui/src/components/payment-card/detail.js b/ui/src/components/payment-card/detail.js
index c6e6d33b..3611af4b 100644
--- a/ui/src/components/payment-card/detail.js
+++ b/ui/src/components/payment-card/detail.js
@@ -1,3 +1,4 @@
+const composers = require('../../shared/composers');
const React = require('react');
const Styled = require('styled-components');
@@ -5,6 +6,10 @@ const {
default: styled
} = Styled;
+const {
+ Baseline
+} = composers;
+
const Container = styled.p`
margin: 0;
line-height: 1.2;
@@ -20,4 +25,6 @@ Detail.propTypes = {
children: React.PropTypes.node
};
-module.exports = Detail;
+module.exports = Baseline(
+ Detail
+);
diff --git a/ui/src/components/payment-card/details.js b/ui/src/components/payment-card/details.js
index 1ee45f4e..43069b27 100644
--- a/ui/src/components/payment-card/details.js
+++ b/ui/src/components/payment-card/details.js
@@ -1,11 +1,16 @@
+const composers = require('../../shared/composers');
+const fns = require('../../shared/functions');
const React = require('react');
const Styled = require('styled-components');
-const fns = require('../../shared/functions');
const {
remcalc
} = fns;
+const {
+ Baseline
+} = composers;
+
const {
default: styled
} = Styled;
@@ -25,4 +30,6 @@ Details.propTypes = {
children: React.PropTypes.node
};
-module.exports = Details;
+module.exports = Baseline(
+ Details
+);
diff --git a/ui/src/components/payment-card/payment-card.js b/ui/src/components/payment-card/payment-card.js
index 02391edb..d1cdf253 100644
--- a/ui/src/components/payment-card/payment-card.js
+++ b/ui/src/components/payment-card/payment-card.js
@@ -2,13 +2,13 @@
const React = require('react');
const Styled = require('styled-components');
+const composers = require('../../shared/composers');
const constants = require('../../shared/constants');
const fns = require('../../shared/functions');
-const MastercardIcon =
- require(
- '!babel-loader!svg-react-loader!./mastercard.svg?name=MastercardIcon'
- );
+const MastercardIcon = require(
+ '!babel-loader!svg-react-loader!./mastercard.svg?name=MastercardIcon'
+);
const {
default: styled
@@ -23,6 +23,10 @@ const {
remcalc
} = fns;
+const {
+ Baseline
+} = composers;
+
const icons = {
mastercard: MastercardIcon
};
@@ -57,18 +61,19 @@ const LargeCard = styled(Card)`
`;
const PaymentCard = ({
- type='mastercard',
- size='small'
+ type = 'mastercard',
+ size = 'small'
}) => {
-
const icon = React.createElement(
icons[type],
sizes[size]
);
- return size === 'small' ?
- {icon} :
- {icon};
+ return size === 'small' ? (
+ {icon}
+ ) : (
+ {icon}
+ );
};
PaymentCard.propTypes = {
@@ -81,4 +86,6 @@ PaymentCard.propTypes = {
]).isRequired
};
-module.exports = PaymentCard;
+module.exports = Baseline(
+ PaymentCard
+);
diff --git a/ui/src/components/payment-card/view.js b/ui/src/components/payment-card/view.js
index 201f3186..cb92d910 100644
--- a/ui/src/components/payment-card/view.js
+++ b/ui/src/components/payment-card/view.js
@@ -1,11 +1,16 @@
const React = require('react');
const Styled = require('styled-components');
+const composers = require('../../shared/composers');
const fns = require('../../shared/functions');
const {
remcalc
} = fns;
+const {
+ Baseline
+} = composers;
+
const {
default: styled
} = Styled;
@@ -26,4 +31,6 @@ View.propTypes = {
children: React.PropTypes.node
};
-module.exports = View;
+module.exports = Baseline(
+ View
+);
diff --git a/ui/src/components/radio-group/index.js b/ui/src/components/radio-group/index.js
index 6bb576c1..677d1a14 100644
--- a/ui/src/components/radio-group/index.js
+++ b/ui/src/components/radio-group/index.js
@@ -5,6 +5,7 @@
* if they have any
*/
+const composers = require('../../shared/composers');
const first = require('lodash.first');
const isUndefined = require('lodash.isundefined');
const get = require('lodash.get');
@@ -14,6 +15,10 @@ const classNames = require('classnames');
const React = require('react');
// const styles = require('./style.css');
+const {
+ Baseline
+} = composers;
+
const RadioGroup = React.createClass({
propTypes: {
children: React.PropTypes.node,
@@ -150,4 +155,6 @@ const RadioGroup = React.createClass({
}
});
-module.exports = RadioGroup;
+module.exports = Baseline(
+ RadioGroup
+);
diff --git a/ui/src/components/radio-group/item.js b/ui/src/components/radio-group/item.js
index 18333b44..4645e9a0 100644
--- a/ui/src/components/radio-group/item.js
+++ b/ui/src/components/radio-group/item.js
@@ -1,7 +1,12 @@
const React = require('react');
const fns = require('../../shared/functions');
-const Styled = require('styled-components');
const constants = require('../../shared/constants');
+const composers = require('../../shared/composers');
+const Styled = require('styled-components');
+
+const {
+ Baseline
+} = composers;
const {
remcalc
@@ -47,19 +52,17 @@ const Item = ({
disabled = false,
onClick,
tabIndex
-}) => {
- return (
-
- {children}
-
- );
-};
+}) => (
+
+ {children}
+
+);
Item.propTypes = {
checked: React.PropTypes.bool,
@@ -70,4 +73,6 @@ Item.propTypes = {
tabIndex: React.PropTypes.number
};
-module.exports = Item;
+module.exports = Baseline(
+ Item
+);
diff --git a/ui/src/components/radio/index.js b/ui/src/components/radio/index.js
index cf1a77cc..494496a4 100644
--- a/ui/src/components/radio/index.js
+++ b/ui/src/components/radio/index.js
@@ -1,7 +1,8 @@
-const React = require('react');
const constants = require('../../shared/constants');
-const Styled = require('styled-components');
+const composers = require('../../shared/composers');
const fns = require('../../shared/functions');
+const React = require('react');
+const Styled = require('styled-components');
const {
colors
@@ -11,6 +12,10 @@ const {
remcalc
} = fns;
+const {
+ Baseline
+} = composers;
+
const {
default: styled
} = Styled;
@@ -78,33 +83,30 @@ const Radio = ({
style,
tabIndex,
value
-}) => {
-
- return (
-
-
-
-
- {children}
-
-
-
- );
-};
+}) => (
+
+
+
+
+ {children}
+
+
+
+);
Radio.propTypes = {
checked: React.PropTypes.bool,
@@ -125,4 +127,6 @@ Radio.propTypes = {
value: React.PropTypes.string.isRequired
};
-module.exports = Radio;
+module.exports = Baseline(
+ Radio
+);
diff --git a/ui/src/components/range-slider/index.js b/ui/src/components/range-slider/index.js
index 0373bb59..7646b4b5 100644
--- a/ui/src/components/range-slider/index.js
+++ b/ui/src/components/range-slider/index.js
@@ -5,7 +5,8 @@ const React = require('react');
const Styled = require('styled-components');
const {
- baseBox
+ baseBox,
+ Baseline
} = composers;
const {
@@ -133,16 +134,14 @@ const RangeSlider = ({
className,
onChange,
style
-}) => {
- return (
-
- );
-};
+}) => (
+
+);
RangeSlider.propTypes = {
className: React.PropTypes.string,
@@ -150,4 +149,6 @@ RangeSlider.propTypes = {
style: React.PropTypes.object
};
-module.exports = RangeSlider;
+module.exports = Baseline(
+ RangeSlider
+);
diff --git a/ui/src/components/row/index.js b/ui/src/components/row/index.js
index e3abecf0..a6709599 100644
--- a/ui/src/components/row/index.js
+++ b/ui/src/components/row/index.js
@@ -3,6 +3,7 @@
* github.com/roylee0704/react-flexbox-grid/blob/master/src/components/Row.js
*/
+const composers = require('../../shared/composers');
const constants = require('../../shared/constants');
const match = require('../../shared/match');
const sizeMatch = require('./size-match');
@@ -13,6 +14,10 @@ const {
sizes
} = constants;
+const {
+ Baseline
+} = composers;
+
const {
default: styled
} = Styled;
@@ -51,7 +56,7 @@ const alignItems = (size) => match(sizeMatch(size, {
*
* ```
**/
-module.exports = styled.div`
+const Row = styled.div`
box-sizing: border-box;
display: flex;
flex: 0 1 auto;
@@ -88,3 +93,7 @@ module.exports = styled.div`
align-items: ${alignItems('lg')};
`}
`;
+
+module.exports = Baseline(
+ Row
+);
diff --git a/ui/src/components/select-custom/index.js b/ui/src/components/select-custom/index.js
index f2bd9bca..a09c7b88 100644
--- a/ui/src/components/select-custom/index.js
+++ b/ui/src/components/select-custom/index.js
@@ -1,4 +1,5 @@
const fns = require('../../shared/functions');
+const composers = require('../../shared/composers');
const constants = require('../../shared/constants');
const React = require('react');
const Styled = require('styled-components');
@@ -15,6 +16,10 @@ const {
colors
} = constants;
+const {
+ Baseline
+} = composers;
+
const {
default: styled
} = Styled;
@@ -29,38 +34,35 @@ const SelectCustom = ({
children,
className,
disabled,
- form,
- id = rndId(),
+ form,
+ id = rndId(),
isLoading,
- label,
+ label,
multi = false,
name,
- onChange,
- options,
+ onChange,
+ options,
required = false,
style,
value = ''
-}) => {
-
- return (
-
-
- {label}
-
-
-
- );
-};
+}) => (
+
+
+ {label}
+
+
+
+);
SelectCustom.propTypes = {
async: React.PropTypes.bool,
@@ -81,4 +83,6 @@ SelectCustom.propTypes = {
value: React.PropTypes.string
};
-module.exports = SelectCustom;
+module.exports = Baseline(
+ SelectCustom
+);
diff --git a/ui/src/components/select/index.js b/ui/src/components/select/index.js
index 475353d8..e1f94c3b 100644
--- a/ui/src/components/select/index.js
+++ b/ui/src/components/select/index.js
@@ -1,5 +1,6 @@
-const fns = require('../../shared/functions');
+const composers = require('../../shared/composers');
const reduxFormProxy = require('../../shared/redux-form-proxy');
+const fns = require('../../shared/functions');
const React = require('react');
const Styled = require('styled-components');
@@ -13,6 +14,10 @@ const {
rndId
} = fns;
+const {
+ Baseline
+} = composers;
+
const {
default: styled
} = Styled;
@@ -92,4 +97,6 @@ Select.propTypes = {
warning: React.PropTypes.string
};
-module.exports = reduxFormProxy(Select);
+module.exports = reduxFormProxy(
+ Baseline(Select)
+);
diff --git a/ui/src/components/table-data-table/index.js b/ui/src/components/table-data-table/index.js
index 461dd0da..3dfd5648 100644
--- a/ui/src/components/table-data-table/index.js
+++ b/ui/src/components/table-data-table/index.js
@@ -1,3 +1,4 @@
+const composers = require('../../shared/composers');
const React = require('react');
const Styled = require('styled-components');
@@ -7,13 +8,17 @@ const {
default: styled
} = Styled;
+const {
+ Baseline
+} = composers;
+
const StyledTitle = styled.h3`
text-align: center
`;
const StyledTableWrapper = styled.section`
font-family: 'LibreFranklin', sans-serif;
- font-style: normal;
+ font-style: normal;
`;
const Table = ({
@@ -21,21 +26,16 @@ const Table = ({
columns = [],
data = [],
style,
- title,
-}) => {
-
- return (
-
-
- {title}
-
-
-
- );
-};
+ title
+}) => (
+
+ {title}
+
+
+);
Table.propTypes = {
children: React.PropTypes.node,
@@ -45,4 +45,6 @@ Table.propTypes = {
title: React.PropTypes.string,
};
-module.exports = Table;
+module.exports = Baseline(
+ Table
+);
diff --git a/ui/src/components/table-data-table/story.js b/ui/src/components/table-data-table/story.js
index bdaaa917..190f6e83 100644
--- a/ui/src/components/table-data-table/story.js
+++ b/ui/src/components/table-data-table/story.js
@@ -7,14 +7,12 @@ const {
const Table = require('./');
-const memberDetail = (name) => {
- return (
-
-
{name}
- {name}@biztech.com
-
- );
-};
+const memberDetail = (name) => (
+
+
{name}
+ {name}@biztech.com
+
+);
const columns = [{
title: 'Memeber',
diff --git a/ui/src/components/table-data-table/table-body.js b/ui/src/components/table-data-table/table-body.js
index a1dbd7fd..b095f777 100644
--- a/ui/src/components/table-data-table/table-body.js
+++ b/ui/src/components/table-data-table/table-body.js
@@ -1,14 +1,19 @@
+const composers = require('../../shared/composers');
const React = require('react');
const Row = require('./table-row');
+const {
+ Baseline
+} = composers;
+
const TableBody = ({
columns,
data
}) => {
- const rows = columns.map( (column, index) => {
- return
;
- });
+ const rows = columns.map((column, index) => (
+
+ ));
return (
@@ -22,4 +27,6 @@ TableBody.propTypes = {
data: React.PropTypes.array
};
-module.exports = TableBody;
\ No newline at end of file
+module.exports = Baseline(
+ TableBody
+);
diff --git a/ui/src/components/table-data-table/table-content.js b/ui/src/components/table-data-table/table-content.js
index 0bb3d16c..7eea541a 100644
--- a/ui/src/components/table-data-table/table-content.js
+++ b/ui/src/components/table-data-table/table-content.js
@@ -1,3 +1,4 @@
+const composers = require('../../shared/composers');
const React = require('react');
const Styled = require('styled-components');
@@ -8,6 +9,10 @@ const {
default: styled
} = Styled;
+const {
+ Baseline
+} = composers;
+
const StyledTable = styled.table`
width: 100%;
`;
@@ -18,15 +23,12 @@ const TableContent = ({
hasHeader = columns.length >= 1,
hasBody = data.length >= 1,
width = '100%'
-}) => {
-
- return (
-
- {hasHeader ? : null}
- {hasBody ? : null}
-
- );
-};
+}) => (
+
+ {hasHeader ? : null}
+ {hasBody ? : null}
+
+);
TableContent.propTypes = {
columns: React.PropTypes.array,
@@ -36,4 +38,6 @@ TableContent.propTypes = {
width: React.PropTypes.string,
};
-module.exports = TableContent;
+module.exports = Baseline(
+ TableContent
+);
diff --git a/ui/src/components/table-data-table/table-head.js b/ui/src/components/table-data-table/table-head.js
index 18a2848a..ee228c7b 100644
--- a/ui/src/components/table-data-table/table-head.js
+++ b/ui/src/components/table-data-table/table-head.js
@@ -3,6 +3,7 @@ const Styled = require('styled-components');
const fns = require('../../shared/functions');
const constants = require('../../shared/constants');
+const composers = require('../../shared/composers');
const {
remcalc
@@ -13,6 +14,10 @@ const {
colors
} = constants;
+const {
+ Baseline
+} = composers;
+
const {
default: styled
} = Styled;
@@ -42,17 +47,14 @@ const TableHeader = ({
const fallBackWidth = `${100 / parseInt(columns.length)}%`;
- const titles = columns.map( (column, i) => {
-
- return (
-
- {column.title}
-
- );
- });
+ const titles = columns.map((column, i) => (
+
+ {column.title}
+
+ ));
return (
@@ -67,4 +69,6 @@ TableHeader.propTypes = {
columns: React.PropTypes.array
};
-module.exports = TableHeader;
\ No newline at end of file
+module.exports = Baseline(
+ TableHeader
+);
diff --git a/ui/src/components/table-data-table/table-row.js b/ui/src/components/table-data-table/table-row.js
index b9d1abf2..ef572904 100644
--- a/ui/src/components/table-data-table/table-row.js
+++ b/ui/src/components/table-data-table/table-row.js
@@ -3,6 +3,7 @@ const Styled = require('styled-components');
const fns = require('../../shared/functions');
const constants = require('../../shared/constants');
+const composers = require('../../shared/composers');
const {
remcalc
@@ -17,6 +18,10 @@ const {
colors
} = constants;
+const {
+ Baseline
+} = composers;
+
const StyledRow = styled.tr`
border: solid ${remcalc(1)} ${colors.base.greyDark};
@@ -36,13 +41,9 @@ const StyledTableItem = styled.td`
const Row = ({
dataItem = {}
}) => {
- const _dataItem = dataItem;
-
- const rowItems = Object.keys(_dataItem).map( (item, i) => {
- const value = _dataItem[item];
-
- return {value};
- });
+ const rowItems = Object.keys(dataItem).map((item, i) => (
+ {dataItem[item]}
+ ));
return (
@@ -55,4 +56,6 @@ Row.propTypes = {
dataItem: React.PropTypes.object
};
-module.exports = Row;
\ No newline at end of file
+module.exports = Baseline(
+ Row
+);
diff --git a/ui/src/components/table-simple-table/table-body.js b/ui/src/components/table-simple-table/table-body.js
index 62066e6a..aeb24f89 100644
--- a/ui/src/components/table-simple-table/table-body.js
+++ b/ui/src/components/table-simple-table/table-body.js
@@ -8,22 +8,24 @@ const {
} = Styled;
const {
- clearfix
+ clearfix,
+ Baseline
} = composers;
const StyledTableBody = styled.article`
box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.05);
-
+
${clearfix}
`;
const TableBody = ({
children
}) => {
-
const itemCount = children.length;
- if (itemCount <= 1) return;
+ if (itemCount <= 1) {
+ return null;
+ }
return (
@@ -36,4 +38,6 @@ TableBody.propTypes = {
children: React.PropTypes.node
};
-module.exports = StyledTableBody;
\ No newline at end of file
+module.exports = Baseline(
+ StyledTableBody
+);
\ No newline at end of file
diff --git a/ui/src/components/table-simple-table/table-head.js b/ui/src/components/table-simple-table/table-head.js
index 2b80b85f..95000822 100644
--- a/ui/src/components/table-simple-table/table-head.js
+++ b/ui/src/components/table-simple-table/table-head.js
@@ -14,23 +14,24 @@ const {
} = Styled;
const {
- clearfix
+ clearfix,
+ Baseline
} = composers;
const StyledTableHead = styled.header`
background: #fafafa;
box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.05);
padding: ${remcalc(24)} 0;
-
+
${clearfix}
-
+
& > .table-item {
text-align: center;
-
+
${props => {
const width = 100 / props.itemCount;
return css`
- width: ${width}%;
+ width: ${width}%;
`;
}}
}
@@ -39,10 +40,11 @@ const StyledTableHead = styled.header`
const TableHead = ({
children
}) => {
-
const itemCount = children.length;
- if (itemCount <= 1) return;
+ if (itemCount <= 1) {
+ return null;
+ }
return (
@@ -55,4 +57,6 @@ TableHead.propTypes = {
children: React.PropTypes.node
};
-module.exports = TableHead;
\ No newline at end of file
+module.exports = Baseline(
+ TableHead
+);
\ No newline at end of file
diff --git a/ui/src/components/table-simple-table/table-item.js b/ui/src/components/table-simple-table/table-item.js
index e43bc69b..db73c86a 100644
--- a/ui/src/components/table-simple-table/table-item.js
+++ b/ui/src/components/table-simple-table/table-item.js
@@ -1,10 +1,16 @@
const React = require('react');
const Styled = require('styled-components');
+const composers = require('../../shared/composers');
+
const {
default: styled
} = Styled;
+const {
+ Baseline
+} = composers;
+
const Item = styled.div`
display: inline-block;
float: left;
@@ -12,17 +18,16 @@ const Item = styled.div`
const TableItem = ({
children
-}) => {
-
- return (
- -
- {children}
-
- );
-};
+}) => (
+ -
+ {children}
+
+);
TableItem.propTypes = {
children: React.PropTypes.node
};
-module.exports = TableItem;
\ No newline at end of file
+module.exports = Baseline(
+ TableItem
+);
diff --git a/ui/src/components/table-simple-table/table-row.js b/ui/src/components/table-simple-table/table-row.js
index cdbaa9fa..f14c009f 100644
--- a/ui/src/components/table-simple-table/table-row.js
+++ b/ui/src/components/table-simple-table/table-row.js
@@ -11,7 +11,8 @@ const {
} = Styled;
const {
- clearfix
+ clearfix,
+ Baseline
} = composers;
const {
@@ -42,18 +43,16 @@ const StyledTableRow = styled.div`
const TableRow = ({
children
-}) => {
- const itemCount = children.length;
-
- return (
-
- {children}
-
- );
-};
+}) => (
+
+ {children}
+
+);
TableRow.propTypes = {
children: React.PropTypes.node
};
-module.exports = TableRow;
\ No newline at end of file
+module.exports = Baseline(
+ TableRow
+);
diff --git a/ui/src/components/table-simple-table/table.js b/ui/src/components/table-simple-table/table.js
index 80de0238..ed5a5faf 100644
--- a/ui/src/components/table-simple-table/table.js
+++ b/ui/src/components/table-simple-table/table.js
@@ -2,6 +2,7 @@ const React = require('react');
const Styled = require('styled-components');
const constants = require('../../shared/constants');
+const composers = require('../../shared/composers');
const {
default: styled
@@ -11,6 +12,10 @@ const {
colors
} = constants;
+const {
+ Baseline
+} = composers;
+
const StyledTableWrapper = styled.section`
border: solid 1px ${colors.base.greyDark}
font-family: 'LibreFranklin', sans-serif;
@@ -20,7 +25,7 @@ const StyledTableWrapper = styled.section`
const Table = ({
children,
style,
- title,
+ title
}) => (
{children}
@@ -33,4 +38,6 @@ Table.propTypes = {
title: React.PropTypes.string,
};
-module.exports = Table;
+module.exports = Baseline(
+ Table
+);
diff --git a/ui/src/components/tabs/index.js b/ui/src/components/tabs/index.js
index 25b84fb7..1a9b06ac 100644
--- a/ui/src/components/tabs/index.js
+++ b/ui/src/components/tabs/index.js
@@ -1,5 +1,6 @@
const React = require('react');
const fns = require('../../shared/functions');
+const composers = require('../../shared/composers');
const Styled = require('styled-components');
const {
@@ -10,6 +11,10 @@ const {
default: styled
} = Styled;
+const {
+ Baseline
+} = composers;
+
const StyledTabs = styled.div`
font-size: 0;
@@ -54,4 +59,6 @@ Tabs.propTypes = {
style: React.PropTypes.object
};
-module.exports = Tabs;
+module.exports = Baseline(
+ Tabs
+);
diff --git a/ui/src/components/tabs/tab/index.js b/ui/src/components/tabs/tab/index.js
index df6320e3..30191a6e 100644
--- a/ui/src/components/tabs/tab/index.js
+++ b/ui/src/components/tabs/tab/index.js
@@ -6,7 +6,8 @@ const React = require('react');
const Styled = require('styled-components');
const {
- moveZ
+ moveZ,
+ Baseline
} = composers;
const {
@@ -137,4 +138,6 @@ Tab.propTypes = {
title: React.PropTypes.string
};
-module.exports = Tab;
+module.exports = Baseline(
+ Tab
+);
diff --git a/ui/src/components/textarea/index.js b/ui/src/components/textarea/index.js
index e8511276..f8c7d0cd 100644
--- a/ui/src/components/textarea/index.js
+++ b/ui/src/components/textarea/index.js
@@ -15,7 +15,8 @@ const {
} = fns;
const {
- baseBox
+ baseBox,
+ Baseline
} = composers;
const {
@@ -143,4 +144,6 @@ Textarea.propTypes = {
value: React.PropTypes.string
};
-module.exports = Textarea;
+module.exports = Baseline(
+ Textarea
+);
diff --git a/ui/src/components/toggle/index.js b/ui/src/components/toggle/index.js
index 67b20b94..b37e2993 100644
--- a/ui/src/components/toggle/index.js
+++ b/ui/src/components/toggle/index.js
@@ -9,7 +9,8 @@ const {
} = constants;
const {
- baseBox
+ baseBox,
+ Baseline
} = composers;
const {
@@ -149,4 +150,6 @@ Toggle.propTypes = {
style: React.PropTypes.object
};
-module.exports = Toggle;
+module.exports = Baseline(
+ Toggle
+);
diff --git a/ui/src/components/tooltip/index.js b/ui/src/components/tooltip/index.js
index 85c743e4..21ea2a0e 100644
--- a/ui/src/components/tooltip/index.js
+++ b/ui/src/components/tooltip/index.js
@@ -2,13 +2,14 @@
const React = require('react');
const composers = require('../../shared/composers');
-const fns = require('../../shared/functions');
const constants = require('../../shared/constants');
+const fns = require('../../shared/functions');
const Styled = require('styled-components');
const {
baseBox,
pseudoEl,
+ Baseline
} = composers;
const {
@@ -73,7 +74,8 @@ const StyledList = styled.ul`
margin-left: ${remcalc(-12)};
}
`;
-module.exports = ({
+
+const Tooltip = ({
children,
className,
style,
@@ -81,21 +83,23 @@ module.exports = ({
bottom: '100%',
left: '10%'
}
-}) => {
- return (
-
- {children}
-
- );
-};
+}) => (
+
+ {children}
+
+);
-module.exports.propTypes = {
+Tooltip.propTypes = {
arrowPosition: React.PropTypes.object,
children: React.PropTypes.node,
className: React.PropTypes.string,
style: React.PropTypes.object
};
+
+module.exports = Baseline(
+ Tooltip
+);
diff --git a/ui/src/components/topology-old/index.js b/ui/src/components/topology-old/index.js
index c4f9d7d4..833582c3 100644
--- a/ui/src/components/topology-old/index.js
+++ b/ui/src/components/topology-old/index.js
@@ -1,3 +1,4 @@
+const composers = require('../../shared/composers');
const constants = require('../../shared/constants');
const d3 = require('d3');
const fns = require('../../shared/functions');
@@ -8,6 +9,10 @@ const {
colors
} = constants;
+const {
+ Baseline
+} = composers;
+
const {
remcalc
} = fns;
@@ -413,7 +418,6 @@ class TopologyGraph extends React.Component {
/>
);
}
-
}
TopologyGraph.propTypes = {
@@ -422,4 +426,6 @@ TopologyGraph.propTypes = {
width: React.PropTypes.number,
};
-module.exports = TopologyGraph;
+module.exports = Baseline(
+ TopologyGraph
+);
diff --git a/ui/src/components/topology-old/view.js b/ui/src/components/topology-old/view.js
index 83aba5b5..e04ad057 100644
--- a/ui/src/components/topology-old/view.js
+++ b/ui/src/components/topology-old/view.js
@@ -1,3 +1,4 @@
+const composers = require('../../shared/composers');
const constants = require('../../shared/constants');
const fns = require('../../shared/functions');
const React = require('react');
@@ -7,6 +8,10 @@ const {
colors
} = constants;
+const {
+ Baseline
+} = composers;
+
const {
remcalc
} = fns;
@@ -30,4 +35,6 @@ Topology.propTypes = {
children: React.PropTypes.node,
};
-module.exports = Topology;
+module.exports = Baseline(
+ Topology
+);
diff --git a/ui/src/components/topology/graph-link.js b/ui/src/components/topology/graph-link.js
index 047c6996..f772d491 100644
--- a/ui/src/components/topology/graph-link.js
+++ b/ui/src/components/topology/graph-link.js
@@ -1,11 +1,16 @@
const React = require('react');
const Styled = require('styled-components');
+const composers = require('../../shared/composers');
const PropTypes = require('./prop-types');
const {
default: styled
} = Styled;
+const {
+ Baseline
+} = composers;
+
const StyledLine = styled.line`
stroke: #343434;
stroke-width: 1.5;
@@ -151,4 +156,6 @@ GraphLink.propTypes = {
nodeSize: PropTypes.Size
};
-module.exports = GraphLink;
+module.exports = Baseline(
+ GraphLink
+);
diff --git a/ui/src/components/topology/graph-node-button.js b/ui/src/components/topology/graph-node-button.js
index 62679ed9..d8856a31 100644
--- a/ui/src/components/topology/graph-node-button.js
+++ b/ui/src/components/topology/graph-node-button.js
@@ -1,10 +1,15 @@
const React = require('react');
+const composers = require('../../shared/composers');
const Styled = require('styled-components');
const {
default: styled
} = Styled;
+const {
+ Baseline
+} = composers;
+
const StyledButton = styled.rect`
opacity: 0;
cursor: pointer;
@@ -54,4 +59,6 @@ GraphNodeButton.propTypes = {
onButtonClick: React.PropTypes.func.isRequired
};
-module.exports = GraphNodeButton;
+module.exports = Baseline(
+ GraphNodeButton
+);
diff --git a/ui/src/components/topology/graph-node-info.js b/ui/src/components/topology/graph-node-info.js
index c3c65f6d..fb9adecf 100644
--- a/ui/src/components/topology/graph-node-info.js
+++ b/ui/src/components/topology/graph-node-info.js
@@ -1,19 +1,24 @@
const React = require('react');
+const composers = require('../../shared/composers');
const Styled = require('styled-components');
-const DataCentresIcon =
- require(
- // eslint-disable-next-line max-len
- '!babel-loader!svg-react-loader!./icon-data-centers.svg?name=DataCentresIcon'
- );
-const InstancesIcon =
- require(
- '!babel-loader!svg-react-loader!./icon-instances.svg?name=InstancesIcon'
- );
+
+const DataCentresIcon = require(
+ // eslint-disable-next-line max-len
+ '!babel-loader!svg-react-loader!./icon-data-centers.svg?name=DataCentresIcon'
+);
+
+const InstancesIcon = require(
+ '!babel-loader!svg-react-loader!./icon-instances.svg?name=InstancesIcon'
+);
const {
default: styled
} = Styled;
+const {
+ Baseline
+} = composers;
+
const StyledText = styled.text`
fill: white;
font-size: 12px;
@@ -56,4 +61,6 @@ GraphNodeInfo.propTypes = {
})
};
-module.exports = GraphNodeInfo;
+module.exports = Baseline(
+ GraphNodeInfo
+);
diff --git a/ui/src/components/topology/graph-node-metrics.js b/ui/src/components/topology/graph-node-metrics.js
index 42e032a3..777649b0 100644
--- a/ui/src/components/topology/graph-node-metrics.js
+++ b/ui/src/components/topology/graph-node-metrics.js
@@ -1,10 +1,15 @@
const React = require('react');
+const composers = require('../../shared/composers');
const Styled = require('styled-components');
const {
default: styled
} = Styled;
+const {
+ Baseline
+} = composers;
+
const StyledText = styled.text`
fill: white;
font-size: 12px;
@@ -45,4 +50,6 @@ GraphNodeMetrics.propTypes = {
})
};
-module.exports = GraphNodeMetrics;
+module.exports = Baseline(
+ GraphNodeMetrics
+);
diff --git a/ui/src/components/topology/graph-node.js b/ui/src/components/topology/graph-node.js
index 5ad315e9..5501b8bd 100644
--- a/ui/src/components/topology/graph-node.js
+++ b/ui/src/components/topology/graph-node.js
@@ -1,18 +1,23 @@
const React = require('react');
+const composers = require('../../shared/composers');
const Styled = require('styled-components');
const PropTypes = require('./prop-types');
const GraphNodeButton = require('./graph-node-button');
const GraphNodeInfo = require('./graph-node-info');
const GraphNodeMetrics = require('./graph-node-metrics');
-const HeartIcon =
- require(
- '!babel-loader!svg-react-loader!./icon-heart.svg?name=HeartIcon'
- );
+
+const HeartIcon = require(
+ '!babel-loader!svg-react-loader!./icon-heart.svg?name=HeartIcon'
+);
const {
default: styled
} = Styled;
+const {
+ Baseline
+} = composers;
+
const StyledRect = styled.rect`
stroke: #343434;
fill: #464646;
@@ -144,4 +149,6 @@ GraphNode.propTypes = {
size: PropTypes.Size
};
-module.exports = GraphNode;
+module.exports = Baseline(
+ GraphNode
+);
diff --git a/ui/src/components/topology/story-helper.js b/ui/src/components/topology/story-helper.js
index 138e1cec..b7ca9e3d 100644
--- a/ui/src/components/topology/story-helper.js
+++ b/ui/src/components/topology/story-helper.js
@@ -1,5 +1,6 @@
const React = require('react');
const Styled = require('styled-components');
+const composers = require('../../shared/composers');
const Input = require('../input');
const Select = require('../select');
const Topology = require('./');
@@ -9,6 +10,10 @@ const {
default: styled
} = Styled;
+const {
+ Baseline
+} = composers;
+
const {
TopologyGraph
} = Topology;
@@ -101,4 +106,6 @@ class StoryHelper extends React.Component {
}
}
-module.exports = StoryHelper;
+module.exports = Baseline(
+ StoryHelper
+);
diff --git a/ui/src/components/topology/topology-graph.js b/ui/src/components/topology/topology-graph.js
index cdc6b4a8..b79a68c0 100644
--- a/ui/src/components/topology/topology-graph.js
+++ b/ui/src/components/topology/topology-graph.js
@@ -1,5 +1,6 @@
const React = require('react');
const Styled = require('styled-components');
+const composers = require('../../shared/composers');
const GraphSimulation = require('./graph-simulation');
const GraphNode = require('./graph-node');
const GraphLink = require('./graph-link');
@@ -13,6 +14,10 @@ const {
updateSimulation
} = GraphSimulation;
+const {
+ Baseline
+} = composers;
+
const StyledSvg = styled.svg`
width: 1024px;
height: 860px;
@@ -36,9 +41,7 @@ let dragInfo = {
};
class TopologyGraph extends React.Component {
-
componentWillMount() {
-
const {
nodes,
links
@@ -265,4 +268,6 @@ TopologyGraph.propTypes = {
})
};
-module.exports = TopologyGraph;
+module.exports = Baseline(
+ TopologyGraph
+);
diff --git a/ui/src/components/widget/index.js b/ui/src/components/widget/index.js
index 377619d4..da8d6c41 100644
--- a/ui/src/components/widget/index.js
+++ b/ui/src/components/widget/index.js
@@ -1,4 +1,5 @@
const React = require('react');
+const composers = require('../../shared/composers');
const constants = require('../../shared/constants');
const fns = require('../../shared/functions');
const Styled = require('styled-components');
@@ -7,6 +8,10 @@ const {
boxes
} = constants;
+const {
+ Baseline
+} = composers;
+
const {
rndId,
remcalc
@@ -96,4 +101,6 @@ Widget.propTypes = {
value: React.PropTypes.string
};
-module.exports = Widget;
+module.exports = Baseline(
+ Widget
+);
diff --git a/ui/src/shared/composers.js b/ui/src/shared/composers.js
index 457975c4..de5389cd 100644
--- a/ui/src/shared/composers.js
+++ b/ui/src/shared/composers.js
@@ -1,15 +1,62 @@
-const constants = require('./constants');
const Styled = require('styled-components');
+const camelCase = require('camel-case');
+
+const constants = require('./constants');
+const fns = require('./functions');
const {
boxes
} = constants;
const {
+ unitcalc
+} = fns;
+
+const {
+ default: styled,
css
} = Styled;
+const sides = [
+ 'top',
+ 'right',
+ 'bottom',
+ 'left'
+];
+
+const unitProps = (() => {
+ const sided = (rule) =>
+ sides.map((side) => `${rule}-${side}`);
+
+ const measures = [
+ 'margin',
+ 'padding'
+ ].reduce((props, rule) => [
+ ...props,
+ rule,
+ ...sided(rule)
+ ], []);
+
+ return sides.reduce((acc, side) => [
+ ...acc,
+ `border-${side}-width`
+ ], [
+ 'border',
+ ...measures
+ ]);
+})();
+
+const unitsFromProps = (props) => unitProps
+ .filter((measure) => props[camelCase(measure)])
+ .map((measure) => `
+ ${measure}: ${unitcalc(props[camelCase(measure)])};
+ `)
+ .join(';\n');
+
module.exports = {
+ Baseline: (Component) => styled(Component)`
+ ${unitsFromProps}
+ `,
verticallyAlignCenter: css`
/* Need to place position:relative on parent */
left: 50%;
@@ -48,15 +95,15 @@ module.exports = {
bottom: ${positions.bottom || 'auto'};
left: ${positions.left || 'auto'};
`,
- clearfix: css`
+ clearfix: css`
&:before,
&:after {
content:"";
display:table;
}
-
+
&:after {
clear:both;
}
- `,
+ `
};
diff --git a/ui/src/shared/fake-data/index.js b/ui/src/shared/fake-data/index.js
index 366dce5e..127a155f 100644
--- a/ui/src/shared/fake-data/index.js
+++ b/ui/src/shared/fake-data/index.js
@@ -1,29 +1,22 @@
-const selectData = [
- {
- value: 'one',
- label: 'One'
- },
- {
- value: 'two',
- label: 'Two'
- },
- {
- value: 'three',
- label: 'Three'
- },
- {
- value: 'four',
- label: 'Four'
- },
- {
- value: 'five',
- label: 'Five'
- },
- {
- value: 'six',
- label: 'Six'
- }
-];
+const selectData = [{
+ value: 'one',
+ label: 'One'
+}, {
+ value: 'two',
+ label: 'Two'
+}, {
+ value: 'three',
+ label: 'Three'
+}, {
+ value: 'four',
+ label: 'Four'
+}, {
+ value: 'five',
+ label: 'Five'
+}, {
+ value: 'six',
+ label: 'Six'
+}];
// eslint-disable-next-line max-len
const profile = 'https://pbs.twimg.com/profile_images/641289584580493312/VBfsPlff_400x400.jpg';
@@ -31,4 +24,4 @@ const profile = 'https://pbs.twimg.com/profile_images/641289584580493312/VBfsPlf
module.exports = {
profile,
selectData
-};
\ No newline at end of file
+};
diff --git a/ui/src/shared/functions.js b/ui/src/shared/functions.js
index 45a2227e..077d4c89 100644
--- a/ui/src/shared/functions.js
+++ b/ui/src/shared/functions.js
@@ -1,6 +1,10 @@
const calc = require('reduce-css-calc');
const randomNatural = require('random-natural');
+const pathToFont = './fonts/';
+const remBase = 16;
+const unitBase = 6;
+
// from https://github.com/styled-components/styled-components/blob/065001c725744629c7870240e4a955b924ef5337/src/utils/generateAlphabeticName.js
const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
const rndId = (_code) => {
@@ -14,52 +18,51 @@ const rndId = (_code) => {
: lastDigit;
};
-const generateFonts = (fonts) => {
- const pathToFont = './fonts/';
- let fontCSS = '';
+const remcalc = (...values) => values.map((value) => (
+ `${String(value).replace('px', '') / remBase}rem`
+)).join(' ');
- fonts.forEach((obj) => {
- const eot = require(`${pathToFont + obj.filename}.eot`);
- const woff = require(`${pathToFont + obj.filename}.woff`);
- const woff2 = require(`${pathToFont + obj.filename}.woff2`);
- const ttf = require(`${pathToFont + obj.filename}.ttf`);
- const svg = require(`${pathToFont + obj.filename}.svg`);
- fontCSS += `
- @font-face {
- font-family: '${obj.family}';
- src: url('${eot}'),
- url('${eot}?#iefix')
- format('embedded-opentype'),
- url('${woff}')
- format('woff'),
- url('${woff2}')
- format('woff2'),
- url('${ttf}')
- format('truetype'),
- url('${svg}#${obj.family}')
- format('svg');
- font-weight: ${obj.weight};
- font-style: ${obj.style};
- }
- `;
- });
- return fontCSS;
-};
+const unitcalc = (...values) => values.map(
+ (value) => remcalc(value * unitBase)
+);
+
+const generateFonts = (fonts) => fonts.reduce((sum, {
+ filename,
+ family,
+ style,
+ weight
+}) => {
+ const eot = require(`${pathToFont + filename}.eot`);
+ const woff = require(`${pathToFont + filename}.woff`);
+ const woff2 = require(`${pathToFont + filename}.woff2`);
+ const ttf = require(`${pathToFont + filename}.ttf`);
+ const svg = require(`${pathToFont + filename}.svg`);
+
+ sum += `
+ @font-face {
+ font-family: '${family}';
+ src: url('${eot}'),
+ url('${eot}?#iefix')
+ format('embedded-opentype'),
+ url('${woff}')
+ format('woff'),
+ url('${woff2}')
+ format('woff2'),
+ url('${ttf}')
+ format('truetype'),
+ url('${svg}#${family}')
+ format('svg');
+ font-weight: ${weight};
+ font-style: ${style};
+ }
+ `;
+
+ return sum;
+});
module.exports = {
- remcalc: (values) => {
- values = values.toString().replace('px', '').split(' ');
-
- let outputRems = '';
- const base = 16;
-
- values.forEach( (value, i) => {
- const remValue = value / base;
- outputRems += i === 0 ? `${remValue}rem` : ` ${remValue}rem`;
- });
-
- return outputRems;
- },
+ unitcalc: unitcalc,
+ remcalc: remcalc,
calc: (str) => calc(`calc(${str})`),
rndId,
generateFonts
diff --git a/ui/yarn.lock b/ui/yarn.lock
index 7743ee48..f804c479 100644
--- a/ui/yarn.lock
+++ b/ui/yarn.lock
@@ -1496,6 +1496,13 @@ callsites@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca"
+camel-case:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/camel-case/-/camel-case-3.0.0.tgz#ca3c3688a4e9cf3a4cda777dc4dcbc713249cf73"
+ dependencies:
+ no-case "^2.2.0"
+ upper-case "^1.1.1"
+
camelcase-keys@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7"
@@ -6803,6 +6810,10 @@ update-notifier@^1.0.0:
semver-diff "^2.0.0"
xdg-basedir "^2.0.0"
+upper-case@^1.1.1:
+ version "1.1.3"
+ resolved "https://registry.yarnpkg.com/upper-case/-/upper-case-1.1.3.tgz#f6b4501c2ec4cdd26ba78be7222961de77621598"
+
url-loader@^0.5.7:
version "0.5.7"
resolved "https://registry.yarnpkg.com/url-loader/-/url-loader-0.5.7.tgz#67e8779759f8000da74994906680c943a9b0925d"