From 19fee9984bf196930acbf96461d3c1234173bf3a Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Sat, 16 Mar 2019 14:15:24 -0700 Subject: [PATCH] Add longhand padding/margin types. --- types/styled-system/index.d.ts | 25 ++++++++++++++++++--- types/styled-system/styled-system-tests.tsx | 22 ++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/types/styled-system/index.d.ts b/types/styled-system/index.d.ts index ec7686ab89..b91f9c1707 100644 --- a/types/styled-system/index.d.ts +++ b/types/styled-system/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for styled-system 3.2 +// Type definitions for styled-system 4.0 // Project: https://github.com/jxnblk/styled-system#readme // Definitions by: Marshall Bowers // Ben McCormick @@ -51,7 +51,7 @@ export type TLengthStyledSystem = string | 0 | number; export type ResponsiveValue = T | Array | { [key: string]: T }; /** - * Converts shorthand margin and padding props to margin and padding CSS declarations + * Converts shorthand or longhand margin and padding props to margin and padding CSS declarations * * - Numbers from 0-4 (or the length of theme.space) are converted to values on the spacing scale. * - Negative values can be used for negative margins. @@ -59,32 +59,51 @@ export type ResponsiveValue = T | Array | { [key: string]: T }; * - String values are passed as raw CSS values. * - Array values are converted into responsive values. */ - export interface SpaceProps { /** Margin on top, left, bottom and right */ m?: ResponsiveValue>; + /** Margin on top, left, bottom and right */ + margin?: ResponsiveValue>; /** Margin for the top */ mt?: ResponsiveValue>; + /** Margin for the top */ + marginTop?: ResponsiveValue>; /** Margin for the right */ mr?: ResponsiveValue>; + /** Margin for the right */ + marginRight?: ResponsiveValue>; /** Margin for the bottom */ mb?: ResponsiveValue>; + /** Margin for the bottom */ + marginBottom?: ResponsiveValue>; /** Margin for the left */ ml?: ResponsiveValue>; + /** Margin for the left */ + marginLeft?: ResponsiveValue>; /** Margin for the left and right */ mx?: ResponsiveValue>; /** Margin for the top and bottom */ my?: ResponsiveValue>; /** Padding on top, left, bottom and right */ p?: ResponsiveValue>; + /** Padding on top, left, bottom and right */ + padding?: ResponsiveValue>; /** Padding for the top */ pt?: ResponsiveValue>; + /** Padding for the top */ + paddingTop?: ResponsiveValue>; /** Padding for the right */ pr?: ResponsiveValue>; + /** Padding for the right */ + paddingRight?: ResponsiveValue>; /** Padding for the bottom */ pb?: ResponsiveValue>; + /** Padding for the bottom */ + paddingBottom?: ResponsiveValue>; /** Padding for the left */ pl?: ResponsiveValue>; + /** Padding for the left */ + paddingLeft?: ResponsiveValue>; /** Padding for the left and right */ px?: ResponsiveValue>; /** Padding for the top and bottom */ diff --git a/types/styled-system/styled-system-tests.tsx b/types/styled-system/styled-system-tests.tsx index ae2f87b7ab..c99a15c8f2 100644 --- a/types/styled-system/styled-system-tests.tsx +++ b/types/styled-system/styled-system-tests.tsx @@ -328,8 +328,30 @@ const test = () => ( // responsive margin + + + + + + + + + + + // responsive padding + + + + + + + + + + + // examples (margin prop) // sets margin value of `theme.space[2]`