@marigold/system 0.0.1 → 0.2.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.
Files changed (50) hide show
  1. package/dist/Element.d.ts +8 -0
  2. package/dist/cache.d.ts +4 -0
  3. package/dist/index.d.ts +6 -4
  4. package/dist/normalize.d.ts +110 -0
  5. package/dist/reset.d.ts +24 -0
  6. package/dist/system.cjs.development.js +332 -95
  7. package/dist/system.cjs.development.js.map +1 -1
  8. package/dist/system.cjs.production.min.js +1 -1
  9. package/dist/system.cjs.production.min.js.map +1 -1
  10. package/dist/system.esm.js +323 -92
  11. package/dist/system.esm.js.map +1 -1
  12. package/dist/types.d.ts +9 -0
  13. package/dist/useClassname.d.ts +2 -0
  14. package/dist/useStyles.d.ts +15 -0
  15. package/dist/useTheme.d.ts +10 -0
  16. package/package.json +7 -10
  17. package/src/Colors.stories.mdx +616 -448
  18. package/src/Element.test.tsx +203 -0
  19. package/src/Element.tsx +59 -0
  20. package/src/cache.ts +4 -0
  21. package/src/concepts-principles.mdx +1 -1
  22. package/src/index.ts +6 -4
  23. package/src/normalize.test.tsx +42 -0
  24. package/src/normalize.ts +131 -0
  25. package/src/reset.ts +108 -0
  26. package/src/types.ts +16 -0
  27. package/src/useClassname.test.tsx +70 -0
  28. package/src/useClassname.ts +23 -0
  29. package/src/useStyles.stories.mdx +24 -0
  30. package/src/useStyles.test.tsx +286 -0
  31. package/src/useStyles.ts +63 -0
  32. package/src/useTheme.test.tsx +115 -0
  33. package/src/useTheme.tsx +22 -0
  34. package/dist/Box/Box.d.ts +0 -6
  35. package/dist/Box/index.d.ts +0 -1
  36. package/dist/MarigoldProvider.d.ts +0 -7
  37. package/dist/categories.d.ts +0 -169
  38. package/dist/emotion.d.ts +0 -7
  39. package/dist/system.d.ts +0 -37
  40. package/src/Box/Box.stories.mdx +0 -148
  41. package/src/Box/Box.test.tsx +0 -215
  42. package/src/Box/Box.tsx +0 -58
  43. package/src/Box/index.ts +0 -1
  44. package/src/MarigoldProvider.test.tsx +0 -80
  45. package/src/MarigoldProvider.tsx +0 -37
  46. package/src/categories.ts +0 -203
  47. package/src/emotion.ts +0 -39
  48. package/src/system.test.tsx +0 -84
  49. package/src/system.tsx +0 -55
  50. package/src/writeComponent.stories.mdx +0 -114
