@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,59 +0,0 @@
1
- import styled, { css } from 'styled-components'
2
- import { Padding, Surface, Borders, Actions } from '@foundations'
3
-
4
- interface ICheckedProps {
5
- checked: boolean;
6
- }
7
-
8
- export const getHoverStyles = () => css`
9
- background: ${Surface.Default.Hover};
10
- `
11
-
12
- export const getDisabledStyles = () => css`
13
- pointer-events: none;
14
- background: ${(props: ICheckedProps) => (props.checked === true ? `${Borders.Default.Default}`: `${Surface.Default.Subdued}` )};
15
- border-color: ${Borders.Default.Default};
16
- `
17
-
18
- export const getInvalidStyles = () => css`
19
- background: ${(props: ICheckedProps) => (props.checked === true ? `${Actions.Critical.Default}`: `${Surface.Critical.Subdued}`)};
20
- border: 2px solid ${Borders.Critical.Default};
21
- `
22
-
23
- export const HiddenCheckbox = styled.input`
24
- border: 0;
25
- clip: rect(0 0 0 0);
26
- clippath: inset(50%);
27
- height: 1px;
28
- margin: -1px;
29
- overflow: hidden;
30
- padding: ${Padding.none};
31
- position: absolute;
32
- white-space: nowrap;
33
- width: 1px;
34
- `
35
-
36
- export const Icon = styled.svg`
37
- width: 100%;
38
- height: 50%;
39
- `
40
-
41
- export const Wrapper = styled.div`
42
- width: 18px;
43
- height: 100%;
44
- `
45
-
46
- export const getTabIndexValue = (
47
- disabled: boolean
48
- ): number => {
49
- return disabled ? -1 : 0
50
- }
51
-
52
- export const getCheckedIcon = () => (
53
- <Icon width="10" height="8" viewBox="0 0 10 8">
54
- <path
55
- d="M4.50846 7.37941C4.0689 7.81898 3.35108 7.81898 2.91151 7.37941L0.330581 4.79848C-0.110194 4.35892 -0.110194 3.64109 0.330581 3.20153C0.770146 2.76196 1.48797 2.76196 1.92753 3.20153L3.70999 4.98399L8.07338 0.620598C8.51294 0.181033 9.23076 0.181033 9.67033 0.620598C10.1099 1.06016 10.1099 1.77798 9.67033 2.21755L4.50846 7.37941Z"
56
- fill="white"
57
- />
58
- </Icon>
59
- )
@@ -1 +0,0 @@
1
- export * from './checkbox'
@@ -1,54 +0,0 @@
1
- import { Canvas, Meta, Story } from '@storybook/addon-docs';
2
- import { Checkbox } from '../index'
3
- import { PlainHTMLFormExample } from './index'
4
-
5
- <Meta
6
- title="Components/Checkbox"
7
- component={Checkbox}
8
- />
9
-
10
- # Checkbox
11
-
12
- This is an atom.
13
-
14
- For more details, check out the component page on [Figma](https://www.figma.com/file/ue1CurHfZ426o2T2l8Dk64/Edvisor-Product-Language?node-id=1008%3A1257)
15
-
16
- ## How to use
17
-
18
- ```javascript
19
- // Import the component
20
- import { Checkbox } from './index'
21
-
22
-
23
- // Render the component sending the required parameters
24
- <Checkbox />
25
- ```
26
-
27
- ## Examples
28
-
29
- <Canvas>
30
- <Checkbox onChange={(e) => console.log('at stories', e)} />
31
- <Checkbox disabled />
32
- <Checkbox error />
33
- <Checkbox checked />
34
- <Checkbox error checked />
35
- </Canvas>
36
-
37
-
38
- ## API
39
-
40
- | Name | Type | Description | Required (Y/N)|
41
- | ---- | ----- | ------ | ------- |
42
- | `checked` | `boolean` | `Set checkbox as filled` | `N` |
43
- | `disabled` | `boolean` | `Set checkbox as a disabled way (can't click or interact with that)` | `N` |
44
- | `error` | `boolean` | `Useful to work inside a form or show some feedback from user action` | `N` |
45
- | `onChange` | `event` | `You can listen the changes from the component` | `N` |
46
-
47
-
48
- ## Playground
49
-
50
- <PlainHTMLFormExample />
51
-
52
- ## Changelog
53
- - Offer the "indeterminate" style
54
- - Get feedback from the component usage (we can migrate to just rendering with css pseudo elements if necessary)
@@ -1,36 +0,0 @@
1
- import { Playground } from 'storybook-addon-jarle-monaco'
2
- import { Checkbox } from '../checkbox'
3
-
4
- export const PlainHTMLFormExample = () => (
5
- <Playground
6
- code={`
7
- /* Edit this code sample! */
8
- const [withError, setWithError] = useState(false);
9
-
10
- <form onSubmit={(e) => {
11
- e.preventDefault()
12
- console.log('form submitted')
13
- }}
14
- >
15
- <label htmlFor="accept_terms">Accept the terms:</label>
16
- <Checkbox
17
- onInvalid={(e) => {
18
- setWithError(true)
19
- }}
20
- error={withError}
21
- onChange={(e) => {
22
- console.log('at stories', e)
23
- setWithError(false)
24
- }}
25
- required />
26
- <input type="submit"/>
27
- </form>
28
- `}
29
- providerProps={{
30
- renderAsComponent: true,
31
- scope: {
32
- Checkbox,
33
- },
34
- }}
35
- />
36
- )
@@ -1 +0,0 @@
1
- export * from './components'
@@ -1,37 +0,0 @@
1
- // this file was generated, but it is safe to modify
2
- import { bitwiseOr, MappedEnum, RequireOnlyOne, PropsWithChildren } from '@helpers'
3
- import { Borders } from '@foundations'
4
-
5
- const enum DividerType {
6
- default = 1,
7
- subdued = 2,
8
- }
9
-
10
- type DividerTypes<T> = MappedEnum<typeof DividerType, T>
11
-
12
- function toDividerType(n: number): DividerType {
13
- switch (n) {
14
- case DividerType.default:
15
- return DividerType.default
16
- case DividerType.subdued:
17
- return DividerType.subdued
18
- default:
19
- return DividerType.default
20
- }
21
- }
22
-
23
- const DividerTypeColor = {
24
- [DividerType.default]: Borders.Default.Default,
25
- [DividerType.subdued]: Borders.Default.Subdued,
26
- }
27
-
28
- export type DivideTypeProps = Partial<RequireOnlyOne<DividerTypes<boolean>>> &
29
- PropsWithChildren
30
-
31
- export function getColor(props: DivideTypeProps): string {
32
- return DividerTypeColor[
33
- toDividerType(
34
- bitwiseOr([props.default, props.subdued])
35
- )
36
- ]
37
- }
@@ -1,34 +0,0 @@
1
- import { render, screen } from '@testing-library/react'
2
- import { Divider } from './index'
3
- import { Borders } from '@foundations'
4
-
5
- describe('Divider Tests', () => {
6
- describe('Divider Tests', () => {
7
- it('should render the Divider with default color', async () => {
8
- render(
9
- <Divider/>
10
- )
11
-
12
- expect(screen.getByTestId('divider-test')).toBeInTheDocument()
13
- expect(screen.getByTestId('divider-test')).toHaveStyle(`border: 1px solid ${Borders.Default.Default}`)
14
- })
15
-
16
- it('should render the Divider with default color using parameter', async () => {
17
- render(
18
- <Divider default/>
19
- )
20
-
21
- expect(screen.getByTestId('divider-test')).toBeInTheDocument()
22
- expect(screen.getByTestId('divider-test')).toHaveStyle(`border: 1px solid ${Borders.Default.Default}`)
23
- })
24
-
25
- it('should render the Divider with subdued color', async () => {
26
- render(
27
- <Divider subdued/>
28
- )
29
-
30
- expect(screen.getByTestId('divider-test')).toBeInTheDocument()
31
- expect(screen.getByTestId('divider-test')).toHaveStyle(`border: 1px solid ${Borders.Default.Subdued}`)
32
- })
33
- })
34
- })
@@ -1,37 +0,0 @@
1
- import styled from 'styled-components'
2
- import { FC } from '@helpers'
3
- import { DivideTypeProps, getColor } from './divider-type-flags'
4
-
5
- /**
6
- * @TODO I added flex here because without it the bottom margin was
7
- * being collapsed with the next sibling (when I applied margins to the divider,
8
- * which I expect we basically _always_ will)
9
- *
10
- * I'm not confident with reasoning about margin-collapse so if you see
11
- * this comment and feel like experimenting, go crazy. Check out the
12
- * card stories for an example of the divider (it's way at the bottom)
13
- */
14
- const DividerWrapper = styled.div`
15
- position: relative;
16
- width:100%;
17
- `
18
-
19
- const DividerLine = styled.hr<{ color: string }>`
20
- position: absolute;
21
- left: 0;
22
- right: 0;
23
- margin: unset;
24
- border: 1px solid ${({ color }) => color};
25
- `
26
-
27
- type IProps = { className?: string } & DivideTypeProps
28
-
29
- export const Divider: FC<IProps> = (props) => {
30
- const color = getColor(props)
31
-
32
- return (
33
- <DividerWrapper className={props.className}>
34
- <DividerLine color={color} data-testid="divider-test"/>
35
- </DividerWrapper>
36
- )
37
- }
@@ -1 +0,0 @@
1
- export * from './divider'
@@ -1,13 +0,0 @@
1
- import styled from 'styled-components'
2
- import { Padding, Surface } from '@foundations'
3
-
4
-
5
- const WrapperStories = styled.div`
6
- width: 390px;
7
- padding: ${Padding.l};
8
- background: ${Surface.Default.Default};
9
- `
10
-
11
- export {
12
- WrapperStories
13
- }
@@ -1,50 +0,0 @@
1
- import { Canvas, Meta, Story, ArgsTable } from '@storybook/addon-docs';
2
- import { Divider } from '../index'
3
- import { WrapperStories, AvatarsWithText, AvatarsWithImage, WrapperStoriesWithLabel } from './components'
4
-
5
- <Meta
6
- title="Components/Divider"
7
- component={Divider}
8
- />
9
-
10
- # Divider
11
-
12
- For more details, check out the component page on [Figma](https://www.figma.com/file/ue1CurHfZ426o2T2l8Dk64/Edvisor-Product-Language?node-id=1194%3A1611)
13
-
14
- ## How to use
15
-
16
- ```javascript
17
- // Import the component
18
- import { Divider } from './index'
19
-
20
-
21
- // Render the component sending the parameters
22
- <Divider default/>
23
-
24
- //or
25
-
26
- <Divider subdued/>
27
- ```
28
-
29
- ## Examples
30
-
31
- Default Divider
32
-
33
- <Canvas>
34
- <Story name="default">
35
- <WrapperStories>
36
- <Divider default/>
37
- </WrapperStories>
38
- </Story>
39
- </Canvas>
40
-
41
- Subdued Divider
42
-
43
- <Canvas>
44
- <Story name="subdued">
45
- <WrapperStories>
46
- <Divider subdued/>
47
- </WrapperStories>
48
- </Story>
49
- </Canvas>
50
-
@@ -1,14 +0,0 @@
1
- export * from './alert-banner'
2
- export * from './badge'
3
- export * from './card'
4
- export * from './checkbox'
5
- export * from './divider'
6
- export * from './input-field'
7
- export * from './layout'
8
- export * from './link'
9
- export * from './thumbnail'
10
- export * from './typography'
11
-
12
- //Adding everything in molecules
13
- export * from './molecules'
14
- export * from './organisms'
@@ -1,2 +0,0 @@
1
- export * from './labeled-input'
2
- export * from './stepper'
@@ -1,61 +0,0 @@
1
- import styled from 'styled-components'
2
-
3
- import { Icons, Margin } from '@foundations'
4
- import { PropsWithChildren, FC, maybeRender, safeArray } from '@helpers'
5
- import { Flex } from 'components/layout'
6
- import { Body, Label1 } from 'components/typography'
7
-
8
- export const Icon = styled.div`
9
- height: 16px;
10
- width: 16px;
11
- border: 2px solid ${Icons.Default};
12
- border-radius: 50%;
13
- margin-right: ${Margin.s};
14
- `
15
-
16
- const ErrorIcon = styled(Icon)`
17
- border: 2px solid ${Icons.Critical};
18
- `
19
-
20
- const HTMLLabel = styled.label`
21
- all: unset;
22
- `
23
-
24
- const LabelText = styled(Label1)`
25
- margin-bottom: ${Margin.xxs};
26
- `
27
-
28
- const HelpText = styled(Body)`
29
- margin-bottom: ${Margin.xxs};
30
- `
31
-
32
- const ErrorMessage = styled(Flex)`
33
- margin-bottom: ${Margin.xxs};
34
- `
35
-
36
- interface ILabeledInputProps extends PropsWithChildren {
37
- label?: string
38
- helpText?: string
39
- errors?: { message: string }[]
40
- }
41
-
42
- export const LabeledInput: FC<ILabeledInputProps> = (props) => {
43
- return (
44
- <HTMLLabel>
45
- <label>
46
- {maybeRender(props.label, <LabelText>{props.label}</LabelText>)}
47
- {props.children}
48
- </label>
49
- {safeArray(props.errors).map((e) => (
50
- <ErrorMessage center key={e.message}>
51
- <ErrorIcon />
52
- <Body>{e.message}</Body>
53
- </ErrorMessage>
54
- ))}
55
- {maybeRender(
56
- props.helpText,
57
- <HelpText subdued>{props.helpText}</HelpText>
58
- )}
59
- </HTMLLabel>
60
- )
61
- }
@@ -1,59 +0,0 @@
1
- import { Margin, Padding, Surface } from '@foundations'
2
- import { FC } from '@helpers'
3
- import { Center } from 'components/layout'
4
- import styled from 'styled-components'
5
-
6
- const Controls = styled.div`
7
- height: 34px;
8
- width: 26px;
9
- padding: ${Padding.xxxs} ${Padding.xxxs};
10
- box-sizing: border-box;
11
- `
12
-
13
- const Up = styled(Center)`
14
- background: ${Surface.Neutral.Default};
15
- width: 22px;
16
- height: 14px;
17
- border-radius: 3px 3px 0px 0px;
18
- margin-bottom: ${Margin.xxxs};
19
- display: flex;
20
- align-items: center;
21
- justify-content: center;
22
- `
23
-
24
- const TriangleUp = styled.div`
25
- width: 0px;
26
- height: 0px;
27
- border-left: 5px solid transparent;
28
- border-right: 5px solid transparent;
29
- border-bottom: 5px solid black;
30
- `
31
-
32
- const TriangleDown = styled.div`
33
- width: 0px;
34
- height: 0px;
35
- border-left: 5px solid transparent;
36
- border-right: 5px solid transparent;
37
- border-top: 5px solid black;
38
- `
39
-
40
- const Down = styled(Center)`
41
- background: ${Surface.Neutral.Default};
42
- width: 22px;
43
- height: 14px;
44
- border-radius: 0px 0px 3px 3px;
45
- `
46
-
47
- interface IStepperProps {
48
- onUpClick?: () => void
49
- onDownClick?: () => void
50
- }
51
-
52
- export const Stepper: FC<IStepperProps> = (props: IStepperProps) => {
53
- return (
54
- <Controls>
55
- <Up onClick={props.onUpClick}><TriangleUp /></Up>
56
- <Down onClick={props.onDownClick}><TriangleDown /></Down>
57
- </Controls>
58
- )
59
- }
@@ -1,6 +0,0 @@
1
- // the html input
2
- export * from './input-field'
3
-
4
- // the simple inputs
5
- export * from './input-number'
6
- export * from './input-text'
@@ -1,108 +0,0 @@
1
- import {fireEvent, render, screen } from '@testing-library/react'
2
- import { InputField } from './index'
3
-
4
- describe('InputField', () => {
5
- describe('the inner input element', () => {
6
- it('should receive nice html props', async () => {
7
- render(
8
- <InputField
9
- value="value"
10
- onChange={() => undefined}
11
- type="text"
12
- label="Label"
13
- placeholder="placeholder"
14
- />
15
- )
16
-
17
- expect(screen.getByRole('textbox')).toBeInTheDocument()
18
- expect(screen.getByPlaceholderText('placeholder')).toBeInTheDocument()
19
- expect(screen.getByDisplayValue('value')).toBeInTheDocument()
20
- })
21
-
22
- it('should call the onChange callback on change events', async () => {
23
- const handleChange = jest.fn()
24
-
25
- render(<InputField value="value" onChange={handleChange} />)
26
-
27
- fireEvent.change(screen.getByRole('textbox'), {
28
- target: { value: 'JavaScript' },
29
- })
30
-
31
- expect(handleChange).toHaveBeenCalledTimes(1)
32
- })
33
- })
34
-
35
- describe('Label', () => {
36
- it('should render when given', async () => {
37
- render(<InputField label="Label" />)
38
-
39
- expect(screen.getByLabelText('Label')).toBeInTheDocument()
40
- })
41
-
42
- it('should not render when not given', async () => {
43
- render(<InputField />)
44
-
45
- expect(screen.queryByLabelText('Label')).not.toBeInTheDocument()
46
- })
47
- })
48
-
49
- describe('Prefix', () => {
50
- it('should render when given', async () => {
51
- render(<InputField prefix="$" />)
52
-
53
- expect(screen.getByText('$')).toBeInTheDocument()
54
- })
55
-
56
- it('should not render when not given', async () => {
57
- render(<InputField />)
58
-
59
- expect(screen.queryByText('$')).not.toBeInTheDocument()
60
- })
61
- })
62
-
63
- describe('Suffix', () => {
64
- it('should render when given', async () => {
65
- render(<InputField suffix="%" />)
66
-
67
- expect(screen.getByText('%')).toBeInTheDocument()
68
- })
69
-
70
- it('should not render when not given', async () => {
71
- render(<InputField />)
72
-
73
- expect(screen.queryByText('&')).not.toBeInTheDocument()
74
- })
75
- })
76
-
77
- describe('Slots', () => {
78
- it('should render the Icon slot', async () => {
79
- render(
80
- <InputField>
81
- <InputField.Icon>Icon</InputField.Icon>
82
- </InputField>
83
- )
84
-
85
- expect(screen.getByText('Icon')).toBeInTheDocument()
86
- })
87
-
88
- it('should render the Controls slot', async () => {
89
- render(
90
- <InputField>
91
- <InputField.Controls>Controls</InputField.Controls>
92
- </InputField>
93
- )
94
-
95
- expect(screen.getByText('Controls')).toBeInTheDocument()
96
- })
97
-
98
- it('should not render other kinds of children', () => {
99
- render(
100
- <InputField>
101
- <div>Other Children</div>
102
- </InputField>
103
- )
104
-
105
- expect(screen.queryByText('Other Children')).not.toBeInTheDocument()
106
- })
107
- })
108
- })