@marigold/system 0.0.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +95 -0
- package/dist/Box.d.ts +14 -0
- package/dist/Global.d.ts +2 -0
- package/dist/SVG.d.ts +6 -0
- package/dist/index.d.ts +7 -4
- package/dist/normalize.d.ts +143 -5
- package/dist/system.cjs.development.js +334 -159
- package/dist/system.cjs.development.js.map +1 -1
- package/dist/system.cjs.production.min.js +1 -1
- package/dist/system.cjs.production.min.js.map +1 -1
- package/dist/system.esm.js +324 -156
- package/dist/system.esm.js.map +1 -1
- package/dist/theme.d.ts +136 -0
- package/dist/types.d.ts +8 -0
- package/dist/useTheme.d.ts +15 -5
- package/dist/variant.d.ts +29 -0
- package/package.json +6 -8
- package/src/Box.test.tsx +308 -0
- package/src/Box.tsx +199 -0
- package/src/Colors.stories.mdx +492 -448
- package/src/Global.test.tsx +57 -0
- package/src/Global.tsx +34 -0
- package/src/SVG.stories.mdx +55 -0
- package/src/SVG.test.tsx +82 -0
- package/src/SVG.tsx +24 -0
- package/src/concepts-principles.mdx +1 -1
- package/src/index.ts +7 -4
- package/src/normalize.test.tsx +15 -0
- package/src/normalize.ts +79 -93
- package/src/theme.ts +157 -0
- package/src/types.ts +14 -0
- package/src/useTheme.test.tsx +92 -17
- package/src/useTheme.tsx +45 -6
- package/src/variant.test.ts +93 -0
- package/src/variant.ts +54 -0
- package/dist/categories.d.ts +0 -169
- package/dist/system.d.ts +0 -37
- package/dist/useClassname.d.ts +0 -2
- package/dist/useStyles.d.ts +0 -10
- package/src/categories.ts +0 -203
- package/src/system.test.tsx +0 -84
- package/src/system.tsx +0 -55
- package/src/useClassname.test.tsx +0 -61
- package/src/useClassname.ts +0 -8
- package/src/useStyles.test.tsx +0 -313
- package/src/useStyles.ts +0 -56
- package/src/writeComponent.stories.mdx +0 -126
package/src/useTheme.test.tsx
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
2
4
|
import { renderHook } from '@testing-library/react-hooks';
|
|
5
|
+
|
|
3
6
|
import { ThemeProvider, useTheme } from './useTheme';
|
|
4
7
|
|
|
5
8
|
// Setup
|
|
@@ -9,6 +12,12 @@ const theme = {
|
|
|
9
12
|
primary: 'hotpink',
|
|
10
13
|
black: '#000',
|
|
11
14
|
},
|
|
15
|
+
space: {
|
|
16
|
+
none: 0,
|
|
17
|
+
small: 16,
|
|
18
|
+
medium: 24,
|
|
19
|
+
large: 32,
|
|
20
|
+
},
|
|
12
21
|
text: {
|
|
13
22
|
body: {
|
|
14
23
|
fontSize: 1,
|
|
@@ -25,24 +34,90 @@ const wrapper: React.FC = ({ children }) => (
|
|
|
25
34
|
<ThemeProvider theme={theme}>{children}</ThemeProvider>
|
|
26
35
|
);
|
|
27
36
|
|
|
28
|
-
test('
|
|
37
|
+
test('returns the theme', () => {
|
|
38
|
+
const { result } = renderHook(() => useTheme(), { wrapper });
|
|
39
|
+
expect(result.current.theme).toEqual(theme);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('returns a "css" function', () => {
|
|
43
|
+
const { result } = renderHook(() => useTheme(), { wrapper });
|
|
44
|
+
expect(result.current.css).toEqual(expect.any(Function));
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('transpile style object to css object', () => {
|
|
29
48
|
const { result } = renderHook(() => useTheme(), { wrapper });
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"heading": Object {
|
|
42
|
-
"color": "primary",
|
|
43
|
-
"fontSize": 3,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
49
|
+
const css = result.current.css;
|
|
50
|
+
|
|
51
|
+
expect(css({ p: 'small' })).toMatchInlineSnapshot(`
|
|
52
|
+
{
|
|
53
|
+
"padding": 16,
|
|
54
|
+
}
|
|
55
|
+
`);
|
|
56
|
+
expect(css({ color: 'primary', p: 'large' })).toMatchInlineSnapshot(`
|
|
57
|
+
{
|
|
58
|
+
"color": "hotpink",
|
|
59
|
+
"padding": 32,
|
|
46
60
|
}
|
|
47
61
|
`);
|
|
62
|
+
expect(css({ variant: 'text.body' })).toMatchInlineSnapshot(`
|
|
63
|
+
{
|
|
64
|
+
"color": "#000",
|
|
65
|
+
"fontSize": 14,
|
|
66
|
+
}
|
|
67
|
+
`);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('themes can be cascaded', () => {
|
|
71
|
+
const outerTheme = {
|
|
72
|
+
colors: {
|
|
73
|
+
primary: 'coral',
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const innerTheme = {
|
|
78
|
+
colors: {
|
|
79
|
+
primary: 'gainsboro',
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const Theme = ({ testId }: { testId: string }) => {
|
|
84
|
+
const { theme } = useTheme();
|
|
85
|
+
return <div data-testid={testId}>{JSON.stringify(theme, null, 2)}</div>;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
render(
|
|
89
|
+
<ThemeProvider theme={outerTheme}>
|
|
90
|
+
<>
|
|
91
|
+
<Theme testId="outer" />
|
|
92
|
+
<ThemeProvider theme={innerTheme}>
|
|
93
|
+
<Theme testId="inner" />
|
|
94
|
+
</ThemeProvider>
|
|
95
|
+
</>
|
|
96
|
+
</ThemeProvider>
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const outer = screen.getByTestId('outer');
|
|
100
|
+
const inner = screen.getByTestId('inner');
|
|
101
|
+
|
|
102
|
+
expect(outer.innerHTML).toMatchInlineSnapshot(`
|
|
103
|
+
"{
|
|
104
|
+
\\"colors\\": {
|
|
105
|
+
\\"primary\\": \\"coral\\"
|
|
106
|
+
}
|
|
107
|
+
}"
|
|
108
|
+
`);
|
|
109
|
+
expect(inner.innerHTML).toMatchInlineSnapshot(`
|
|
110
|
+
"{
|
|
111
|
+
\\"colors\\": {
|
|
112
|
+
\\"primary\\": \\"gainsboro\\"
|
|
113
|
+
}
|
|
114
|
+
}"
|
|
115
|
+
`);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('theme is passed down to emotion', () => {
|
|
119
|
+
const css = jest.fn().mockReturnValue({});
|
|
120
|
+
render(<ThemeProvider theme={theme}>{jsx('div', { css })}</ThemeProvider>);
|
|
121
|
+
|
|
122
|
+
expect(css).toHaveBeenCalledWith(theme);
|
|
48
123
|
});
|
package/src/useTheme.tsx
CHANGED
|
@@ -1,11 +1,50 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
createContext,
|
|
3
|
+
ReactNode,
|
|
4
|
+
useCallback,
|
|
5
|
+
useContext,
|
|
6
|
+
} from 'react';
|
|
7
|
+
import { css as transformStyleObject } from '@theme-ui/css';
|
|
8
|
+
import { ThemeProvider as EmotionProvider } from '@emotion/react';
|
|
2
9
|
|
|
3
|
-
|
|
10
|
+
import { Theme } from './theme';
|
|
11
|
+
import { StyleObject } from './types';
|
|
4
12
|
|
|
5
|
-
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export const __defaultTheme: Theme = {};
|
|
6
17
|
|
|
7
|
-
|
|
8
|
-
|
|
18
|
+
const InternalContext = createContext<Theme>(__defaultTheme);
|
|
19
|
+
|
|
20
|
+
export const useTheme = () => {
|
|
21
|
+
const theme = useContext(InternalContext);
|
|
22
|
+
/**
|
|
23
|
+
* We cast the theme here to `any` since our subset is not
|
|
24
|
+
* compatible with the typings of `theme-ui`, since they
|
|
25
|
+
* also support arrays as scale values, while we don't.
|
|
26
|
+
*/
|
|
27
|
+
const css = useCallback(
|
|
28
|
+
(style: StyleObject) => transformStyleObject(style)(theme as any),
|
|
29
|
+
[theme]
|
|
30
|
+
);
|
|
31
|
+
return { theme, css };
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type ThemeProviderProps<T extends Theme> = {
|
|
35
|
+
theme: T;
|
|
36
|
+
children: ReactNode;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export function ThemeProvider<T extends Theme>({
|
|
9
40
|
theme,
|
|
10
41
|
children,
|
|
11
|
-
}
|
|
42
|
+
}: ThemeProviderProps<T>) {
|
|
43
|
+
return (
|
|
44
|
+
<EmotionProvider theme={theme}>
|
|
45
|
+
<InternalContext.Provider value={theme}>
|
|
46
|
+
{children}
|
|
47
|
+
</InternalContext.Provider>
|
|
48
|
+
</EmotionProvider>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
appendVariantState,
|
|
3
|
+
conditional,
|
|
4
|
+
ensureArray,
|
|
5
|
+
ensureArrayVariant,
|
|
6
|
+
ensureVariantDefault,
|
|
7
|
+
} from './variant';
|
|
8
|
+
|
|
9
|
+
test('ensure array', () => {
|
|
10
|
+
expect(ensureArray('foo')).toEqual(['foo']);
|
|
11
|
+
expect(ensureArray(['foo'])).toEqual(['foo']);
|
|
12
|
+
expect(ensureArray(['foo', 'bar'])).toEqual(['foo', 'bar']);
|
|
13
|
+
expect(ensureArray(null)).toEqual([]);
|
|
14
|
+
expect(ensureArray(undefined)).toEqual([]);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('ensure variant default', () => {
|
|
18
|
+
expect(ensureVariantDefault('foo.')).toEqual('foo');
|
|
19
|
+
expect(ensureVariantDefault('foo')).toEqual('foo');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('ensure array of variants', () => {
|
|
23
|
+
expect(ensureArrayVariant('foo')).toEqual(['foo']);
|
|
24
|
+
expect(ensureArrayVariant(['foo'])).toEqual(['foo']);
|
|
25
|
+
expect(ensureArrayVariant(['foo', 'bar'])).toEqual(['foo', 'bar']);
|
|
26
|
+
expect(ensureArrayVariant(undefined)).toEqual([]);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('append variant state', () => {
|
|
30
|
+
expect(appendVariantState('foo', 'checked')).toEqual('foo.:checked');
|
|
31
|
+
expect(appendVariantState('foo', 'focus')).toEqual('foo.:focus');
|
|
32
|
+
expect(appendVariantState('foo', 'disabled')).toEqual('foo.:disabled');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('conditional variants', () => {
|
|
36
|
+
expect(
|
|
37
|
+
conditional('foo', {
|
|
38
|
+
checked: true,
|
|
39
|
+
})
|
|
40
|
+
).toMatchInlineSnapshot(`
|
|
41
|
+
[
|
|
42
|
+
"foo",
|
|
43
|
+
"foo.:checked",
|
|
44
|
+
]
|
|
45
|
+
`);
|
|
46
|
+
|
|
47
|
+
expect(
|
|
48
|
+
conditional('foo', {
|
|
49
|
+
checked: true,
|
|
50
|
+
focus: true,
|
|
51
|
+
disabled: true,
|
|
52
|
+
})
|
|
53
|
+
).toMatchInlineSnapshot(`
|
|
54
|
+
[
|
|
55
|
+
"foo",
|
|
56
|
+
"foo.:checked",
|
|
57
|
+
"foo.:focus",
|
|
58
|
+
"foo.:disabled",
|
|
59
|
+
]
|
|
60
|
+
`);
|
|
61
|
+
|
|
62
|
+
expect(
|
|
63
|
+
conditional('foo', {
|
|
64
|
+
checked: true,
|
|
65
|
+
focus: false,
|
|
66
|
+
disabled: true,
|
|
67
|
+
})
|
|
68
|
+
).toMatchInlineSnapshot(`
|
|
69
|
+
[
|
|
70
|
+
"foo",
|
|
71
|
+
"foo.:checked",
|
|
72
|
+
"foo.:disabled",
|
|
73
|
+
]
|
|
74
|
+
`);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('disabled is always last state variant', () => {
|
|
78
|
+
const one = conditional('foo', {
|
|
79
|
+
disabled: true,
|
|
80
|
+
checked: true,
|
|
81
|
+
focus: true,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
expect(one[one.length - 1]).toMatchInlineSnapshot(`"foo.:disabled"`);
|
|
85
|
+
|
|
86
|
+
const two = conditional('foo', {
|
|
87
|
+
checked: true,
|
|
88
|
+
disabled: true,
|
|
89
|
+
focus: true,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
expect(two[two.length - 1]).toMatchInlineSnapshot(`"foo.:disabled"`);
|
|
93
|
+
});
|
package/src/variant.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const isNil = (value: any): value is null | undefined =>
|
|
2
|
+
value === null || value === undefined;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Ensures that the `val` is an array. Will return an empty array if `val` is falsy.
|
|
6
|
+
*/
|
|
7
|
+
export const ensureArray = <T>(val?: T | T[]) =>
|
|
8
|
+
isNil(val) ? [] : Array.isArray(val) ? val : [val];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Removes trailing dot from variant, if necessary. This is necessary to support
|
|
12
|
+
* `__default` styles. See https://github.com/system-ui/theme-ui/pull/951
|
|
13
|
+
*/
|
|
14
|
+
export const ensureVariantDefault = (val: string) => val.replace(/\.$/, '');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Ensures that the `variant` is an array and supports the `__default` key.
|
|
18
|
+
*/
|
|
19
|
+
export const ensureArrayVariant = <T extends string>(variant?: T | T[]) =>
|
|
20
|
+
ensureArray(variant).map(ensureVariantDefault);
|
|
21
|
+
|
|
22
|
+
export type State = {
|
|
23
|
+
checked?: boolean;
|
|
24
|
+
focus?: boolean;
|
|
25
|
+
hover?: boolean;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
error?: boolean;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Appends given `state` to a `variant`.
|
|
32
|
+
*/
|
|
33
|
+
export const appendVariantState = (variant: string, state: keyof State) => {
|
|
34
|
+
return `${ensureVariantDefault(variant)}.:${state}`;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a variant array from a `variant` and `state` containing
|
|
39
|
+
* passed states, if they are truthy.
|
|
40
|
+
*/
|
|
41
|
+
export const conditional = (
|
|
42
|
+
variant: string,
|
|
43
|
+
{ disabled = false, ...states }: State
|
|
44
|
+
) => {
|
|
45
|
+
const entries = [...Object.entries(states), ['disabled', disabled]] as [
|
|
46
|
+
keyof State,
|
|
47
|
+
boolean
|
|
48
|
+
][];
|
|
49
|
+
const stateVariants = entries
|
|
50
|
+
.filter(([, val]) => Boolean(val))
|
|
51
|
+
.map(([key]) => appendVariantState(variant, key));
|
|
52
|
+
|
|
53
|
+
return [variant, ...stateVariants];
|
|
54
|
+
};
|
package/dist/categories.d.ts
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { PropertiesFallback } from 'csstype';
|
|
2
|
-
/**
|
|
3
|
-
* System categories are based on https://primer.style/components/docs/system-props
|
|
4
|
-
*/
|
|
5
|
-
export declare const SPACE_PROPS: string[];
|
|
6
|
-
declare type StandardCSSProperties = PropertiesFallback<number | string>;
|
|
7
|
-
export declare type SpacingProps = {
|
|
8
|
-
/**
|
|
9
|
-
* The **`margin`** CSS property sets the margin area on all four sides of an element. It is a shorthand for `margin-top`, `margin-right`, `margin-bottom`, and `margin-left`.
|
|
10
|
-
*
|
|
11
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/margin
|
|
12
|
-
*/
|
|
13
|
-
m?: StandardCSSProperties['margin'];
|
|
14
|
-
/**
|
|
15
|
-
* The **`margin-top`** CSS property sets the margin area on the top of an element. A positive value places it farther from its neighbors, while a negative value places it closer.
|
|
16
|
-
*
|
|
17
|
-
* **Initial value**: `0`
|
|
18
|
-
*
|
|
19
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/margin-top
|
|
20
|
-
*/
|
|
21
|
-
mt?: StandardCSSProperties['marginTop'];
|
|
22
|
-
/**
|
|
23
|
-
* The **`margin-right`** CSS property sets the margin area on the right side of an element. A positive value places it farther from its neighbors, while a negative value places it closer.
|
|
24
|
-
*
|
|
25
|
-
* **Initial value**: `0`
|
|
26
|
-
*
|
|
27
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/margin-right
|
|
28
|
-
*/
|
|
29
|
-
mr?: StandardCSSProperties['marginRight'];
|
|
30
|
-
/**
|
|
31
|
-
* The **`margin-bottom`** CSS property sets the margin area on the bottom of an element. A positive value places it farther from its neighbors, while a negative value places it closer.
|
|
32
|
-
*
|
|
33
|
-
* **Initial value**: `0`
|
|
34
|
-
*
|
|
35
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/margin-bottom
|
|
36
|
-
*/
|
|
37
|
-
mb?: StandardCSSProperties['marginBottom'];
|
|
38
|
-
/**
|
|
39
|
-
* The **`margin-left`** CSS property sets the margin area on the left side of an element. A positive value places it farther from its neighbors, while a negative value places it closer.
|
|
40
|
-
*
|
|
41
|
-
* **Initial value**: `0`
|
|
42
|
-
*
|
|
43
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/margin-left
|
|
44
|
-
*/
|
|
45
|
-
ml?: StandardCSSProperties['marginLeft'];
|
|
46
|
-
/**
|
|
47
|
-
* The **`mx`** is shorthand for using both **`margin-left`** and **`margin-right`** CSS properties. They set the margin area on the left and right side of an element. A positive value placesit
|
|
48
|
-
* farther from its neighbors, while a negative value places it closer.
|
|
49
|
-
*
|
|
50
|
-
* **Initial value**: `0`
|
|
51
|
-
*
|
|
52
|
-
* @see https://styled-system.com/#margin-props
|
|
53
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/margin-left
|
|
54
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/margin-right
|
|
55
|
-
*/
|
|
56
|
-
mx?: StandardCSSProperties['marginLeft'];
|
|
57
|
-
/**
|
|
58
|
-
* The **`marginX`** is shorthand for using both **`margin-left`** and **`margin-right`** CSS properties. They set the margin area on the left and right side of an element. A positive value
|
|
59
|
-
* places it farther from its neighbors, while a negative value places it closer.
|
|
60
|
-
*
|
|
61
|
-
* **Initial value**: `0`
|
|
62
|
-
*
|
|
63
|
-
* @see https://styled-system.com/#margin-props
|
|
64
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/margin-left
|
|
65
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/margin-right
|
|
66
|
-
*/
|
|
67
|
-
marginX?: StandardCSSProperties['marginLeft'];
|
|
68
|
-
/**
|
|
69
|
-
* The **`my`** is shorthard for using both **`margin-top`** and **`margin-bottom`** CSS properties. They set the margin area on the top and bottom of an element. A positive value places it
|
|
70
|
-
* farther from its neighbors, while a negative value places it closer.
|
|
71
|
-
*
|
|
72
|
-
* **Initial value**: `0`
|
|
73
|
-
*
|
|
74
|
-
* @see https://styled-system.com/#margin-props
|
|
75
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/margin-top
|
|
76
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/margin-bottom
|
|
77
|
-
*/
|
|
78
|
-
my?: StandardCSSProperties['marginTop'];
|
|
79
|
-
/**
|
|
80
|
-
* The **`marginY`** is shorthard for using both **`margin-top`** and **`margin-bottom`** CSS properties. They set the margin area on the top and bottom of an element. A positive value places
|
|
81
|
-
* it farther from its neighbors, while a negative value places it closer.
|
|
82
|
-
*
|
|
83
|
-
* **Initial value**: `0`
|
|
84
|
-
*
|
|
85
|
-
* @see https://styled-system.com/#margin-props
|
|
86
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/margin-top
|
|
87
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/margin-bottom
|
|
88
|
-
*/
|
|
89
|
-
marginY?: StandardCSSProperties['marginTop'];
|
|
90
|
-
/**
|
|
91
|
-
* The **`padding`** CSS property sets the padding area on all four sides of an element. It is a shorthand for `padding-top`, `padding-right`, `padding-bottom`, and `padding-left`.
|
|
92
|
-
*
|
|
93
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/padding
|
|
94
|
-
*/
|
|
95
|
-
p?: StandardCSSProperties['padding'];
|
|
96
|
-
/**
|
|
97
|
-
* The **`padding-top`** padding area on the top of an element.
|
|
98
|
-
*
|
|
99
|
-
* **Initial value**: `0`
|
|
100
|
-
*
|
|
101
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/padding-top
|
|
102
|
-
*/
|
|
103
|
-
pt?: StandardCSSProperties['paddingTop'];
|
|
104
|
-
/**
|
|
105
|
-
* The **`padding-right`** CSS property sets the width of the padding area on the right side of an element.
|
|
106
|
-
*
|
|
107
|
-
* **Initial value**: `0`
|
|
108
|
-
*
|
|
109
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/padding-right
|
|
110
|
-
*/
|
|
111
|
-
pr?: StandardCSSProperties['paddingRight'];
|
|
112
|
-
/**
|
|
113
|
-
* The **`padding-bottom`** CSS property sets the height of the padding area on the bottom of an element.
|
|
114
|
-
*
|
|
115
|
-
* **Initial value**: `0`
|
|
116
|
-
*
|
|
117
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/padding-bottom
|
|
118
|
-
*/
|
|
119
|
-
pb?: StandardCSSProperties['paddingBottom'];
|
|
120
|
-
/**
|
|
121
|
-
* The **`padding-left`** CSS property sets the width of the padding area on the left side of an element.
|
|
122
|
-
*
|
|
123
|
-
* **Initial value**: `0`
|
|
124
|
-
*
|
|
125
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/padding-left
|
|
126
|
-
*/
|
|
127
|
-
pl?: StandardCSSProperties['paddingLeft'];
|
|
128
|
-
/**
|
|
129
|
-
* The **`px`** is shorthand property for CSS properties **`padding-left`** and **`padding-right`**. They set the width of the padding area on the left and right side of an element.
|
|
130
|
-
*
|
|
131
|
-
* **Initial value**: `0`
|
|
132
|
-
*
|
|
133
|
-
* @see https://styled-system.com/#padding-props
|
|
134
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/padding-left
|
|
135
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/padding-right
|
|
136
|
-
*/
|
|
137
|
-
px?: StandardCSSProperties['paddingLeft'];
|
|
138
|
-
/**
|
|
139
|
-
* The **`paddingX`** is shorthand property for CSS properties **`padding-left`** and **`padding-right`**. They set the width of the padding area on the left and right side of an element.
|
|
140
|
-
*
|
|
141
|
-
* **Initial value**: `0`
|
|
142
|
-
*
|
|
143
|
-
* @see https://styled-system.com/#padding-props
|
|
144
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/padding-left
|
|
145
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/padding-right
|
|
146
|
-
*/
|
|
147
|
-
paddingX?: StandardCSSProperties['paddingLeft'];
|
|
148
|
-
/**
|
|
149
|
-
* The **`py`** is shorthand property for CSS properties **`padding-top`** and **`padding-bottom`**. They set the width of the padding area on the top and bottom of an element.
|
|
150
|
-
*
|
|
151
|
-
* **Initial value**: `0`
|
|
152
|
-
*
|
|
153
|
-
* @see https://styled-system.com/#padding-props
|
|
154
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/padding-top
|
|
155
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/padding-bottom
|
|
156
|
-
*/
|
|
157
|
-
py?: StandardCSSProperties['paddingTop'];
|
|
158
|
-
/**
|
|
159
|
-
* The **`paddingY`** is shorthand property for CSS properties **`padding-top`** and **`padding-bottom`**. They set the width of the padding area on the top and bottom of an element.
|
|
160
|
-
*
|
|
161
|
-
* **Initial value**: `0`
|
|
162
|
-
*
|
|
163
|
-
* @see https://styled-system.com/#padding-props
|
|
164
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/padding-top
|
|
165
|
-
* @see https://developer.mozilla.org/docs/Web/CSS/padding-bottom
|
|
166
|
-
*/
|
|
167
|
-
paddingY?: StandardCSSProperties['paddingTop'];
|
|
168
|
-
};
|
|
169
|
-
export {};
|
package/dist/system.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typings are based on [Reach UI](https://github.com/reach/reach-ui/blob/4cb497f530b0f83f80c6f6f2da46ab55b1160cb6/packages/utils/src/types.tsx).
|
|
3
|
-
*/
|
|
4
|
-
import { ComponentPropsWithRef, ElementType, ReactElement, ValidationMap, WeakValidationMap } from 'react';
|
|
5
|
-
/**
|
|
6
|
-
* SystemProps support the `as` and `variant` prop. The former
|
|
7
|
-
* is used to changed the rendered root element of a component.
|
|
8
|
-
*
|
|
9
|
-
* These props also infer additional allowed props based on the
|
|
10
|
-
* value of the `as` prop. For example, setting `as="button"` will
|
|
11
|
-
* allow to use HTMLButtonAttributes on the component.
|
|
12
|
-
*/
|
|
13
|
-
export declare type SystemProps<P, T extends ElementType> = P & Omit<ComponentPropsWithRef<T>, 'as' | keyof P> & {
|
|
14
|
-
as?: T;
|
|
15
|
-
variant?: string;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Enhanced version of `React.FunctionComponent` that accepts `SystemProps`
|
|
19
|
-
* and infers allowed properties based on the `as` prop.
|
|
20
|
-
*/
|
|
21
|
-
export interface SystemComponent<P, T extends ElementType> {
|
|
22
|
-
/**
|
|
23
|
-
* These types are a bit of a hack, but cover us in cases where the `as` prop
|
|
24
|
-
* is not a JSX string type. Makes the compiler happy so 🤷♂️
|
|
25
|
-
*/
|
|
26
|
-
<TT extends ElementType>(props: SystemProps<P, TT>): ReactElement | null;
|
|
27
|
-
(props: SystemProps<P, T>): ReactElement | null;
|
|
28
|
-
displayName?: string;
|
|
29
|
-
propTypes?: WeakValidationMap<SystemProps<P, T>>;
|
|
30
|
-
contextTypes?: ValidationMap<any>;
|
|
31
|
-
defaultProps?: Partial<SystemProps<P, T>>;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Helper to write components that adhere to a common design system API,
|
|
35
|
-
* which includes the `as` and `variant` prop.
|
|
36
|
-
*/
|
|
37
|
-
export declare function system<P, T extends ElementType>(render: (props: SystemProps<P, T>) => ReactElement | null): SystemComponent<P, T>;
|
package/dist/useClassname.d.ts
DELETED
package/dist/useStyles.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ElementType } from 'react';
|
|
2
|
-
export declare type StylesProps = {
|
|
3
|
-
element?: ElementType[];
|
|
4
|
-
variant?: string | string[];
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Hook function that can add base styles, normalization, variant and custom styles
|
|
9
|
-
*/
|
|
10
|
-
export declare const useStyles: ({ element, variant, ...styles }: StylesProps, classNames?: string | undefined) => string;
|