@elliemae/ds-system 2.3.0-alpha.9 → 2.3.0-next.3

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 (105) hide show
  1. package/cjs/arithmetic.js +43 -0
  2. package/cjs/constants.js +19 -0
  3. package/cjs/globalStyles.js +25 -0
  4. package/cjs/index.js +84 -0
  5. package/cjs/mobileUtilities.js +41 -0
  6. package/cjs/spaceUtilities.js +68 -0
  7. package/cjs/styled/index.d.js +2 -0
  8. package/cjs/styled/index.js +124 -0
  9. package/cjs/styled/styleGetters.js +44 -0
  10. package/cjs/styled/types.js +12 -0
  11. package/cjs/styled/utils.js +24 -0
  12. package/cjs/th.js +43 -0
  13. package/cjs/theme.js +9 -0
  14. package/cjs/themeProviderHOC.js +29 -0
  15. package/cjs/utils.js +184 -0
  16. package/{dist/esm → esm}/arithmetic.js +25 -13
  17. package/esm/constants.js +13 -0
  18. package/esm/globalStyles.js +17 -0
  19. package/esm/index.js +11 -0
  20. package/esm/mobileUtilities.js +34 -0
  21. package/esm/spaceUtilities.js +57 -0
  22. package/esm/styled/index.d.js +1 -0
  23. package/esm/styled/index.js +115 -0
  24. package/esm/styled/styleGetters.js +38 -0
  25. package/esm/styled/types.js +1 -0
  26. package/esm/styled/utils.js +18 -0
  27. package/esm/th.js +39 -0
  28. package/esm/theme.js +5 -0
  29. package/esm/themeProviderHOC.js +20 -0
  30. package/esm/utils.js +136 -0
  31. package/package.json +45 -47
  32. package/{dist/types → types}/arithmetic.d.ts +0 -0
  33. package/{dist/types → types}/constants.d.ts +0 -0
  34. package/{dist/types → types}/globalStyles.d.ts +0 -0
  35. package/{dist/types → types}/index.d.ts +0 -0
  36. package/{dist/types → types}/mobileUtilities.d.ts +0 -0
  37. package/{dist/types → types}/spaceUtilities.d.ts +0 -0
  38. package/{dist/types → types}/styled/index.d.ts +0 -0
  39. package/{dist/types → types}/styled/styleGetters.d.ts +0 -0
  40. package/{dist/types → types}/styled/types.d.ts +0 -0
  41. package/{dist/types → types}/styled/utils.d.ts +0 -0
  42. package/{dist/types → types}/tests/arithmetic.test.d.ts +0 -0
  43. package/{dist/types → types}/th.d.ts +0 -0
  44. package/{dist/types → types}/theme.d.ts +0 -0
  45. package/{dist/types → types}/themeProviderHOC.d.ts +0 -0
  46. package/{dist/types → types}/utils.d.ts +2 -1
  47. package/dist/cjs/arithmetic.js +0 -55
  48. package/dist/cjs/arithmetic.js.map +0 -7
  49. package/dist/cjs/constants.js +0 -47
  50. package/dist/cjs/constants.js.map +0 -7
  51. package/dist/cjs/globalStyles.js +0 -47
  52. package/dist/cjs/globalStyles.js.map +0 -7
  53. package/dist/cjs/index.js +0 -43
  54. package/dist/cjs/index.js.map +0 -7
  55. package/dist/cjs/mobileUtilities.js +0 -72
  56. package/dist/cjs/mobileUtilities.js.map +0 -7
  57. package/dist/cjs/spaceUtilities.js +0 -94
  58. package/dist/cjs/spaceUtilities.js.map +0 -7
  59. package/dist/cjs/styled/index.d.js +0 -27
  60. package/dist/cjs/styled/index.d.js.map +0 -7
  61. package/dist/cjs/styled/index.js +0 -89
  62. package/dist/cjs/styled/index.js.map +0 -7
  63. package/dist/cjs/styled/styleGetters.js +0 -56
  64. package/dist/cjs/styled/styleGetters.js.map +0 -7
  65. package/dist/cjs/styled/types.js +0 -35
  66. package/dist/cjs/styled/types.js.map +0 -7
  67. package/dist/cjs/styled/utils.js +0 -47
  68. package/dist/cjs/styled/utils.js.map +0 -7
  69. package/dist/cjs/th.js +0 -58
  70. package/dist/cjs/th.js.map +0 -7
  71. package/dist/cjs/theme.js +0 -36
  72. package/dist/cjs/theme.js.map +0 -7
  73. package/dist/cjs/themeProviderHOC.js +0 -42
  74. package/dist/cjs/themeProviderHOC.js.map +0 -7
  75. package/dist/cjs/utils.js +0 -294
  76. package/dist/cjs/utils.js.map +0 -7
  77. package/dist/esm/arithmetic.js.map +0 -7
  78. package/dist/esm/constants.js +0 -18
  79. package/dist/esm/constants.js.map +0 -7
  80. package/dist/esm/globalStyles.js +0 -18
  81. package/dist/esm/globalStyles.js.map +0 -7
  82. package/dist/esm/index.js +0 -14
  83. package/dist/esm/index.js.map +0 -7
  84. package/dist/esm/mobileUtilities.js +0 -43
  85. package/dist/esm/mobileUtilities.js.map +0 -7
  86. package/dist/esm/spaceUtilities.js +0 -65
  87. package/dist/esm/spaceUtilities.js.map +0 -7
  88. package/dist/esm/styled/index.d.js +0 -2
  89. package/dist/esm/styled/index.d.js.map +0 -7
  90. package/dist/esm/styled/index.js +0 -60
  91. package/dist/esm/styled/index.js.map +0 -7
  92. package/dist/esm/styled/styleGetters.js +0 -27
  93. package/dist/esm/styled/styleGetters.js.map +0 -7
  94. package/dist/esm/styled/types.js +0 -6
  95. package/dist/esm/styled/types.js.map +0 -7
  96. package/dist/esm/styled/utils.js +0 -18
  97. package/dist/esm/styled/utils.js.map +0 -7
  98. package/dist/esm/th.js +0 -29
  99. package/dist/esm/th.js.map +0 -7
  100. package/dist/esm/theme.js +0 -7
  101. package/dist/esm/theme.js.map +0 -7
  102. package/dist/esm/themeProviderHOC.js +0 -13
  103. package/dist/esm/themeProviderHOC.js.map +0 -7
  104. package/dist/esm/utils.js +0 -265
  105. package/dist/esm/utils.js.map +0 -7
