Skip to content

Commit

Permalink
refactor :: VStack
Browse files Browse the repository at this point in the history
  • Loading branch information
dutexion committed Sep 11, 2024
1 parent b883750 commit 64b5ea4
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/components/Layouts/VStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,28 @@ import styled from '@emotion/styled';
interface IProps extends IChildren {
widthFit?: boolean;
gap?: number;
justify?: 'left' | 'center' | 'right';
}

export const VStack = ({ children, widthFit = true, gap = 0 }: IProps) => (
<Wrapper widthFit={widthFit} gap={gap}>
export const VStack = ({ children, widthFit = true, gap = 0, justify = 'center' }: IProps) => (
<Wrapper widthFit={widthFit} gap={gap} justify={justify}>
{children}
</Wrapper>
);

const Wrapper = styled.div<Pick<IProps, 'widthFit' | 'gap'>>`
const Wrapper = styled.div<Omit<IProps, 'children'>>`
display: flex;
flex-direction: column;
align-items: center;
align-items: ${({ justify }) => {
switch (justify) {
case 'left':
return 'start';
case 'right':
return 'end';
default:
return 'center';
}
}};
justify-content: flex-start;
gap: ${({ gap }) => `${gap}px`};
width: ${({ widthFit }) => (widthFit ? '100%' : 'auto')};
Expand Down

0 comments on commit 64b5ea4

Please sign in to comment.