-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Flex.Container): add
Flex.withChildren
HOC for handling wrapped…
… children with spacing (#3200)
- Loading branch information
1 parent
fe0dbef
commit 93df77c
Showing
11 changed files
with
273 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+6.67 KB
..._tests__/__image_snapshots__/flexcontainer-have-to-match-with-children.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/dnb-eufemia/src/components/flex/stories/Flex.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @dnb/eufemia Component Story | ||
* | ||
*/ | ||
|
||
import { TestElement } from '../../../extensions/forms' | ||
import Flex from '../Flex' | ||
|
||
export default { | ||
title: 'Eufemia/Components/Flex', | ||
} | ||
|
||
const Wrapper = Flex.withChildren(({ children }) => { | ||
return <div className="wrapper">{children}</div> | ||
}) | ||
|
||
export function FlexWithChildren() { | ||
return ( | ||
<Flex.Container direction="vertical"> | ||
<TestElement>FlexItem 1</TestElement> | ||
<Wrapper> | ||
<TestElement>FlexItem 2</TestElement> | ||
<TestElement>FlexItem 3</TestElement> | ||
</Wrapper> | ||
<TestElement>FlexItem 4</TestElement> | ||
</Flex.Container> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react' | ||
|
||
type WithChildrenProps = { | ||
children?: React.ReactNode | ||
} | ||
|
||
function withChildren<T>( | ||
Component: React.ComponentType<T> | ||
): React.ComponentType<T & WithChildrenProps> { | ||
Component['_supportsSpacingProps'] = 'children' | ||
return Component | ||
} | ||
|
||
export default withChildren |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters