@edvisor/product-language 0.2.0 → 0.3.1

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 (248) hide show
  1. package/index.d.ts +2 -0
  2. package/index.js +7914 -0
  3. package/lib/components/alert-banner/alert-banner.d.ts +11 -0
  4. package/lib/components/alert-banner/alert-level-flags.d.ts +13 -0
  5. package/lib/components/alert-banner/index.d.ts +1 -0
  6. package/lib/components/badge/badge-type-flags.d.ts +18 -0
  7. package/lib/components/badge/badge.d.ts +5 -0
  8. package/lib/components/badge/index.d.ts +1 -0
  9. package/{src/lib/components/card/atoms/card-frame.tsx → lib/components/card/atoms/card-frame.d.ts} +7 -17
  10. package/lib/components/card/atoms/index.d.ts +1 -0
  11. package/lib/components/card/card.d.ts +14 -0
  12. package/lib/components/card/components/card-alert-banner-slot.d.ts +5 -0
  13. package/lib/components/card/components/card-controls-slot.d.ts +4 -0
  14. package/lib/components/card/components/card-section-slot.d.ts +11 -0
  15. package/lib/components/card/components/index.d.ts +3 -0
  16. package/lib/components/card/index.d.ts +2 -0
  17. package/lib/components/card/molecules/index.d.ts +1 -0
  18. package/lib/components/card/molecules/left-right-card.d.ts +16 -0
  19. package/lib/components/checkbox/checkbox.d.ts +10 -0
  20. package/lib/components/checkbox/helpers.d.ts +12 -0
  21. package/lib/components/checkbox/index.d.ts +1 -0
  22. package/lib/components/divider/divider-type-flags.d.ts +9 -0
  23. package/lib/components/divider/divider.d.ts +7 -0
  24. package/lib/components/divider/index.d.ts +1 -0
  25. package/lib/components/flag/flag-size-flags.d.ts +12 -0
  26. package/lib/components/flag/flag.d.ts +9 -0
  27. package/lib/components/flag/flag.list.d.ts +781 -0
  28. package/lib/components/flag/index.d.ts +1 -0
  29. package/lib/components/icon/icon-list.d.ts +131 -0
  30. package/lib/components/icon/icon.d.ts +131 -0
  31. package/lib/components/icon/index.d.ts +1 -0
  32. package/lib/components/index.d.ts +17 -0
  33. package/lib/components/input-field/components/index.d.ts +2 -0
  34. package/lib/components/input-field/components/labeled-input.d.ts +10 -0
  35. package/lib/components/input-field/components/stepper.d.ts +7 -0
  36. package/lib/components/input-field/index.d.ts +3 -0
  37. package/lib/components/input-field/input-field.d.ts +25 -0
  38. package/lib/components/input-field/input-number.d.ts +18 -0
  39. package/lib/components/input-field/input-text.d.ts +14 -0
  40. package/lib/components/layout/flex.d.ts +16 -0
  41. package/lib/components/layout/grid-layout.d.ts +11 -0
  42. package/lib/components/layout/index.d.ts +3 -0
  43. package/lib/components/layout/left-right-layout.d.ts +34 -0
  44. package/lib/components/link/index.d.ts +1 -0
  45. package/lib/components/link/link.d.ts +14 -0
  46. package/lib/components/molecules/avatar/avatar-size-flags.d.ts +12 -0
  47. package/lib/components/molecules/avatar/avatar.d.ts +12 -0
  48. package/lib/components/molecules/avatar/index.d.ts +1 -0
  49. package/lib/components/molecules/button/button-flags.d.ts +44 -0
  50. package/lib/components/molecules/button/button.d.ts +12 -0
  51. package/lib/components/molecules/button/index.d.ts +1 -0
  52. package/lib/components/molecules/index.d.ts +3 -0
  53. package/lib/components/molecules/input-checkbox/index.d.ts +1 -0
  54. package/lib/components/molecules/input-checkbox/input-checkbox.d.ts +8 -0
  55. package/lib/components/organisms/index.d.ts +1 -0
  56. package/lib/components/organisms/multi-choice-list/index.d.ts +1 -0
  57. package/lib/components/organisms/multi-choice-list/multi-choice-list.d.ts +10 -0
  58. package/lib/components/spinner/index.d.ts +1 -0
  59. package/lib/components/spinner/spinner-size-flags.d.ts +10 -0
  60. package/lib/components/spinner/spinner.d.ts +9 -0
  61. package/lib/components/tabs/components/index.d.ts +1 -0
  62. package/lib/components/tabs/components/tab.d.ts +7 -0
  63. package/lib/components/tabs/index.d.ts +1 -0
  64. package/lib/components/tabs/tabs.d.ts +15 -0
  65. package/lib/components/tag/components/close-button.d.ts +8 -0
  66. package/lib/components/tag/components/index.d.ts +2 -0
  67. package/lib/components/tag/components/tag-label.d.ts +8 -0
  68. package/lib/components/tag/index.d.ts +1 -0
  69. package/lib/components/tag/tag.d.ts +10 -0
  70. package/lib/components/thumbnail/index.d.ts +1 -0
  71. package/lib/components/thumbnail/thumbnail-size-flags.d.ts +10 -0
  72. package/lib/components/thumbnail/thumbnail.d.ts +10 -0
  73. package/lib/components/typography/index.d.ts +1 -0
  74. package/lib/components/typography/typography.d.ts +24 -0
  75. package/lib/foundations/color-system/base-palette/base-palette.d.ts +76 -0
  76. package/lib/foundations/color-system/base-palette/index.d.ts +1 -0
  77. package/lib/foundations/color-system/color-guidelines/color-guidelines.d.ts +132 -0
  78. package/lib/foundations/color-system/color-guidelines/index.d.ts +1 -0
  79. package/lib/foundations/color-system/components/color-sample.d.ts +17 -0
  80. package/lib/foundations/color-system/components/index.d.ts +1 -0
  81. package/lib/foundations/color-system/index.d.ts +1 -0
  82. package/lib/foundations/index.d.ts +4 -0
  83. package/lib/foundations/shadows/components.d.ts +8 -0
  84. package/lib/foundations/shadows/index.d.ts +1 -0
  85. package/lib/foundations/shadows/shadows.d.ts +8 -0
  86. package/lib/foundations/spacing/index.d.ts +1 -0
  87. package/lib/foundations/spacing/spacing-guidelines.d.ts +22 -0
  88. package/lib/foundations/spacing/spacing.d.ts +18 -0
  89. package/lib/foundations/typography/constants.d.ts +22 -0
  90. package/lib/foundations/typography/fonts.d.ts +1 -0
  91. package/lib/foundations/typography/index.d.ts +1 -0
  92. package/lib/foundations/typography/text-aspect-flags.d.ts +19 -0
  93. package/lib/foundations/typography/typography.d.ts +24 -0
  94. package/lib/helpers/generic-types.d.ts +21 -0
  95. package/lib/helpers/index.d.ts +6 -0
  96. package/lib/helpers/nothing.d.ts +8 -0
  97. package/{src/lib/helpers/numbers.ts → lib/helpers/numbers.d.ts} +50 -53
  98. package/lib/helpers/safe-navigation.d.ts +15 -0
  99. package/lib/helpers/slots.d.ts +23 -0
  100. package/lib/helpers/strings.d.ts +1 -0
  101. package/package.json +12 -5
  102. package/.babelrc +0 -12
  103. package/.eslintrc.json +0 -139
  104. package/.storybook/main.js +0 -57
  105. package/.storybook/manager.js +0 -7
  106. package/.storybook/preview-head.html +0 -1
  107. package/.storybook/preview.js +0 -15
  108. package/.storybook/tsconfig.json +0 -30
  109. package/jest.config.ts +0 -15
  110. package/jest.setup.ts +0 -2
  111. package/project.json +0 -85
  112. package/release-it.json +0 -18
  113. package/src/assets/svg/example_icon.svg +0 -3
  114. package/src/assets/svg/example_icon_white.svg +0 -3
  115. package/src/assets/svg/spinner.svg +0 -3
  116. package/src/assets/svg/spinner_white.svg +0 -3
  117. package/src/helpers/index.ts +0 -3
  118. package/src/helpers/talesOf.tsx +0 -42
  119. package/src/index.ts +0 -2
  120. package/src/lib/components/README.md +0 -49
  121. package/src/lib/components/alert-banner/alert-banner.tsx +0 -34
  122. package/src/lib/components/alert-banner/alert-level-flags.ts +0 -77
  123. package/src/lib/components/alert-banner/index.ts +0 -1
  124. package/src/lib/components/badge/badge-type-flags.ts +0 -72
  125. package/src/lib/components/badge/badge.stories.tsx +0 -16
  126. package/src/lib/components/badge/badge.test.tsx +0 -29
  127. package/src/lib/components/badge/badge.tsx +0 -31
  128. package/src/lib/components/badge/index.ts +0 -1
  129. package/src/lib/components/card/atoms/index.ts +0 -1
  130. package/src/lib/components/card/card.test.tsx +0 -163
  131. package/src/lib/components/card/card.tsx +0 -78
  132. package/src/lib/components/card/components/card-alert-banner-slot.tsx +0 -16
  133. package/src/lib/components/card/components/card-controls-slot.tsx +0 -19
  134. package/src/lib/components/card/components/card-section-slot.tsx +0 -51
  135. package/src/lib/components/card/components/index.ts +0 -3
  136. package/src/lib/components/card/index.ts +0 -2
  137. package/src/lib/components/card/molecules/index.ts +0 -1
  138. package/src/lib/components/card/molecules/left-right-card.test.tsx +0 -89
  139. package/src/lib/components/card/molecules/left-right-card.tsx +0 -63
  140. package/src/lib/components/card/storybook/card.stories.mdx +0 -100
  141. package/src/lib/components/card/storybook/components.tsx +0 -240
  142. package/src/lib/components/checkbox/checkbox.test.tsx +0 -39
  143. package/src/lib/components/checkbox/checkbox.tsx +0 -124
  144. package/src/lib/components/checkbox/components/components.tsx +0 -59
  145. package/src/lib/components/checkbox/index.tsx +0 -1
  146. package/src/lib/components/checkbox/stories/checkbox.stories.mdx +0 -54
  147. package/src/lib/components/checkbox/stories/components.tsx +0 -36
  148. package/src/lib/components/checkbox/stories/index.tsx +0 -1
  149. package/src/lib/components/divider/divider-type-flags.tsx +0 -37
  150. package/src/lib/components/divider/divider.test.tsx +0 -34
  151. package/src/lib/components/divider/divider.tsx +0 -37
  152. package/src/lib/components/divider/index.tsx +0 -1
  153. package/src/lib/components/divider/stories/components.tsx +0 -13
  154. package/src/lib/components/divider/stories/divider.stories.mdx +0 -50
  155. package/src/lib/components/index.ts +0 -14
  156. package/src/lib/components/input-field/components/index.ts +0 -2
  157. package/src/lib/components/input-field/components/labeled-input.tsx +0 -61
  158. package/src/lib/components/input-field/components/stepper.tsx +0 -59
  159. package/src/lib/components/input-field/index.ts +0 -6
  160. package/src/lib/components/input-field/input-field.test.tsx +0 -108
  161. package/src/lib/components/input-field/input-field.tsx +0 -126
  162. package/src/lib/components/input-field/input-number.tsx +0 -41
  163. package/src/lib/components/input-field/input-text.tsx +0 -30
  164. package/src/lib/components/input-field/storybook/components.tsx +0 -334
  165. package/src/lib/components/input-field/storybook/input-field.stories.mdx +0 -113
  166. package/src/lib/components/layout/flex.tsx +0 -22
  167. package/src/lib/components/layout/grid-layout.tsx +0 -40
  168. package/src/lib/components/layout/index.ts +0 -3
  169. package/src/lib/components/layout/left-right-layout.tsx +0 -67
  170. package/src/lib/components/link/index.ts +0 -1
  171. package/src/lib/components/link/link.test.tsx +0 -29
  172. package/src/lib/components/link/link.tsx +0 -56
  173. package/src/lib/components/link/storybook/link.stories.mdx +0 -51
  174. package/src/lib/components/molecules/avatar/avatar-size-flags.tsx +0 -55
  175. package/src/lib/components/molecules/avatar/avatar.test.tsx +0 -114
  176. package/src/lib/components/molecules/avatar/avatar.tsx +0 -80
  177. package/src/lib/components/molecules/avatar/index.tsx +0 -1
  178. package/src/lib/components/molecules/avatar/stories/avatar.stories.mdx +0 -55
  179. package/src/lib/components/molecules/avatar/stories/components.tsx +0 -36
  180. package/src/lib/components/molecules/button/button-flags.tsx +0 -235
  181. package/src/lib/components/molecules/button/button.test.tsx +0 -77
  182. package/src/lib/components/molecules/button/button.tsx +0 -231
  183. package/src/lib/components/molecules/button/index.tsx +0 -1
  184. package/src/lib/components/molecules/button/stories/button.stories.mdx +0 -104
  185. package/src/lib/components/molecules/button/stories/components.tsx +0 -86
  186. package/src/lib/components/molecules/index.ts +0 -3
  187. package/src/lib/components/molecules/input-checkbox/index.tsx +0 -1
  188. package/src/lib/components/molecules/input-checkbox/input-checkbox.test.tsx +0 -34
  189. package/src/lib/components/molecules/input-checkbox/input-checkbox.tsx +0 -50
  190. package/src/lib/components/molecules/input-checkbox/stories/components.tsx +0 -36
  191. package/src/lib/components/molecules/input-checkbox/stories/index.tsx +0 -1
  192. package/src/lib/components/molecules/input-checkbox/stories/input-checkbox.stories.mdx +0 -51
  193. package/src/lib/components/organisms/index.ts +0 -1
  194. package/src/lib/components/organisms/multi-choice-list/index.tsx +0 -1
  195. package/src/lib/components/organisms/multi-choice-list/multi-choice-list.test.tsx +0 -33
  196. package/src/lib/components/organisms/multi-choice-list/multi-choice-list.tsx +0 -53
  197. package/src/lib/components/organisms/multi-choice-list/stories/components.tsx +0 -126
  198. package/src/lib/components/organisms/multi-choice-list/stories/index.tsx +0 -1
  199. package/src/lib/components/organisms/multi-choice-list/stories/multi-choice-list.stories.mdx +0 -99
  200. package/src/lib/components/spinner/index.tsx +0 -1
  201. package/src/lib/components/spinner/spinner-size-flags.tsx +0 -39
  202. package/src/lib/components/spinner/spinner.test.tsx +0 -31
  203. package/src/lib/components/spinner/spinner.tsx +0 -67
  204. package/src/lib/components/spinner/stories/components.tsx +0 -8
  205. package/src/lib/components/spinner/stories/spinner.stories.mdx +0 -42
  206. package/src/lib/components/thumbnail/index.tsx +0 -1
  207. package/src/lib/components/thumbnail/stories/thumbnail.stories.mdx +0 -34
  208. package/src/lib/components/thumbnail/thumbnail-size-flags.tsx +0 -41
  209. package/src/lib/components/thumbnail/thumbnail.test.tsx +0 -51
  210. package/src/lib/components/thumbnail/thumbnail.tsx +0 -40
  211. package/src/lib/components/typography/index.ts +0 -1
  212. package/src/lib/components/typography/storybook/components.tsx +0 -256
  213. package/src/lib/components/typography/storybook/typography.stories.mdx +0 -88
  214. package/src/lib/components/typography/typography.test.tsx +0 -93
  215. package/src/lib/components/typography/typography.tsx +0 -57
  216. package/src/lib/foundations/color-system/base-palette/base-palette.stories.tsx +0 -123
  217. package/src/lib/foundations/color-system/base-palette/base-palette.ts +0 -94
  218. package/src/lib/foundations/color-system/base-palette/index.ts +0 -1
  219. package/src/lib/foundations/color-system/color-guidelines/color-guidelines.stories.mdx +0 -85
  220. package/src/lib/foundations/color-system/color-guidelines/color-guidelines.stories.tsx +0 -231
  221. package/src/lib/foundations/color-system/color-guidelines/color-guidelines.ts +0 -159
  222. package/src/lib/foundations/color-system/color-guidelines/index.ts +0 -1
  223. package/src/lib/foundations/color-system/components/color-sample.tsx +0 -99
  224. package/src/lib/foundations/color-system/components/index.ts +0 -1
  225. package/src/lib/foundations/color-system/index.ts +0 -1
  226. package/src/lib/foundations/index.ts +0 -4
  227. package/src/lib/foundations/shadows/components.tsx +0 -59
  228. package/src/lib/foundations/shadows/index.ts +0 -1
  229. package/src/lib/foundations/shadows/shadows.stories.mdx +0 -71
  230. package/src/lib/foundations/shadows/shadows.tsx +0 -47
  231. package/src/lib/foundations/spacing/index.ts +0 -1
  232. package/src/lib/foundations/spacing/spacing-guidelines.ts +0 -24
  233. package/src/lib/foundations/spacing/spacing.stories.mdx +0 -51
  234. package/src/lib/foundations/spacing/spacing.ts +0 -18
  235. package/src/lib/foundations/typography/constants.ts +0 -25
  236. package/src/lib/foundations/typography/index.tsx +0 -1
  237. package/src/lib/foundations/typography/text-aspect-flags.ts +0 -54
  238. package/src/lib/foundations/typography/typography.tsx +0 -97
  239. package/src/lib/helpers/generic-types.ts +0 -44
  240. package/src/lib/helpers/index.ts +0 -6
  241. package/src/lib/helpers/nothing.tsx +0 -18
  242. package/src/lib/helpers/safe-navigation.ts +0 -34
  243. package/src/lib/helpers/slots.tsx +0 -76
  244. package/src/lib/helpers/strings.test.ts +0 -47
  245. package/src/lib/helpers/strings.ts +0 -16
  246. package/tsconfig.json +0 -35
  247. package/tsconfig.lib.json +0 -28
  248. package/tsconfig.spec.json +0 -21