@@ -0,0 +1,8 @@
1
+ import { PolymorphicPropsWithRef, PolymorphicComponentWithRef } from '@marigold/types';
2
+ import { CSSObject } from './types';
3
+ export declare type ElementOwnProps = {
4
+ css?: CSSObject;
5
+ variant?: string | string[];
6
+ };
7
+ export declare type ElementProps = PolymorphicPropsWithRef<ElementOwnProps, 'div'>;
8
+ export declare const Element: PolymorphicComponentWithRef<ElementOwnProps, 'div'>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Expose cache from emotion so we can use the same cache when doing SSR.
3
+ */
4
+ export { cache } from '@emotion/css';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- export * from './Box';
2
- export * from './categories';
3
- export * from './MarigoldProvider';
4
- export * from './system';
1
+ export * from './Element';
2
+ export * from './cache';
3
+ export * from './types';
4
+ export * from './useClassname';
5
+ export * from './useStyles';
6
+ export * from './useTheme';
@@ -0,0 +1,110 @@
1
+ /// <reference types="react" />
2
+ declare const reset: {
3
+ readonly article: {
4
+ readonly display: "block";
5
+ };
6
+ readonly aside: {
7
+ readonly display: "block";
8
+ };
9
+ readonly details: {
10
+ readonly display: "block";
11
+ };
12
+ readonly figcaption: {
13
+ readonly display: "block";
14
+ };
15
+ readonly figure: {
16
+ readonly display: "block";
17
+ };
18
+ readonly footer: {
19
+ readonly display: "block";
20
+ };
21
+ readonly header: {
22
+ readonly display: "block";
23
+ };
24
+ readonly hgroup: {
25
+ readonly display: "block";
26
+ };
27
+ readonly menu: {
28
+ readonly display: "block";
29
+ };
30
+ readonly nav: {
31
+ readonly display: "block";
32
+ };
33
+ readonly section: {
34
+ readonly display: "block";
35
+ };
36
+ readonly ul: {};
37
+ readonly ol: {};
38
+ readonly blockquote: {
39
+ readonly quotes: "none";
40
+ readonly selectors: {
41
+ readonly '&:before, &:after': {
42
+ readonly content: "''";
43
+ };
44
+ };
45
+ };
46
+ readonly q: {
47
+ readonly quotes: "none";
48
+ readonly selectors: {
49
+ readonly '&:before, &:after': {
50
+ readonly content: "''";
51
+ };
52
+ };
53
+ };
54
+ readonly a: {
55
+ readonly textDecoration: "none";
56
+ readonly touchAction: "manipulation";
57
+ };
58
+ readonly base: {
59
+ readonly boxSizing: "border-box";
60
+ readonly margin: 0;
61
+ readonly padding: 0;
62
+ readonly minWidth: 0;
63
+ readonly fontSize: "100%";
64
+ readonly fontFamily: "inherit";
65
+ readonly verticalAlign: "baseline";
66
+ readonly WebkitTapHighlightColor: "transparent";
67
+ };
68
+ readonly table: {
69
+ readonly borderCollapse: "collapse";
70
+ readonly borderSpacing: 0;
71
+ };
72
+ readonly select: {
73
+ readonly display: "block";
74
+ readonly appearance: "none";
75
+ readonly selectors: {
76
+ readonly '&::-ms-expand': {
77
+ readonly display: "none";
78
+ };
79
+ };
80
+ };
81
+ readonly button: {
82
+ readonly display: "block";
83
+ readonly appearance: "none";
84
+ readonly background: "transparent";
85
+ readonly textAlign: "center";
86
+ readonly touchAction: "manipulation";
87
+ };
88
+ readonly textarea: {
89
+ readonly display: "block";
90
+ readonly appearance: "none";
91
+ };
92
+ readonly input: {
93
+ readonly display: "block";
94
+ readonly appearance: "none";
95
+ readonly selectors: {
96
+ readonly '&::-ms-clear': {
97
+ readonly display: "none";
98
+ };
99
+ readonly '&::-webkit-search-cancel-button': {
100
+ readonly WebkitAppearance: "none";
101
+ };
102
+ };
103
+ };
104
+ };
105
+ export declare type NormalizedElement = keyof typeof reset;
106
+ /**
107
+ * Helper to conveniently get reset styles.
108
+ */
109
+ export declare const getNormalizedStyles: (input?: "symbol" | "object" | "article" | "aside" | "details" | "figcaption" | "figure" | "footer" | "header" | "hgroup" | "menu" | "nav" | "section" | "ul" | "ol" | "blockquote" | "q" | "a" | "base" | "table" | "select" | "button" | "textarea" | "input" | "abbr" | "address" | "area" | "audio" | "b" | "bdi" | "bdo" | "big" | "body" | "br" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "dfn" | "dialog" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "hr" | "html" | "i" | "iframe" | "img" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "menuitem" | "meta" | "meter" | "noindex" | "noscript" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "rp" | "rt" | "ruby" | "s" | "samp" | "slot" | "script" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "template" | "tbody" | "td" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "var" | "video" | "wbr" | "webview" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | import("react").ComponentClass<any, any> | import("react").FunctionComponent<any> | undefined) => object;
110
+ export {};
@@ -0,0 +1,24 @@
1
+ export declare const reset: {
2
+ readonly article: string;
3
+ readonly aside: string;
4
+ readonly details: string;
5
+ readonly figcaption: string;
6
+ readonly figure: string;
7
+ readonly footer: string;
8
+ readonly header: string;
9
+ readonly hgroup: string;
10
+ readonly menu: string;
11
+ readonly nav: string;
12
+ readonly section: string;
13
+ readonly ul: string;
14
+ readonly ol: string;
15
+ readonly blockquote: string;
16
+ readonly q: string;
17
+ readonly a: string;
18
+ readonly base: string;
19
+ readonly table: string;
20
+ readonly select: string;
21
+ readonly button: string;
22
+ readonly textarea: string;
23
+ readonly input: string;
24
+ };
@@ -2,11 +2,11 @@
2
2
 
