Skip to content

Commit cd3a82a

Browse files
committed
adding defaults for createBox
1 parent 3ad5cc0 commit cd3a82a

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/index.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,25 @@ const shift = (spacing: Spacing, point: Position): Spacing => ({
113113
right: spacing.right + point.x,
114114
});
115115

116+
const noSpacing: Spacing = {
117+
top: 0,
118+
right: 0,
119+
bottom: 0,
120+
left: 0,
121+
};
122+
116123
type CreateBoxArgs = {|
117124
borderBox: AnyRectType,
118-
margin: Spacing,
119-
border: Spacing,
120-
padding: Spacing,
125+
margin?: Spacing,
126+
border?: Spacing,
127+
padding?: Spacing,
121128
|};
122129

123130
export const createBox = ({
124131
borderBox,
125-
margin,
126-
border,
127-
padding,
132+
margin = noSpacing,
133+
border = noSpacing,
134+
padding = noSpacing,
128135
}: CreateBoxArgs): BoxModel => {
129136
// marginBox = borderBox + margin
130137
const marginBox: Rect = getRect(expand(borderBox, margin));

0 commit comments

Comments
 (0)