Skip to content

Commit

Permalink
Storybook Stack: transient props
Browse files Browse the repository at this point in the history
  • Loading branch information
oddvernes committed Sep 14, 2023
1 parent 4f7d558 commit 7a1eeb4
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions packages/eds-core-react/.storybook/components/Stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,30 @@ import { styled, StyledObject } from 'styled-components'
type StackProps = {
direction?: StyledObject<any>['flexDirection']
align?: StyledObject<any>['alignItems']
children: React.ReactNode
} & React.HTMLAttributes<HTMLDivElement>

type StyledStackProps = {
$direction?: StyledObject<any>['flexDirection']
$align?: StyledObject<any>['alignItems']
}

export const Stack = styled.div<StackProps>`
const StyledStack = styled.div<StyledStackProps>`
display: flex;
flex-direction: column;
justify-content: center;
align-items: ${({ align }) => align || 'center'};
align-items: ${({ $align }) => $align || 'center'};
gap: 1rem;
flex-wrap: wrap;
@media screen and (min-width: 600px) {
flex-direction: ${({ direction }) => direction || 'row'};
flex-direction: ${({ $direction }) => $direction || 'row'};
}
`

export const Stack = ({ children, direction, align, ...rest }: StackProps) => {
return (
<StyledStack $direction={direction} $align={align} {...rest}>
{children}
</StyledStack>
)
}

0 comments on commit 7a1eeb4

Please sign in to comment.