/** * Stack system * * @author Dominique Rau [domi.github@gmail.com](mailto:domi.github@gmail.com) * @version 0.0.1 */ import * as React from 'react'; /** * Spacer */ export type SpacerProps = { spacing?: number | string; variant: 'row' | 'column' }; export const Spacer: React.FunctionComponent = props => { const width = typeof props.spacing === 'number' ? `${props.spacing}px` : props.spacing; return (
); }; /** * Stacks */ type FlexAlignType = 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline'; type FlexJustifyType = | 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly'; export type StackProps = { spacing?: number | string; padding?: number | string; margin?: number | string; flex?: boolean | number; alignItems?: FlexAlignType; justifyContent?: FlexJustifyType; variant: 'row' | 'column'; debug?: boolean; } & React.HTMLProps; export const Stack: React.FC = props => { const { children, spacing = 0, padding, margin, style, variant, alignItems, justifyContent, flex = false, debug = false, ...restProps } = props; const oldChildren = React.Children.toArray(children); const newChildren: React.ReactNode[] = []; for (let i = 0; i < oldChildren.length; i++) { newChildren.push(oldChildren[i]); if (i < oldChildren.length - 1 && spacing !== 0) { newChildren.push( ); } } return (
{newChildren}
); }; type StackVariantProps = Omit; export const VStack: React.FunctionComponent = props => ( ); export const HStack: React.FunctionComponent = props => ( );