-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9b9157
commit ffc440a
Showing
8 changed files
with
116 additions
and
103 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// @flow | ||
import memoizeOne from 'memoize-one'; | ||
import type { Spacing, Box } from 'css-box-model'; | ||
import type { BoxSpacing, BoxSizing } from '../types'; | ||
|
||
export const withBoxSpacing = memoizeOne((box: Spacing): BoxSpacing => ({ | ||
paddingTop: box.padding.top, | ||
paddingRight: box.padding.right, | ||
paddingBottom: box.padding.bottom, | ||
paddingLeft: box.padding.left, | ||
marginTop: box.margin.top, | ||
marginRight: box.margin.right, | ||
marginBottom: box.margin.bottom, | ||
marginLeft: box.margin.left, | ||
borderTopWidth: box.border.top, | ||
borderRightWidth: box.border.right, | ||
borderBottomWidth: box.border.bottom, | ||
borderLeftWidth: box.border.left, | ||
})); | ||
|
||
type WidthAndHeight = {| | ||
width: number, | ||
height: number, | ||
|} | ||
|
||
export const getBoxSizingHeightAndWidth = memoizeOne((box: Box, boxSizing: BoxSizing): WidthAndHeight => { | ||
const isBorderBox: boolean = boxSizing === 'border-box'; | ||
const width: number = isBorderBox ? box.borderBox.width : box.contentBox.width; | ||
const height: number = isBorderBox ? box.borderBox.height : box.contentBox.height; | ||
|
||
return { width, height }; | ||
}); |
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
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