3
3
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
4
 
5
- var css = require('@theme-ui/css');
6
- var pick = _interopDefault(require('lodash.pick'));
7
- var core = require('@emotion/core');
5
+ var react = require('@emotion/react');
8
6
  var React = require('react');
9
7
  var React__default = _interopDefault(React);
8
+ var css = require('@theme-ui/css');
9
+ var css$1 = require('@emotion/css');
10
10
 
11
11
  function _extends() {
12
12
  _extends = Object.assign || function (target) {
@@ -41,127 +41,364 @@ function _objectWithoutPropertiesLoose(source, excluded) {
41
41
  return target;
42
42
  }
43
43
 
44
- /**
45
- * System categories are based on https://primer.style/components/docs/system-props
46
- */
47
- // Spacing
44
+ var base = {
45
+ boxSizing: 'border-box',
46
+ margin: 0,
47
+ padding: 0,
48
+ minWidth: 0,
49
+ fontSize: '100%',
50
+ fontFamily: 'inherit',
51
+ verticalAlign: 'baseline',
52
+ WebkitTapHighlightColor: 'transparent'
53
+ }; // Content
48
54
  // ---------------
49
- var SPACE_PROPS = ['m', 'margin', 'mt', 'marginTop', 'mr', 'marginRight', 'mb', 'marginBottom', 'ml', 'marginLeft', 'mx', 'marginX', 'my', 'marginY', 'p', 'padding', 'pt', 'paddingTop', 'pr', 'paddingRight', 'pb', 'paddingBottom', 'pl', 'paddingLeft', 'px', 'paddingX', 'py', 'paddingY'];
50
55
 
51
- /**
52
- * Fix until the global JSX augmentation is not included in
53
- * `@emotion/core`. See https://github.com/emotion-js/emotion/issues/1257
54
- * for more information.
55
- *
56
- * *Why is this a problem?*
57
- *
58
- * (1) Every JSX element accepts a `css` prop, but we don't parse that.
59
- * (2) Every JSX element only accepts a type that is compatible with emotion's
60
- * css prop, which we don't care, since we first pass the `css` prop
61
- * to styled-system.
62
- *
63
- * *The fix consist of two parts:*
64
- *
65
- * (1) using `.yarnclean` to remove the `emotion/core` typings completly.
66
- * (2) having this sink file to re-apply the typings and tell TS to ignore
67
- * the untyped import.
68
- */
56
+ var block = {
57
+ display: 'block'
58
+ };
59
+ var list = {// empty
60
+ };
61
+ var table = {
62
+ borderCollapse: 'collapse',
63
+ borderSpacing: 0
64
+ }; // Typography
69
65
  // ---------------
70
66
 
71
- var jsx = core.jsx;
72
- var ThemeContext = core.ThemeContext;
73
- var Global = core.Global;
74
-
75
- /**
76
- * Helper to write components that adhere to a common design system API,
77
- * which includes the `as` and `variant` prop.
78
- */
67
+ var a = {
68
+ textDecoration: 'none',
69
+ touchAction: 'manipulation'
70
+ };
71
+ var quote = {
72
+ quotes: 'none',
73
+ selectors: {
74
+ '&:before, &:after': {
75
+ content: "''"
76
+ }
77
+ }
78
+ }; // Form Elements
79
+ // ---------------
79
80
 
80
- function system(render) {
81
- return React.forwardRef(function (props, ref) {
82
- return render(_extends({}, props, {
83
- ref: ref
84
- }));
85
- });
86
- }
81
+ var button = {
82
+ display: 'block',
83
+ appearance: 'none',
84
+ background: 'transparent',
85
+ textAlign: 'center',
86
+ touchAction: 'manipulation'
87
+ };
88
+ var input = {
89
+ display: 'block',
90
+ appearance: 'none',
91
+ selectors: {
92
+ '&::-ms-clear': {
93
+ display: 'none'
94
+ },
95
+ '&::-webkit-search-cancel-button': {
96
+ WebkitAppearance: 'none'
97
+ }
98
+ }
99
+ };
100
+ var select = {
101
+ display: 'block',
102
+ appearance: 'none',
103
+ selectors: {
104
+ '&::-ms-expand': {
105
+ display: 'none'
106
+ }
107
+ }
108
+ };
109
+ var textarea = {
110
+ display: 'block',
111
+ appearance: 'none'
112
+ }; // Reset
113
+ // ---------------
87
114
 
88
- /**
89
- * Props that we have to remove (because they are not valid HTML attributes)
90
- * and want to process (for styling the component).
91
- */
115
+ var reset = {
116
+ article: block,
117
+ aside: block,
118
+ details: block,
119
+ figcaption: block,
120
+ figure: block,
121
+ footer: block,
122
+ header: block,
123
+ hgroup: block,
124
+ menu: block,
125
+ nav: block,
126
+ section: block,
127
+ ul: list,
128
+ ol: list,
129
+ blockquote: quote,
130
+ q: quote,
131
+ a: a,
132
+ base: base,
133
+ table: table,
134
+ select: select,
135
+ button: button,
136
+ textarea: textarea,
137
+ input: input
138
+ };
92
139
 
93
- var SKIP_PROPS = /*#__PURE__*/['css', 'variant', 'themeSection'].concat(SPACE_PROPS);
140
+ var isKnownElement = function isKnownElement(input) {
141
+ return input in reset;
142
+ };
94
143
  /**
95
- * Gather styling related props (css, variant, space props, ...) and put them in a
96
- * single `css` prop for emotion. All gathered props will be passed to `@theme-ui/css`
97
- * before emotion will process them. This way CSS properties will interpolated based on
98
- * the given theme.
144
+ * Helper to conveniently get reset styles.
99
145
  */
100
146
 
101
- var parseProps = function parseProps(props) {
102
- var next = {}; // TODO: optimize loop such that the style props are picked
103
- // within the loop (and remove lodash.pick!)
104
147
 
105
- for (var key in props) {
106
- if (SKIP_PROPS.includes(key)) continue;
107
- next[key] = props[key];
148
+ var getNormalizedStyles = function getNormalizedStyles(input) {
149
+ /**
150
+ * If a React component is given, we don't apply any reset styles
151
+ * and return the base reset.
152
+ */
153
+ if (typeof input !== 'string') {
154
+ return reset.base;
108
155
  }
156
+ /**
157
+ * Try to find the reset style for a HTML element. If the element
158
+ * is not included return empty styles.
159
+ */
109
160
 
110
- var styles = _extends({}, props.css, {}, pick(props, SPACE_PROPS));
111
161
 
112
- var variant = props.themeSection && props.variant && props.themeSection + "." + props.variant;
162
+ return isKnownElement(input) ? reset[input] : {};
163
+ };
113
164
 
114
- next.css = function (theme) {
115
- return [{
116
- boxSizing: 'border-box',
117
- margin: 0,
118
- minWidth: 0
119
- }, css.css(styles)(theme), css.css({
120
- variant: variant
121
- })(theme)];
165
+ var Context = /*#__PURE__*/React.createContext({});
166
+ var useTheme = function useTheme() {
167
+ var theme = React.useContext(Context);
168
+ var css$1 = React.useCallback(function (style) {
169
+ return css.css(style)(theme);
170
+ }, [theme]);
171
+ return {
172
+ theme: theme,
173
+ css: css$1
122
174
  };
175
+ };
176
+ var ThemeProvider = function ThemeProvider(_ref) {
177
+ var theme = _ref.theme,
178
+ children = _ref.children;
179
+ return React__default.createElement(Context.Provider, {
180
+ value: theme
181
+ }, children);
182
+ };
183
+
184
+ var _excluded = ["as", "css", "variant", "children"];
185
+ /**
186
+ * Function expression to check if there is any falsy value or empty object
187
+ */
123
188
 
124
- return next;
189
+ var isNotEmpty = function isNotEmpty(val) {
190
+ return !(val && Object.keys(val).length === 0 && val.constructor === Object);
125
191
  };
192
+ /**
193
+ * Get the normalized base styles
194
+ */
195
+
126
196
 
127
- var Box = /*#__PURE__*/system(function (_ref) {
197
+ var baseStyles = /*#__PURE__*/getNormalizedStyles('base');
198
+ var Element = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
128
199
  var _ref$as = _ref.as,
129
200
  as = _ref$as === void 0 ? 'div' : _ref$as,
201
+ _ref$css = _ref.css,
202
+ styles = _ref$css === void 0 ? {} : _ref$css,
203
+ variant = _ref.variant,
130
204
  children = _ref.children,
131
- props = _objectWithoutPropertiesLoose(_ref, ["as", "children"]);
205
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
206
+
207
+ var _useTheme = useTheme(),
208
+ css = _useTheme.css;
209
+ /**
210
+ * Transform variant input for `@theme-ui/css`
211
+ */
212
+
132
213
 
133
- return jsx(as, parseProps(props), children);
214
+ var variants = Array.isArray(variant) ? variant.map(function (v) {
215
+ return {
216
+ variant: v
217
+ };
218
+ }) : [{
219
+ variant: variant
220
+ }];
221
+ return react.jsx(as, _extends({}, props, {
222
+ css: [baseStyles, getNormalizedStyles(as)].concat(variants.map(function (v) {
223
+ return css(v);
224
+ }), [css(styles)]).filter(isNotEmpty)
225
+ }, {
226
+ ref: ref
227
+ }), children);
134
228
  });
135
229
 
136
- /**
137
- * CSS snippet and idea from:
138
- * https://css-tricks.com/revisiting-prefers-reduced-motion-the-reduced-motion-media-query/
139
- */
230
+ // lodash.isEmpty is tooo much KBs!
140
231
 
141
- var ReduceMotion = function ReduceMotion() {
142
- return React__default.createElement(Global, {
143
- styles: {
144
- '@media screen and (prefers-reduced-motion: reduce), (update: slow)': {
145
- '*': {
146
- animationDuration: '0.001ms !important',
147
- animationIterationCount: '1 !important',
148
- transitionDuration: '0.001ms !important'
149
- }
150
- }
232
+ var isEmpty = function isEmpty(val) {
233
+ return val && Object.keys(val).length === 0 && val.constructor === Object;
234
+ };
235
+
236
+ var useClassname = function useClassname() {
237
+ var _useTheme = useTheme(),
238
+ css = _useTheme.css;
239
+
240
+ for (var _len = arguments.length, styles = new Array(_len), _key = 0; _key < _len; _key++) {
241
+ styles[_key] = arguments[_key];
242
+ }
243
+
244
+ return styles.map(function (style) {
245
+ /**
246
+ * emotion will create a `css-0` class whenever an empty object is
247
+ * passed. Since this makes debugging harder we'll do not pass empty
248
+ * objects to emotion.
249
+ */
250
+ var themedStyle = css(style);
251
+ return isEmpty(themedStyle) ? '' : css$1.css(themedStyle);
252
+ }).join(' ');
253
+ };
254
+
255
+ var base$1 = /*#__PURE__*/css$1.css({
256
+ boxSizing: 'border-box',
257
+ margin: 0,
258
+ padding: 0,
259
+ minWidth: 0,
260
+ fontSize: '100%',
261
+ font: 'inherit',
262
+ verticalAlign: 'baseline',
263
+ WebkitTapHighlightColor: 'transparent'
264
+ }); // Content
265
+ // ---------------
266
+
267
+ var block$1 = /*#__PURE__*/css$1.css({
268
+ display: 'block'
269
+ });
270
+ var list$1 = /*#__PURE__*/css$1.css({// empty
271
+ });
272
+ var table$1 = /*#__PURE__*/css$1.css({
273
+ borderCollapse: 'collapse',
274
+ borderSpacing: 0
275
+ }); // Typography
276
+ // ---------------
277
+
278
+ var a$1 = /*#__PURE__*/css$1.css({
279
+ textDecoration: 'none',
280
+ touchAction: 'manipulation'
281
+ });
282
+ var quote$1 = /*#__PURE__*/css$1.css({
283
+ quotes: 'none',
284
+ selectors: {
285
+ '&:before, &:after': {
286
+ content: "''"
151
287
  }
152
- });
288
+ }
289
+ }); // Form Elements
290
+ // ---------------
291
+
292
+ var button$1 = /*#__PURE__*/css$1.css({
293
+ display: 'block',
294
+ appearance: 'none',
295
+ background: 'transparent',
296
+ textAlign: 'center',
297
+ touchAction: 'manipulation'
298
+ });
299
+ var input$1 = /*#__PURE__*/css$1.css({
300
+ display: 'block',
301
+ appearance: 'none',
302
+ selectors: {
303
+ '&::-ms-clear': {
304
+ display: 'none'
305
+ },
306
+ '&::-webkit-search-cancel-button': {
307
+ WebkitAppearance: 'none'
308
+ }
309
+ }
310
+ });
311
+ var select$1 = /*#__PURE__*/css$1.css({
312
+ display: 'block',
313
+ appearance: 'none',
314
+ selectors: {
315
+ '&::-ms-expand': {
316
+ display: 'none'
317
+ }
318
+ }
319
+ });
320
+ var textarea$1 = /*#__PURE__*/css$1.css({
321
+ display: 'block',
322
+ appearance: 'none'
323
+ }); // Reset
324
+ // ---------------
325
+
326
+ var reset$1 = {
327
+ article: block$1,
328
+ aside: block$1,
329
+ details: block$1,
330
+ figcaption: block$1,
331
+ figure: block$1,
332
+ footer: block$1,
333
+ header: block$1,
334
+ hgroup: block$1,
335
+ menu: block$1,
336
+ nav: block$1,
337
+ section: block$1,
338
+ ul: list$1,
339
+ ol: list$1,
340
+ blockquote: quote$1,
341
+ q: quote$1,
342
+ a: a$1,
343
+ base: base$1,
344
+ table: table$1,
345
+ select: select$1,
346
+ button: button$1,
347
+ textarea: textarea$1,
348
+ input: input$1
153
349
  };
154
350
 
155
- var MarigoldProvider = function MarigoldProvider(_ref) {
156
- var theme = _ref.theme,
157
- children = _ref.children;
158
- return React__default.createElement(ThemeContext.Provider, {
159
- value: theme
160
- }, React__default.createElement(React__default.Fragment, null, React__default.createElement(ReduceMotion, null), children));
351
+ /**
352
+ * Hook that can adds base styles, reset for certain elements, variants and custom styles
353
+ */
354
+
355
+ var useStyles = function useStyles(_ref) {
356
+ var element = _ref.element,
357
+ _ref$css = _ref.css,
358
+ styles = _ref$css === void 0 ? {} : _ref$css,
359
+ variant = _ref.variant,
360
+ _ref$className = _ref.className,
361
+ className = _ref$className === void 0 ? '' : _ref$className;
362
+
363
+ /**
364
+ * Get reset styles. Base is always applied. An additional reset maybe applied
365
+ * based on the passed element.
366
+ *
367
+ * We check the passed className if it already includes the reset styles so no
368
+ * duplicates are applied.
369
+ */
370
+ var baseClassName = className.includes(reset$1.base) ? '' : reset$1.base;
371
+ var resetClassName = typeof element === 'string' ? className.includes(reset$1[element]) ? '' : reset$1[element] : '';
372
+ /**
373
+ * Get variant styles (from theme).
374
+ */
375
+
376
+ var variants = Array.isArray(variant) ? variant.map(function (v) {
377
+ return {
378
+ variant: v
379
+ };
380
+ }) : [{
381
+ variant: variant
382
+ }];
383
+ var variantsClassName = useClassname.apply(void 0, variants);
384
+ /**
385
+ * Custom styles are applied "on runtime". They are usually controlled via component
386
+ * props and can change between component instances.
387
+ */
388
+
389
+ var customClassName = useClassname(styles);
390
+ return [baseClassName, resetClassName, variantsClassName, customClassName, className].filter(Boolean).join(' ');
161
391
  };
162
392
 
163
- exports.Box = Box;
164
- exports.MarigoldProvider = MarigoldProvider;
165
- exports.SPACE_PROPS = SPACE_PROPS;
166
- exports.system = system;
393
+ Object.defineProperty(exports, 'cache', {
394
+ enumerable: true,
395
+ get: function () {
396
+ return css$1.cache;
397
+ }
398
+ });
399
+ exports.Element = Element;
400
+ exports.ThemeProvider = ThemeProvider;
401
+ exports.useClassname = useClassname;
402
+ exports.useStyles = useStyles;
403
+ exports.useTheme = useTheme;
167
404
  //# sourceMappingURL=system.cjs.development.js.map