@@ -1,27 +0,0 @@
1
- import * as React from "react";
2
- import { propsToClassKey } from "./utils";
3
- const getStyleOverrides = (name, theme) => theme.components?.[name]?.styleOverrides || null;
4
- const getVariantStyles = (name, theme) => {
5
- const variants = theme.components?.[name]?.variants || [];
6
- return variants.reduce((styles, definition) => {
7
- const key = propsToClassKey(definition.props);
8
- styles[key] = definition.style;
9
- return styles;
10
- }, {});
11
- };
12
- const variantsResolver = (props, styles, theme, name) => {
13
- const themeVariants = theme?.components?.[name]?.variants || [];
14
- return themeVariants.reduce((variantsStyles, themeVariant) => {
15
- const isMatch = Object.keys(themeVariant.props).every((key) => props[key] === themeVariant.props[key]);
16
- if (isMatch) {
17
- variantsStyles.push(styles[propsToClassKey(themeVariant.props)]);
18
- }
19
- return variantsStyles;
20
- }, []);
21
- };
22
- export {
23
- getStyleOverrides,
24
- getVariantStyles,
25
- variantsResolver
26
- };
27
- //# sourceMappingURL=styleGetters.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/styled/styleGetters.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\nimport type { Theme, CSSObject } from './types';\nimport { propsToClassKey } from './utils';\n\nexport const getStyleOverrides = (name: string, theme: Theme): CSSObject | null =>\n theme.components?.[name]?.styleOverrides || null;\n\nexport const getVariantStyles = (name: string, theme: Theme): Record<string, CSSObject> => {\n const variants = theme.components?.[name]?.variants || [];\n\n return variants.reduce((styles, definition) => {\n const key = propsToClassKey(definition.props);\n styles[key] = definition.style;\n return styles;\n }, {} as Record<string, CSSObject>);\n};\n\nexport const variantsResolver = (\n props: Record<string, unknown>,\n styles: CSSObject,\n theme: Theme,\n name: string,\n): CSSObject[keyof CSSObject][] => {\n const themeVariants = theme?.components?.[name]?.variants || [];\n\n return themeVariants.reduce((variantsStyles, themeVariant) => {\n const isMatch = Object.keys(themeVariant.props).every((key) => props[key] === themeVariant.props[key]);\n if (isMatch) {\n variantsStyles.push(styles[propsToClassKey(themeVariant.props)]);\n }\n return variantsStyles;\n }, [] as CSSObject[keyof CSSObject][]);\n};\n"],
5
- "mappings": "AAAA;ACEA;AAEO,MAAM,oBAAoB,CAAC,MAAc,UAC9C,MAAM,aAAa,OAAO,kBAAkB;AAEvC,MAAM,mBAAmB,CAAC,MAAc,UAA4C;AACzF,QAAM,WAAW,MAAM,aAAa,OAAO,YAAY;AAEvD,SAAO,SAAS,OAAO,CAAC,QAAQ,eAAe;AAC7C,UAAM,MAAM,gBAAgB,WAAW;AACvC,WAAO,OAAO,WAAW;AACzB,WAAO;AAAA,KACN;AAAA;AAGE,MAAM,mBAAmB,CAC9B,OACA,QACA,OACA,SACiC;AACjC,QAAM,gBAAgB,OAAO,aAAa,OAAO,YAAY;AAE7D,SAAO,cAAc,OAAO,CAAC,gBAAgB,iBAAiB;AAC5D,UAAM,UAAU,OAAO,KAAK,aAAa,OAAO,MAAM,CAAC,QAAQ,MAAM,SAAS,aAAa,MAAM;AACjG,QAAI,SAAS;AACX,qBAAe,KAAK,OAAO,gBAAgB,aAAa;AAAA;AAE1D,WAAO;AAAA,KACN;AAAA;",
6
- "names": []
7
- }
@@ -1,6 +0,0 @@
1
- import * as React from "react";
2
- import { CSSObject as CSSObject2 } from "styled-components";
3
- export {
4
- CSSObject2 as CSSObject
5
- };
6
- //# sourceMappingURL=types.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/styled/types.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport type { Theme as PuiTheme } from '@elliemae/pui-theme';\nimport {\n AnyStyledComponent,\n CSSObject,\n Interpolation,\n InterpolationFunction,\n StyledComponent,\n StyledComponentInnerAttrs,\n StyledComponentInnerComponent,\n StyledComponentInnerOtherProps,\n StyledComponentPropsWithRef,\n ThemedStyledProps,\n} from 'styled-components';\n\nexport { CSSObject } from 'styled-components';\n\nexport interface Theme extends PuiTheme {\n components?: {\n [componentName: string]: {\n styleOverrides?: CSSObject;\n variants?: { props: Record<string, { toString: () => string }>; style: CSSObject }[];\n };\n };\n}\n\nexport type ThemedStyledFunctionBase<\n C extends keyof JSX.IntrinsicElements | React.ComponentType<any>,\n T extends object,\n O extends object = {},\n A extends keyof any = never,\n> = <U extends object = {}>(\n first:\n | TemplateStringsArray\n | CSSObject\n | InterpolationFunction<ThemedStyledProps<StyledComponentPropsWithRef<C> & O & U, T>>,\n ...rest: Array<Interpolation<ThemedStyledProps<StyledComponentPropsWithRef<C> & O & U, T>>>\n) => StyledComponent<C, T, O & U, A>;\n\ntype ThemedStyledComponentFactories<T extends object> = {\n [TTag in keyof JSX.IntrinsicElements]: ThemedStyledFunctionBase<TTag, T>;\n};\n\nexport type StyledFunction = <C extends AnyStyledComponent | keyof JSX.IntrinsicElements | React.ComponentType<any>>(\n tag: C,\n options?: { name: string | null; slot: string | null; },\n) => ThemedStyledFunctionBase<\n C extends AnyStyledComponent ? StyledComponentInnerComponent<C> : C,\n Theme,\n C extends AnyStyledComponent ? StyledComponentInnerOtherProps<C> : {},\n C extends AnyStyledComponent ? StyledComponentInnerAttrs<C> : never\n>;\n\nexport type StyledObject = ThemedStyledComponentFactories<Theme>;\n\nexport type Styled = StyledFunction & StyledObject;\n"],
5
- "mappings": "AAAA;ACeA;",
6
- "names": []
7
- }
@@ -1,18 +0,0 @@
1
- import * as React from "react";
2
- import { capitalize } from "@elliemae/ds-utilities";
3
- import { theme as defaultTheme } from "../theme";
4
- const systemTheme = defaultTheme;
5
- const isEmpty = (string) => string.length === 0;
6
- const coerceWithDefaultTheme = (themeInput) => themeInput ?? systemTheme;
7
- const propsToClassKey = (props) => Object.keys(props).sort().reduce((classKey, key) => {
8
- if (key === "color") {
9
- return classKey + isEmpty(String(classKey)) ? String(props[key]) : capitalize(String(props[key]));
10
- }
11
- return `${classKey}${isEmpty(String(classKey)) ? key : capitalize(key)}${capitalize(props[key].toString())}`;
12
- }, "");
13
- export {
14
- coerceWithDefaultTheme,
15
- isEmpty,
16
- propsToClassKey
17
- };
18
- //# sourceMappingURL=utils.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/styled/utils.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { capitalize } from '@elliemae/ds-utilities';\nimport type { Theme } from './types';\nimport { theme as defaultTheme } from '../theme';\n\nconst systemTheme = defaultTheme;\n\nexport const isEmpty = (string: string): boolean => string.length === 0;\n\nexport const coerceWithDefaultTheme = (themeInput: Theme): Theme => themeInput ?? systemTheme;\n\nexport const propsToClassKey = (props: Record<string, { toString: () => string }>): string =>\n Object.keys(props)\n .sort()\n .reduce((classKey, key) => {\n if (key === 'color') {\n return classKey + isEmpty(String(classKey)) ? String(props[key]) : capitalize(String(props[key]));\n }\n return `${classKey}${isEmpty(String(classKey)) ? key : capitalize(key)}${capitalize(props[key].toString())}`;\n }, '');\n"],
5
- "mappings": "AAAA;ACAA;AAEA;AAEA,MAAM,cAAc;AAEb,MAAM,UAAU,CAAC,WAA4B,OAAO,WAAW;AAE/D,MAAM,yBAAyB,CAAC,eAA6B,cAAc;AAE3E,MAAM,kBAAkB,CAAC,UAC9B,OAAO,KAAK,OACT,OACA,OAAO,CAAC,UAAU,QAAQ;AACzB,MAAI,QAAQ,SAAS;AACnB,WAAO,WAAW,QAAQ,OAAO,aAAa,OAAO,MAAM,QAAQ,WAAW,OAAO,MAAM;AAAA;AAE7F,SAAO,GAAG,WAAW,QAAQ,OAAO,aAAa,MAAM,WAAW,OAAO,WAAW,MAAM,KAAK;AAAA,GAC9F;",
6
- "names": []
7
- }
package/dist/esm/th.js DELETED
@@ -1,29 +0,0 @@
1
- import * as React from "react";
2
- const th = (property) => {
3
- const thGetter = (value, dfault = "") => {
4
- const func = ({ theme }) => {
5
- const parts = value.split("-");
6
- let result = theme[property];
7
- parts.forEach((part) => {
8
- if (result)
9
- result = result[part];
10
- });
11
- return result ?? dfault;
12
- };
13
- return func;
14
- };
15
- return thGetter;
16
- };
17
- th.space = th("space");
18
- th.fontSize = th("fontSizes");
19
- th.fontWeight = th("fontWeights");
20
- th.lineHeight = th("lineHeights");
21
- th.letterSpacing = th("letterSpacings");
22
- th.font = th("fonts");
23
- th.color = th("colors");
24
- th.breakpoint = th("breakpoints");
25
- th.media = th("media");
26
- export {
27
- th
28
- };
29
- //# sourceMappingURL=th.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/th.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { Theme } from '@elliemae/pui-theme';\ntype ThGetter = (value: string, dfault?: string) => ({ theme }: { theme: Theme }) => string;\ntype ThConstructor = ((property: keyof Theme) => ThGetter) & {\n space: ThGetter;\n fontSize: ThGetter;\n fontWeight: ThGetter;\n lineHeight: ThGetter;\n letterSpacing: ThGetter;\n font: ThGetter;\n color: ThGetter;\n breakpoint: ThGetter;\n media: ThGetter;\n};\n\nexport const th: ThConstructor = (property): ThGetter => {\n const thGetter: ThGetter = (value, dfault = '') => {\n const func: ReturnType<ThGetter> = ({ theme }) => {\n const parts = value.split('-');\n let result = theme[property];\n parts.forEach((part) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n if (result) result = result[part as keyof typeof result];\n });\n return (result as unknown as string) ?? dfault;\n };\n return func;\n };\n return thGetter;\n};\nth.space = th('space');\nth.fontSize = th('fontSizes');\nth.fontWeight = th('fontWeights');\nth.lineHeight = th('lineHeights');\nth.letterSpacing = th('letterSpacings');\nth.font = th('fonts');\nth.color = th('colors');\nth.breakpoint = th('breakpoints');\nth.media = th('media');\n"],
5
- "mappings": "AAAA;ACcO,MAAM,KAAoB,CAAC,aAAuB;AACvD,QAAM,WAAqB,CAAC,OAAO,SAAS,OAAO;AACjD,UAAM,OAA6B,CAAC,EAAE,YAAY;AAChD,YAAM,QAAQ,MAAM,MAAM;AAC1B,UAAI,SAAS,MAAM;AACnB,YAAM,QAAQ,CAAC,SAAS;AAEtB,YAAI;AAAQ,mBAAS,OAAO;AAAA;AAE9B,aAAQ,UAAgC;AAAA;AAE1C,WAAO;AAAA;AAET,SAAO;AAAA;AAET,GAAG,QAAQ,GAAG;AACd,GAAG,WAAW,GAAG;AACjB,GAAG,aAAa,GAAG;AACnB,GAAG,aAAa,GAAG;AACnB,GAAG,gBAAgB,GAAG;AACtB,GAAG,OAAO,GAAG;AACb,GAAG,QAAQ,GAAG;AACd,GAAG,aAAa,GAAG;AACnB,GAAG,QAAQ,GAAG;",
6
- "names": []
7
- }
package/dist/esm/theme.js DELETED
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- import { getDefaultTheme } from "@elliemae/pui-theme";
3
- const theme = getDefaultTheme();
4
- export {
5
- theme
6
- };
7
- //# sourceMappingURL=theme.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/theme.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { getDefaultTheme } from '@elliemae/pui-theme';\nimport type { Theme } from '@elliemae/pui-theme';\n\nexport const theme = getDefaultTheme() as Theme;\n"],
5
- "mappings": "AAAA;ACAA;AAGO,MAAM,QAAQ;",
6
- "names": []
7
- }
@@ -1,13 +0,0 @@
1
- import * as React from "react";
2
- import React2 from "react";
3
- import { ThemeProvider } from "styled-components";
4
- import { theme } from "./theme";
5
- const themeProviderHOC = (Component) => (props) => /* @__PURE__ */ React2.createElement(ThemeProvider, {
6
- theme
7
- }, /* @__PURE__ */ React2.createElement(Component, {
8
- ...props
9
- }));
10
- export {
11
- themeProviderHOC
12
- };
13
- //# sourceMappingURL=themeProviderHOC.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/themeProviderHOC.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { ThemeProvider } from 'styled-components';\nimport { theme } from './theme';\n\nexport const themeProviderHOC = (Component: React.ElementType) => (\n props: Record<string, unknown>,\n): JSX.Element => (\n <ThemeProvider theme={theme}>\n <Component {...props} />\n </ThemeProvider>\n);\n"],
5
- "mappings": "AAAA;ACAA;AACA;AACA;AAEO,MAAM,mBAAmB,CAAC,cAAiC,CAChE,UAEA,qCAAC,eAAD;AAAA,EAAe;AAAA,GACb,qCAAC,WAAD;AAAA,KAAe;AAAA;",
6
- "names": []
7
- }
package/dist/esm/utils.js DELETED
@@ -1,265 +0,0 @@
1
- import * as React from "react";
2
- import { lighten, rgba } from "polished";
3
- import { reduce } from "lodash";
4
- import { css, withTheme, keyframes as kfrm, createGlobalStyle, useTheme } from "styled-components";
5
- import { theme } from "./theme";
6
- import { toMobile } from "./mobileUtilities";
7
- function truncate(width) {
8
- return (props) => css`
9
- ${!!width || props.width ? `width: ${props.width || width};` : ""}
10
- white-space: nowrap;
11
- overflow: hidden;
12
- text-overflow: ellipsis;
13
- `;
14
- }
15
- function flexCenter() {
16
- return `
17
- display: flex;
18
- justify-content: center;
19
- align-items: center;
20
- `;
21
- }
22
- function disabled() {
23
- return `
24
- cursor: not-allowed;
25
- pointer-events: none;
26
- `;
27
- }
28
- function keyframes(obj) {
29
- return kfrm`${reduce(obj, (result, value, key) => `
30
- ${result}
31
- ${key}% {
32
- ${value}
33
- }
34
- `, "")}
35
- `;
36
- }
37
- function boxShadow(top, left, blur, color2, inset = false) {
38
- return `box-shadow: ${inset ? "inset" : ""} ${top} ${left} ${blur} ${color2};`;
39
- }
40
- function color(variant = "neutral", type = 400) {
41
- return css`
42
- color: ${(props) => props.theme.colors[variant][type]};
43
- `;
44
- }
45
- function border(color2 = theme.colors.brand[600], size = "1px", type = "solid") {
46
- return `${size} ${type} ${color2}`;
47
- }
48
- function animation(animationKeyframes, animationLength, animationTimingFn) {
49
- return (props) => css`
50
- animation: ${props.animationKeyframes || animationKeyframes} ${props.animationLength || animationLength}
51
- ${props.animationTimingFn || animationTimingFn};
52
- `;
53
- }
54
- function focus(color2 = theme.colors.brand[600]) {
55
- return () => css`
56
- outline: none;
57
- border: 1px solid ${color2};
58
- box-shadow: inset 0 0 0 1px ${lighten(0.3, color2)};
59
- border-radius: 2px;
60
- `;
61
- }
62
- function focusAfter(color2) {
63
- return css`
64
- outline: none;
65
- position: relative;
66
- &:after {
67
- content: '';
68
- z-index: 10;
69
- position: absolute;
70
- top: 0;
71
- left: 0;
72
- width: 100%;
73
- height: 100%;
74
- pointer-events: none;
75
- ${focus(color2)}
76
- }
77
- `;
78
- }
79
- function active() {
80
- return (props) => css`
81
- outline: none;
82
- border: 1px solid ${props.theme.colors.brand[700]};
83
- border-radius: 2px;
84
- `;
85
- }
86
- function hover() {
87
- return (props) => css`
88
- outline: 1px solid ${props.theme.colors.brand[600]};
89
- outline-offset: -1px;
90
- `;
91
- }
92
- function textStyle(type, weight = "regular") {
93
- return (props) => {
94
- let cssVar = `font-weight: ${props.theme.fontWeights[weight]};`;
95
- switch (type) {
96
- case "h1":
97
- cssVar += `
98
- font-size: ${toMobile("2.7692rem")};
99
- line-height: normal;
100
- `;
101
- break;
102
- case "h2":
103
- cssVar += `
104
- font-size: ${toMobile(props.theme.fontSizes.title[800])};
105
- line-height: normal;
106
- `;
107
- break;
108
- case "h3":
109
- cssVar += `
110
- font-size: ${toMobile(props.theme.fontSizes.title[700])};
111
- line-height: 1.2;
112
- `;
113
- break;
114
- case "h4":
115
- cssVar += `
116
- font-size: ${toMobile(props.theme.fontSizes.title[600])};
117
- line-height: normal;
118
- `;
119
- break;
120
- case "h5":
121
- cssVar += `
122
- font-size: ${toMobile(props.theme.fontSizes.title[500])};
123
- line-height: normal;
124
- `;
125
- break;
126
- case "section-header":
127
- cssVar += `
128
- font-size: ${toMobile(props.theme.fontSizes.title[500])};
129
- line-height: normal;
130
- text-transform: uppercase;
131
- `;
132
- break;
133
- case "body":
134
- cssVar += `
135
- font-size: ${toMobile(props.theme.fontSizes.value[400])};
136
- line-height: normal;
137
- `;
138
- break;
139
- case "body-small":
140
- cssVar += `
141
- font-size: ${toMobile(props.theme.fontSizes.value[300])};
142
- line-height: normal;
143
- `;
144
- break;
145
- case "body-micro":
146
- cssVar += `
147
- font-size: ${toMobile(props.theme.fontSizes.microText[200])};
148
- line-height: normal;
149
- `;
150
- break;
151
- case "list":
152
- cssVar += `
153
- font-size: ${toMobile(props.theme.fontSizes.value[400])};
154
- line-height: normal;
155
- `;
156
- break;
157
- case "link":
158
- cssVar += `
159
- line-height: ${props.theme.xl};
160
- color: ${props.theme.colors.brand[600]};
161
- cursor: pointer;
162
- `;
163
- break;
164
- }
165
- return cssVar;
166
- };
167
- }
168
- function iconColor(variant = "neutral", type = 400) {
169
- return css`
170
- fill: ${(props) => props.theme.colors[variant][type]};
171
- `;
172
- }
173
- function fakeBorder() {
174
- return css`
175
- box-shadow: inset 0 0 0 1px ${(props) => props.theme.colors.neutral[200]};
176
- border-radius: 2px;
177
- `;
178
- }
179
- function fakeActive() {
180
- return css`
181
- outline: none;
182
- box-shadow: inset 0 0 0 1px ${(props) => props.theme.colors.brand[700]};
183
- border-radius: 2px;
184
- `;
185
- }
186
- function clearFocus() {
187
- return `
188
- border: none;
189
- box-shadow: none;
190
- `;
191
- }
192
- function buttonLink() {
193
- return `
194
- background-color: transparent;
195
- border: 1px solid transparent;
196
- cursor: pointer;
197
- `;
198
- }
199
- function transition(t = "all 1s ease") {
200
- return `
201
- transition: ${t};
202
- `;
203
- }
204
- const onlySafariAndFirefox = (styles) => css`
205
- @media not all and (min-resolution: 0.001dpcm) {
206
- ${styles}
207
- }
208
- @media screen and (min--moz-device-pixel-ratio: 0) {
209
- ${styles}
210
- }
211
- `;
212
- const onlySafari = (styles) => `
213
- @media not all and (min-resolution: 0.001dpcm) {
214
- ${styles}
215
- }
216
- `;
217
- const onlyFirefox = (styles) => `
218
- @media screen and (min--moz-device-pixel-ratio: 0) {
219
- ${styles}
220
- }
221
- `;
222
- const safariAndFirefoxBold = (color2) => `
223
- @media not all and (min-resolution: 0.001dpcm) {
224
- font-weight: 400;
225
- -webkit-font-smoothing: subpixel-antialiased;
226
- -webkit-text-stroke: 0.4px ${color2};
227
- }
228
- @media screen and (min--moz-device-pixel-ratio: 0) {
229
- font-weight: 400;
230
- -webkit-font-smoothing: subpixel-antialiased;
231
- -webkit-text-stroke: 0.4px ${color2};
232
- }
233
- `;
234
- export {
235
- active,
236
- animation,
237
- border,
238
- boxShadow,
239
- buttonLink,
240
- clearFocus,
241
- color,
242
- createGlobalStyle,
243
- css,
244
- disabled,
245
- fakeActive,
246
- fakeBorder,
247
- flexCenter,
248
- focus,
249
- focusAfter,
250
- hover,
251
- iconColor,
252
- keyframes,
253
- kfrm,
254
- onlyFirefox,
255
- onlySafari,
256
- onlySafariAndFirefox,
257
- rgba,
258
- safariAndFirefoxBold,
259
- textStyle,
260
- transition,
261
- truncate,
262
- useTheme,
263
- withTheme
264
- };
265
- //# sourceMappingURL=utils.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/utils.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-shadow */\n/* eslint-disable max-lines */\n// https://github.com/styled-components/babel-plugin-styled-components/issues/216#issuecomment-516941240\nimport { lighten, rgba } from 'polished';\nimport { reduce } from 'lodash';\nimport { Keyframes, css, withTheme, keyframes as kfrm, createGlobalStyle, useTheme } from 'styled-components';\nimport { theme } from './theme';\nimport { toMobile } from './mobileUtilities';\n\nexport { withTheme, createGlobalStyle, rgba, useTheme, kfrm, css };\n\nexport function truncate(width?: string) {\n return (props) => css`\n ${!!width || props.width ? `width: ${props.width || width};` : ''}\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n `;\n}\n\nexport function flexCenter(): string {\n return `\n display: flex;\n justify-content: center;\n align-items: center;\n `;\n}\n\nexport function disabled(): string {\n return `\n cursor: not-allowed;\n pointer-events: none;\n `;\n}\n\nexport function keyframes(obj: Record<string, unknown>): Keyframes {\n return kfrm`${reduce(\n obj,\n (result, value, key) => `\n ${result}\n ${key}% {\n ${value}\n }\n `,\n '',\n )}\n `;\n}\n\n// eslint-disable-next-line max-params\nexport function boxShadow(top: string, left: string, blur: string, color: string, inset = false): string {\n return `box-shadow: ${inset ? 'inset' : ''} ${top} ${left} ${blur} ${color};`;\n}\n\nexport function color(variant = 'neutral', type = 400) {\n return css`\n color: ${(props) => props.theme.colors[variant][type]};\n `;\n}\n\nexport function border(color = theme.colors.brand[600], size = '1px', type = 'solid'): string {\n return `${size} ${type} ${color}`;\n}\n\nexport function animation(animationKeyframes: string, animationLength: string, animationTimingFn: string) {\n return (props) => css`\n animation: ${props.animationKeyframes || animationKeyframes} ${props.animationLength || animationLength}\n ${props.animationTimingFn || animationTimingFn};\n `;\n}\n// 0.0769\nexport function focus(color: string = theme.colors.brand[600]) {\n return () => css`\n outline: none;\n border: 1px solid ${color};\n box-shadow: inset 0 0 0 1px ${lighten(0.3, color)};\n border-radius: 2px;\n `;\n}\n\nexport function focusAfter(color: string) {\n return css`\n outline: none;\n position: relative;\n &:after {\n content: '';\n z-index: 10;\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n ${focus(color)}\n }\n `;\n}\n\nexport function active() {\n return (props) => css`\n outline: none;\n border: 1px solid ${props.theme.colors.brand[700]};\n border-radius: 2px;\n `;\n}\n\nexport function hover() {\n return (props) => css`\n outline: 1px solid ${props.theme.colors.brand[600]};\n outline-offset: -1px;\n `;\n}\n\nexport function textStyle(type: string, weight = 'regular') {\n // eslint-disable-next-line complexity\n return (props): string => {\n let cssVar = `font-weight: ${props.theme.fontWeights[weight]};`;\n // eslint-disable-next-line default-case\n switch (type) {\n case 'h1':\n cssVar += `\n font-size: ${toMobile('2.7692rem')};\n line-height: normal;\n `;\n break;\n case 'h2':\n cssVar += `\n font-size: ${toMobile(props.theme.fontSizes.title[800])};\n line-height: normal;\n `;\n break;\n case 'h3':\n cssVar += `\n font-size: ${toMobile(props.theme.fontSizes.title[700])};\n line-height: 1.2;\n `;\n break;\n case 'h4':\n cssVar += `\n font-size: ${toMobile(props.theme.fontSizes.title[600])};\n line-height: normal;\n `;\n break;\n case 'h5':\n cssVar += `\n font-size: ${toMobile(props.theme.fontSizes.title[500])};\n line-height: normal;\n `;\n break;\n case 'section-header':\n cssVar += `\n font-size: ${toMobile(props.theme.fontSizes.title[500])};\n line-height: normal;\n text-transform: uppercase;\n `;\n break;\n case 'body':\n cssVar += `\n font-size: ${toMobile(props.theme.fontSizes.value[400])};\n line-height: normal;\n `;\n break;\n case 'body-small':\n cssVar += `\n font-size: ${toMobile(props.theme.fontSizes.value[300])};\n line-height: normal;\n `;\n break;\n case 'body-micro':\n cssVar += `\n font-size: ${toMobile(props.theme.fontSizes.microText[200])};\n line-height: normal;\n `;\n break;\n case 'list':\n cssVar += `\n font-size: ${toMobile(props.theme.fontSizes.value[400])};\n line-height: normal;\n `;\n break;\n case 'link':\n cssVar += `\n line-height: ${props.theme.xl};\n color: ${props.theme.colors.brand[600]};\n cursor: pointer;\n `;\n break;\n }\n return cssVar;\n };\n}\n\nexport function iconColor(variant = 'neutral', type = 400) {\n return css`\n fill: ${(props) => props.theme.colors[variant][type]};\n `;\n}\n\nexport function fakeBorder() {\n return css`\n box-shadow: inset 0 0 0 1px ${(props) => props.theme.colors.neutral[200]};\n border-radius: 2px;\n `;\n}\n\nexport function fakeActive() {\n return css`\n outline: none;\n box-shadow: inset 0 0 0 1px ${(props) => props.theme.colors.brand[700]};\n border-radius: 2px;\n `;\n}\n\nexport function clearFocus(): string {\n return `\n border: none;\n box-shadow: none;\n `;\n}\n\nexport function buttonLink(): string {\n return `\n background-color: transparent;\n border: 1px solid transparent;\n cursor: pointer;\n `;\n}\n\nexport function transition(t = 'all 1s ease'): string {\n return `\n transition: ${t};\n `;\n}\n\nexport const onlySafariAndFirefox = (styles: string): string => css`\n @media not all and (min-resolution: 0.001dpcm) {\n ${styles}\n }\n @media screen and (min--moz-device-pixel-ratio: 0) {\n ${styles}\n }\n`;\n\nexport const onlySafari = (styles: string): string => `\n @media not all and (min-resolution: 0.001dpcm) {\n ${styles}\n }\n `;\n\nexport const onlyFirefox = (styles: string): string => `\n @media screen and (min--moz-device-pixel-ratio: 0) {\n ${styles}\n }\n `;\n\nexport const safariAndFirefoxBold = (color: string): string => `\n @media not all and (min-resolution: 0.001dpcm) {\n font-weight: 400;\n -webkit-font-smoothing: subpixel-antialiased;\n -webkit-text-stroke: 0.4px ${color};\n }\n @media screen and (min--moz-device-pixel-ratio: 0) {\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