aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/components/ui/flex.tsx
diff options
context:
space:
mode:
authorRemco Bloemen <remco@wicked.ventures>2018-11-09 01:32:40 +0800
committerRemco Bloemen <remco@wicked.ventures>2018-11-09 01:32:40 +0800
commitd71362af993d3797dbdbfcac245ad57f0086bce3 (patch)
tree888826fe23c2d06d6c9191fb3a238e14f9fe4aac /packages/instant/src/components/ui/flex.tsx
parenta5665a68756c905637c551fc48c9b7011a55c237 (diff)
parentf6abc007ffb249e4bbf85b8a7a77309d43e0a147 (diff)
downloaddexon-sol-tools-d71362af993d3797dbdbfcac245ad57f0086bce3.tar
dexon-sol-tools-d71362af993d3797dbdbfcac245ad57f0086bce3.tar.gz
dexon-sol-tools-d71362af993d3797dbdbfcac245ad57f0086bce3.tar.bz2
dexon-sol-tools-d71362af993d3797dbdbfcac245ad57f0086bce3.tar.lz
dexon-sol-tools-d71362af993d3797dbdbfcac245ad57f0086bce3.tar.xz
dexon-sol-tools-d71362af993d3797dbdbfcac245ad57f0086bce3.tar.zst
dexon-sol-tools-d71362af993d3797dbdbfcac245ad57f0086bce3.zip
Merge remote-tracking branch 'origin/development' into feature/utils/prettybignum
Diffstat (limited to 'packages/instant/src/components/ui/flex.tsx')
-rw-r--r--packages/instant/src/components/ui/flex.tsx39
1 files changed, 39 insertions, 0 deletions
diff --git a/packages/instant/src/components/ui/flex.tsx b/packages/instant/src/components/ui/flex.tsx
new file mode 100644
index 000000000..fd218b0cd
--- /dev/null
+++ b/packages/instant/src/components/ui/flex.tsx
@@ -0,0 +1,39 @@
+import { MediaChoice, stylesForMedia } from '../../style/media';
+import { ColorOption, styled } from '../../style/theme';
+import { cssRuleIfExists } from '../../style/util';
+
+export interface FlexProps {
+ direction?: 'row' | 'column';
+ flexWrap?: 'wrap' | 'nowrap';
+ justify?: 'flex-start' | 'center' | 'space-around' | 'space-between' | 'space-evenly' | 'flex-end';
+ align?: 'flex-start' | 'center' | 'space-around' | 'space-between' | 'space-evenly' | 'flex-end';
+ width?: MediaChoice;
+ height?: MediaChoice;
+ backgroundColor?: ColorOption;
+ inline?: boolean;
+ flexGrow?: number | string;
+}
+
+export const Flex =
+ styled.div <
+ FlexProps >
+ `
+ display: ${props => (props.inline ? 'inline-flex' : 'flex')};
+ flex-direction: ${props => props.direction};
+ flex-wrap: ${props => props.flexWrap};
+ ${props => cssRuleIfExists(props, 'flexGrow')}
+ justify-content: ${props => props.justify};
+ align-items: ${props => props.align};
+ background-color: ${props => (props.backgroundColor ? props.theme[props.backgroundColor] : 'none')};
+ ${props => stylesForMedia('width', props.width || 'auto')}
+ ${props => stylesForMedia('height', props.height || 'auto')}
+`;
+
+Flex.defaultProps = {
+ direction: 'row',
+ flexWrap: 'nowrap',
+ justify: 'center',
+ align: 'center',
+};
+
+Flex.displayName = 'Flex';