diff --git a/src/components/flex/theme.css b/src/components/flex/theme.css
index cde92cb47..3c3b6e9ff 100644
--- a/src/components/flex/theme.css
+++ b/src/components/flex/theme.css
@@ -4,6 +4,8 @@
.flex {
box-sizing: border-box;
display: flex;
+ background-color: black;
+ height: 200px;
}
.row {
@@ -21,3 +23,9 @@
gap: $spacer;
}
}
+
+@each $item-alignment in (center, flex-start, flex-end, baseline, stretch) {
+ .align-items-$(item-alignment) {
+ align-items: $item-alignment;
+ }
+}
From 7966f84c4c41b1673dd1711e32bc9f2819e45854 Mon Sep 17 00:00:00 2001
From: Faraz <78449551+farazatarodi@users.noreply.github.com>
Date: Tue, 31 May 2022 22:17:53 +0200
Subject: [PATCH 09/19] :sparkles: add style property to Flex component
---
src/components/flex/Flex.tsx | 7 ++++---
src/components/flex/flex.stories.tsx | 23 +++++++++++++++++------
src/components/flex/theme.css | 2 --
3 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/src/components/flex/Flex.tsx b/src/components/flex/Flex.tsx
index 40f7af7a2..3e00c691a 100644
--- a/src/components/flex/Flex.tsx
+++ b/src/components/flex/Flex.tsx
@@ -1,4 +1,4 @@
-import React, { ReactNode } from 'react';
+import React, { CSSProperties, ReactNode } from 'react';
import cx from 'classnames';
import theme from './theme.css';
@@ -9,16 +9,17 @@ interface FlexProps {
direction?: 'row' | 'column';
gap?: Gap;
alignItems?: 'center' | 'flex-start' | 'flex-end' | 'baseline' | 'stretch';
+ style?: CSSProperties;
}
-const Flex = ({ children, direction = 'row', gap = 0, alignItems, ...otherProps }: FlexProps) => {
+const Flex = ({ children, direction = 'row', gap = 0, alignItems, style, ...otherProps }: FlexProps) => {
const classNames = cx(theme['flex'], theme[`${direction}`], {
[theme[`gap-${gap}`]]: gap > 0,
[theme[`align-items-${alignItems}`]]: alignItems,
});
return (
-
+
{children}
);
diff --git a/src/components/flex/flex.stories.tsx b/src/components/flex/flex.stories.tsx
index b8362d30b..73b1eb930 100644
--- a/src/components/flex/flex.stories.tsx
+++ b/src/components/flex/flex.stories.tsx
@@ -6,25 +6,36 @@ import { Flex, Box, TextBody } from '../../index';
export default {
component: Flex,
title: addStoryInGroup(LOW_LEVEL_BLOCKS, 'Flex'),
+
+ argTypes: {
+ style: {
+ table: {
+ disable: true,
+ },
+ },
+ },
};
const PreppedBox = () => (
Box Content
);
export const basic: ComponentStory
= (args) => (
-
-
-
-
+
+
+
+
+
+
);
basic.args = {
diff --git a/src/components/flex/theme.css b/src/components/flex/theme.css
index 3c3b6e9ff..6928fc7d0 100644
--- a/src/components/flex/theme.css
+++ b/src/components/flex/theme.css
@@ -4,8 +4,6 @@
.flex {
box-sizing: border-box;
display: flex;
- background-color: black;
- height: 200px;
}
.row {
From 551b51a81ea58efd203696febaa19b6fab38cb7a Mon Sep 17 00:00:00 2001
From: Faraz <78449551+farazatarodi@users.noreply.github.com>
Date: Tue, 31 May 2022 22:48:12 +0200
Subject: [PATCH 10/19] :sparkles: add justifyContent property to Flex
component
---
src/components/flex/Flex.tsx | 14 +++++++++++++-
src/components/flex/flex.stories.tsx | 17 +++++++++++------
src/components/flex/theme.css | 6 ++++++
3 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/src/components/flex/Flex.tsx b/src/components/flex/Flex.tsx
index 3e00c691a..0e42a8c5a 100644
--- a/src/components/flex/Flex.tsx
+++ b/src/components/flex/Flex.tsx
@@ -9,13 +9,23 @@ interface FlexProps {
direction?: 'row' | 'column';
gap?: Gap;
alignItems?: 'center' | 'flex-start' | 'flex-end' | 'baseline' | 'stretch';
+ justifyContent?: 'center' | 'flex-start' | 'flex-end' | 'space-around' | 'space-between' | 'space-evenly';
style?: CSSProperties;
}
-const Flex = ({ children, direction = 'row', gap = 0, alignItems, style, ...otherProps }: FlexProps) => {
+const Flex = ({
+ children,
+ direction = 'row',
+ gap = 0,
+ alignItems,
+ justifyContent,
+ style,
+ ...otherProps
+}: FlexProps) => {
const classNames = cx(theme['flex'], theme[`${direction}`], {
[theme[`gap-${gap}`]]: gap > 0,
[theme[`align-items-${alignItems}`]]: alignItems,
+ [theme[`justify-content-${justifyContent}`]]: justifyContent,
});
return (
@@ -25,4 +35,6 @@ const Flex = ({ children, direction = 'row', gap = 0, alignItems, style, ...othe
);
};
+Flex.displayName = 'Flex';
+
export default Flex;
diff --git a/src/components/flex/flex.stories.tsx b/src/components/flex/flex.stories.tsx
index 73b1eb930..eebb9df7e 100644
--- a/src/components/flex/flex.stories.tsx
+++ b/src/components/flex/flex.stories.tsx
@@ -2,6 +2,7 @@ import { ComponentStory } from '@storybook/react';
import React from 'react';
import { addStoryInGroup, LOW_LEVEL_BLOCKS } from '../../../.storybook/utils';
import { Flex, Box, TextBody } from '../../index';
+import { Heading3 } from '../typography';
export default {
component: Flex,
@@ -26,15 +27,19 @@ const PreppedBox = () => (
padding={2}
borderRadius="rounded"
>
- Box Content
+ Content
);
export const basic: ComponentStory = (args) => (
-
-
-
-
-
+
+ Flex Box
+
+
+
+
+
+
+
);
diff --git a/src/components/flex/theme.css b/src/components/flex/theme.css
index 6928fc7d0..bff2acfe9 100644
--- a/src/components/flex/theme.css
+++ b/src/components/flex/theme.css
@@ -27,3 +27,9 @@
align-items: $item-alignment;
}
}
+
+@each $justify in (center, flex-start, flex-end, space-around, space-between, space-evenly) {
+ .justify-content-$(justify) {
+ justify-content: $justify;
+ }
+}
From bc61c15a3d201d884808546e45e8dbcba9f0888e Mon Sep 17 00:00:00 2001
From: Faraz <78449551+farazatarodi@users.noreply.github.com>
Date: Tue, 31 May 2022 22:52:57 +0200
Subject: [PATCH 11/19] :label: expand Flex prop types
---
src/components/flex/Flex.tsx | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/components/flex/Flex.tsx b/src/components/flex/Flex.tsx
index 0e42a8c5a..3ccac4b71 100644
--- a/src/components/flex/Flex.tsx
+++ b/src/components/flex/Flex.tsx
@@ -1,17 +1,20 @@
-import React, { CSSProperties, ReactNode } from 'react';
+import React, { CSSProperties, HTMLProps, ReactNode } from 'react';
import cx from 'classnames';
import theme from './theme.css';
const gaps = [0, 1, 2, 3, 4, 5, 6, 7, 8] as const;
export type Gap = typeof gaps[number];
-interface FlexProps {
- children: ReactNode;
- direction?: 'row' | 'column';
- gap?: Gap;
- alignItems?: 'center' | 'flex-start' | 'flex-end' | 'baseline' | 'stretch';
- justifyContent?: 'center' | 'flex-start' | 'flex-end' | 'space-around' | 'space-between' | 'space-evenly';
- style?: CSSProperties;
-}
+
+type FlexProps = Partial<
+ {
+ children: ReactNode;
+ direction: 'row' | 'column';
+ gap: Gap;
+ alignItems: 'center' | 'flex-start' | 'flex-end' | 'baseline' | 'stretch';
+ justifyContent: 'center' | 'flex-start' | 'flex-end' | 'space-around' | 'space-between' | 'space-evenly';
+ style: CSSProperties;
+ } & HTMLProps
+>;
const Flex = ({
children,
From da8ddb3b698fe2787da0795ea5fcfa4d27d4aa38 Mon Sep 17 00:00:00 2001
From: Faraz <78449551+farazatarodi@users.noreply.github.com>
Date: Wed, 1 Jun 2022 10:22:04 +0200
Subject: [PATCH 12/19] :fire: remove extra properties from Flex component
---
src/components/flex/Flex.tsx | 35 ++++++++--------------------
src/components/flex/flex.stories.tsx | 21 +++++++++--------
2 files changed, 21 insertions(+), 35 deletions(-)
diff --git a/src/components/flex/Flex.tsx b/src/components/flex/Flex.tsx
index 3ccac4b71..25fb4db88 100644
--- a/src/components/flex/Flex.tsx
+++ b/src/components/flex/Flex.tsx
@@ -1,41 +1,26 @@
-import React, { CSSProperties, HTMLProps, ReactNode } from 'react';
+import React, { ReactNode } from 'react';
import cx from 'classnames';
import theme from './theme.css';
const gaps = [0, 1, 2, 3, 4, 5, 6, 7, 8] as const;
export type Gap = typeof gaps[number];
-type FlexProps = Partial<
- {
- children: ReactNode;
- direction: 'row' | 'column';
- gap: Gap;
- alignItems: 'center' | 'flex-start' | 'flex-end' | 'baseline' | 'stretch';
- justifyContent: 'center' | 'flex-start' | 'flex-end' | 'space-around' | 'space-between' | 'space-evenly';
- style: CSSProperties;
- } & HTMLProps
->;
+type FlexProps = Partial<{
+ children: ReactNode;
+ direction: 'row' | 'column';
+ gap: Gap;
+ alignItems: 'center' | 'flex-start' | 'flex-end' | 'baseline' | 'stretch';
+ justifyContent: 'center' | 'flex-start' | 'flex-end' | 'space-around' | 'space-between' | 'space-evenly';
+}>;
-const Flex = ({
- children,
- direction = 'row',
- gap = 0,
- alignItems,
- justifyContent,
- style,
- ...otherProps
-}: FlexProps) => {
+const Flex = ({ children, direction = 'row', gap = 0, alignItems, justifyContent }: FlexProps) => {
const classNames = cx(theme['flex'], theme[`${direction}`], {
[theme[`gap-${gap}`]]: gap > 0,
[theme[`align-items-${alignItems}`]]: alignItems,
[theme[`justify-content-${justifyContent}`]]: justifyContent,
});
- return (
-
- {children}
-
- );
+ return {children}
;
};
Flex.displayName = 'Flex';
diff --git a/src/components/flex/flex.stories.tsx b/src/components/flex/flex.stories.tsx
index eebb9df7e..7b59e59c5 100644
--- a/src/components/flex/flex.stories.tsx
+++ b/src/components/flex/flex.stories.tsx
@@ -1,7 +1,7 @@
import { ComponentStory } from '@storybook/react';
import React from 'react';
import { addStoryInGroup, LOW_LEVEL_BLOCKS } from '../../../.storybook/utils';
-import { Flex, Box, TextBody } from '../../index';
+import { Flex, Box } from '../../index';
import { Heading3 } from '../typography';
export default {
@@ -17,27 +17,28 @@ export default {
},
};
-const PreppedBox = () => (
+const MintBox = ({ size }: { size: number }) => (
- Content
-
+ style={{
+ minHeight: `${size / 2}px`,
+ width: `${size}px`,
+ }}
+ />
);
export const basic: ComponentStory = (args) => (
Flex Box
-
-
-
-
+
+
+
+
From e25d9b35f4f00d7dcb0e9bac71fd6ccddcda6bad Mon Sep 17 00:00:00 2001
From: Faraz <78449551+farazatarodi@users.noreply.github.com>
Date: Wed, 1 Jun 2022 11:31:04 +0200
Subject: [PATCH 13/19] :recycle: move properties from class names to inline
styles
---
src/components/flex/Flex.tsx | 16 +++++++++++-----
src/components/flex/theme.css | 12 ------------
2 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/src/components/flex/Flex.tsx b/src/components/flex/Flex.tsx
index 25fb4db88..fa2d0e5df 100644
--- a/src/components/flex/Flex.tsx
+++ b/src/components/flex/Flex.tsx
@@ -2,13 +2,15 @@ import React, { ReactNode } from 'react';
import cx from 'classnames';
import theme from './theme.css';
-const gaps = [0, 1, 2, 3, 4, 5, 6, 7, 8] as const;
-export type Gap = typeof gaps[number];
+type Gap = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
type FlexProps = Partial<{
children: ReactNode;
direction: 'row' | 'column';
gap: Gap;
+ // Ideally CSSProperties should be used as the type.
+ // However because of the two-value sytnax of these properties the type includes (string & {}) which is not suitable for us.
+ // The library can be fixed with template literal types.
alignItems: 'center' | 'flex-start' | 'flex-end' | 'baseline' | 'stretch';
justifyContent: 'center' | 'flex-start' | 'flex-end' | 'space-around' | 'space-between' | 'space-evenly';
}>;
@@ -16,11 +18,15 @@ type FlexProps = Partial<{
const Flex = ({ children, direction = 'row', gap = 0, alignItems, justifyContent }: FlexProps) => {
const classNames = cx(theme['flex'], theme[`${direction}`], {
[theme[`gap-${gap}`]]: gap > 0,
- [theme[`align-items-${alignItems}`]]: alignItems,
- [theme[`justify-content-${justifyContent}`]]: justifyContent,
});
- return {children}
;
+ const flexStyles = { alignItems, justifyContent };
+
+ return (
+
+ {children}
+
+ );
};
Flex.displayName = 'Flex';
diff --git a/src/components/flex/theme.css b/src/components/flex/theme.css
index bff2acfe9..cde92cb47 100644
--- a/src/components/flex/theme.css
+++ b/src/components/flex/theme.css
@@ -21,15 +21,3 @@
gap: $spacer;
}
}
-
-@each $item-alignment in (center, flex-start, flex-end, baseline, stretch) {
- .align-items-$(item-alignment) {
- align-items: $item-alignment;
- }
-}
-
-@each $justify in (center, flex-start, flex-end, space-around, space-between, space-evenly) {
- .justify-content-$(justify) {
- justify-content: $justify;
- }
-}
From 779f8935de5909cb59fba744a8e45ac7aef5c208 Mon Sep 17 00:00:00 2001
From: Faraz <78449551+farazatarodi@users.noreply.github.com>
Date: Wed, 1 Jun 2022 11:53:24 +0200
Subject: [PATCH 14/19] :memo: add nesting story
---
src/components/flex/flex.stories.tsx | 72 ++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/src/components/flex/flex.stories.tsx b/src/components/flex/flex.stories.tsx
index 7b59e59c5..32e39c490 100644
--- a/src/components/flex/flex.stories.tsx
+++ b/src/components/flex/flex.stories.tsx
@@ -31,6 +31,7 @@ const MintBox = ({ size }: { size: number }) => (
}}
/>
);
+
export const basic: ComponentStory = (args) => (
Flex Box
@@ -48,3 +49,74 @@ basic.args = {
direction: 'row',
gap: 0,
};
+
+export const nesting: ComponentStory = () => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+);
From 32ca9b4a048828c0f27ac4fac3be7cda693768ac Mon Sep 17 00:00:00 2001
From: Faraz <78449551+farazatarodi@users.noreply.github.com>
Date: Wed, 1 Jun 2022 12:01:28 +0200
Subject: [PATCH 15/19] :sparkles: forward ref in Flex component
---
src/components/flex/Flex.tsx | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/components/flex/Flex.tsx b/src/components/flex/Flex.tsx
index fa2d0e5df..705cebd33 100644
--- a/src/components/flex/Flex.tsx
+++ b/src/components/flex/Flex.tsx
@@ -1,4 +1,4 @@
-import React, { ReactNode } from 'react';
+import React, { ForwardedRef, forwardRef, ReactNode } from 'react';
import cx from 'classnames';
import theme from './theme.css';
@@ -13,9 +13,10 @@ type FlexProps = Partial<{
// The library can be fixed with template literal types.
alignItems: 'center' | 'flex-start' | 'flex-end' | 'baseline' | 'stretch';
justifyContent: 'center' | 'flex-start' | 'flex-end' | 'space-around' | 'space-between' | 'space-evenly';
+ ref: ForwardedRef;
}>;
-const Flex = ({ children, direction = 'row', gap = 0, alignItems, justifyContent }: FlexProps) => {
+const Flex = forwardRef(({ children, direction = 'row', gap = 0, alignItems, justifyContent, ref }: FlexProps) => {
const classNames = cx(theme['flex'], theme[`${direction}`], {
[theme[`gap-${gap}`]]: gap > 0,
});
@@ -23,11 +24,11 @@ const Flex = ({ children, direction = 'row', gap = 0, alignItems, justifyContent
const flexStyles = { alignItems, justifyContent };
return (
-
+
{children}
);
-};
+});
Flex.displayName = 'Flex';
From a28283375bb65578b98200554ae60cc01090c1cd Mon Sep 17 00:00:00 2001
From: Faraz <78449551+farazatarodi@users.noreply.github.com>
Date: Wed, 1 Jun 2022 13:57:43 +0200
Subject: [PATCH 16/19] :fire: remove redundant UI color import
---
src/components/flex/theme.css | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/components/flex/theme.css b/src/components/flex/theme.css
index cde92cb47..b8583bb02 100644
--- a/src/components/flex/theme.css
+++ b/src/components/flex/theme.css
@@ -1,4 +1,3 @@
-@import '@teamleader/ui-colors';
@import '@teamleader/ui-utilities';
.flex {
From 234d658dccb8e95ff7b317e06a1c2d75bdd76bc9 Mon Sep 17 00:00:00 2001
From: Faraz <78449551+farazatarodi@users.noreply.github.com>
Date: Wed, 1 Jun 2022 13:59:18 +0200
Subject: [PATCH 17/19] :fire: remove redundant storybook style control disable
---
src/components/flex/flex.stories.tsx | 8 --------
1 file changed, 8 deletions(-)
diff --git a/src/components/flex/flex.stories.tsx b/src/components/flex/flex.stories.tsx
index 32e39c490..fb21b83b9 100644
--- a/src/components/flex/flex.stories.tsx
+++ b/src/components/flex/flex.stories.tsx
@@ -7,14 +7,6 @@ import { Heading3 } from '../typography';
export default {
component: Flex,
title: addStoryInGroup(LOW_LEVEL_BLOCKS, 'Flex'),
-
- argTypes: {
- style: {
- table: {
- disable: true,
- },
- },
- },
};
const MintBox = ({ size }: { size: number }) => (
From 179eb9f2e6ac38b2dc5e01148fc454dc00f5ff2a Mon Sep 17 00:00:00 2001
From: Faraz <78449551+farazatarodi@users.noreply.github.com>
Date: Wed, 1 Jun 2022 15:51:14 +0200
Subject: [PATCH 18/19] :memo: update changelog
---
CHANGELOG.md | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5ed9531da..bbd48be58 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,12 @@
### Dependency updates
+## [14.6.0]
+
+### Added
+
+- `Flex`: a new component used for layouts ([@farazatarodi](https://github.com/farazatarodi) in [#2185](https://github.com/teamleadercrm/ui/pull/2185))
+
## [14.5.7] - 2022-05-26
### Fixed
From 55de2e4bd8fffb3de7468bca3fb3febeac7c3cc7 Mon Sep 17 00:00:00 2001
From: Faraz <78449551+farazatarodi@users.noreply.github.com>
Date: Wed, 1 Jun 2022 15:57:45 +0200
Subject: [PATCH 19/19] :memo: move changes to unreleased
---
CHANGELOG.md | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bbd48be58..62d46884c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
### Added
+- `Flex`: a new component used for layouts ([@farazatarodi](https://github.com/farazatarodi) in [#2185](https://github.com/teamleadercrm/ui/pull/2185))
+
### Changed
### Deprecated
@@ -12,12 +14,6 @@
### Dependency updates
-## [14.6.0]
-
-### Added
-
-- `Flex`: a new component used for layouts ([@farazatarodi](https://github.com/farazatarodi) in [#2185](https://github.com/teamleadercrm/ui/pull/2185))
-
## [14.5.7] - 2022-05-26
### Fixed