Skip to content

Commit

Permalink
feat(atoms): add offsets to the FlexLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
ej9x committed Aug 23, 2018
1 parent 89c6cb6 commit 494ab53
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/atoms/FlexLayout/FlexLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export type FlexLayoutCommonProps = {|
gap?: PropSizes,
offsetX?: PropSizes,
offsetY?: PropSizes,
offsetTop?: PropSizes,
offsetBottom?: PropSizes,
offsetLeft?: PropSizes,
offsetRight?: PropSizes,
cursor?: 'pointer' | 'default' | 'inherit',
stretch?: boolean,
grow?: boolean,
Expand Down
21 changes: 13 additions & 8 deletions src/atoms/FlexLayout/FlexLayout.theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { createStyledTag } from '../../utils';

const name = 'flex-layout';

const offestSizes = {
const paddingSizes = {
none: '0',
xs: '0.5rem',
sm: '1rem',
md: '1.5rem',
lg: '2rem',
xl: '2.5rem',
xl: '3rem',
};

const gapSizes = {
Expand All @@ -19,7 +19,7 @@ const gapSizes = {
sm: '1rem',
md: '1.5rem',
lg: '2rem',
xl: '2.5rem',
xl: '3rem',
};

const justifyContentStyles = {
Expand Down Expand Up @@ -73,6 +73,11 @@ const getGrowChildrenStyles = (growChildren: boolean) =>
}
: {};

const getGrowStyles = (grow: boolean) =>
grow
? { flexGrow: '1' }
: {};

const FlexLayoutTag = createStyledTag(name, props => ({
display: 'flex',

Expand All @@ -82,17 +87,17 @@ const FlexLayoutTag = createStyledTag(name, props => ({
alignContent: alignContentStyles[props.alignContent],
alignItems: alignItemsStyles[props.alignItems],

paddingLeft: offestSizes[props.offsetX],
paddingRight: offestSizes[props.offsetX],
paddingTop: offestSizes[props.offsetY],
paddingBottom: offestSizes[props.offsetY],
paddingLeft: paddingSizes[props.offsetX] || paddingSizes[props.offsetLeft],
paddingRight: paddingSizes[props.offsetX] || paddingSizes[props.offsetRight],
paddingTop: paddingSizes[props.offsetY] || paddingSizes[props.offsetTop],
paddingBottom: paddingSizes[props.offsetY] || paddingSizes[props.offsetBottom],

cursor: props.cursor,
flexGrow: props.grow && '1',

...getGapStyle(props.direction, props.gap),
...getStretchStyles(props.stretch),
...getGrowChildrenStyles(props.growChildren),
...getGrowStyles(props.grow),
}));

FlexLayoutTag.defaultProps = {
Expand Down

0 comments on commit 494ab53

Please sign in to comment.