@charcoal-ui/styled 3.9.1 → 3.10.1-beta.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/index.cjs.js +177 -11
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +12 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.esm.js +174 -11
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.story.d.ts +0 -8
  8. package/dist/index.story.d.ts.map +1 -1
  9. package/dist/index.test.d.ts +5 -0
  10. package/dist/index.test.d.ts.map +1 -1
  11. package/dist/storyHelper.d.ts +2 -1
  12. package/dist/storyHelper.d.ts.map +1 -1
  13. package/dist/styles/assertiveRingCss.d.ts +2 -0
  14. package/dist/styles/assertiveRingCss.d.ts.map +1 -0
  15. package/dist/styles/disabledCss.d.ts +2 -0
  16. package/dist/styles/disabledCss.d.ts.map +1 -0
  17. package/dist/utils/CharcoalStyledTheme.d.ts +35 -0
  18. package/dist/utils/CharcoalStyledTheme.d.ts.map +1 -0
  19. package/dist/utils/addThemeUtils.d.ts +8 -0
  20. package/dist/utils/addThemeUtils.d.ts.map +1 -0
  21. package/dist/utils/gap.d.ts +7 -0
  22. package/dist/utils/gap.d.ts.map +1 -0
  23. package/dist/utils/helpers/SpacingType.d.ts +3 -0
  24. package/dist/utils/helpers/SpacingType.d.ts.map +1 -0
  25. package/dist/utils/helpers/pxIfNum.d.ts +2 -0
  26. package/dist/utils/helpers/pxIfNum.d.ts.map +1 -0
  27. package/dist/utils/margin.d.ts +11 -0
  28. package/dist/utils/margin.d.ts.map +1 -0
  29. package/dist/utils/padding.d.ts +11 -0
  30. package/dist/utils/padding.d.ts.map +1 -0
  31. package/dist/utils/typographyCss.d.ts +2 -0
  32. package/dist/utils/typographyCss.d.ts.map +1 -0
  33. package/package.json +8 -6
  34. package/src/__snapshots__/index.story.storyshot +88 -691
  35. package/src/__snapshots__/index.test.tsx.snap +177 -664
  36. package/src/index.story.tsx +81 -272
  37. package/src/index.test.tsx +55 -5
  38. package/src/index.ts +12 -1
  39. package/src/storyHelper.ts +8 -5
  40. package/src/styles/assertiveRingCss.ts +5 -0
  41. package/src/styles/disabledCss.ts +9 -0
  42. package/src/themeUtils.mdx +44 -0
  43. package/src/utils/CharcoalStyledTheme.ts +47 -0
  44. package/src/utils/addThemeUtils.ts +52 -0
  45. package/src/utils/gap.ts +28 -0
  46. package/src/utils/helpers/SpacingType.ts +3 -0
  47. package/src/utils/helpers/pxIfNum.ts +5 -0
  48. package/src/utils/margin.ts +58 -0
  49. package/src/utils/padding.ts +58 -0
  50. package/src/utils/typographyCss.ts +39 -0
