-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #707 from artsy/feat/flex-box
Unifies Box/Flex
- Loading branch information
Showing
7 changed files
with
41 additions
and
233 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,129 +1,18 @@ | ||
import { styled as primitives } from "../../platform/primitives" | ||
import { styledWrapper } from "../../platform/primitives" | ||
import { Box, BoxProps } from "../Box" | ||
|
||
import { | ||
alignContent, | ||
AlignContentProps, | ||
alignItems, | ||
AlignItemsProps, | ||
alignSelf, | ||
AlignSelfProps, | ||
background, | ||
BackgroundProps, | ||
borderRadius, | ||
BorderRadiusProps, | ||
bottom, | ||
BottomProps, | ||
compose, | ||
display, | ||
DisplayProps, | ||
flex, | ||
flexBasis, | ||
FlexBasisProps, | ||
flexDirection, | ||
FlexDirectionProps, | ||
FlexProps as SystemFlexProps, | ||
flexWrap, | ||
FlexWrapProps, | ||
height, | ||
HeightProps, | ||
justifyContent, | ||
JustifyContentProps, | ||
justifyItems, | ||
JustifyItemsProps, | ||
justifySelf, | ||
JustifySelfProps, | ||
maxHeight, | ||
MaxHeightProps, | ||
maxWidth, | ||
MaxWidthProps, | ||
order, | ||
OrderProps, | ||
position, | ||
PositionProps, | ||
space, | ||
SpaceProps, | ||
style, | ||
top, | ||
TopProps, | ||
width, | ||
WidthProps, | ||
zIndex, | ||
ZIndexProps, | ||
} from "styled-system" | ||
|
||
// @ts-ignore | ||
import { ClassAttributes, HTMLAttributes } from "react" | ||
|
||
const flexGrow = style({ | ||
prop: "flexGrow", | ||
}) | ||
|
||
const flexShrink = style({ | ||
prop: "flexShrink", | ||
}) | ||
|
||
export interface FlexProps | ||
extends AlignContentProps, | ||
AlignItemsProps, | ||
AlignSelfProps, | ||
BackgroundProps, | ||
BorderRadiusProps, | ||
BottomProps, | ||
DisplayProps, | ||
FlexBasisProps, | ||
FlexDirectionProps, | ||
FlexWrapProps, | ||
HeightProps, | ||
JustifyContentProps, | ||
JustifyItemsProps, | ||
JustifySelfProps, | ||
MaxHeightProps, | ||
MaxWidthProps, | ||
OrderProps, | ||
PositionProps, | ||
SpaceProps, | ||
SystemFlexProps, | ||
TopProps, | ||
WidthProps, | ||
ZIndexProps { | ||
flexGrow?: number | string | ||
flexShrink?: number | string | ||
} | ||
|
||
const flexMixin = compose( | ||
alignContent, | ||
alignItems, | ||
alignSelf, | ||
background, | ||
borderRadius, | ||
bottom, | ||
display, | ||
flex, | ||
flexBasis, | ||
flexDirection, | ||
flexWrap, | ||
height, | ||
justifyContent, | ||
justifyItems, | ||
justifySelf, | ||
maxHeight, | ||
maxWidth, | ||
order, | ||
position, | ||
space, | ||
top, | ||
width, | ||
zIndex | ||
) | ||
/** | ||
* Flex is Box with display: flex | ||
*/ | ||
export type FlexProps = BoxProps | ||
|
||
/** | ||
* A utility component that encapsulates flexbox behavior | ||
* Flex is Box with display: flex | ||
*/ | ||
export const Flex = primitives.View<FlexProps>` | ||
display: flex; | ||
${flexMixin} | ||
${flexGrow} | ||
${flexShrink} | ||
` | ||
export const Flex = styledWrapper(Box)<FlexProps>`` | ||
|
||
Flex.defaultProps = { | ||
display: "flex", | ||
} | ||
|
||
Flex.displayName = "Flex" |
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