Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Commit

Permalink
feat(Box): Add new size styleProps (width, height)
Browse files Browse the repository at this point in the history
Including max/min variants (minHeight, maxHeight, minWidth, maxWidth)
  • Loading branch information
diondiondion committed Feb 27, 2020
1 parent 3c11198 commit 4ab2bc4
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/Box/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
positionProps,
displayProps,
flexItemProps,
sizeProps,
marginProps,
paddingProps,
borderProps,
Expand All @@ -15,6 +16,7 @@ const Box = styled.div`
${positionProps}
${displayProps}
${flexItemProps}
${sizeProps}
${marginProps}
${paddingProps}
${borderProps}
Expand All @@ -30,6 +32,36 @@ Box.propTypes = {
PropTypes.oneOf(['block', 'inline', 'inline-block']),
PropTypes.array,
]),
width: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
PropTypes.array,
]),
maxWidth: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
PropTypes.array,
]),
minWidth: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
PropTypes.array,
]),
height: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
PropTypes.array,
]),
maxHeight: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
PropTypes.array,
]),
minHeight: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
PropTypes.array,
]),
border: PropTypes.oneOfType([
PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
PropTypes.array,
Expand Down
2 changes: 2 additions & 0 deletions src/styleProps/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import borderProps from './borderProps';
import displayProps from './displayProps';
import flexItemProps from './flexItemProps';
import sizeProps from './sizeProps';
import paddingProps from './paddingProps';
import positionProps from './positionProps';
import marginProps from './marginProps';
Expand All @@ -10,6 +11,7 @@ export {
borderProps,
displayProps,
flexItemProps,
sizeProps,
paddingProps,
positionProps,
marginProps,
Expand Down
31 changes: 31 additions & 0 deletions src/styleProps/sizeProps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {createStyleFunction} from '../utils/styleProps';
import {getLength} from '../utils';

const sizeProps = createStyleFunction([
{
styleProp: 'width',
getValue: getLength,
},
{
styleProp: 'maxWidth',
getValue: getLength,
},
{
styleProp: 'minWidth',
getValue: getLength,
},
{
styleProp: 'height',
getValue: getLength,
},
{
styleProp: 'maxHeight',
getValue: getLength,
},
{
styleProp: 'minHeight',
getValue: getLength,
},
]);

export default sizeProps;

0 comments on commit 4ab2bc4

Please sign in to comment.