Skip to content

Commit

Permalink
feat: add maxW, maxH, minW, minH shortcuts
Browse files Browse the repository at this point in the history
Closes #199
  • Loading branch information
gregberge committed Mar 22, 2021
1 parent 0660565 commit fde802e
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 4 deletions.
84 changes: 80 additions & 4 deletions packages/system/src/styles/sizing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type MaxWidthProp<T extends ITheme> = SystemProp<
T
>
export interface MaxWidthProps<T extends ITheme = Theme> {
// maxWidth
maxWidth?: MaxWidthProp<T>
motionSafeMaxWidth?: MaxWidthProp<T>
motionReduceMaxWidth?: MaxWidthProp<T>
Expand All @@ -91,9 +92,27 @@ export interface MaxWidthProps<T extends ITheme = Theme> {
activeMaxWidth?: MaxWidthProp<T>
disabledMaxWidth?: MaxWidthProp<T>
placeholderMaxWidth?: MaxWidthProp<T>

// maxW
maxW?: MaxWidthProp<T>
motionSafeMaxW?: MaxWidthProp<T>
motionReduceMaxW?: MaxWidthProp<T>
firstMaxW?: MaxWidthProp<T>
lastMaxW?: MaxWidthProp<T>
oddMaxW?: MaxWidthProp<T>
evenMaxW?: MaxWidthProp<T>
visitedMaxW?: MaxWidthProp<T>
checkedMaxW?: MaxWidthProp<T>
focusWithinMaxW?: MaxWidthProp<T>
hoverMaxW?: MaxWidthProp<T>
focusMaxW?: MaxWidthProp<T>
focusVisibleMaxW?: MaxWidthProp<T>
activeMaxW?: MaxWidthProp<T>
disabledMaxW?: MaxWidthProp<T>
placeholderMaxW?: MaxWidthProp<T>
}
export const maxWidth = style({
prop: 'maxWidth',
prop: ['maxWidth', 'maxW'],
themeGet: getSize,
})

Expand All @@ -102,6 +121,7 @@ type MaxHeightProp<T extends ITheme> = SystemProp<
T
>
export interface MaxHeightProps<T extends ITheme = Theme> {
// maxHeight
maxHeight?: MaxHeightProp<T>
motionSafeMaxHeight?: MaxHeightProp<T>
motionReduceMaxHeight?: MaxHeightProp<T>
Expand All @@ -118,9 +138,27 @@ export interface MaxHeightProps<T extends ITheme = Theme> {
activeMaxHeight?: MaxHeightProp<T>
disabledMaxHeight?: MaxHeightProp<T>
placeholderMaxHeight?: MaxHeightProp<T>

// maxH
maxH?: MaxWidthProp<T>
motionSafeMaxH?: MaxWidthProp<T>
motionReduceMaxH?: MaxWidthProp<T>
firstMaxH?: MaxWidthProp<T>
lastMaxH?: MaxWidthProp<T>
oddMaxH?: MaxWidthProp<T>
evenMaxH?: MaxWidthProp<T>
visitedMaxH?: MaxWidthProp<T>
checkedMaxH?: MaxWidthProp<T>
focusWithinMaxH?: MaxWidthProp<T>
hoverMaxH?: MaxWidthProp<T>
focusMaxH?: MaxWidthProp<T>
focusVisibleMaxH?: MaxWidthProp<T>
activeMaxH?: MaxWidthProp<T>
disabledMaxH?: MaxWidthProp<T>
placeholderMaxH?: MaxWidthProp<T>
}
export const maxHeight = style({
prop: 'maxHeight',
prop: ['maxHeight', 'maxH'],
themeGet: getSize,
})

Expand All @@ -129,6 +167,7 @@ type MinWidthProp<T extends ITheme> = SystemProp<
T
>
export interface MinWidthProps<T extends ITheme = Theme> {
// minWidth
minWidth?: MinWidthProp<T>
motionSafeMinWidth?: MinWidthProp<T>
motionReduceMinWidth?: MinWidthProp<T>
Expand All @@ -145,9 +184,27 @@ export interface MinWidthProps<T extends ITheme = Theme> {
activeMinWidth?: MinWidthProp<T>
disabledMinWidth?: MinWidthProp<T>
placeholderMinWidth?: MinWidthProp<T>

// minW
minW?: MaxWidthProp<T>
motionSafeMinW?: MaxWidthProp<T>
motionReduceMinW?: MaxWidthProp<T>
firstMinW?: MaxWidthProp<T>
lastMinW?: MaxWidthProp<T>
oddMinW?: MaxWidthProp<T>
evenMinW?: MaxWidthProp<T>
visitedMinW?: MaxWidthProp<T>
checkedMinW?: MaxWidthProp<T>
focusWithinMinW?: MaxWidthProp<T>
hoverMinW?: MaxWidthProp<T>
focusMinW?: MaxWidthProp<T>
focusVisibleMinW?: MaxWidthProp<T>
activeMinW?: MaxWidthProp<T>
disabledMinW?: MaxWidthProp<T>
placeholderMinW?: MaxWidthProp<T>
}
export const minWidth = style({
prop: 'minWidth',
prop: ['minWidth', 'minW'],
themeGet: getSize,
})

Expand All @@ -156,6 +213,7 @@ type MinHeightProp<T extends ITheme> = SystemProp<
T
>
export interface MinHeightProps<T extends ITheme = Theme> {
// minHeight
minHeight?: MinHeightProp<T>
motionSafeMinHeight?: MinHeightProp<T>
motionReduceMinHeight?: MinHeightProp<T>
Expand All @@ -172,9 +230,27 @@ export interface MinHeightProps<T extends ITheme = Theme> {
activeMinHeight?: MinHeightProp<T>
disabledMinHeight?: MinHeightProp<T>
placeholderMinHeight?: MinHeightProp<T>

// minH
minH?: MaxWidthProp<T>
motionSafeMinH?: MaxWidthProp<T>
motionReduceMinH?: MaxWidthProp<T>
firstMinH?: MaxWidthProp<T>
lastMinH?: MaxWidthProp<T>
oddMinH?: MaxWidthProp<T>
evenMinH?: MaxWidthProp<T>
visitedMinH?: MaxWidthProp<T>
checkedMinH?: MaxWidthProp<T>
focusWithinMinH?: MaxWidthProp<T>
hoverMinH?: MaxWidthProp<T>
focusMinH?: MaxWidthProp<T>
focusVisibleMinH?: MaxWidthProp<T>
activeMinH?: MaxWidthProp<T>
disabledMinH?: MaxWidthProp<T>
placeholderMinH?: MaxWidthProp<T>
}
export const minHeight = style({
prop: 'minHeight',
prop: ['minHeight', 'minH'],
themeGet: getSize,
})

Expand Down
1 change: 1 addition & 0 deletions website/pages/docs/sizing/max-height.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Utilities for setting the maximum height of an element.
| React props | CSS Properties |
| ------------------ | --------------------- |
| `maxHeight={size}` | `max-height: {size};` |
| `maxH={size}` | `max-height: {size};` |

## Scaled Max-Height

Expand Down
1 change: 1 addition & 0 deletions website/pages/docs/sizing/max-width.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Utilities for setting the maximum width of an element
| React props | CSS Properties |
| ----------------- | -------------------- |
| `maxWidth={size}` | `max-width: {size};` |
| `maxW={size}` | `max-width: {size};` |

## Scaled Max-Width

Expand Down
1 change: 1 addition & 0 deletions website/pages/docs/sizing/min-height.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Utilities for setting the minimum height of an element.
| React props | CSS Properties |
| ------------------ | --------------------- |
| `minHeight={size}` | `min-height: {size};` |
| `minH={size}` | `min-height: {size};` |

## Scaled Min-Height

Expand Down
1 change: 1 addition & 0 deletions website/pages/docs/sizing/min-width.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Utilities for setting the minimum width of an element.
| React props | CSS Properties |
| ----------------- | -------------------- |
| `minWidth={size}` | `min-width: {size};` |
| `minW={size}` | `min-width: {size};` |

## Scaled Min-Width

Expand Down

0 comments on commit fde802e

Please sign in to comment.