Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding scroll-margin props #1664

Merged
merged 1 commit into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/css/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ export const multiples = {
marginY: ['marginTop', 'marginBottom'],
paddingX: ['paddingLeft', 'paddingRight'],
paddingY: ['paddingTop', 'paddingBottom'],
scrollMarginX: ['scrollMarginLeft', 'scrollMarginRight'],
scrollMarginY: ['scrollMarginTop', 'scrollMarginBottom'],
scrollPaddingX: ['scrollPaddingLeft', 'scrollPaddingRight'],
scrollPaddingY: ['scrollPaddingTop', 'scrollPaddingBottom'],
size: ['width', 'height'],
Expand Down Expand Up @@ -142,6 +144,13 @@ export const scales = {
paddingInline: 'space',
paddingInlineEnd: 'space',
paddingInlineStart: 'space',
scrollMargin: 'space',
scrollMarginTop: 'space',
scrollMarginRight: 'space',
scrollMarginBottom: 'space',
scrollMarginLeft: 'space',
scrollMarginX: 'space',
scrollMarginY: 'space',
scrollPadding: 'space',
scrollPaddingTop: 'space',
scrollPaddingRight: 'space',
Expand Down
16 changes: 16 additions & 0 deletions packages/css/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,22 @@ interface AliasesCSSProperties {
* @see https://developer.mozilla.org/docs/Web/CSS/height
*/

/**
* The **`scrollMarginX`** is shorthand property for CSS properties **`scroll-margin-left`** and **`scroll-margin-right`**. They set the margin of the scroll snap area that is used for snapping the element to the snapport.
*
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-left
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-right
*/
scrollMarginX?: StandardCSSProperties['scrollMarginLeft']

/**
* The **`scrollMarginY`** is shorthand property for CSS properties **`scroll-margin-top`** and **`scroll-margin-bottom`**. They set the margin of the scroll snap area that is used for snapping the element to the snapport.
*
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-top
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-bottom
*/
scrollMarginY?: StandardCSSProperties['scrollMarginTop']

/**
* The **`scrollPaddingX`** is shorthand property for CSS properties **`scroll-padding-left`** and **`scroll-padding-right`**. They set the width of the scroll padding area on the left and right side of an element.
*
Expand Down
11 changes: 11 additions & 0 deletions packages/css/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ test('handles all core styled system props', () => {
mx: 'auto',
p: 3,
py: 4,
scrollMargin: 5,
scrollMarginY: 6,
scrollPadding: 1,
scrollPaddingY: 2,
fontSize: 3,
Expand All @@ -205,6 +207,9 @@ test('handles all core styled system props', () => {
padding: 16,
paddingTop: 32,
paddingBottom: 32,
scrollMargin: 64,
scrollMarginTop: 128,
scrollMarginBottom: 128,
scrollPadding: 4,
scrollPaddingTop: 8,
scrollPaddingBottom: 8,
Expand Down Expand Up @@ -577,6 +582,8 @@ test('multiples are transformed', () => {
marginY: 2,
paddingX: 2,
paddingY: 2,
scrollMarginX: 2,
scrollMarginY: 2,
scrollPaddingX: 2,
scrollPaddingY: 2,

Expand All @@ -591,6 +598,10 @@ test('multiples are transformed', () => {
paddingRight: 8,
paddingTop: 8,
paddingBottom: 8,
scrollMarginLeft: 8,
scrollMarginRight: 8,
scrollMarginTop: 8,
scrollMarginBottom: 8,
scrollPaddingLeft: 8,
scrollPaddingRight: 8,
scrollPaddingTop: 8,
Expand Down
7 changes: 7 additions & 0 deletions packages/docs/src/pages/sx-prop.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ The following CSS properties will use values defined in the theme, when availabl
| `pl`, `paddingLeft` | `space` |
| `px`, `paddingX` | `space` |
| `py`, `paddingY` | `space` |
| `scrollMargin` | `space` |
| `scrollMarginTop` | `space` |
| `scrollMarginRight` | `space` |
| `scrollMarginBottom` | `space` |
| `scrollMarginLeft` | `space` |
| `scrollMarginX` | `space` |
| `scrollMarginY` | `space` |
| `scrollPadding` | `space` |
| `scrollPaddingTop` | `space` |
| `scrollPaddingRight` | `space` |
Expand Down