@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.
- package/index.d.ts +2 -0
- package/index.js +7914 -0
- package/lib/components/alert-banner/alert-banner.d.ts +11 -0
- package/lib/components/alert-banner/alert-level-flags.d.ts +13 -0
- package/lib/components/alert-banner/index.d.ts +1 -0
- package/lib/components/badge/badge-type-flags.d.ts +18 -0
- package/lib/components/badge/badge.d.ts +5 -0
- package/lib/components/badge/index.d.ts +1 -0
- package/{src/lib/components/card/atoms/card-frame.tsx → lib/components/card/atoms/card-frame.d.ts} +7 -17
- package/lib/components/card/atoms/index.d.ts +1 -0
- package/lib/components/card/card.d.ts +14 -0
- package/lib/components/card/components/card-alert-banner-slot.d.ts +5 -0
- package/lib/components/card/components/card-controls-slot.d.ts +4 -0
- package/lib/components/card/components/card-section-slot.d.ts +11 -0
- package/lib/components/card/components/index.d.ts +3 -0
- package/lib/components/card/index.d.ts +2 -0
- package/lib/components/card/molecules/index.d.ts +1 -0
- package/lib/components/card/molecules/left-right-card.d.ts +16 -0
- package/lib/components/checkbox/checkbox.d.ts +10 -0
- package/lib/components/checkbox/helpers.d.ts +12 -0
- package/lib/components/checkbox/index.d.ts +1 -0
- package/lib/components/divider/divider-type-flags.d.ts +9 -0
- package/lib/components/divider/divider.d.ts +7 -0
- package/lib/components/divider/index.d.ts +1 -0
- package/lib/components/flag/flag-size-flags.d.ts +12 -0
- package/lib/components/flag/flag.d.ts +9 -0
- package/lib/components/flag/flag.list.d.ts +781 -0
- package/lib/components/flag/index.d.ts +1 -0
- package/lib/components/icon/icon-list.d.ts +131 -0
- package/lib/components/icon/icon.d.ts +131 -0
- package/lib/components/icon/index.d.ts +1 -0
- package/lib/components/index.d.ts +17 -0
- package/lib/components/input-field/components/index.d.ts +2 -0
- package/lib/components/input-field/components/labeled-input.d.ts +10 -0
- package/lib/components/input-field/components/stepper.d.ts +7 -0
- package/lib/components/input-field/index.d.ts +3 -0
- package/lib/components/input-field/input-field.d.ts +25 -0
- package/lib/components/input-field/input-number.d.ts +18 -0
- package/lib/components/input-field/input-text.d.ts +14 -0
- package/lib/components/layout/flex.d.ts +16 -0
- package/lib/components/layout/grid-layout.d.ts +11 -0
- package/lib/components/layout/index.d.ts +3 -0
- package/lib/components/layout/left-right-layout.d.ts +34 -0
- package/lib/components/link/index.d.ts +1 -0
- package/lib/components/link/link.d.ts +14 -0
- package/lib/components/molecules/avatar/avatar-size-flags.d.ts +12 -0
- package/lib/components/molecules/avatar/avatar.d.ts +12 -0
- package/lib/components/molecules/avatar/index.d.ts +1 -0
- package/lib/components/molecules/button/button-flags.d.ts +44 -0
- package/lib/components/molecules/button/button.d.ts +12 -0
- package/lib/components/molecules/button/index.d.ts +1 -0
- package/lib/components/molecules/index.d.ts +3 -0
- package/lib/components/molecules/input-checkbox/index.d.ts +1 -0
- package/lib/components/molecules/input-checkbox/input-checkbox.d.ts +8 -0
- package/lib/components/organisms/index.d.ts +1 -0
- package/lib/components/organisms/multi-choice-list/index.d.ts +1 -0
- package/lib/components/organisms/multi-choice-list/multi-choice-list.d.ts +10 -0
- package/lib/components/spinner/index.d.ts +1 -0
- package/lib/components/spinner/spinner-size-flags.d.ts +10 -0
- package/lib/components/spinner/spinner.d.ts +9 -0
- package/lib/components/tabs/components/index.d.ts +1 -0
- package/lib/components/tabs/components/tab.d.ts +7 -0
- package/lib/components/tabs/index.d.ts +1 -0
- package/lib/components/tabs/tabs.d.ts +15 -0
- package/lib/components/tag/components/close-button.d.ts +8 -0
- package/lib/components/tag/components/index.d.ts +2 -0
- package/lib/components/tag/components/tag-label.d.ts +8 -0
- package/lib/components/tag/index.d.ts +1 -0
- package/lib/components/tag/tag.d.ts +10 -0
- package/lib/components/thumbnail/index.d.ts +1 -0
- package/lib/components/thumbnail/thumbnail-size-flags.d.ts +10 -0
- package/lib/components/thumbnail/thumbnail.d.ts +10 -0
- package/lib/components/typography/index.d.ts +1 -0
- package/lib/components/typography/typography.d.ts +24 -0
- package/lib/foundations/color-system/base-palette/base-palette.d.ts +76 -0
- package/lib/foundations/color-system/base-palette/index.d.ts +1 -0
- package/lib/foundations/color-system/color-guidelines/color-guidelines.d.ts +132 -0
- package/lib/foundations/color-system/color-guidelines/index.d.ts +1 -0
- package/lib/foundations/color-system/components/color-sample.d.ts +17 -0
- package/lib/foundations/color-system/components/index.d.ts +1 -0
- package/lib/foundations/color-system/index.d.ts +1 -0
- package/lib/foundations/index.d.ts +4 -0
- package/lib/foundations/shadows/components.d.ts +8 -0
- package/lib/foundations/shadows/index.d.ts +1 -0
- package/lib/foundations/shadows/shadows.d.ts +8 -0
- package/lib/foundations/spacing/index.d.ts +1 -0
- package/lib/foundations/spacing/spacing-guidelines.d.ts +22 -0
- package/lib/foundations/spacing/spacing.d.ts +18 -0
- package/lib/foundations/typography/constants.d.ts +22 -0
- package/lib/foundations/typography/fonts.d.ts +1 -0
- package/lib/foundations/typography/index.d.ts +1 -0
- package/lib/foundations/typography/text-aspect-flags.d.ts +19 -0
- package/lib/foundations/typography/typography.d.ts +24 -0
- package/lib/helpers/generic-types.d.ts +21 -0
- package/lib/helpers/index.d.ts +6 -0
- package/lib/helpers/nothing.d.ts +8 -0
- package/{src/lib/helpers/numbers.ts → lib/helpers/numbers.d.ts} +50 -53
- package/lib/helpers/safe-navigation.d.ts +15 -0
- package/lib/helpers/slots.d.ts +23 -0
- package/lib/helpers/strings.d.ts +1 -0
- package/package.json +12 -5
- package/.babelrc +0 -12
- package/.eslintrc.json +0 -139
- package/.storybook/main.js +0 -57
- package/.storybook/manager.js +0 -7
- package/.storybook/preview-head.html +0 -1
- package/.storybook/preview.js +0 -15
- package/.storybook/tsconfig.json +0 -30
- package/jest.config.ts +0 -15
- package/jest.setup.ts +0 -2
- package/project.json +0 -85
- package/release-it.json +0 -18
- package/src/assets/svg/example_icon.svg +0 -3
- package/src/assets/svg/example_icon_white.svg +0 -3
- package/src/assets/svg/spinner.svg +0 -3
- package/src/assets/svg/spinner_white.svg +0 -3
- package/src/helpers/index.ts +0 -3
- package/src/helpers/talesOf.tsx +0 -42
- package/src/index.ts +0 -2
- package/src/lib/components/README.md +0 -49
- package/src/lib/components/alert-banner/alert-banner.tsx +0 -34
- package/src/lib/components/alert-banner/alert-level-flags.ts +0 -77
- package/src/lib/components/alert-banner/index.ts +0 -1
- package/src/lib/components/badge/badge-type-flags.ts +0 -72
- package/src/lib/components/badge/badge.stories.tsx +0 -16
- package/src/lib/components/badge/badge.test.tsx +0 -29
- package/src/lib/components/badge/badge.tsx +0 -31
- package/src/lib/components/badge/index.ts +0 -1
- package/src/lib/components/card/atoms/index.ts +0 -1
- package/src/lib/components/card/card.test.tsx +0 -163
- package/src/lib/components/card/card.tsx +0 -78
- package/src/lib/components/card/components/card-alert-banner-slot.tsx +0 -16
- package/src/lib/components/card/components/card-controls-slot.tsx +0 -19
- package/src/lib/components/card/components/card-section-slot.tsx +0 -51
- package/src/lib/components/card/components/index.ts +0 -3
- package/src/lib/components/card/index.ts +0 -2
- package/src/lib/components/card/molecules/index.ts +0 -1
- package/src/lib/components/card/molecules/left-right-card.test.tsx +0 -89
- package/src/lib/components/card/molecules/left-right-card.tsx +0 -63
- package/src/lib/components/card/storybook/card.stories.mdx +0 -100
- package/src/lib/components/card/storybook/components.tsx +0 -240
- package/src/lib/components/checkbox/checkbox.test.tsx +0 -39
- package/src/lib/components/checkbox/checkbox.tsx +0 -124
- package/src/lib/components/checkbox/components/components.tsx +0 -59
- package/src/lib/components/checkbox/index.tsx +0 -1
- package/src/lib/components/checkbox/stories/checkbox.stories.mdx +0 -54
- package/src/lib/components/checkbox/stories/components.tsx +0 -36
- package/src/lib/components/checkbox/stories/index.tsx +0 -1
- package/src/lib/components/divider/divider-type-flags.tsx +0 -37
- package/src/lib/components/divider/divider.test.tsx +0 -34
- package/src/lib/components/divider/divider.tsx +0 -37
- package/src/lib/components/divider/index.tsx +0 -1
- package/src/lib/components/divider/stories/components.tsx +0 -13
- package/src/lib/components/divider/stories/divider.stories.mdx +0 -50
- package/src/lib/components/index.ts +0 -14
- package/src/lib/components/input-field/components/index.ts +0 -2
- package/src/lib/components/input-field/components/labeled-input.tsx +0 -61
- package/src/lib/components/input-field/components/stepper.tsx +0 -59
- package/src/lib/components/input-field/index.ts +0 -6
- package/src/lib/components/input-field/input-field.test.tsx +0 -108
- package/src/lib/components/input-field/input-field.tsx +0 -126
- package/src/lib/components/input-field/input-number.tsx +0 -41
- package/src/lib/components/input-field/input-text.tsx +0 -30
- package/src/lib/components/input-field/storybook/components.tsx +0 -334
- package/src/lib/components/input-field/storybook/input-field.stories.mdx +0 -113
- package/src/lib/components/layout/flex.tsx +0 -22
- package/src/lib/components/layout/grid-layout.tsx +0 -40
- package/src/lib/components/layout/index.ts +0 -3
- package/src/lib/components/layout/left-right-layout.tsx +0 -67
- package/src/lib/components/link/index.ts +0 -1
- package/src/lib/components/link/link.test.tsx +0 -29
- package/src/lib/components/link/link.tsx +0 -56
- package/src/lib/components/link/storybook/link.stories.mdx +0 -51
- package/src/lib/components/molecules/avatar/avatar-size-flags.tsx +0 -55
- package/src/lib/components/molecules/avatar/avatar.test.tsx +0 -114
- package/src/lib/components/molecules/avatar/avatar.tsx +0 -80
- package/src/lib/components/molecules/avatar/index.tsx +0 -1
- package/src/lib/components/molecules/avatar/stories/avatar.stories.mdx +0 -55
- package/src/lib/components/molecules/avatar/stories/components.tsx +0 -36
- package/src/lib/components/molecules/button/button-flags.tsx +0 -235
- package/src/lib/components/molecules/button/button.test.tsx +0 -77
- package/src/lib/components/molecules/button/button.tsx +0 -231
- package/src/lib/components/molecules/button/index.tsx +0 -1
- package/src/lib/components/molecules/button/stories/button.stories.mdx +0 -104
- package/src/lib/components/molecules/button/stories/components.tsx +0 -86
- package/src/lib/components/molecules/index.ts +0 -3
- package/src/lib/components/molecules/input-checkbox/index.tsx +0 -1
- package/src/lib/components/molecules/input-checkbox/input-checkbox.test.tsx +0 -34
- package/src/lib/components/molecules/input-checkbox/input-checkbox.tsx +0 -50
- package/src/lib/components/molecules/input-checkbox/stories/components.tsx +0 -36
- package/src/lib/components/molecules/input-checkbox/stories/index.tsx +0 -1
- package/src/lib/components/molecules/input-checkbox/stories/input-checkbox.stories.mdx +0 -51
- package/src/lib/components/organisms/index.ts +0 -1
- package/src/lib/components/organisms/multi-choice-list/index.tsx +0 -1
- package/src/lib/components/organisms/multi-choice-list/multi-choice-list.test.tsx +0 -33
- package/src/lib/components/organisms/multi-choice-list/multi-choice-list.tsx +0 -53
- package/src/lib/components/organisms/multi-choice-list/stories/components.tsx +0 -126
- package/src/lib/components/organisms/multi-choice-list/stories/index.tsx +0 -1
- package/src/lib/components/organisms/multi-choice-list/stories/multi-choice-list.stories.mdx +0 -99
- package/src/lib/components/spinner/index.tsx +0 -1
- package/src/lib/components/spinner/spinner-size-flags.tsx +0 -39
- package/src/lib/components/spinner/spinner.test.tsx +0 -31
- package/src/lib/components/spinner/spinner.tsx +0 -67
- package/src/lib/components/spinner/stories/components.tsx +0 -8
- package/src/lib/components/spinner/stories/spinner.stories.mdx +0 -42
- package/src/lib/components/thumbnail/index.tsx +0 -1
- package/src/lib/components/thumbnail/stories/thumbnail.stories.mdx +0 -34
- package/src/lib/components/thumbnail/thumbnail-size-flags.tsx +0 -41
- package/src/lib/components/thumbnail/thumbnail.test.tsx +0 -51
- package/src/lib/components/thumbnail/thumbnail.tsx +0 -40
- package/src/lib/components/typography/index.ts +0 -1
- package/src/lib/components/typography/storybook/components.tsx +0 -256
- package/src/lib/components/typography/storybook/typography.stories.mdx +0 -88
- package/src/lib/components/typography/typography.test.tsx +0 -93
- package/src/lib/components/typography/typography.tsx +0 -57
- package/src/lib/foundations/color-system/base-palette/base-palette.stories.tsx +0 -123
- package/src/lib/foundations/color-system/base-palette/base-palette.ts +0 -94
- package/src/lib/foundations/color-system/base-palette/index.ts +0 -1
- package/src/lib/foundations/color-system/color-guidelines/color-guidelines.stories.mdx +0 -85
- package/src/lib/foundations/color-system/color-guidelines/color-guidelines.stories.tsx +0 -231
- package/src/lib/foundations/color-system/color-guidelines/color-guidelines.ts +0 -159
- package/src/lib/foundations/color-system/color-guidelines/index.ts +0 -1
- package/src/lib/foundations/color-system/components/color-sample.tsx +0 -99
- package/src/lib/foundations/color-system/components/index.ts +0 -1
- package/src/lib/foundations/color-system/index.ts +0 -1
- package/src/lib/foundations/index.ts +0 -4
- package/src/lib/foundations/shadows/components.tsx +0 -59
- package/src/lib/foundations/shadows/index.ts +0 -1
- package/src/lib/foundations/shadows/shadows.stories.mdx +0 -71
- package/src/lib/foundations/shadows/shadows.tsx +0 -47
- package/src/lib/foundations/spacing/index.ts +0 -1
- package/src/lib/foundations/spacing/spacing-guidelines.ts +0 -24
- package/src/lib/foundations/spacing/spacing.stories.mdx +0 -51
- package/src/lib/foundations/spacing/spacing.ts +0 -18
- package/src/lib/foundations/typography/constants.ts +0 -25
- package/src/lib/foundations/typography/index.tsx +0 -1
- package/src/lib/foundations/typography/text-aspect-flags.ts +0 -54
- package/src/lib/foundations/typography/typography.tsx +0 -97
- package/src/lib/helpers/generic-types.ts +0 -44
- package/src/lib/helpers/index.ts +0 -6
- package/src/lib/helpers/nothing.tsx +0 -18
- package/src/lib/helpers/safe-navigation.ts +0 -34
- package/src/lib/helpers/slots.tsx +0 -76
- package/src/lib/helpers/strings.test.ts +0 -47
- package/src/lib/helpers/strings.ts +0 -16
- package/tsconfig.json +0 -35
- package/tsconfig.lib.json +0 -28
- 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,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,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,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
|
-
})
|