@edvisor/product-language 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +12 -0
- package/.eslintrc.json +139 -0
- package/.storybook/main.js +57 -0
- package/.storybook/manager.js +7 -0
- package/.storybook/preview-head.html +1 -0
- package/.storybook/preview.js +15 -0
- package/.storybook/tsconfig.json +30 -0
- package/jest.config.ts +15 -0
- package/jest.setup.ts +2 -0
- package/package.json +22 -10
- package/project.json +85 -0
- package/src/assets/svg/example_icon.svg +3 -0
- package/src/assets/svg/example_icon_white.svg +3 -0
- package/src/assets/svg/spinner.svg +3 -0
- package/src/assets/svg/spinner_white.svg +3 -0
- package/src/helpers/index.ts +3 -0
- package/src/helpers/talesOf.tsx +42 -0
- package/src/index.ts +2 -0
- package/src/lib/components/README.md +49 -0
- package/src/lib/components/alert-banner/alert-banner.tsx +34 -0
- package/src/lib/components/alert-banner/alert-level-flags.ts +77 -0
- package/src/lib/components/alert-banner/index.ts +1 -0
- package/src/lib/components/badge/badge-type-flags.ts +72 -0
- package/src/lib/components/badge/badge.stories.tsx +16 -0
- package/src/lib/components/badge/badge.test.tsx +29 -0
- package/src/lib/components/badge/badge.tsx +31 -0
- package/src/lib/components/badge/index.ts +1 -0
- package/{lib/components/card/atoms/card-frame.d.ts → src/lib/components/card/atoms/card-frame.tsx} +17 -7
- package/src/lib/components/card/atoms/index.ts +1 -0
- package/src/lib/components/card/card.test.tsx +163 -0
- package/src/lib/components/card/card.tsx +78 -0
- package/src/lib/components/card/components/card-alert-banner-slot.tsx +16 -0
- package/src/lib/components/card/components/card-controls-slot.tsx +19 -0
- package/src/lib/components/card/components/card-section-slot.tsx +51 -0
- package/src/lib/components/card/components/index.ts +3 -0
- package/src/lib/components/card/index.ts +2 -0
- package/src/lib/components/card/molecules/index.ts +1 -0
- package/src/lib/components/card/molecules/left-right-card.test.tsx +89 -0
- package/src/lib/components/card/molecules/left-right-card.tsx +63 -0
- package/src/lib/components/card/storybook/card.stories.mdx +100 -0
- package/src/lib/components/card/storybook/components.tsx +240 -0
- package/src/lib/components/checkbox/checkbox.test.tsx +39 -0
- package/src/lib/components/checkbox/checkbox.tsx +124 -0
- package/src/lib/components/checkbox/components/components.tsx +59 -0
- package/src/lib/components/checkbox/index.tsx +1 -0
- package/src/lib/components/checkbox/stories/checkbox.stories.mdx +54 -0
- package/src/lib/components/checkbox/stories/components.tsx +36 -0
- package/src/lib/components/checkbox/stories/index.tsx +1 -0
- package/src/lib/components/divider/divider-type-flags.tsx +37 -0
- package/src/lib/components/divider/divider.test.tsx +34 -0
- package/src/lib/components/divider/divider.tsx +37 -0
- package/src/lib/components/divider/index.tsx +1 -0
- package/src/lib/components/divider/stories/components.tsx +13 -0
- package/src/lib/components/divider/stories/divider.stories.mdx +50 -0
- package/src/lib/components/index.ts +14 -0
- package/src/lib/components/input-field/components/index.ts +2 -0
- package/src/lib/components/input-field/components/labeled-input.tsx +61 -0
- package/src/lib/components/input-field/components/stepper.tsx +59 -0
- package/src/lib/components/input-field/index.ts +6 -0
- package/src/lib/components/input-field/input-field.test.tsx +108 -0
- package/src/lib/components/input-field/input-field.tsx +126 -0
- package/src/lib/components/input-field/input-number.tsx +41 -0
- package/src/lib/components/input-field/input-text.tsx +30 -0
- package/src/lib/components/input-field/storybook/components.tsx +334 -0
- package/src/lib/components/input-field/storybook/input-field.stories.mdx +113 -0
- package/src/lib/components/layout/flex.tsx +22 -0
- package/src/lib/components/layout/grid-layout.tsx +40 -0
- package/src/lib/components/layout/index.ts +3 -0
- package/src/lib/components/layout/left-right-layout.tsx +67 -0
- package/src/lib/components/link/index.ts +1 -0
- package/src/lib/components/link/link.test.tsx +29 -0
- package/src/lib/components/link/link.tsx +56 -0
- package/src/lib/components/link/storybook/link.stories.mdx +51 -0
- package/src/lib/components/molecules/avatar/avatar-size-flags.tsx +55 -0
- package/src/lib/components/molecules/avatar/avatar.test.tsx +114 -0
- package/src/lib/components/molecules/avatar/avatar.tsx +80 -0
- package/src/lib/components/molecules/avatar/index.tsx +1 -0
- package/src/lib/components/molecules/avatar/stories/avatar.stories.mdx +55 -0
- package/src/lib/components/molecules/avatar/stories/components.tsx +36 -0
- package/src/lib/components/molecules/button/button-flags.tsx +235 -0
- package/src/lib/components/molecules/button/button.test.tsx +77 -0
- package/src/lib/components/molecules/button/button.tsx +231 -0
- package/src/lib/components/molecules/button/index.tsx +1 -0
- package/src/lib/components/molecules/button/stories/button.stories.mdx +104 -0
- package/src/lib/components/molecules/button/stories/components.tsx +86 -0
- package/src/lib/components/molecules/index.ts +3 -0
- package/src/lib/components/molecules/input-checkbox/index.tsx +1 -0
- package/src/lib/components/molecules/input-checkbox/input-checkbox.test.tsx +34 -0
- package/src/lib/components/molecules/input-checkbox/input-checkbox.tsx +50 -0
- package/src/lib/components/molecules/input-checkbox/stories/components.tsx +36 -0
- package/src/lib/components/molecules/input-checkbox/stories/index.tsx +1 -0
- package/src/lib/components/molecules/input-checkbox/stories/input-checkbox.stories.mdx +51 -0
- package/src/lib/components/organisms/index.ts +1 -0
- package/src/lib/components/organisms/multi-choice-list/index.tsx +1 -0
- package/src/lib/components/organisms/multi-choice-list/multi-choice-list.test.tsx +33 -0
- package/src/lib/components/organisms/multi-choice-list/multi-choice-list.tsx +53 -0
- package/src/lib/components/organisms/multi-choice-list/stories/components.tsx +126 -0
- package/src/lib/components/organisms/multi-choice-list/stories/index.tsx +1 -0
- package/src/lib/components/organisms/multi-choice-list/stories/multi-choice-list.stories.mdx +99 -0
- package/src/lib/components/spinner/index.tsx +1 -0
- package/src/lib/components/spinner/spinner-size-flags.tsx +39 -0
- package/src/lib/components/spinner/spinner.test.tsx +31 -0
- package/src/lib/components/spinner/spinner.tsx +67 -0
- package/src/lib/components/spinner/stories/components.tsx +8 -0
- package/src/lib/components/spinner/stories/spinner.stories.mdx +42 -0
- package/src/lib/components/thumbnail/index.tsx +1 -0
- package/src/lib/components/thumbnail/stories/thumbnail.stories.mdx +34 -0
- package/src/lib/components/thumbnail/thumbnail-size-flags.tsx +41 -0
- package/src/lib/components/thumbnail/thumbnail.test.tsx +51 -0
- package/src/lib/components/thumbnail/thumbnail.tsx +40 -0
- package/src/lib/components/typography/index.ts +1 -0
- package/src/lib/components/typography/storybook/components.tsx +256 -0
- package/src/lib/components/typography/storybook/typography.stories.mdx +88 -0
- package/src/lib/components/typography/typography.test.tsx +93 -0
- package/src/lib/components/typography/typography.tsx +57 -0
- package/src/lib/foundations/color-system/base-palette/base-palette.stories.tsx +123 -0
- package/src/lib/foundations/color-system/base-palette/base-palette.ts +94 -0
- package/src/lib/foundations/color-system/base-palette/index.ts +1 -0
- package/src/lib/foundations/color-system/color-guidelines/color-guidelines.stories.mdx +85 -0
- package/src/lib/foundations/color-system/color-guidelines/color-guidelines.stories.tsx +231 -0
- package/src/lib/foundations/color-system/color-guidelines/color-guidelines.ts +159 -0
- package/src/lib/foundations/color-system/color-guidelines/index.ts +1 -0
- package/src/lib/foundations/color-system/components/color-sample.tsx +99 -0
- package/src/lib/foundations/color-system/components/index.ts +1 -0
- package/src/lib/foundations/color-system/index.ts +1 -0
- package/src/lib/foundations/index.ts +4 -0
- package/src/lib/foundations/shadows/components.tsx +59 -0
- package/src/lib/foundations/shadows/index.ts +1 -0
- package/src/lib/foundations/shadows/shadows.stories.mdx +71 -0
- package/src/lib/foundations/shadows/shadows.tsx +47 -0
- package/src/lib/foundations/spacing/index.ts +1 -0
- package/src/lib/foundations/spacing/spacing-guidelines.ts +24 -0
- package/src/lib/foundations/spacing/spacing.stories.mdx +51 -0
- package/src/lib/foundations/spacing/spacing.ts +18 -0
- package/src/lib/foundations/typography/constants.ts +25 -0
- package/src/lib/foundations/typography/index.tsx +1 -0
- package/src/lib/foundations/typography/text-aspect-flags.ts +54 -0
- package/src/lib/foundations/typography/typography.tsx +97 -0
- package/src/lib/helpers/generic-types.ts +44 -0
- package/src/lib/helpers/index.ts +6 -0
- package/src/lib/helpers/nothing.tsx +18 -0
- package/{lib/helpers/numbers.d.ts → src/lib/helpers/numbers.ts} +53 -41
- package/src/lib/helpers/safe-navigation.ts +34 -0
- package/src/lib/helpers/slots.tsx +76 -0
- package/src/lib/helpers/strings.test.ts +47 -0
- package/src/lib/helpers/strings.ts +16 -0
- package/tsconfig.json +35 -0
- package/tsconfig.lib.json +28 -0
- package/tsconfig.spec.json +21 -0
- package/index.d.ts +0 -2
- package/index.js +0 -6078
- package/lib/components/alert-banner/alert-banner.d.ts +0 -11
- package/lib/components/alert-banner/alert-level-flags.d.ts +0 -13
- package/lib/components/alert-banner/index.d.ts +0 -1
- package/lib/components/badge/badge-type-flags.d.ts +0 -18
- package/lib/components/badge/badge.d.ts +0 -5
- package/lib/components/badge/index.d.ts +0 -1
- package/lib/components/card/atoms/index.d.ts +0 -1
- package/lib/components/card/card.d.ts +0 -14
- package/lib/components/card/components/card-alert-banner-slot.d.ts +0 -5
- package/lib/components/card/components/card-controls-slot.d.ts +0 -4
- package/lib/components/card/components/card-section-slot.d.ts +0 -11
- package/lib/components/card/components/index.d.ts +0 -3
- package/lib/components/card/index.d.ts +0 -2
- package/lib/components/card/molecules/index.d.ts +0 -1
- package/lib/components/card/molecules/left-right-card.d.ts +0 -16
- package/lib/components/checkbox/checkbox.d.ts +0 -11
- package/lib/components/checkbox/components/components.d.ts +0 -12
- package/lib/components/checkbox/index.d.ts +0 -1
- package/lib/components/divider/divider-type-flags.d.ts +0 -9
- package/lib/components/divider/divider.d.ts +0 -7
- package/lib/components/divider/index.d.ts +0 -1
- package/lib/components/index.d.ts +0 -12
- package/lib/components/input-field/components/index.d.ts +0 -2
- package/lib/components/input-field/components/labeled-input.d.ts +0 -11
- package/lib/components/input-field/components/stepper.d.ts +0 -7
- package/lib/components/input-field/index.d.ts +0 -3
- package/lib/components/input-field/input-field.d.ts +0 -25
- package/lib/components/input-field/input-number.d.ts +0 -18
- package/lib/components/input-field/input-text.d.ts +0 -14
- package/lib/components/layout/flex.d.ts +0 -16
- package/lib/components/layout/grid-layout.d.ts +0 -11
- package/lib/components/layout/index.d.ts +0 -3
- package/lib/components/layout/left-right-layout.d.ts +0 -70
- package/lib/components/link/index.d.ts +0 -1
- package/lib/components/link/link.d.ts +0 -14
- package/lib/components/molecules/avatar/avatar-size-flags.d.ts +0 -12
- package/lib/components/molecules/avatar/avatar.d.ts +0 -12
- package/lib/components/molecules/avatar/index.d.ts +0 -1
- package/lib/components/molecules/button/button-flags.d.ts +0 -39
- package/lib/components/molecules/button/button.d.ts +0 -24
- package/lib/components/molecules/button/index.d.ts +0 -1
- package/lib/components/molecules/index.d.ts +0 -3
- package/lib/components/molecules/input-checkbox/index.d.ts +0 -1
- package/lib/components/molecules/input-checkbox/input-checkbox.d.ts +0 -8
- package/lib/components/organisms/index.d.ts +0 -1
- package/lib/components/organisms/multi-choice-list/index.d.ts +0 -1
- package/lib/components/organisms/multi-choice-list/multi-choice-list.d.ts +0 -11
- package/lib/components/spinner/index.d.ts +0 -1
- package/lib/components/spinner/spinner-size-flags.d.ts +0 -10
- package/lib/components/spinner/spinner.d.ts +0 -9
- package/lib/components/thumbnail/index.d.ts +0 -1
- package/lib/components/thumbnail/thumbnail-size-flags.d.ts +0 -10
- package/lib/components/thumbnail/thumbnail.d.ts +0 -9
- package/lib/components/typography/index.d.ts +0 -1
- package/lib/components/typography/typography.d.ts +0 -23
- package/lib/foundations/color-system/base-palette/base-palette.d.ts +0 -77
- package/lib/foundations/color-system/base-palette/index.d.ts +0 -1
- package/lib/foundations/color-system/color-guidelines/color-guidelines.d.ts +0 -131
- package/lib/foundations/color-system/color-guidelines/index.d.ts +0 -1
- package/lib/foundations/color-system/components/color-sample.d.ts +0 -17
- package/lib/foundations/color-system/components/index.d.ts +0 -1
- package/lib/foundations/color-system/index.d.ts +0 -1
- package/lib/foundations/index.d.ts +0 -4
- package/lib/foundations/shadows/components.d.ts +0 -8
- package/lib/foundations/shadows/index.d.ts +0 -1
- package/lib/foundations/shadows/shadows.d.ts +0 -8
- package/lib/foundations/spacing/index.d.ts +0 -1
- package/lib/foundations/spacing/spacing-guidelines.d.ts +0 -22
- package/lib/foundations/spacing/spacing.d.ts +0 -18
- package/lib/foundations/typography/constants.d.ts +0 -22
- package/lib/foundations/typography/index.d.ts +0 -1
- package/lib/foundations/typography/text-aspect-flags.d.ts +0 -14
- package/lib/foundations/typography/typography.d.ts +0 -19
- package/lib/helpers/generic-types.d.ts +0 -21
- package/lib/helpers/index.d.ts +0 -6
- package/lib/helpers/nothing.d.ts +0 -8
- package/lib/helpers/safe-navigation.d.ts +0 -14
- package/lib/helpers/slots.d.ts +0 -8
- package/lib/helpers/strings.d.ts +0 -1
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { Actions, Borders, Surface, Text } from 'foundations/color-system'
|
|
2
|
+
import { Margin, Padding } from 'foundations/spacing'
|
|
3
|
+
import styled from 'styled-components'
|
|
4
|
+
import { is } from '@helpers'
|
|
5
|
+
import {
|
|
6
|
+
Display,
|
|
7
|
+
Heading1,
|
|
8
|
+
Heading2,
|
|
9
|
+
Heading3,
|
|
10
|
+
Heading4,
|
|
11
|
+
BodyLarge,
|
|
12
|
+
Body,
|
|
13
|
+
Caption,
|
|
14
|
+
Label1,
|
|
15
|
+
Label2,
|
|
16
|
+
} from '../typography'
|
|
17
|
+
import { Typography } from '@foundations'
|
|
18
|
+
import { Flex } from 'components/layout'
|
|
19
|
+
import { useState } from 'react'
|
|
20
|
+
import { StoryComponent } from '@stories'
|
|
21
|
+
|
|
22
|
+
const Table = styled.div`
|
|
23
|
+
background: ${Surface.Default};
|
|
24
|
+
border-radius: 6px;
|
|
25
|
+
`
|
|
26
|
+
|
|
27
|
+
const Row = styled.div<{ gray?: boolean }>`
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: row;
|
|
30
|
+
background-color: ${(props) => (is(props.gray) ? Surface.Default.Subdued : Surface.Default)};
|
|
31
|
+
border-bottom: 1px solid ${Borders.Default.Subdued};
|
|
32
|
+
`
|
|
33
|
+
|
|
34
|
+
const Column = styled.div`
|
|
35
|
+
${Typography.Body}
|
|
36
|
+
display: flex;
|
|
37
|
+
padding: ${Padding.l};
|
|
38
|
+
flex: 1;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
justify-content: space-between;
|
|
42
|
+
&:nth-child(1) {
|
|
43
|
+
flex: 2;
|
|
44
|
+
}
|
|
45
|
+
`
|
|
46
|
+
|
|
47
|
+
const HeaderColumn = styled(Column)`
|
|
48
|
+
color: ${Text.Subdued};
|
|
49
|
+
`
|
|
50
|
+
|
|
51
|
+
export const Button = styled.div<{ critical?: boolean, primary?: boolean }>`
|
|
52
|
+
background: ${({ critical, primary }) => {
|
|
53
|
+
if (is(critical)) {
|
|
54
|
+
return Actions.Critical.Default
|
|
55
|
+
} else if (is(primary)) {
|
|
56
|
+
return Actions.Primary.Default
|
|
57
|
+
} else {
|
|
58
|
+
return Actions.Secondary.Default
|
|
59
|
+
}
|
|
60
|
+
}};
|
|
61
|
+
border: 1px solid ${({ critical, primary }) => {
|
|
62
|
+
if (is(critical)) {
|
|
63
|
+
return 'none'
|
|
64
|
+
} else if (is(primary)) {
|
|
65
|
+
return 'none'
|
|
66
|
+
} else {
|
|
67
|
+
return Borders.Default
|
|
68
|
+
}
|
|
69
|
+
}};
|
|
70
|
+
box-sizing: border-box;
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-direction: row;
|
|
75
|
+
justify-content: center;
|
|
76
|
+
align-items: center;
|
|
77
|
+
padding: ${Padding.xs} ${Padding.m};
|
|
78
|
+
|
|
79
|
+
border-radius: 6px;
|
|
80
|
+
margin-right: ${Margin.s};
|
|
81
|
+
`
|
|
82
|
+
|
|
83
|
+
const Header = () => (
|
|
84
|
+
<Row>
|
|
85
|
+
<HeaderColumn><Label1 subdued>Typographic System</Label1></HeaderColumn>
|
|
86
|
+
<HeaderColumn><Label1 subdued>Weight</Label1></HeaderColumn>
|
|
87
|
+
<HeaderColumn><Label1 subdued>Size</Label1></HeaderColumn>
|
|
88
|
+
<HeaderColumn><Label1 subdued>Line Height</Label1></HeaderColumn>
|
|
89
|
+
<HeaderColumn><Label1 subdued>Spacing</Label1></HeaderColumn>
|
|
90
|
+
</Row>
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
const toTextAspectProps = (aspect: string) => {
|
|
94
|
+
switch (aspect) {
|
|
95
|
+
case 'subdued': return { subdued: true }
|
|
96
|
+
case 'light': return { light: true }
|
|
97
|
+
case 'critical': return { critical: true }
|
|
98
|
+
case 'success': return { success: true }
|
|
99
|
+
case 'onPrimary': return { onPrimary: true }
|
|
100
|
+
case 'onCritical': return { onCritical: true }
|
|
101
|
+
default: return {}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const toButtonProps = (aspect: string) => {
|
|
106
|
+
switch (aspect) {
|
|
107
|
+
case 'onPrimary': return { primary: true }
|
|
108
|
+
case 'onCritical': return { critical: true }
|
|
109
|
+
default: return {}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export const TypographyTable: StoryComponent = () => {
|
|
114
|
+
const [aspect, setAspect] = useState('')
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<div>
|
|
118
|
+
<Flex>
|
|
119
|
+
<Button onClick={() => setAspect('default')}>
|
|
120
|
+
<Body>Default</Body>
|
|
121
|
+
</Button>
|
|
122
|
+
<Button onClick={() => setAspect('subdued')}>
|
|
123
|
+
<Body subdued>Subdued</Body>
|
|
124
|
+
</Button>
|
|
125
|
+
<Button onClick={() => setAspect('light')}>
|
|
126
|
+
<Body light>Light</Body>
|
|
127
|
+
</Button>
|
|
128
|
+
<Button onClick={() => setAspect('critical')}>
|
|
129
|
+
<Body critical>Critical</Body>
|
|
130
|
+
</Button>
|
|
131
|
+
<Button onClick={() => setAspect('success')}>
|
|
132
|
+
<Body success>Success</Body>
|
|
133
|
+
</Button>
|
|
134
|
+
<Button primary onClick={() => setAspect('onPrimary')}>
|
|
135
|
+
<Body onPrimary>OnPrimary</Body>
|
|
136
|
+
</Button>
|
|
137
|
+
<Button critical onClick={() => setAspect('onCritical')}>
|
|
138
|
+
<Body onCritical>OnCritical</Body>
|
|
139
|
+
</Button>
|
|
140
|
+
</Flex>
|
|
141
|
+
<Table>
|
|
142
|
+
<Header />
|
|
143
|
+
<Row gray>
|
|
144
|
+
<Column>
|
|
145
|
+
<Button {...toButtonProps(aspect)}>
|
|
146
|
+
<Display {...toTextAspectProps(aspect)}>Display1</Display>
|
|
147
|
+
</Button>
|
|
148
|
+
</Column>
|
|
149
|
+
<Column>Regular 400</Column>
|
|
150
|
+
<Column>36px (2.25rem)</Column>
|
|
151
|
+
<Column>44px</Column>
|
|
152
|
+
<Column>0 px</Column>
|
|
153
|
+
</Row>
|
|
154
|
+
<Row>
|
|
155
|
+
<Column>
|
|
156
|
+
<Button {...toButtonProps(aspect)}>
|
|
157
|
+
<Heading1 {...toTextAspectProps(aspect)}>Heading1</Heading1>
|
|
158
|
+
</Button>
|
|
159
|
+
</Column>
|
|
160
|
+
<Column>Semibold 600</Column>
|
|
161
|
+
<Column>28px (1.75rem)</Column>
|
|
162
|
+
<Column>32px</Column>
|
|
163
|
+
<Column>0 px</Column>
|
|
164
|
+
</Row>
|
|
165
|
+
<Row>
|
|
166
|
+
<Column>
|
|
167
|
+
<Button {...toButtonProps(aspect)}>
|
|
168
|
+
<Heading2 {...toTextAspectProps(aspect)}>Heading2</Heading2>
|
|
169
|
+
</Button>
|
|
170
|
+
</Column>
|
|
171
|
+
<Column>Semibold 600</Column>
|
|
172
|
+
<Column>20px (1.25rem)</Column>
|
|
173
|
+
<Column>28px</Column>
|
|
174
|
+
<Column>0 px</Column>
|
|
175
|
+
</Row>
|
|
176
|
+
<Row>
|
|
177
|
+
<Column>
|
|
178
|
+
<Button {...toButtonProps(aspect)}>
|
|
179
|
+
<Heading3 {...toTextAspectProps(aspect)}>Heading3</Heading3>
|
|
180
|
+
</Button>
|
|
181
|
+
</Column>
|
|
182
|
+
<Column>Semibold 600</Column>
|
|
183
|
+
<Column>16px (1 rem)</Column>
|
|
184
|
+
<Column>24px</Column>
|
|
185
|
+
<Column>0 px</Column>
|
|
186
|
+
</Row>
|
|
187
|
+
<Row>
|
|
188
|
+
<Column>
|
|
189
|
+
<Button {...toButtonProps(aspect)}>
|
|
190
|
+
<Heading4 {...toTextAspectProps(aspect)}>Heading4</Heading4>
|
|
191
|
+
</Button>
|
|
192
|
+
</Column>
|
|
193
|
+
<Column>Semibold 600</Column>
|
|
194
|
+
<Column>14px (0.875rem)</Column>
|
|
195
|
+
<Column>20px</Column>
|
|
196
|
+
<Column>0 px</Column>
|
|
197
|
+
</Row>
|
|
198
|
+
<Row gray>
|
|
199
|
+
<Column>
|
|
200
|
+
<Button {...toButtonProps(aspect)}>
|
|
201
|
+
<BodyLarge {...toTextAspectProps(aspect)}>BodyLarge</BodyLarge>
|
|
202
|
+
</Button>
|
|
203
|
+
</Column>
|
|
204
|
+
<Column>Reg 400 / Semibold 600</Column>
|
|
205
|
+
<Column>18px (1.125rem)</Column>
|
|
206
|
+
<Column>28px</Column>
|
|
207
|
+
<Column>0 px</Column>
|
|
208
|
+
</Row>
|
|
209
|
+
<Row gray>
|
|
210
|
+
<Column>
|
|
211
|
+
<Button {...toButtonProps(aspect)}>
|
|
212
|
+
<Body {...toTextAspectProps(aspect)}>Body</Body>
|
|
213
|
+
</Button>
|
|
214
|
+
</Column>
|
|
215
|
+
<Column>Reg 400 / Medium 500</Column>
|
|
216
|
+
<Column>14px (0.875rem)</Column>
|
|
217
|
+
<Column>20px</Column>
|
|
218
|
+
<Column>0 px</Column>
|
|
219
|
+
</Row>
|
|
220
|
+
<Row gray>
|
|
221
|
+
<Column>
|
|
222
|
+
<Button {...toButtonProps(aspect)}>
|
|
223
|
+
<Caption {...toTextAspectProps(aspect)}>Caption</Caption>
|
|
224
|
+
</Button>
|
|
225
|
+
</Column>
|
|
226
|
+
<Column>Regular 400</Column>
|
|
227
|
+
<Column>13px (0.8125rem)</Column>
|
|
228
|
+
<Column>16px</Column>
|
|
229
|
+
<Column>0 px</Column>
|
|
230
|
+
</Row>
|
|
231
|
+
<Row>
|
|
232
|
+
<Column>
|
|
233
|
+
<Button {...toButtonProps(aspect)}>
|
|
234
|
+
<Label1 {...toTextAspectProps(aspect)}>Label1</Label1>
|
|
235
|
+
</Button>
|
|
236
|
+
</Column>
|
|
237
|
+
<Column>Reg 400 / Medium 500</Column>
|
|
238
|
+
<Column>14px (0.875rem)</Column>
|
|
239
|
+
<Column>20px</Column>
|
|
240
|
+
<Column>0 px</Column>
|
|
241
|
+
</Row>
|
|
242
|
+
<Row>
|
|
243
|
+
<Column>
|
|
244
|
+
<Button {...toButtonProps(aspect)}>
|
|
245
|
+
<Label2 {...toTextAspectProps(aspect)}>Label2</Label2>
|
|
246
|
+
</Button>
|
|
247
|
+
</Column>
|
|
248
|
+
<Column>Regular 400</Column>
|
|
249
|
+
<Column>13px (0.8125rem)</Column>
|
|
250
|
+
<Column>16px</Column>
|
|
251
|
+
<Column>0 px</Column>
|
|
252
|
+
</Row>
|
|
253
|
+
</Table>
|
|
254
|
+
</div>
|
|
255
|
+
)
|
|
256
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Canvas, Meta } from '@storybook/addon-docs';
|
|
2
|
+
import { TypographyTable, Button } from './components'
|
|
3
|
+
import { Heading3, Label1, Body } from '../typography'
|
|
4
|
+
|
|
5
|
+
<Meta title="Components/Typography" />
|
|
6
|
+
|
|
7
|
+
# Typography
|
|
8
|
+
|
|
9
|
+
All text that appears in the front-end should be wrapped by one of these components.
|
|
10
|
+
|
|
11
|
+
## Basic usage
|
|
12
|
+
|
|
13
|
+
When you are building from a mockup you will be clicking on elements and checking in the figma inspector to see what components you should use, and how you should configure them. With typography there are two relevant sections: Typography and Color.
|
|
14
|
+
|
|
15
|
+
### Typography: Ag
|
|
16
|
+
|
|
17
|
+
When you see text in a mockup you can click that text to see what kind of typographic component it represents. In the typography section of the figma inspector you will see a label Ag with a value like "Label1" or "Label1/emphasis". This is the name of the component you should use, and whether you should set the emphasis flag.
|
|
18
|
+
|
|
19
|
+
For example if you see "Ag Heading3".
|
|
20
|
+
|
|
21
|
+
<Canvas>
|
|
22
|
+
<Heading3>Heading 3, no modifiers</Heading3>
|
|
23
|
+
</Canvas>
|
|
24
|
+
|
|
25
|
+
If you see "Ag Label 1/emphasis" you should use a Label1 with emphasis set.
|
|
26
|
+
|
|
27
|
+
<Canvas>
|
|
28
|
+
<Label1 emphasis>Label 1, emphasis</Label1>
|
|
29
|
+
</Canvas>
|
|
30
|
+
|
|
31
|
+
### Colors: Text
|
|
32
|
+
|
|
33
|
+
Below the Typography section in the figma inspector you will see the Colors section. Here you will see a color swatch and a label like "Text/Default" or "Text/Subdued". In most cases you will see "Text/Default" and can proceed without any modifiers. When you do see a modifier you will be able to use it as is to configure your component.
|
|
34
|
+
|
|
35
|
+
<Canvas>
|
|
36
|
+
<Button><Body>Text/Default</Body></Button>
|
|
37
|
+
<Button><Body subdued>Text/Subdued</Body></Button>
|
|
38
|
+
<Button><Body light>Text/Light</Body></Button>
|
|
39
|
+
<Button primary><Body onPrimary>Text/onPrimary</Body></Button>
|
|
40
|
+
<Button critical><Body onCritical>Text/onCritical</Body></Button>
|
|
41
|
+
</Canvas>
|
|
42
|
+
|
|
43
|
+
In addition there are two less commonly used text colors: Text/Critical and Text/Success. These appear from time to time in mockups to indicate some problems (like an invalid field) or some big win (like a discount on a price).
|
|
44
|
+
|
|
45
|
+
<Canvas>
|
|
46
|
+
<Body critical>Text/Critical</Body>
|
|
47
|
+
<Body success>Text/Success</Body>
|
|
48
|
+
</Canvas>
|
|
49
|
+
|
|
50
|
+
## Recommended usage with i18n
|
|
51
|
+
|
|
52
|
+
In practice you will not be using these typographic components without i18n. In our previous projects i18n has usually looked something like this:
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
<Body critical><T.Trans>YOU_LOSE</T.Trans></Body>
|
|
56
|
+
<Body success><T.Trans>YOU_WIN</T.Trans></Body>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Or like this,
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
<Body critical>{t(YOU_LOSE)}</Body>
|
|
63
|
+
<Body success>{t(YOU_WIN)}</Body>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Instead we recommend wrapping the typographic components with i18n helpers and re-exporting them in your project.
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
// my/typography.tsx
|
|
70
|
+
import { Body as _Body, IBodyProps } from '@edvisor/product-language'
|
|
71
|
+
import { useI18n } from 'your-i18n-library'
|
|
72
|
+
|
|
73
|
+
// something like this:
|
|
74
|
+
export const Body = (props: IBodyProps) => {
|
|
75
|
+
const { t } = useI18n()
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<_Body {...props}>{t(props.children)}</_Body>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// then you can use it like this:
|
|
83
|
+
<Body success>YOU_WIN</Body>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Typography Table
|
|
87
|
+
|
|
88
|
+
<TypographyTable />
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react'
|
|
2
|
+
import {
|
|
3
|
+
Display,
|
|
4
|
+
Heading1,
|
|
5
|
+
Heading2,
|
|
6
|
+
Heading3,
|
|
7
|
+
Heading4,
|
|
8
|
+
BodyLarge,
|
|
9
|
+
Body,
|
|
10
|
+
Caption,
|
|
11
|
+
Label1,
|
|
12
|
+
Label2,
|
|
13
|
+
} from './typography'
|
|
14
|
+
|
|
15
|
+
describe('Typography', () => {
|
|
16
|
+
it('should render Display successfully', () => {
|
|
17
|
+
const { baseElement } = render(<Display>My Text Here</Display>)
|
|
18
|
+
expect(baseElement).toBeTruthy()
|
|
19
|
+
expect(screen.getByText('My Text Here')).toBeTruthy()
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('should render Heading1 successfully', () => {
|
|
23
|
+
const { baseElement } = render(<Heading1>My Text Here</Heading1>)
|
|
24
|
+
expect(baseElement).toBeTruthy()
|
|
25
|
+
expect(screen.getByText('My Text Here')).toBeTruthy()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('should render Heading2 successfully', () => {
|
|
29
|
+
const { baseElement } = render(<Heading2>My Text Here</Heading2>)
|
|
30
|
+
expect(baseElement).toBeTruthy()
|
|
31
|
+
expect(screen.getByText('My Text Here')).toBeTruthy()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('should render Heading3 successfully', () => {
|
|
35
|
+
const { baseElement } = render(<Heading3>My Text Here</Heading3>)
|
|
36
|
+
expect(baseElement).toBeTruthy()
|
|
37
|
+
expect(screen.getByText('My Text Here')).toBeTruthy()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('should render Heading4 successfully', () => {
|
|
41
|
+
const { baseElement } = render(<Heading4>My Text Here</Heading4>)
|
|
42
|
+
expect(baseElement).toBeTruthy()
|
|
43
|
+
expect(screen.getByText('My Text Here')).toBeTruthy()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('should render BodyLarge successfully', () => {
|
|
47
|
+
const { baseElement } = render(<BodyLarge>My Text Here</BodyLarge>)
|
|
48
|
+
expect(baseElement).toBeTruthy()
|
|
49
|
+
expect(screen.getByText('My Text Here')).toBeTruthy()
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('should render Body successfully', () => {
|
|
53
|
+
const { baseElement } = render(<Body>My Text Here</Body>)
|
|
54
|
+
expect(baseElement).toBeTruthy()
|
|
55
|
+
expect(screen.getByText('My Text Here')).toBeTruthy()
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('should render Subdued successfully', () => {
|
|
59
|
+
const { baseElement } = render(<Body subdued>My Text Here</Body>)
|
|
60
|
+
expect(baseElement).toBeTruthy()
|
|
61
|
+
expect(screen.getByText('My Text Here')).toBeTruthy()
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('should render Light successfully', () => {
|
|
65
|
+
const { baseElement } = render(<Body light>My Text Here</Body>)
|
|
66
|
+
expect(baseElement).toBeTruthy()
|
|
67
|
+
expect(screen.getByText('My Text Here')).toBeTruthy()
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('should render White successfully', () => {
|
|
71
|
+
const { baseElement } = render(<Body onPrimary>My Text Here</Body>)
|
|
72
|
+
expect(baseElement).toBeTruthy()
|
|
73
|
+
expect(screen.getByText('My Text Here')).toBeTruthy()
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('should render Caption successfully', () => {
|
|
77
|
+
const { baseElement } = render(<Caption>My Text Here</Caption>)
|
|
78
|
+
expect(baseElement).toBeTruthy()
|
|
79
|
+
expect(screen.getByText('My Text Here')).toBeTruthy()
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
it('should render Label1 successfully', () => {
|
|
83
|
+
const { baseElement } = render(<Label1>My Text Here</Label1>)
|
|
84
|
+
expect(baseElement).toBeTruthy()
|
|
85
|
+
expect(screen.getByText('My Text Here')).toBeTruthy()
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('should render Label2 successfully', () => {
|
|
89
|
+
const { baseElement } = render(<Label2>My Text Here</Label2>)
|
|
90
|
+
expect(baseElement).toBeTruthy()
|
|
91
|
+
expect(screen.getByText('My Text Here')).toBeTruthy()
|
|
92
|
+
})
|
|
93
|
+
})
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Typography, ITextProps, Margin } from '@foundations'
|
|
2
|
+
import { PropsWithChildren } from '@helpers'
|
|
3
|
+
import styled from 'styled-components'
|
|
4
|
+
|
|
5
|
+
type Semibold = { semibold?: boolean }
|
|
6
|
+
type Regular = { regular?: boolean }
|
|
7
|
+
type Medium = { medium?: boolean }
|
|
8
|
+
|
|
9
|
+
type ITextComponentProps = ITextProps & PropsWithChildren
|
|
10
|
+
|
|
11
|
+
export const Display = styled.div<ITextComponentProps & Regular>`
|
|
12
|
+
${Typography.Display};
|
|
13
|
+
`
|
|
14
|
+
|
|
15
|
+
export const Heading1 = styled.h1<ITextComponentProps & Semibold>`
|
|
16
|
+
${Typography.Heading1};
|
|
17
|
+
margin: ${Margin.none};
|
|
18
|
+
margin-bottom: ${Margin.l};
|
|
19
|
+
`
|
|
20
|
+
|
|
21
|
+
export const Heading2 = styled.h2<ITextComponentProps & Semibold>`
|
|
22
|
+
${Typography.Heading2};
|
|
23
|
+
margin: ${Margin.none};
|
|
24
|
+
margin-bottom: ${Margin.m};
|
|
25
|
+
`
|
|
26
|
+
|
|
27
|
+
export const Heading3 = styled.h3<ITextComponentProps & Semibold>`
|
|
28
|
+
${Typography.Heading3};
|
|
29
|
+
margin: ${Margin.none};
|
|
30
|
+
margin-bottom: ${Margin.l};
|
|
31
|
+
`
|
|
32
|
+
|
|
33
|
+
export const Heading4 = styled.h4<ITextComponentProps & Semibold>`
|
|
34
|
+
${Typography.Heading4};
|
|
35
|
+
margin: ${Margin.none};
|
|
36
|
+
margin-bottom: ${Margin.m};
|
|
37
|
+
`
|
|
38
|
+
|
|
39
|
+
export const BodyLarge = styled.div<ITextComponentProps & Regular & Semibold>`
|
|
40
|
+
${Typography.BodyLarge};
|
|
41
|
+
`
|
|
42
|
+
|
|
43
|
+
export const Body = styled.div<ITextComponentProps & Regular & Medium>`
|
|
44
|
+
${Typography.Body};
|
|
45
|
+
`
|
|
46
|
+
|
|
47
|
+
export const Caption = styled.div<ITextComponentProps & Regular>`
|
|
48
|
+
${Typography.Caption};
|
|
49
|
+
`
|
|
50
|
+
|
|
51
|
+
export const Label1 = styled.div<ITextComponentProps & Regular & Medium>`
|
|
52
|
+
${Typography.Label1};
|
|
53
|
+
`
|
|
54
|
+
|
|
55
|
+
export const Label2 = styled.div<ITextComponentProps & Regular>`
|
|
56
|
+
${Typography.Label2};
|
|
57
|
+
`
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Card, gridLayoutGenerator, leftRightLayoutGenerator } from '@components'
|
|
2
|
+
import { FC } from '@helpers'
|
|
3
|
+
import { BLUE, BRAND, ColorPalette, GRAY, GREEN, ORANGE, RED, SHADES } from './base-palette'
|
|
4
|
+
import { ColorRectangle } from '../components'
|
|
5
|
+
import { StoryComponent, talesOf } from '@stories'
|
|
6
|
+
|
|
7
|
+
const Story: StoryComponent = () => {
|
|
8
|
+
return (
|
|
9
|
+
<Card
|
|
10
|
+
heading={'Color System: Base Palette'}
|
|
11
|
+
>
|
|
12
|
+
<Card.Section>
|
|
13
|
+
<Hue
|
|
14
|
+
colorName={'Gray'}
|
|
15
|
+
colorPalette={GRAY}
|
|
16
|
+
description={
|
|
17
|
+
'These colors are used as supporting colors in backgrounds, text colors, seperators, modals, etc.'
|
|
18
|
+
}
|
|
19
|
+
/>
|
|
20
|
+
</Card.Section>
|
|
21
|
+
<Card.Section>
|
|
22
|
+
<Hue
|
|
23
|
+
colorName={'Blue'}
|
|
24
|
+
colorPalette={BLUE}
|
|
25
|
+
description={
|
|
26
|
+
'These colors are used as across all the interactive elements such as CTAs, links, active states, etc.'
|
|
27
|
+
}
|
|
28
|
+
/>
|
|
29
|
+
</Card.Section>
|
|
30
|
+
<Card.Section>
|
|
31
|
+
<Hue
|
|
32
|
+
colorName={'Green'}
|
|
33
|
+
colorPalette={GREEN}
|
|
34
|
+
description={
|
|
35
|
+
'These colors are used to depict the emotion of positivity. Generally used across success and complete states.'
|
|
36
|
+
}
|
|
37
|
+
/>
|
|
38
|
+
</Card.Section>
|
|
39
|
+
<Card.Section>
|
|
40
|
+
<Hue
|
|
41
|
+
colorName={'Orange'}
|
|
42
|
+
colorPalette={ORANGE}
|
|
43
|
+
description={
|
|
44
|
+
'These colors are used to depict the emotion of caution. Generally used across warning states.'
|
|
45
|
+
}
|
|
46
|
+
/>
|
|
47
|
+
</Card.Section>
|
|
48
|
+
<Card.Section>
|
|
49
|
+
<Hue
|
|
50
|
+
colorName={'Red'}
|
|
51
|
+
colorPalette={RED}
|
|
52
|
+
description={
|
|
53
|
+
'These colors decpict the emotion of negativity. Generally used across critical or destructive states.'
|
|
54
|
+
}
|
|
55
|
+
/>
|
|
56
|
+
</Card.Section>
|
|
57
|
+
<Card.Section>
|
|
58
|
+
<Hue
|
|
59
|
+
colorName={'Shades'}
|
|
60
|
+
colorPalette={SHADES}
|
|
61
|
+
description={
|
|
62
|
+
'White is generally used to color text on surfaces such as primary buttons. Various opacities of black are used for shadows.'
|
|
63
|
+
}
|
|
64
|
+
/>
|
|
65
|
+
</Card.Section>
|
|
66
|
+
<Card.Section>
|
|
67
|
+
<Hue
|
|
68
|
+
colorName={'Brand'}
|
|
69
|
+
colorPalette={BRAND}
|
|
70
|
+
description={
|
|
71
|
+
'Edvisor brand color.'
|
|
72
|
+
}
|
|
73
|
+
/>
|
|
74
|
+
</Card.Section>
|
|
75
|
+
</Card>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const { Layout } = leftRightLayoutGenerator()
|
|
80
|
+
|
|
81
|
+
interface IHueProps {
|
|
82
|
+
colorName: string
|
|
83
|
+
colorPalette: ColorPalette
|
|
84
|
+
description: string
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** a "hue" is a color like "green" or "red" without saturation or value */
|
|
88
|
+
const Hue: FC<IHueProps> = (props) => {
|
|
89
|
+
return (
|
|
90
|
+
<Layout>
|
|
91
|
+
<Layout.Left>
|
|
92
|
+
<Layout.HeadingText>{props.colorName}</Layout.HeadingText>
|
|
93
|
+
<Layout.HelpText>{props.description}</Layout.HelpText>
|
|
94
|
+
</Layout.Left>
|
|
95
|
+
<Layout.Right>
|
|
96
|
+
<Palette colors={props.colorPalette} />
|
|
97
|
+
</Layout.Right>
|
|
98
|
+
</Layout>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const { Grid } = gridLayoutGenerator({
|
|
103
|
+
columns: 5,
|
|
104
|
+
rows: 2,
|
|
105
|
+
columnGutter: 16,
|
|
106
|
+
rowGutter: 24,
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
interface IPaletteProps {
|
|
110
|
+
colors: ColorPalette
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const Palette: FC<IPaletteProps> = (props) => {
|
|
114
|
+
return (
|
|
115
|
+
<Grid>
|
|
116
|
+
{Object.entries(props.colors).map(([name, hex]) =>
|
|
117
|
+
<ColorRectangle key={hex} name={name} hex={hex}/>
|
|
118
|
+
)}
|
|
119
|
+
</Grid>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
talesOf(__filename, module, Story)
|