Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update Box styled-system props and their types
BREAKING CHANGE removes boxSizing properties from the supported styled-system props on the Box component.
- Loading branch information
1 parent
a61c6ed
commit 1e05962
Showing
12 changed files
with
348 additions
and
211 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,18 @@ | ||
import { ComponentPropsWithRef } from "react"; | ||
import styled from "styled-components"; | ||
import { motion, MotionProps } from "framer-motion"; | ||
import { | ||
color, | ||
space, | ||
layout, | ||
border, | ||
boxShadow, | ||
textAlign, | ||
order, | ||
flexbox, | ||
flexGrow, | ||
position, | ||
background, | ||
overflow, | ||
ColorProps, | ||
SpaceProps, | ||
LayoutProps, | ||
BoxShadowProps, | ||
TextAlignProps, | ||
OrderProps, | ||
FlexGrowProps, | ||
PositionProps, | ||
BorderProps, | ||
FlexboxProps, | ||
BackgroundProps, | ||
OverflowProps, | ||
typography, | ||
} from "styled-system"; | ||
import { TypographyProps } from "styled-system"; | ||
import { transition, TransitionProps } from "../StyledProps/transition"; | ||
import { transform, TransformProps } from "../StyledProps/transform"; | ||
import { CursorProps, cursor } from "../StyledProps/cursor"; | ||
import { VisibilityProps, visibility } from "../StyledProps/visibility"; | ||
import { ThemeType } from "../theme.type"; | ||
import { addStyledProps, StyledProps } from "../StyledProps"; | ||
|
||
type SharedBoxProps = ColorProps & | ||
SpaceProps & | ||
LayoutProps & | ||
BoxShadowProps & | ||
TextAlignProps & | ||
OrderProps & | ||
FlexGrowProps & | ||
PositionProps & | ||
BorderProps & | ||
FlexboxProps & | ||
BackgroundProps & | ||
TransformProps & | ||
CursorProps & | ||
VisibilityProps & | ||
OverflowProps & | ||
TypographyProps & { | ||
boxSizing?: string; | ||
}; | ||
export interface BoxProps extends StyledProps, ComponentPropsWithRef<"div"> { | ||
as?: React.ElementType; | ||
} | ||
|
||
type CssArg = { | ||
theme: ThemeType; | ||
}; | ||
export type BoxProps = SharedBoxProps & | ||
TransitionProps & | ||
React.ComponentPropsWithRef<"div"> & { | ||
as?: string; | ||
css?: (props: CssArg) => any; | ||
}; | ||
const Box = styled.div<BoxProps>(addStyledProps); | ||
|
||
const Box: React.FC<BoxProps> = styled.div( | ||
color, | ||
space, | ||
layout, | ||
border, | ||
boxShadow, | ||
textAlign, | ||
order, | ||
flexbox, | ||
flexGrow, | ||
position, | ||
background, | ||
transform, | ||
cursor, | ||
overflow, | ||
transition, | ||
visibility, | ||
typography | ||
); | ||
export interface AnimatedBoxProps | ||
extends MotionProps, | ||
Omit<BoxProps, "onAnimationStart" | "onDrag" | "onDragStart" | "onDragEnd" | "style" | "transition"> {} | ||
|
||
export type AnimatedBoxProps = SharedBoxProps & | ||
MotionProps & { | ||
role?: string; | ||
ref?: any; | ||
onClick?: (event: React.MouseEvent<any>) => void; | ||
onMouseEnter?: (event: React.MouseEvent<any>) => void; | ||
onMouseOut?: (event: React.MouseEvent<any>) => void; | ||
onMouseDown?: (event: React.MouseEvent<any>) => void; | ||
}; | ||
|
||
export const AnimatedBox: React.FC<AnimatedBoxProps> = styled(motion.div)( | ||
color, | ||
space, | ||
layout, | ||
border, | ||
boxShadow, | ||
textAlign, | ||
order, | ||
flexbox, | ||
flexGrow, | ||
position, | ||
background, | ||
transform, | ||
cursor, | ||
overflow, | ||
visibility, | ||
typography | ||
); | ||
export const AnimatedBox = styled(motion.div)<AnimatedBoxProps>(addStyledProps); | ||
|
||
export default Box; |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.