@@ -1,235 +0,0 @@
1
- // this file was generated, but it is safe to modify
2
- import {
3
- bitwiseOr,
4
- MappedEnum,
5
- RequireOnlyOne,
6
- PropsWithChildren,
7
- } from '@helpers'
8
- import { Actions, Padding, Interactive, Text, Borders } from '@foundations'
9
-
10
- export const enum ButtonType {
11
- basic = 1,
12
- primary = 2,
13
- primaryDestructive = 4,
14
- destructive = 8,
15
- outline = 16,
16
- plain = 32,
17
- plainSubtle = 64,
18
- }
19
-
20
- const enum ButtonSize {
21
- default = 1,
22
- small = 2,
23
- large = 4,
24
- }
25
-
26
- const enum ButtonDisabledType {
27
- enabled = 1,
28
- disabled = 2,
29
- }
30
-
31
- type ButtonTypes<T> = MappedEnum<typeof ButtonType, T>
32
- type ButtonSizes<T> = MappedEnum<typeof ButtonSize, T>
33
- type ButtonDisabledTypes<T> = MappedEnum<typeof ButtonDisabledType, T>
34
-
35
- function toButtonSize(n: number): ButtonSize {
36
- switch (n) {
37
- case ButtonSize.default:
38
- return ButtonSize.default
39
- case ButtonSize.small:
40
- return ButtonSize.small
41
- case ButtonSize.large:
42
- return ButtonSize.large
43
- default:
44
- return ButtonSize.default
45
- }
46
- }
47
-
48
- function toButtonDisabledType(n: number): ButtonDisabledType {
49
- switch (n) {
50
- case ButtonDisabledType.enabled:
51
- return ButtonDisabledType.enabled
52
- case ButtonDisabledType.disabled:
53
- return ButtonDisabledType.disabled
54
- default:
55
- return ButtonDisabledType.enabled
56
- }
57
- }
58
-
59
- const ButtonBackgroundColorValues = {
60
- [ButtonType.basic]: Actions.Secondary.Default,
61
- [ButtonType.primary]: Actions.Primary.Default,
62
- [ButtonType.primaryDestructive]: Actions.Critical.Default,
63
- [ButtonType.destructive]: 'none',
64
- [ButtonType.outline]: 'none',
65
- [ButtonType.plain]: 'none',
66
- [ButtonType.plainSubtle]: 'none',
67
- }
68
-
69
- const ButtonBackgroundColorDisabledValues = {
70
- [ButtonType.basic]: Actions.Secondary.Disabled,
71
- [ButtonType.primary]: Actions.Primary.Disabled,
72
- [ButtonType.primaryDestructive]: Actions.Critical.Disabled,
73
- [ButtonType.destructive]: Actions.Secondary.Disabled,
74
- [ButtonType.outline]: 'none',
75
- [ButtonType.plain]: 'none',
76
- [ButtonType.plainSubtle]: 'none',
77
- }
78
-
79
- const ButtonBackgroundColorHoverValues = {
80
- [ButtonType.basic]: Actions.Secondary.Hover,
81
- [ButtonType.primary]: Actions.Primary.Hover,
82
- [ButtonType.primaryDestructive]: Actions.Critical.Hover,
83
- [ButtonType.destructive]: Actions.Critical.Hover,
84
- [ButtonType.outline]: Actions.Secondary.Hover,
85
- [ButtonType.plain]: '',
86
- [ButtonType.plainSubtle]: '',
87
- }
88
-
89
- const ButtonBackgroundColorPressedValues = {
90
- [ButtonType.basic]: Actions.Secondary.Pressed,
91
- [ButtonType.primary]: Actions.Primary.Pressed,
92
- [ButtonType.primaryDestructive]: Actions.Critical.Pressed,
93
- [ButtonType.destructive]: Actions.Critical.Pressed,
94
- [ButtonType.outline]: Actions.Secondary.Pressed,
95
- [ButtonType.plain]: Actions.Secondary.Hover,
96
- [ButtonType.plainSubtle]: Actions.Secondary.Hover,
97
- }
98
-
99
- const ButtonTextColorValues = {
100
- [ButtonType.basic]: Text.Default,
101
- [ButtonType.primary]: Text.OnPrimary,
102
- [ButtonType.primaryDestructive]: Text.OnCritical,
103
- [ButtonType.destructive]: Text.Default,
104
- [ButtonType.outline]: Text.Default,
105
- [ButtonType.plain]: Interactive.Default.Default,
106
- [ButtonType.plainSubtle]: Interactive.Subtle.Default,
107
- }
108
-
109
- const ButtonTextColorHoverValues = {
110
- [ButtonType.basic]: Text.Default,
111
- [ButtonType.primary]: Text.OnPrimary,
112
- [ButtonType.primaryDestructive]: Text.OnCritical,
113
- [ButtonType.destructive]: Text.OnCritical,
114
- [ButtonType.outline]: Text.Default,
115
- [ButtonType.plain]: Interactive.Default.Hover,
116
- [ButtonType.plainSubtle]: Interactive.Subtle.Hover,
117
- }
118
-
119
- const ButtonBorderValues = {
120
- [ButtonType.basic]: `1px solid ${Borders.Default.Default}`,
121
- [ButtonType.primary]: 'none',
122
- [ButtonType.primaryDestructive]: 'none',
123
- [ButtonType.destructive]: `1px solid ${Borders.Default.Default}`,
124
- [ButtonType.outline]: `1px solid ${Borders.Default.Default}`,
125
- [ButtonType.plain]: 'none',
126
- [ButtonType.plainSubtle]: 'none',
127
- }
128
-
129
- const ButtonBorderDisabledValues = {
130
- [ButtonType.basic]: `1px solid ${Borders.Default.Subdued}`,
131
- [ButtonType.primary]: 'none',
132
- [ButtonType.primaryDestructive]: 'none',
133
- [ButtonType.destructive]: `1px solid ${Borders.Default.Subdued}`,
134
- [ButtonType.outline]: `1px solid ${Borders.Default.Default}`,
135
- [ButtonType.plain]: 'none',
136
- [ButtonType.plainSubtle]: 'none',
137
- }
138
-
139
- const ButtonTextColorDisabled = {
140
- [ButtonDisabledType.enabled]: '',
141
- [ButtonDisabledType.disabled]: Text.Light,
142
- }
143
-
144
- const ButtonCursor = {
145
- [ButtonDisabledType.enabled]: 'pointer',
146
- [ButtonDisabledType.disabled]: 'not-allowed',
147
- }
148
-
149
- const ButtonSizeValues = {
150
- [ButtonSize.small]: `${Padding.xxs} ${Padding.s}`,
151
- [ButtonSize.default]: `${Padding.xs} ${Padding.m}`,
152
- [ButtonSize.large]: `${Padding.s} ${Padding.l}`,
153
- }
154
-
155
- const ButtonSizeValuesByType = {
156
- [ButtonType.basic]: '',
157
- [ButtonType.primary]: '',
158
- [ButtonType.primaryDestructive]: '',
159
- [ButtonType.destructive]: '',
160
- [ButtonType.outline]: '',
161
- [ButtonType.plain]: `${Padding.xxxs} ${Padding.xxs}`,
162
- [ButtonType.plainSubtle]: `${Padding.xxxs} ${Padding.xxs}`,
163
- }
164
-
165
- export type ButtonTypeProps = Partial<RequireOnlyOne<ButtonTypes<boolean>>> &
166
- PropsWithChildren
167
-
168
- export type ButtonSizeProps = Partial<RequireOnlyOne<ButtonSizes<boolean>>> &
169
- PropsWithChildren
170
-
171
- export type ButtonDisabledTypeProps = Partial<
172
- RequireOnlyOne<ButtonDisabledTypes<boolean>>
173
- > &
174
- PropsWithChildren
175
-
176
- export function getBackgroundColorByType(type: ButtonType): string {
177
- return ButtonBackgroundColorValues[type]
178
- }
179
-
180
- export function getBackgroundColorHoverByType(type: ButtonType): string {
181
- return ButtonBackgroundColorHoverValues[type]
182
- }
183
-
184
- export function getBackgroundColorDisabledByType(type: ButtonType): string {
185
- return ButtonBackgroundColorDisabledValues[type]
186
- }
187
-
188
- export function getBackgroundColorPressedByType(type: ButtonType): string {
189
- return ButtonBackgroundColorPressedValues[type]
190
- }
191
-
192
- export function getTextColorByType(type: ButtonType): string {
193
- return ButtonTextColorValues[type]
194
- }
195
-
196
- export function getTextColorOnHoverByType(type: ButtonType): string {
197
- return ButtonTextColorHoverValues[type]
198
- }
199
-
200
- export function getBorderByType(type: ButtonType): string {
201
- return ButtonBorderValues[type]
202
- }
203
-
204
- export function getBorderDisabledByType(type: ButtonType): string {
205
- return ButtonBorderDisabledValues[type]
206
- }
207
-
208
- export function getPaddingBySize(props: ButtonSizeProps): string {
209
- return ButtonSizeValues[
210
- toButtonSize(bitwiseOr([props.default, props.small, props.large]))
211
- ]
212
- }
213
-
214
- export function getPaddingByType(type: ButtonType): string {
215
- return ButtonSizeValuesByType[type]
216
- }
217
-
218
- export function getTextColorIfDisabled(props: ButtonDisabledTypeProps): string {
219
- return ButtonTextColorDisabled[
220
- toButtonDisabledType(bitwiseOr([props.enabled, props.disabled]))
221
- ]
222
- }
223
-
224
- export function getCursor(props: ButtonDisabledTypeProps): string {
225
- return ButtonCursor[
226
- toButtonDisabledType(bitwiseOr([props.enabled, props.disabled]))
227
- ]
228
- }
229
-
230
- export function getIsDisabled(props: ButtonDisabledTypeProps): boolean {
231
- return (
232
- toButtonDisabledType(bitwiseOr([props.enabled, props.disabled])) ===
233
- ButtonDisabledType.disabled
234
- )
235
- }
@@ -1,77 +0,0 @@
1
- import { Actions } from '@foundations'
2
- import {render, screen } from '@testing-library/react'
3
- import { ButtonBasic, ButtonPrimary, ButtonDestructive, ButtonOutline, ButtonPlain } from './index'
4
-
5
- describe('Button Tests', () => {
6
- describe('ButtonBasic Tests', () => {
7
- it('should render Button with given Text', async () => {
8
- render(
9
- <ButtonBasic>Test Button</ButtonBasic>
10
- )
11
-
12
- expect(screen.getByText('Test Button')).toBeInTheDocument()
13
- expect(screen.queryByRole('button')).toBeInTheDocument()
14
- })
15
-
16
- })
17
-
18
- describe('ButtonPrimary Tests', () => {
19
- it('should render Button with given Text', async () => {
20
- render(
21
- <ButtonPrimary>Test Button</ButtonPrimary>
22
- )
23
-
24
- expect(screen.getByText('Test Button')).toBeInTheDocument()
25
- expect(screen.queryByRole('button')).toBeInTheDocument()
26
- })
27
-
28
- })
29
-
30
- describe('ButtonDestructive Tests', () => {
31
- it('should render Button with given Text', async () => {
32
- render(
33
- <ButtonDestructive>Test Button</ButtonDestructive>
34
- )
35
-
36
- expect(screen.getByText('Test Button')).toBeInTheDocument()
37
- expect(screen.queryByRole('button')).toBeInTheDocument()
38
- expect(screen.getByTestId('button-test')).toHaveStyle('background: none')
39
- })
40
-
41
- it('should render Button with given Text', async () => {
42
- render(
43
- <ButtonDestructive primary>Test Button</ButtonDestructive>
44
- )
45
-
46
- expect(screen.getByText('Test Button')).toBeInTheDocument()
47
- expect(screen.queryByRole('button')).toBeInTheDocument()
48
- expect(screen.getByTestId('button-test')).toHaveStyle(`background: ${Actions.Critical.Default}`)
49
- })
50
-
51
-
52
- })
53
-
54
- describe('ButtonOutline Tests', () => {
55
- it('should render Button with given Text', async () => {
56
- render(
57
- <ButtonOutline>Test Button</ButtonOutline>
58
- )
59
-
60
- expect(screen.getByText('Test Button')).toBeInTheDocument()
61
- expect(screen.queryByRole('button')).toBeInTheDocument()
62
- })
63
-
64
- })
65
-
66
- describe('ButtonPlain Tests', () => {
67
- it('should render Button with given Text', async () => {
68
- render(
69
- <ButtonPlain>Test Button</ButtonPlain>
70
- )
71
-
72
- expect(screen.getByText('Test Button')).toBeInTheDocument()
73
- expect(screen.queryByRole('button')).toBeInTheDocument()
74
- })
75
- })
76
-
77
- })
@@ -1,231 +0,0 @@
1
- import styled from 'styled-components'
2
- import { FC, is, isDefined } from '@helpers'
3
- import { Focused } from '@foundations'
4
- import {
5
- ButtonSizeProps,
6
- getBackgroundColorByType,
7
- getIsDisabled,
8
- getTextColorByType,
9
- getTextColorIfDisabled,
10
- getCursor,
11
- getPaddingBySize,
12
- getBackgroundColorHoverByType,
13
- getTextColorOnHoverByType,
14
- getBorderByType,
15
- getPaddingByType,
16
- getBackgroundColorDisabledByType,
17
- getBorderDisabledByType,
18
- ButtonType,
19
- getBackgroundColorPressedByType,
20
- } from './button-flags'
21
- import { ComponentType } from 'react'
22
- import { Label1 } from 'components/typography'
23
- import { Spinner } from 'components/spinner'
24
-
25
- const ButtonFrame = styled.button<{
26
- backgroundColor: string
27
- buttonSize: string
28
- cursor: string
29
- backgroundHover: string
30
- backgroundPressed: string
31
- textColorHover: string
32
- buttonBorder: string
33
- isDisabled: boolean
34
- }>`
35
- padding: ${(props) => props.buttonSize};
36
- border: ${(props) => props.buttonBorder};
37
- border-radius: 6px;
38
- background: ${(props) => props.backgroundColor};
39
- cursor: ${(props) => props.cursor};
40
- display: flex;
41
- flex-direction: row;
42
- justify-content: center;
43
- gap: 8px;
44
- align-items: center;
45
- position: relative;
46
-
47
- ${(props) =>
48
- !props.isDisabled
49
- ? `
50
- &:hover {
51
- background: ${props.backgroundHover};
52
-
53
- div {
54
- color: ${props.textColorHover};
55
- }
56
- }
57
-
58
- &:focus {
59
- outline: 2px solid ${Focused.Default}
60
- }
61
-
62
- &:focus-visible {
63
- border: 2px solid ${Focused.Default}
64
- }
65
-
66
- &:active {
67
- background: ${props.backgroundPressed}
68
- }
69
- `
70
- : ''}
71
- `
72
-
73
- const ButtonText = styled(Label1)<{
74
- textColor: string
75
- textColorDisabled: string
76
- isLoading: boolean
77
- }>`
78
- color: ${(props) =>
79
- props.textColorDisabled !== '' ? props.textColorDisabled : props.textColor};
80
-
81
- ${(props) =>
82
- props.isLoading
83
- ? `
84
- opacity: 0;
85
- `
86
- : ''}
87
- `
88
-
89
- const Loading = styled(Spinner)`
90
- position: absolute;
91
- `
92
-
93
- interface DummyIconProps {
94
- type: ButtonType
95
- }
96
-
97
- interface IButtonProps {
98
- loading?: boolean
99
- IconPrefix?: ComponentType<DummyIconProps>
100
- IconSuffix?: ComponentType<DummyIconProps>
101
- children?: string
102
- }
103
-
104
- interface IButtonDestructiveProps extends IButtonProps {
105
- primary?: boolean
106
- }
107
-
108
- interface IButtonPlainProps extends IButtonProps {
109
- subtle?: boolean
110
- }
111
-
112
- interface ISecretInnerButtonProps
113
- extends IButtonPlainProps,
114
- IButtonDestructiveProps {
115
- buttonType: ButtonType
116
- }
117
-
118
- function makeButtonConfig(props: ISecretInnerButtonProps & ButtonSizeProps) {
119
- const { buttonType } = props
120
- const isDisabled = getIsDisabled(props)
121
- const backgroundColor = isDisabled
122
- ? getBackgroundColorDisabledByType(buttonType)
123
- : getBackgroundColorByType(buttonType)
124
- const buttonPadding = getPaddingBySize(props)
125
- const buttonOverridePadding = getPaddingByType(buttonType)
126
- const cursor = getCursor(props)
127
- const backgroundHover = getBackgroundColorHoverByType(buttonType)
128
- const backgroundPressed = getBackgroundColorPressedByType(buttonType)
129
- const textColorHover = getTextColorOnHoverByType(buttonType)
130
- const buttonBorder = isDisabled
131
- ? getBorderDisabledByType(buttonType)
132
- : getBorderByType(buttonType)
133
- const buttonSize =
134
- buttonOverridePadding !== '' ? buttonOverridePadding : buttonPadding
135
- const textColor = getTextColorByType(buttonType)
136
- const textColorDisabled = getTextColorIfDisabled(props)
137
-
138
- return {
139
- backgroundColor,
140
- buttonSize,
141
- cursor,
142
- backgroundHover,
143
- backgroundPressed,
144
- textColorHover,
145
- buttonBorder,
146
- isDisabled,
147
- textColor,
148
- textColorDisabled,
149
- }
150
- }
151
-
152
- const SecretInnerButton: FC<ISecretInnerButtonProps & ButtonSizeProps> = (
153
- props
154
- ) => {
155
- const {
156
- children,
157
- buttonType,
158
- loading,
159
- IconPrefix,
160
- IconSuffix,
161
- ...htmlProps
162
- } = props
163
- const { textColor, textColorDisabled, ...buttonConfig } =
164
- makeButtonConfig(props)
165
-
166
- return (
167
- <ButtonFrame {...htmlProps} {...buttonConfig} data-testid="button-test">
168
- {isDefined(IconPrefix) ? <IconPrefix type={buttonType} /> : ''}
169
-
170
- <ButtonText
171
- textColor={textColor}
172
- textColorDisabled={textColorDisabled}
173
- isLoading={is(loading)}
174
- >
175
- {children}
176
- </ButtonText>
177
- {is(loading) ? (
178
- <Loading
179
- small
180
- onPrimary={
181
- buttonType === ButtonType.primary ||
182
- buttonType === ButtonType.primaryDestructive
183
- }
184
- />
185
- ) : (
186
- ''
187
- )}
188
-
189
- {isDefined(IconSuffix) ? <IconSuffix type={buttonType} /> : ''}
190
- </ButtonFrame>
191
- )
192
- }
193
-
194
- export const ButtonBasic: FC<IButtonProps> = (props) => {
195
- return <SecretInnerButton buttonType={ButtonType.basic} {...props} />
196
- }
197
-
198
- export const ButtonPrimary: FC<IButtonProps> = (props) => {
199
- return <SecretInnerButton buttonType={ButtonType.primary} {...props} />
200
- }
201
-
202
- export const ButtonDestructive: FC<IButtonDestructiveProps> = (props) => {
203
- const { primary } = props
204
- return (
205
- <SecretInnerButton
206
- buttonType={
207
- isDefined(primary) && primary
208
- ? ButtonType.primaryDestructive
209
- : ButtonType.destructive
210
- }
211
- {...props}
212
- />
213
- )
214
- }
215
-
216
- export const ButtonOutline: FC<IButtonProps> = (props) => {
217
- return <SecretInnerButton buttonType={ButtonType.outline} {...props} />
218
- }
219
-
220
- export const ButtonPlain: FC<IButtonPlainProps> = (props) => {
221
- const { subtle } = props
222
-
223
- return (
224
- <SecretInnerButton
225
- buttonType={
226
- isDefined(subtle) && subtle ? ButtonType.plainSubtle : ButtonType.plain
227
- }
228
- {...props}
229
- />
230
- )
231
- }
@@ -1 +0,0 @@
1
- export * from './button'
@@ -1,104 +0,0 @@
1
- import { Canvas, Meta, Story, ArgsTable } from '@storybook/addon-docs';
2
- import { ButtonPrimary, ButtonBasic, ButtonDestructive, ButtonOutline, ButtonPlain, DummyIcon } from '../index'
3
- import { PlainHTMLFormExample, DisabledLoadingExample } from './components'
4
-
5
- <Meta
6
- title="Components/Button"
7
- component={ButtonPrimary}
8
- />
9
-
10
- # Button
11
-
12
- For more details, check out the component page on [Figma](https://www.figma.com/file/ue1CurHfZ426o2T2l8Dk64/Edvisor-Product-Language?node-id=1008%3A1257)
13
-
14
- ## How to use
15
-
16
- ```javascript
17
- // Import the component
18
- import { ButtonPrimary } from './index'
19
-
20
-
21
- // Render the component sending the required parameters
22
- <ButtonPrimary label="SOME-label-HERE" />
23
- ```
24
-
25
- ## Properties
26
-
27
- The Buttons accepts the same properties as a normal button and has some additional ones.
28
-
29
- The available optional properties are as follows, try them out in the editable code sample below!
30
-
31
- | Prop | Type | Description |
32
- | ---------- | --------- | ------------------------------------------------------------------------ |
33
- | `IconPrefix?` | `Icon` | It will add the given Icon before the text |
34
- | `IconSuffix?` | `Icon` | It will add the given Icon after the text |
35
- | `loading?` | `boolean` | Replaces the text for a loading icon |
36
- | `size?` | `small / large` | Changes the size of the button. Leave it empty for the default size |
37
-
38
- ### Using as form controls
39
- <PlainHTMLFormExample />
40
-
41
- ### Disabled until something is typed then loading until response
42
- <DisabledLoadingExample />
43
-
44
- ## Examples
45
-
46
- <Canvas>
47
- <ButtonBasic type="submit">Basic</ButtonBasic>
48
- <ButtonPrimary>Primary</ButtonPrimary>
49
- <ButtonDestructive>Destructive</ButtonDestructive>
50
- <ButtonDestructive primary>Primary Destructive</ButtonDestructive>
51
- <ButtonOutline>Outline</ButtonOutline>
52
- <ButtonPlain>Plain</ButtonPlain>
53
- <ButtonPlain subtle >Plain Subtle</ButtonPlain>
54
- </Canvas>
55
-
56
- Disabled
57
- <Canvas>
58
- <ButtonBasic disabled>Basic</ButtonBasic>
59
- <ButtonPrimary disabled>Primary</ButtonPrimary>
60
- <ButtonDestructive disabled>Destructive</ButtonDestructive>
61
- <ButtonDestructive primary disabled>Primary Destructive</ButtonDestructive>
62
- <ButtonOutline disabled>Outline</ButtonOutline>
63
- <ButtonPlain disabled>Plain</ButtonPlain>
64
- <ButtonPlain subtle disabled>Plain Subtle</ButtonPlain>
65
- </Canvas>
66
-
67
- Loading
68
- <Canvas>
69
- <ButtonBasic loading>Basic</ButtonBasic>
70
- <ButtonPrimary loading>Primary</ButtonPrimary>
71
- <ButtonDestructive loading>Destructive</ButtonDestructive>
72
- <ButtonDestructive primary loading>Primary Destructive</ButtonDestructive>
73
- <ButtonOutline loading>Outline</ButtonOutline>
74
- <ButtonPlain loading>Plain</ButtonPlain>
75
- <ButtonPlain subtle loading>Plain Subtle</ButtonPlain>
76
- </Canvas>
77
-
78
- Icons
79
- <Canvas>
80
- <ButtonBasic IconPrefix={DummyIcon}>Basic</ButtonBasic>
81
- <ButtonPrimary IconPrefix={DummyIcon}>Primary</ButtonPrimary>
82
- <ButtonDestructive IconPrefix={DummyIcon}>Destructive</ButtonDestructive>
83
- <ButtonDestructive primary IconPrefix={DummyIcon}>Primary Destructive</ButtonDestructive>
84
- <ButtonOutline IconPrefix={DummyIcon}>Outline</ButtonOutline>
85
- <ButtonPlain IconPrefix={DummyIcon}>Plain</ButtonPlain>
86
- <ButtonPlain subtle IconPrefix={DummyIcon}>Plain Subtle</ButtonPlain>
87
- </Canvas>
88
-
89
- <Canvas>
90
- <ButtonBasic IconSuffix={DummyIcon}>Basic</ButtonBasic>
91
- <ButtonPrimary IconSuffix={DummyIcon}>Primary</ButtonPrimary>
92
- <ButtonDestructive IconSuffix={DummyIcon}>Destructive</ButtonDestructive>
93
- <ButtonDestructive primary IconSuffix={DummyIcon}>Primary Destructive</ButtonDestructive>
94
- <ButtonOutline IconSuffix={DummyIcon}>Outline</ButtonOutline>
95
- <ButtonPlain IconSuffix={DummyIcon}>Plain</ButtonPlain>
96
- <ButtonPlain subtle IconSuffix={DummyIcon}>Plain Subtle</ButtonPlain>
97
- </Canvas>
98
-
99
- <Canvas>
100
- <ButtonBasic large>Large</ButtonBasic>
101
- <ButtonBasic>Default</ButtonBasic>
102
- <ButtonBasic small>Small</ButtonBasic>
103
- </Canvas>
104
-