Skip to content

Commit

Permalink
fix(Flex): extend Box for easier styling
Browse files Browse the repository at this point in the history
  • Loading branch information
LexSwed committed Oct 31, 2020
1 parent d726436 commit fd77ffb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/lib/Box/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const Box: React.FC<Props> = ({ children, css, ...props }) => {
),
Object.values(props) //eslint-disable-line
);

return <Div css={Object.assign(style, css)} {...attrs} children={children} />;
};

Expand Down
5 changes: 3 additions & 2 deletions src/lib/Flex/Flex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import React from 'react';
import { StitchesProps, StitchesVariants } from '@stitches/react';
import { styled } from '../stitches.config';
import { gaps } from '../theme/variants';
import Box from '../Box';

const FlexBox = styled('div', {
const FlexBox = styled(Box, {
display: 'flex',

variants: {
Expand Down Expand Up @@ -81,7 +82,7 @@ const FlexBox = styled('div', {

const Flex = React.forwardRef<
HTMLDivElement,
React.ComponentProps<typeof FlexBox> & { as?: keyof JSX.IntrinsicElements }
React.ComponentProps<typeof FlexBox> & { as?: keyof JSX.IntrinsicElements | React.ReactElement }
>(({ space = 'none', flow = 'column', wrap = 'nowrap', main = 'start', cross = 'start', ...props }, ref) => (
<FlexBox space={space} flow={flow} wrap={wrap} main={main} cross={cross} {...props} ref={ref} />
));
Expand Down
10 changes: 10 additions & 0 deletions src/pages/components/Flex.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ import { ExampleBox } from '../../pages-helpers';

# Flex

A `Box` with `flex` shorthands alignment properties.

<Playground>
<Flex width="200px" bc="$orange050" cross="center" space="sm">
<ExampleBox />
<ExampleBox />
<ExampleBox />
</Flex>
</Playground>

## Space

Define gap between elements via `space` prop:
Expand Down

1 comment on commit fd77ffb

@vercel
Copy link

@vercel vercel bot commented on fd77ffb Oct 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.