@edvisor/product-language 0.2.0 → 0.3.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/.eslintrc.json +14 -6
- package/package.json +2 -3
- package/project.json +18 -7
- package/src/README.md +61 -0
- package/src/helpers/index.ts +2 -1
- package/src/helpers/playground.ts +16 -0
- package/src/lib/components/badge/badge.tsx +8 -17
- package/src/lib/components/badge/stories/badge.stories.mdx +44 -0
- package/src/lib/components/badge/stories/components.tsx +49 -0
- package/src/lib/components/card/card.test.tsx +4 -5
- package/src/lib/components/card/card.tsx +2 -2
- package/src/lib/components/card/components/card-section-slot.tsx +2 -2
- package/src/lib/components/card/storybook/card.stories.mdx +1 -1
- package/src/lib/components/card/storybook/components.tsx +6 -23
- package/src/lib/components/checkbox/checkbox.tsx +34 -95
- package/src/lib/components/checkbox/helpers.tsx +100 -0
- package/src/lib/components/checkbox/stories/checkbox.stories.mdx +27 -24
- package/src/lib/components/checkbox/stories/components.tsx +63 -15
- package/src/lib/components/divider/stories/divider.stories.mdx +7 -13
- package/src/lib/components/flag/flag-size-flags.tsx +55 -0
- package/src/lib/components/flag/flag.list.tsx +788 -0
- package/src/lib/components/flag/flag.test.tsx +65 -0
- package/src/lib/components/flag/flag.tsx +97 -0
- package/src/lib/components/flag/index.tsx +1 -0
- package/src/lib/components/flag/stories/components.tsx +403 -0
- package/src/lib/components/flag/stories/flag.stories.mdx +48 -0
- package/src/lib/components/flag/stories/playGround-select.tsx +145 -0
- package/src/lib/components/icon/icon-list.tsx +135 -0
- package/src/lib/components/icon/icon.test.tsx +48 -0
- package/src/lib/components/icon/icon.tsx +181 -0
- package/src/lib/components/icon/index.tsx +1 -0
- package/src/lib/components/icon/stories/components.tsx +282 -0
- package/src/lib/components/icon/stories/icon.stories.mdx +65 -0
- package/src/lib/components/index.ts +5 -0
- package/src/lib/components/input-field/components/labeled-input.tsx +7 -14
- package/src/lib/components/input-field/components/stepper.tsx +4 -3
- package/src/lib/components/input-field/input-field.test.tsx +5 -6
- package/src/lib/components/input-field/input-field.tsx +8 -8
- package/src/lib/components/input-field/storybook/components.tsx +9 -16
- package/src/lib/components/link/storybook/link.stories.mdx +1 -0
- package/src/lib/components/molecules/avatar/avatar-size-flags.tsx +3 -3
- package/src/lib/components/molecules/avatar/avatar.tsx +2 -2
- package/src/lib/components/molecules/avatar/stories/avatar.stories.mdx +18 -21
- package/src/lib/components/molecules/button/button-flags.tsx +120 -15
- package/src/lib/components/molecules/button/button.test.tsx +9 -9
- package/src/lib/components/molecules/button/button.tsx +61 -78
- package/src/lib/components/molecules/button/stories/button.stories.mdx +43 -42
- package/src/lib/components/molecules/button/stories/components.tsx +6 -8
- package/src/lib/components/molecules/input-checkbox/input-checkbox.tsx +23 -24
- package/src/lib/components/molecules/input-checkbox/stories/components.tsx +32 -15
- package/src/lib/components/molecules/input-checkbox/stories/input-checkbox.stories.mdx +6 -8
- package/src/lib/components/organisms/multi-choice-list/multi-choice-list.tsx +7 -8
- package/src/lib/components/organisms/multi-choice-list/stories/components.tsx +3 -5
- package/src/lib/components/organisms/multi-choice-list/stories/multi-choice-list.stories.mdx +4 -4
- package/src/lib/components/spinner/spinner.test.tsx +2 -2
- package/src/lib/components/spinner/spinner.tsx +15 -28
- package/src/lib/components/spinner/stories/components.tsx +33 -2
- package/src/lib/components/spinner/stories/spinner.stories.mdx +3 -10
- package/src/lib/components/tabs/components/index.ts +1 -0
- package/src/lib/components/tabs/components/tab.tsx +62 -0
- package/src/lib/components/tabs/index.tsx +1 -0
- package/src/lib/components/tabs/storybook/components.tsx +282 -0
- package/src/lib/components/tabs/storybook/tabs.stories.mdx +97 -0
- package/src/lib/components/tabs/tabs.test.tsx +86 -0
- package/src/lib/components/tabs/tabs.tsx +101 -0
- package/src/lib/components/tag/components/close-button.tsx +85 -0
- package/src/lib/components/tag/components/index.ts +2 -0
- package/src/lib/components/tag/components/tag-label.tsx +44 -0
- package/src/lib/components/tag/index.tsx +1 -0
- package/src/lib/components/tag/stories/components.tsx +86 -0
- package/src/lib/components/tag/stories/tag.stories.mdx +42 -0
- package/src/lib/components/tag/tag.test.tsx +36 -0
- package/src/lib/components/tag/tag.tsx +33 -0
- package/src/lib/components/thumbnail/thumbnail.tsx +7 -2
- package/src/lib/components/typography/storybook/components.tsx +47 -15
- package/src/lib/components/typography/storybook/typography.stories.mdx +6 -4
- package/src/lib/components/typography/typography.test.tsx +34 -30
- package/src/lib/components/typography/typography.tsx +61 -19
- package/src/lib/foundations/color-system/base-palette/base-palette.ts +0 -1
- package/src/lib/foundations/color-system/color-guidelines/color-guidelines.ts +5 -4
- package/src/lib/foundations/color-system/components/color-sample.tsx +3 -3
- package/src/lib/foundations/typography/fonts.ts +205 -0
- package/src/lib/foundations/typography/text-aspect-flags.ts +11 -4
- package/src/lib/foundations/typography/typography.tsx +38 -33
- package/src/lib/helpers/numbers.ts +14 -0
- package/src/lib/helpers/safe-navigation.ts +10 -0
- package/src/lib/helpers/slots.test.tsx +98 -0
- package/src/lib/helpers/slots.tsx +93 -12
- package/.storybook/preview-head.html +0 -1
- package/src/lib/components/badge/badge.stories.tsx +0 -16
- package/src/lib/components/checkbox/components/components.tsx +0 -59
- package/src/lib/components/checkbox/stories/index.tsx +0 -1
- package/src/lib/components/molecules/input-checkbox/stories/index.tsx +0 -1
- package/src/lib/components/organisms/multi-choice-list/stories/index.tsx +0 -1
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import styled from 'styled-components'
|
|
2
|
-
import { FC, is, isDefined } from '@helpers'
|
|
2
|
+
import { FC, is, isDefined, Nothing } from '@helpers'
|
|
3
3
|
import { Focused } from '@foundations'
|
|
4
4
|
import {
|
|
5
5
|
ButtonSizeProps,
|
|
6
6
|
getBackgroundColorByType,
|
|
7
7
|
getIsDisabled,
|
|
8
8
|
getTextColorByType,
|
|
9
|
+
getIconColorByType,
|
|
9
10
|
getTextColorIfDisabled,
|
|
10
11
|
getCursor,
|
|
11
12
|
getPaddingBySize,
|
|
12
13
|
getBackgroundColorHoverByType,
|
|
14
|
+
getTextDecorationHoverByType,
|
|
13
15
|
getTextColorOnHoverByType,
|
|
16
|
+
getIconColorOnHoverByType,
|
|
14
17
|
getBorderByType,
|
|
15
18
|
getPaddingByType,
|
|
16
19
|
getBackgroundColorDisabledByType,
|
|
17
20
|
getBorderDisabledByType,
|
|
18
21
|
ButtonType,
|
|
19
22
|
getBackgroundColorPressedByType,
|
|
23
|
+
getButtonType,
|
|
24
|
+
ButtonTypeProps,
|
|
20
25
|
} from './button-flags'
|
|
21
26
|
import { ComponentType } from 'react'
|
|
22
|
-
import {
|
|
27
|
+
import { Label } from 'components/typography'
|
|
23
28
|
import { Spinner } from 'components/spinner'
|
|
24
29
|
|
|
25
30
|
const ButtonFrame = styled.button<{
|
|
@@ -27,10 +32,13 @@ const ButtonFrame = styled.button<{
|
|
|
27
32
|
buttonSize: string
|
|
28
33
|
cursor: string
|
|
29
34
|
backgroundHover: string
|
|
35
|
+
textDecorationHover: string,
|
|
30
36
|
backgroundPressed: string
|
|
31
37
|
textColorHover: string
|
|
32
38
|
buttonBorder: string
|
|
33
39
|
isDisabled: boolean
|
|
40
|
+
iconColor: string
|
|
41
|
+
iconColorHover: string
|
|
34
42
|
}>`
|
|
35
43
|
padding: ${(props) => props.buttonSize};
|
|
36
44
|
border: ${(props) => props.buttonBorder};
|
|
@@ -43,16 +51,27 @@ const ButtonFrame = styled.button<{
|
|
|
43
51
|
gap: 8px;
|
|
44
52
|
align-items: center;
|
|
45
53
|
position: relative;
|
|
54
|
+
svg[role='icon'] {
|
|
55
|
+
path {
|
|
56
|
+
fill: ${(props) => props.iconColor};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
46
60
|
|
|
47
61
|
${(props) =>
|
|
48
62
|
!props.isDisabled
|
|
49
63
|
? `
|
|
50
64
|
&:hover {
|
|
51
65
|
background: ${props.backgroundHover};
|
|
52
|
-
|
|
66
|
+
text-decoration: ${props.textDecorationHover};
|
|
53
67
|
div {
|
|
54
68
|
color: ${props.textColorHover};
|
|
55
69
|
}
|
|
70
|
+
svg[role='icon'] {
|
|
71
|
+
path {
|
|
72
|
+
fill: ${props.iconColorHover};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
56
75
|
}
|
|
57
76
|
|
|
58
77
|
&:focus {
|
|
@@ -64,17 +83,14 @@ const ButtonFrame = styled.button<{
|
|
|
64
83
|
}
|
|
65
84
|
|
|
66
85
|
&:active {
|
|
86
|
+
text-decoration: 'none'
|
|
67
87
|
background: ${props.backgroundPressed}
|
|
68
88
|
}
|
|
69
89
|
`
|
|
70
90
|
: ''}
|
|
71
91
|
`
|
|
72
92
|
|
|
73
|
-
const ButtonText = styled(
|
|
74
|
-
textColor: string
|
|
75
|
-
textColorDisabled: string
|
|
76
|
-
isLoading: boolean
|
|
77
|
-
}>`
|
|
93
|
+
const ButtonText = styled(Label)<{ textColor: string, textColorDisabled: string, isLoading: boolean }>`
|
|
78
94
|
color: ${(props) =>
|
|
79
95
|
props.textColorDisabled !== '' ? props.textColorDisabled : props.textColor};
|
|
80
96
|
|
|
@@ -86,37 +102,29 @@ const ButtonText = styled(Label1)<{
|
|
|
86
102
|
: ''}
|
|
87
103
|
`
|
|
88
104
|
|
|
89
|
-
const
|
|
90
|
-
|
|
105
|
+
const IconContainer = styled.div<{ isLoading: boolean }>`
|
|
106
|
+
width: 20px;
|
|
107
|
+
${(props) =>
|
|
108
|
+
props.isLoading
|
|
109
|
+
? 'visibility: hidden;'
|
|
110
|
+
: ''
|
|
111
|
+
}
|
|
91
112
|
`
|
|
92
113
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
114
|
+
const Loading = styled(Spinner)`
|
|
115
|
+
position: absolute;
|
|
116
|
+
`
|
|
96
117
|
|
|
97
|
-
interface IButtonProps {
|
|
118
|
+
interface IButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
98
119
|
loading?: boolean
|
|
99
|
-
IconPrefix?: ComponentType
|
|
100
|
-
IconSuffix?: ComponentType
|
|
120
|
+
IconPrefix?: ComponentType
|
|
121
|
+
IconSuffix?: ComponentType
|
|
101
122
|
children?: string
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
interface IButtonDestructiveProps extends IButtonProps {
|
|
105
|
-
primary?: boolean
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
interface IButtonPlainProps extends IButtonProps {
|
|
109
123
|
subtle?: boolean
|
|
110
124
|
}
|
|
111
125
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
IButtonDestructiveProps {
|
|
115
|
-
buttonType: ButtonType
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function makeButtonConfig(props: ISecretInnerButtonProps & ButtonSizeProps) {
|
|
119
|
-
const { buttonType } = props
|
|
126
|
+
function makeButtonConfig(props: IButtonProps & ButtonTypeProps & ButtonSizeProps) {
|
|
127
|
+
const buttonType = getButtonType(props)
|
|
120
128
|
const isDisabled = getIsDisabled(props)
|
|
121
129
|
const backgroundColor = isDisabled
|
|
122
130
|
? getBackgroundColorDisabledByType(buttonType)
|
|
@@ -125,14 +133,17 @@ function makeButtonConfig(props: ISecretInnerButtonProps & ButtonSizeProps) {
|
|
|
125
133
|
const buttonOverridePadding = getPaddingByType(buttonType)
|
|
126
134
|
const cursor = getCursor(props)
|
|
127
135
|
const backgroundHover = getBackgroundColorHoverByType(buttonType)
|
|
136
|
+
const textDecorationHover = getTextDecorationHoverByType(buttonType)
|
|
128
137
|
const backgroundPressed = getBackgroundColorPressedByType(buttonType)
|
|
129
138
|
const textColorHover = getTextColorOnHoverByType(buttonType)
|
|
139
|
+
const iconColorHover = getIconColorOnHoverByType(buttonType)
|
|
130
140
|
const buttonBorder = isDisabled
|
|
131
141
|
? getBorderDisabledByType(buttonType)
|
|
132
142
|
: getBorderByType(buttonType)
|
|
133
143
|
const buttonSize =
|
|
134
144
|
buttonOverridePadding !== '' ? buttonOverridePadding : buttonPadding
|
|
135
145
|
const textColor = getTextColorByType(buttonType)
|
|
146
|
+
const iconColor = getIconColorByType(buttonType)
|
|
136
147
|
const textColorDisabled = getTextColorIfDisabled(props)
|
|
137
148
|
|
|
138
149
|
return {
|
|
@@ -140,33 +151,39 @@ function makeButtonConfig(props: ISecretInnerButtonProps & ButtonSizeProps) {
|
|
|
140
151
|
buttonSize,
|
|
141
152
|
cursor,
|
|
142
153
|
backgroundHover,
|
|
154
|
+
textDecorationHover,
|
|
143
155
|
backgroundPressed,
|
|
144
156
|
textColorHover,
|
|
157
|
+
iconColorHover,
|
|
145
158
|
buttonBorder,
|
|
146
159
|
isDisabled,
|
|
147
160
|
textColor,
|
|
161
|
+
iconColor,
|
|
148
162
|
textColorDisabled,
|
|
163
|
+
buttonType,
|
|
149
164
|
}
|
|
150
165
|
}
|
|
151
166
|
|
|
152
|
-
const
|
|
167
|
+
export const Button: FC<IButtonProps & ButtonTypeProps & ButtonSizeProps> = (
|
|
153
168
|
props
|
|
154
169
|
) => {
|
|
155
170
|
const {
|
|
156
171
|
children,
|
|
157
|
-
buttonType,
|
|
158
172
|
loading,
|
|
159
173
|
IconPrefix,
|
|
160
174
|
IconSuffix,
|
|
175
|
+
type = 'button',
|
|
161
176
|
...htmlProps
|
|
162
177
|
} = props
|
|
163
|
-
const { textColor, textColorDisabled, ...buttonConfig } =
|
|
178
|
+
const { textColor, textColorDisabled, buttonType, ...buttonConfig } =
|
|
164
179
|
makeButtonConfig(props)
|
|
165
|
-
|
|
166
180
|
return (
|
|
167
|
-
<ButtonFrame {...htmlProps} {...buttonConfig} data-testid="button-test">
|
|
168
|
-
{isDefined(IconPrefix) ?
|
|
169
|
-
|
|
181
|
+
<ButtonFrame {...htmlProps} type={type} {...buttonConfig} data-testid="button-test">
|
|
182
|
+
{isDefined(IconPrefix) ? (
|
|
183
|
+
<IconContainer isLoading={is(loading)}>
|
|
184
|
+
<IconPrefix />
|
|
185
|
+
</IconContainer>
|
|
186
|
+
) : <Nothing />}
|
|
170
187
|
<ButtonText
|
|
171
188
|
textColor={textColor}
|
|
172
189
|
textColorDisabled={textColorDisabled}
|
|
@@ -179,53 +196,19 @@ const SecretInnerButton: FC<ISecretInnerButtonProps & ButtonSizeProps> = (
|
|
|
179
196
|
small
|
|
180
197
|
onPrimary={
|
|
181
198
|
buttonType === ButtonType.primary ||
|
|
182
|
-
buttonType === ButtonType.
|
|
199
|
+
buttonType === ButtonType.destructivePrimary
|
|
183
200
|
}
|
|
184
201
|
/>
|
|
185
202
|
) : (
|
|
186
203
|
''
|
|
187
204
|
)}
|
|
188
205
|
|
|
189
|
-
{isDefined(IconSuffix) ?
|
|
206
|
+
{isDefined(IconSuffix) ? (
|
|
207
|
+
<IconContainer isLoading={is(loading)}>
|
|
208
|
+
<IconSuffix />
|
|
209
|
+
</IconContainer>
|
|
210
|
+
) : <Nothing />}
|
|
190
211
|
</ButtonFrame>
|
|
191
212
|
)
|
|
192
213
|
}
|
|
193
214
|
|
|
194
|
-
export const ButtonBasic: FC<IButtonProps> = (props) => {
|
|
195
|
-
return <SecretInnerButton buttonType={ButtonType.basic} {...props} />
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export const ButtonPrimary: FC<IButtonProps> = (props) => {
|
|
199
|
-
return <SecretInnerButton buttonType={ButtonType.primary} {...props} />
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export const ButtonDestructive: FC<IButtonDestructiveProps> = (props) => {
|
|
203
|
-
const { primary } = props
|
|
204
|
-
return (
|
|
205
|
-
<SecretInnerButton
|
|
206
|
-
buttonType={
|
|
207
|
-
isDefined(primary) && primary
|
|
208
|
-
? ButtonType.primaryDestructive
|
|
209
|
-
: ButtonType.destructive
|
|
210
|
-
}
|
|
211
|
-
{...props}
|
|
212
|
-
/>
|
|
213
|
-
)
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export const ButtonOutline: FC<IButtonProps> = (props) => {
|
|
217
|
-
return <SecretInnerButton buttonType={ButtonType.outline} {...props} />
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export const ButtonPlain: FC<IButtonPlainProps> = (props) => {
|
|
221
|
-
const { subtle } = props
|
|
222
|
-
|
|
223
|
-
return (
|
|
224
|
-
<SecretInnerButton
|
|
225
|
-
buttonType={
|
|
226
|
-
isDefined(subtle) && subtle ? ButtonType.plainSubtle : ButtonType.plain
|
|
227
|
-
}
|
|
228
|
-
{...props}
|
|
229
|
-
/>
|
|
230
|
-
)
|
|
231
|
-
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Canvas, Meta, Story, ArgsTable } from '@storybook/addon-docs';
|
|
2
|
-
import {
|
|
2
|
+
import { Button } from '../index'
|
|
3
|
+
import { IconMinor } from 'components/icon'
|
|
3
4
|
import { PlainHTMLFormExample, DisabledLoadingExample } from './components'
|
|
4
5
|
|
|
5
6
|
<Meta
|
|
6
7
|
title="Components/Button"
|
|
7
|
-
component={
|
|
8
|
+
component={Button}
|
|
8
9
|
/>
|
|
9
10
|
|
|
10
11
|
# Button
|
|
@@ -15,11 +16,11 @@ For more details, check out the component page on [Figma](https://www.figma.com/
|
|
|
15
16
|
|
|
16
17
|
```javascript
|
|
17
18
|
// Import the component
|
|
18
|
-
import {
|
|
19
|
+
import { Button } from './index'
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
// Render the component sending the required parameters
|
|
22
|
-
<
|
|
23
|
+
<Button primary label="SOME-label-HERE" />
|
|
23
24
|
```
|
|
24
25
|
|
|
25
26
|
## Properties
|
|
@@ -44,61 +45,61 @@ The available optional properties are as follows, try them out in the editable c
|
|
|
44
45
|
## Examples
|
|
45
46
|
|
|
46
47
|
<Canvas>
|
|
47
|
-
<
|
|
48
|
-
<
|
|
49
|
-
<
|
|
50
|
-
<
|
|
51
|
-
<
|
|
52
|
-
<
|
|
53
|
-
<
|
|
48
|
+
<Button type="submit">Basic</Button>
|
|
49
|
+
<Button primary>Primary</Button>
|
|
50
|
+
<Button destructive>Destructive</Button>
|
|
51
|
+
<Button destructive primary>Destructive Primary</Button>
|
|
52
|
+
<Button outline>Outline</Button>
|
|
53
|
+
<Button plain>Plain</Button>
|
|
54
|
+
<Button plain subtle >Plain Subtle</Button>
|
|
54
55
|
</Canvas>
|
|
55
56
|
|
|
56
57
|
Disabled
|
|
57
58
|
<Canvas>
|
|
58
|
-
<
|
|
59
|
-
<
|
|
60
|
-
<
|
|
61
|
-
<
|
|
62
|
-
<
|
|
63
|
-
<
|
|
64
|
-
<
|
|
59
|
+
<Button disabled>Basic</Button>
|
|
60
|
+
<Button primary disabled>Primary</Button>
|
|
61
|
+
<Button destructive disabled>Destructive</Button>
|
|
62
|
+
<Button destructive primary disabled>Destructive Primary</Button>
|
|
63
|
+
<Button outline disabled>Outline</Button>
|
|
64
|
+
<Button plain disabled>Plain</Button>
|
|
65
|
+
<Button plain subtle disabled>Plain Subtle</Button>
|
|
65
66
|
</Canvas>
|
|
66
67
|
|
|
67
68
|
Loading
|
|
68
69
|
<Canvas>
|
|
69
|
-
<
|
|
70
|
-
<
|
|
71
|
-
<
|
|
72
|
-
<
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
<
|
|
70
|
+
<Button loading>Basic</Button>
|
|
71
|
+
<Button primary loading>Primary</Button>
|
|
72
|
+
<Button destructive loading>Destructive</Button>
|
|
73
|
+
<Button destructive primary loading>Destructive Primary</Button>
|
|
74
|
+
<Button outline loading>Outline</Button>
|
|
75
|
+
<Button plain loading>Plain</Button>
|
|
76
|
+
<Button plain subtle loading>Plain Subtle</Button>
|
|
76
77
|
</Canvas>
|
|
77
78
|
|
|
78
79
|
Icons
|
|
79
80
|
<Canvas>
|
|
80
|
-
<
|
|
81
|
-
<
|
|
82
|
-
<
|
|
83
|
-
<
|
|
84
|
-
<
|
|
85
|
-
<
|
|
86
|
-
<
|
|
81
|
+
<Button IconPrefix={IconMinor.Fire}>Basic</Button>
|
|
82
|
+
<Button primary IconPrefix={IconMinor.Fire}>Primary</Button>
|
|
83
|
+
<Button destructive IconPrefix={IconMinor.Fire}>Destructive</Button>
|
|
84
|
+
<Button destructive primary IconPrefix={IconMinor.Fire}>Destructive Primary</Button>
|
|
85
|
+
<Button outline IconPrefix={IconMinor.Fire}>Outline</Button>
|
|
86
|
+
<Button plain IconPrefix={IconMinor.Fire}>Plain</Button>
|
|
87
|
+
<Button plain subtle IconPrefix={IconMinor.Fire}>Plain Subtle</Button>
|
|
87
88
|
</Canvas>
|
|
88
89
|
|
|
89
90
|
<Canvas>
|
|
90
|
-
<
|
|
91
|
-
<
|
|
92
|
-
<
|
|
93
|
-
<
|
|
94
|
-
<
|
|
95
|
-
<
|
|
96
|
-
<
|
|
91
|
+
<Button IconSuffix={IconMinor.Fire}>Basic</Button>
|
|
92
|
+
<Button primary IconSuffix={IconMinor.Fire}>Primary</Button>
|
|
93
|
+
<Button destructive IconSuffix={IconMinor.Fire}>Destructive</Button>
|
|
94
|
+
<Button destructive primary IconSuffix={IconMinor.Fire}>Destructive Primary</Button>
|
|
95
|
+
<Button outline IconSuffix={IconMinor.Fire}>Outline</Button>
|
|
96
|
+
<Button plain IconSuffix={IconMinor.Fire}>Plain</Button>
|
|
97
|
+
<Button plain subtle IconSuffix={IconMinor.Fire}>Plain Subtle</Button>
|
|
97
98
|
</Canvas>
|
|
98
99
|
|
|
99
100
|
<Canvas>
|
|
100
|
-
<
|
|
101
|
-
<
|
|
102
|
-
<
|
|
101
|
+
<Button large>Large</Button>
|
|
102
|
+
<Button>Default</Button>
|
|
103
|
+
<Button small>Small</Button>
|
|
103
104
|
</Canvas>
|
|
104
105
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { Playground } from 'storybook-addon-jarle-monaco'
|
|
3
3
|
import { InputField } from '../../../input-field'
|
|
4
|
-
import { Button
|
|
4
|
+
import { Button } from '../button'
|
|
5
5
|
|
|
6
6
|
export const PlainHTMLFormExample = () => (
|
|
7
7
|
<Playground
|
|
@@ -24,8 +24,8 @@ const [invalid, setInvalid] = useState(false);
|
|
|
24
24
|
required
|
|
25
25
|
/>
|
|
26
26
|
<div style={{display:'flex', gap:'8px'}}>
|
|
27
|
-
<
|
|
28
|
-
<
|
|
27
|
+
<Button type="reset">Clear</Button>
|
|
28
|
+
<Button primary type="submit">Send</Button>
|
|
29
29
|
</div>
|
|
30
30
|
</form>
|
|
31
31
|
`}
|
|
@@ -33,8 +33,7 @@ const [invalid, setInvalid] = useState(false);
|
|
|
33
33
|
renderAsComponent: true,
|
|
34
34
|
scope: {
|
|
35
35
|
InputField,
|
|
36
|
-
|
|
37
|
-
ButtonPrimary
|
|
36
|
+
Button
|
|
38
37
|
},
|
|
39
38
|
}}
|
|
40
39
|
/>
|
|
@@ -70,7 +69,7 @@ const [loading, setLoading] = useState(false);
|
|
|
70
69
|
required
|
|
71
70
|
/>
|
|
72
71
|
<div style={{display:'flex', gap:'8px'}}>
|
|
73
|
-
<
|
|
72
|
+
<Button primary type="submit" disabled={disabled} loading={loading}>Send</Button>
|
|
74
73
|
</div>
|
|
75
74
|
</form>
|
|
76
75
|
`}
|
|
@@ -78,8 +77,7 @@ const [loading, setLoading] = useState(false);
|
|
|
78
77
|
renderAsComponent: true,
|
|
79
78
|
scope: {
|
|
80
79
|
InputField,
|
|
81
|
-
|
|
82
|
-
ButtonPrimary
|
|
80
|
+
Button
|
|
83
81
|
},
|
|
84
82
|
}}
|
|
85
83
|
/>
|
|
@@ -1,48 +1,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputHTMLAttributes } from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
import { FC, isDefined, isEmpty, Nothing } from '@helpers'
|
|
4
4
|
import { Margin } from '@foundations'
|
|
5
|
-
import { Checkbox
|
|
6
|
-
import {
|
|
7
|
-
import { Flex } from 'components/layout'
|
|
5
|
+
import { Checkbox } from '../../checkbox'
|
|
6
|
+
import { Label } from 'components/typography'
|
|
8
7
|
|
|
9
|
-
const Text = styled(
|
|
10
|
-
margin-left: ${Margin.
|
|
8
|
+
const Text = styled(Label)`
|
|
9
|
+
margin-left: ${Margin.xs};
|
|
11
10
|
user-select: none;
|
|
12
11
|
`
|
|
13
|
-
|
|
12
|
+
|
|
13
|
+
const Wrapper = styled.label`
|
|
14
|
+
display: flex;
|
|
14
15
|
width: 100%;
|
|
15
16
|
align-items: center;
|
|
16
17
|
`
|
|
17
|
-
|
|
18
|
+
|
|
19
|
+
export type IInputCheckboxProps = InputHTMLAttributes<HTMLInputElement> & {
|
|
18
20
|
label: string
|
|
21
|
+
error?: boolean
|
|
22
|
+
onChange?: (change: boolean) => void
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
export
|
|
25
|
+
export const InputCheckbox: FC<IInputCheckboxProps> = (props) => {
|
|
26
|
+
const {
|
|
27
|
+
onChange,
|
|
28
|
+
label = '',
|
|
29
|
+
} = props
|
|
22
30
|
|
|
23
|
-
export const InputCheckbox: FC<IInputCheckbox> = (props) => {
|
|
24
|
-
const { onChange, label = '', disabled = false, error = false, checked = false } = props
|
|
25
|
-
const [isChecked, setIsChecked] = useState(checked)
|
|
26
31
|
if (isEmpty(label)) {
|
|
27
32
|
return <Nothing />
|
|
28
33
|
}
|
|
29
34
|
|
|
30
|
-
const handleOnChange = () => {
|
|
31
|
-
setIsChecked(!isChecked)
|
|
32
|
-
if(isDefined(onChange)){
|
|
33
|
-
onChange(!isChecked)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
35
|
return (
|
|
38
36
|
<Wrapper>
|
|
39
37
|
<Checkbox
|
|
40
38
|
{...props}
|
|
41
|
-
onChange={
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
onChange={(e) => {
|
|
40
|
+
if (isDefined(onChange)) {
|
|
41
|
+
onChange(e.target.checked)
|
|
42
|
+
}
|
|
43
|
+
}}
|
|
44
|
+
name={isDefined(props.name) ? props.name : label}
|
|
46
45
|
/>
|
|
47
46
|
<Text>{label}</Text>
|
|
48
47
|
</Wrapper>
|
|
@@ -1,36 +1,53 @@
|
|
|
1
1
|
import { Playground } from 'storybook-addon-jarle-monaco'
|
|
2
|
-
import
|
|
2
|
+
import styled from 'styled-components'
|
|
3
|
+
import { Margin } from '@foundations'
|
|
4
|
+
import { If } from '@helpers'
|
|
5
|
+
import { Button } from 'components/molecules/button'
|
|
6
|
+
import { Caption } from 'components/typography'
|
|
7
|
+
import { InputCheckbox } from '../input-checkbox'
|
|
3
8
|
|
|
4
|
-
|
|
9
|
+
const Fields = styled.div`
|
|
10
|
+
margin-bottom: ${Margin.s};
|
|
11
|
+
`
|
|
12
|
+
|
|
13
|
+
export const InputCheckboxExample = () => (
|
|
5
14
|
<Playground
|
|
6
15
|
code={`
|
|
7
16
|
/* Edit this code sample! */
|
|
8
17
|
const [withError, setWithError] = useState(false);
|
|
18
|
+
const [accepted, setAccepted] = useState(false);
|
|
9
19
|
|
|
10
20
|
<form onSubmit={(e) => {
|
|
11
21
|
e.preventDefault()
|
|
12
|
-
console.log('form submitted')
|
|
13
22
|
}}
|
|
14
23
|
>
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
<Fields>
|
|
25
|
+
<InputCheckbox
|
|
26
|
+
onInvalid={(e) => {
|
|
27
|
+
setWithError(true)
|
|
28
|
+
}}
|
|
29
|
+
error={withError}
|
|
30
|
+
onChange={(e) => {
|
|
31
|
+
setAccepted(!accepted)
|
|
32
|
+
setWithError(false)
|
|
33
|
+
}}
|
|
34
|
+
label="I accept the terms."
|
|
35
|
+
required />
|
|
36
|
+
<If is={accepted}><Caption subdued>You have accepted the terms.</Caption></If>
|
|
37
|
+
</Fields>
|
|
38
|
+
<Button primary type="submit">Submit</Button>
|
|
27
39
|
</form>
|
|
28
40
|
`}
|
|
29
41
|
providerProps={{
|
|
30
42
|
renderAsComponent: true,
|
|
31
43
|
scope: {
|
|
32
44
|
InputCheckbox,
|
|
45
|
+
Caption,
|
|
46
|
+
Button,
|
|
47
|
+
If,
|
|
48
|
+
Fields,
|
|
33
49
|
},
|
|
34
50
|
}}
|
|
35
51
|
/>
|
|
36
52
|
)
|
|
53
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
|
-
import { InputCheckbox } from '../
|
|
3
|
-
import {
|
|
2
|
+
import { InputCheckbox } from '../input-checkbox'
|
|
3
|
+
import { InputCheckboxExample } from './components'
|
|
4
4
|
|
|
5
5
|
<Meta
|
|
6
6
|
title="Components/InputCheckbox"
|
|
@@ -27,11 +27,9 @@ import { InputCheckbox } from './index'
|
|
|
27
27
|
## Examples
|
|
28
28
|
|
|
29
29
|
<Canvas>
|
|
30
|
-
<InputCheckbox label="
|
|
31
|
-
<InputCheckbox label="
|
|
32
|
-
<InputCheckbox label="
|
|
33
|
-
<InputCheckbox label="My label" checked />
|
|
34
|
-
<InputCheckbox label="My label" error checked />
|
|
30
|
+
<InputCheckbox label="Burger" />
|
|
31
|
+
<InputCheckbox label="Fries" disabled />
|
|
32
|
+
<InputCheckbox label="Drink" error />
|
|
35
33
|
</Canvas>
|
|
36
34
|
|
|
37
35
|
|
|
@@ -48,4 +46,4 @@ Also, you can sen this parameters:
|
|
|
48
46
|
|
|
49
47
|
## Playground
|
|
50
48
|
|
|
51
|
-
<
|
|
49
|
+
<InputCheckboxExample />
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import styled from 'styled-components'
|
|
2
2
|
import { FC, isDefined, isEmpty, Nothing } from '@helpers'
|
|
3
|
-
import {
|
|
3
|
+
import { Margin } from '@foundations'
|
|
4
4
|
import { Flex } from 'components/layout'
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { Label } from 'components/typography'
|
|
6
|
+
import { IInputCheckboxProps, InputCheckbox } from 'components/molecules/input-checkbox'
|
|
7
7
|
|
|
8
|
-
const HelpfulMessage = styled(
|
|
8
|
+
const HelpfulMessage = styled(Label)`
|
|
9
9
|
margin-top: ${Margin.xxs};
|
|
10
10
|
margin-left: ${Margin.xl};
|
|
11
|
-
color: ${Text.Subdued};
|
|
12
11
|
user-select: none;
|
|
13
12
|
`
|
|
14
13
|
const Group = styled(Flex)`
|
|
@@ -16,8 +15,7 @@ const Group = styled(Flex)`
|
|
|
16
15
|
flex-direction: column;
|
|
17
16
|
gap: 18px;
|
|
18
17
|
`
|
|
19
|
-
interface IOption extends
|
|
20
|
-
id: string
|
|
18
|
+
interface IOption extends IInputCheckboxProps {
|
|
21
19
|
helpfulMessage?: string
|
|
22
20
|
}
|
|
23
21
|
interface IMultiChoiceList {
|
|
@@ -30,6 +28,7 @@ export const MultiChoiceList: FC<IMultiChoiceList> = (props: IMultiChoiceList) =
|
|
|
30
28
|
if (isEmpty(options)) {
|
|
31
29
|
return <Nothing />
|
|
32
30
|
}
|
|
31
|
+
|
|
33
32
|
return (
|
|
34
33
|
<Group role="group">
|
|
35
34
|
{options.map((option:IOption) => (
|
|
@@ -42,7 +41,7 @@ export const MultiChoiceList: FC<IMultiChoiceList> = (props: IMultiChoiceList) =
|
|
|
42
41
|
{...option}
|
|
43
42
|
/>
|
|
44
43
|
{isDefined(option.helpfulMessage) && (
|
|
45
|
-
<HelpfulMessage id={`${option.id}-id`}>
|
|
44
|
+
<HelpfulMessage subdued id={`${option.id}-id`}>
|
|
46
45
|
{option.helpfulMessage}
|
|
47
46
|
</HelpfulMessage>
|
|
48
47
|
)}
|