@@ -0,0 +1,28 @@
1
+ import { Spacing } from '@charcoal-ui/theme'
2
+ import { css, FlattenSimpleInterpolation } from 'styled-components'
3
+ import { pxIfNum } from './helpers/pxIfNum'
4
+
5
+ export function gap(v1: keyof Spacing): FlattenSimpleInterpolation
6
+
7
+ export function gap(
8
+ v1: keyof Spacing,
9
+ v2: keyof Spacing
10
+ ): FlattenSimpleInterpolation
11
+
12
+ export function gap(v1: keyof Spacing, v2?: keyof Spacing) {
13
+ return css`
14
+ gap: ${v1}px ${pxIfNum(v2)};
15
+ `
16
+ }
17
+
18
+ export function rowGap(v: keyof Spacing) {
19
+ return css`
20
+ row-gap: ${v}px;
21
+ `
22
+ }
23
+
24
+ export function columnGap(v: keyof Spacing) {
25
+ return css`
26
+ column-gap: ${v}px;
27
+ `
28
+ }
@@ -0,0 +1,3 @@
1
+ import { Spacing } from '@charcoal-ui/theme'
2
+
3
+ export type SpacingType = keyof Spacing | 'auto'
@@ -0,0 +1,5 @@
1
+ export function pxIfNum(v?: number | string) {
2
+ if (v === undefined) return ''
3
+ if (typeof v === 'number') return `${v}px`
4
+ return v
5
+ }
@@ -0,0 +1,58 @@
1
+ import { css, FlattenSimpleInterpolation } from 'styled-components'
2
+ import { SpacingType } from './helpers/SpacingType'
3
+ import { pxIfNum } from './helpers/pxIfNum'
4
+
5
+ export function margin(arg1: SpacingType): FlattenSimpleInterpolation
6
+
7
+ export function margin(
8
+ arg1: SpacingType,
9
+ arg2: SpacingType
10
+ ): FlattenSimpleInterpolation
11
+
12
+ export function margin(
13
+ arg1: SpacingType,
14
+ arg2: SpacingType,
15
+ arg3: SpacingType
16
+ ): FlattenSimpleInterpolation
17
+
18
+ export function margin(
19
+ arg1: SpacingType,
20
+ arg2: SpacingType,
21
+ arg3: SpacingType,
22
+ arg4: SpacingType
23
+ ): FlattenSimpleInterpolation
24
+
25
+ export function margin(
26
+ arg1: SpacingType,
27
+ arg2?: SpacingType,
28
+ arg3?: SpacingType,
29
+ arg4?: SpacingType
30
+ ) {
31
+ return css`
32
+ margin: ${pxIfNum(arg1)} ${pxIfNum(arg2)} ${pxIfNum(arg3)} ${pxIfNum(arg4)};
33
+ `
34
+ }
35
+
36
+ export function marginTop(v: SpacingType) {
37
+ return css`
38
+ margin-top: ${pxIfNum(v)};
39
+ `
40
+ }
41
+
42
+ export function marginBottom(v: SpacingType) {
43
+ return css`
44
+ margin-bottom: ${pxIfNum(v)};
45
+ `
46
+ }
47
+
48
+ export function marginLeft(v: SpacingType) {
49
+ return css`
50
+ margin-left: ${pxIfNum(v)};
51
+ `
52
+ }
53
+
54
+ export function marginRight(v: SpacingType) {
55
+ return css`
56
+ margin-right: ${pxIfNum(v)};
57
+ `
58
+ }
@@ -0,0 +1,58 @@
1
+ import { Spacing } from '@charcoal-ui/theme'
2
+ import { css, FlattenSimpleInterpolation } from 'styled-components'
3
+ import { pxIfNum } from './helpers/pxIfNum'
4
+
5
+ export function padding(arg1: keyof Spacing): FlattenSimpleInterpolation
6
+
7
+ export function padding(
8
+ arg1: keyof Spacing,
9
+ arg2: keyof Spacing
10
+ ): FlattenSimpleInterpolation
11
+
12
+ export function padding(
13
+ arg1: keyof Spacing,
14
+ arg2: keyof Spacing,
15
+ arg3: keyof Spacing
16
+ ): FlattenSimpleInterpolation
17
+
18
+ export function padding(
19
+ arg1: keyof Spacing,
20
+ arg2: keyof Spacing,
21
+ arg3: keyof Spacing,
22
+ arg4: keyof Spacing
23
+ ): FlattenSimpleInterpolation
24
+
25
+ export function padding(
26
+ arg1: keyof Spacing,
27
+ arg2?: keyof Spacing,
28
+ arg3?: keyof Spacing,
29
+ arg4?: keyof Spacing
30
+ ) {
31
+ return css`
32
+ padding: ${arg1}px ${pxIfNum(arg2)} ${pxIfNum(arg3)} ${pxIfNum(arg4)};
33
+ `
34
+ }
35
+
36
+ export function paddingTop(v: keyof Spacing) {
37
+ return css`
38
+ padding-top: ${v}px;
39
+ `
40
+ }
41
+
42
+ export function paddingBottom(v: keyof Spacing) {
43
+ return css`
44
+ padding-bottom: ${v}px;
45
+ `
46
+ }
47
+
48
+ export function paddingLeft(v: keyof Spacing) {
49
+ return css`
50
+ padding-left: ${v}px;
51
+ `
52
+ }
53
+
54
+ export function paddingRight(v: keyof Spacing) {
55
+ return css`
56
+ padding-right: ${v}px;
57
+ `
58
+ }
@@ -0,0 +1,39 @@
1
+ import { css } from 'styled-components'
2
+
3
+ const boldCss = css`
4
+ font-weight: bold;
5
+ `
6
+
7
+ const removeHalfLeadingCss = css`
8
+ &::before {
9
+ display: block;
10
+ width: 0;
11
+ height: 0;
12
+ content: '';
13
+ margin-top: -4px;
14
+ }
15
+
16
+ &::after {
17
+ display: block;
18
+ width: 0;
19
+ height: 0;
20
+ content: '';
21
+ margin-bottom: -4px;
22
+ }
23
+ `
24
+
25
+ export function typography(
26
+ size: 12 | 14 | 16 | 20,
27
+ bold = false,
28
+ preserveHalfLeading = false
29
+ ) {
30
+ const cssObj = css`
31
+ font-size: ${size}px;
32
+ line-height: ${size + 8}px;
33
+ display: flow-root;
34
+ ${bold === true && boldCss}
35
+ ${preserveHalfLeading !== true && removeHalfLeadingCss}
36
+ `
37
+
38
+ return cssObj
39
+ }