@faststore/core 0.3.6 → 0.3.8
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/.storybook/preview.js +0 -4
- package/CHANGELOG.md +9 -0
- package/README.md +13 -11
- package/cypress/integration/analytics.test.js +1 -1
- package/cypress/integration/search.test.js +1 -1
- package/package.json +17 -16
- package/src/components/cart/CartItem/CartItem.tsx +4 -4
- package/src/components/cart/CartSidebar/CartSidebar.stories.mdx +3 -3
- package/src/components/cart/CartSidebar/CartSidebar.tsx +14 -11
- package/src/components/cart/CartToggle/CartToggle.tsx +6 -4
- package/src/components/cart/EmptyCart/EmptyCart.tsx +4 -3
- package/src/components/common/Footer/Footer.tsx +9 -5
- package/src/components/common/Footer/FooterLinks.tsx +1 -1
- package/src/components/common/Navbar/Navbar.tsx +4 -6
- package/src/components/common/Navbar/NavbarSlider.tsx +3 -5
- package/src/components/common/Navbar/navbar.module.scss +1 -1
- package/src/components/product/OutOfStock/OutOfStock.tsx +5 -5
- package/src/components/product/ProductCard/ProductCard.stories.mdx +14 -14
- package/src/components/product/ProductCard/ProductCard.tsx +10 -9
- package/src/components/regionalization/Regionalization.stories.mdx +2 -6
- package/src/components/regionalization/RegionalizationBar/RegionalizationBar.tsx +3 -3
- package/src/components/regionalization/RegionalizationButton/RegionalizationButton.tsx +4 -3
- package/src/components/regionalization/RegionalizationInput/RegionalizationInput.tsx +2 -2
- package/src/components/regionalization/RegionalizationModal/RegionalizationModalContent.tsx +3 -2
- package/src/components/search/Filter/Facets.tsx +9 -6
- package/src/components/search/Filter/FilterSlider.tsx +6 -6
- package/src/components/search/SearchHistory/SearchHistory.tsx +4 -5
- package/src/components/search/SearchInput/search-input.module.scss +1 -14
- package/src/components/search/SearchTop/SearchTop.tsx +4 -5
- package/src/components/search/Sort/Sort.tsx +2 -3
- package/src/components/sections/BannerText/banner-text.module.scss +6 -6
- package/src/components/sections/Incentives/Incentives.tsx +1 -1
- package/src/components/sections/Newsletter/Newsletter.tsx +10 -8
- package/src/components/sections/Newsletter/newsletter.module.scss +1 -1
- package/src/components/sections/ProducDetailsContent/ProductDetailsContent.tsx +1 -1
- package/src/components/sections/ProducDetailsContent/product-details-content.module.scss +0 -9
- package/src/components/sections/ProductDetails/ProductDetails.tsx +11 -5
- package/src/components/sections/ProductDetails/product-details.module.scss +1 -1
- package/src/components/sections/ProductGallery/ProductGallery.tsx +4 -3
- package/src/components/sections/ScrollToTopButton/ScrollToTopButton.tsx +5 -4
- package/src/components/ui/Alert/Alert.tsx +7 -4
- package/src/components/ui/Button/Button.stories.mdx +3 -44
- package/src/components/ui/Button/ButtonLink/ButtonLink.tsx +2 -1
- package/src/components/ui/Button/button.module.scss +0 -381
- package/src/components/ui/Button/index.ts +0 -3
- package/src/components/ui/Gift/Gift.tsx +2 -2
- package/src/components/ui/ImageGallery/ImageGallerySelector.tsx +5 -5
- package/src/components/ui/ImageGallery/image-gallery-selector.module.scss +6 -0
- package/src/components/ui/Link/Link.tsx +19 -34
- package/src/components/ui/PriceRange/PriceRange.tsx +6 -4
- package/src/components/ui/PriceRange/price-range.module.scss +1 -1
- package/src/components/ui/ProductTitle/ProductTitle.stories.mdx +13 -15
- package/src/components/ui/QuantitySelector/quantity-selector.module.scss +21 -26
- package/src/components/ui/ShippingSimulation/ShippingSimulation.stories.mdx +1 -1
- package/src/components/ui/ShippingSimulation/ShippingSimulation.tsx +8 -3
- package/src/components/ui/SlideOver/SlideOver.stories.mdx +3 -3
- package/src/pages/_app.tsx +3 -4
- package/src/styles/global/components.scss +0 -3
- package/src/styles/global/storybook-components.scss +3 -3
- package/src/styles/global/utilities.scss +12 -5
- package/src/components/ui/Badge/Badge.stories.mdx +0 -465
- package/src/components/ui/Badge/Badge.tsx +0 -76
- package/src/components/ui/Badge/DiscountBadge.stories.mdx +0 -191
- package/src/components/ui/Badge/DiscountBadge.tsx +0 -57
- package/src/components/ui/Badge/badge.module.scss +0 -252
- package/src/components/ui/Badge/index.ts +0 -4
- package/src/components/ui/Button/Button.tsx +0 -85
- package/src/components/ui/Button/ButtonBuy/ButtonBuy.tsx +0 -24
- package/src/components/ui/Button/ButtonBuy/index.ts +0 -1
- package/src/components/ui/Checkbox/Checkbox.stories.mdx +0 -268
- package/src/components/ui/Checkbox/Checkbox.tsx +0 -20
- package/src/components/ui/Checkbox/checkbox.module.scss +0 -157
- package/src/components/ui/Checkbox/index.ts +0 -2
- package/src/components/ui/InputText/InputText.stories.mdx +0 -311
- package/src/components/ui/InputText/InputText.tsx +0 -128
- package/src/components/ui/InputText/index.ts +0 -2
- package/src/components/ui/InputText/input-text.module.scss +0 -168
- package/src/components/ui/Link/link.module.scss +0 -98
- package/src/components/ui/Radio/Radio.stories.mdx +0 -237
- package/src/components/ui/Radio/Radio.tsx +0 -36
- package/src/components/ui/Radio/index.ts +0 -2
- package/src/components/ui/Radio/radio.module.scss +0 -122
- package/src/components/ui/Select/Select.stories.mdx +0 -168
- package/src/components/ui/Select/Select.tsx +0 -70
- package/src/components/ui/Select/index.ts +0 -2
- package/src/components/ui/Select/select.module.scss +0 -85
- package/src/components/ui/SlideOver/overlay.scss +0 -14
- package/src/styles/global/resets.scss +0 -48
- package/src/styles/global/tokens.scss +0 -276
- package/src/styles/global/typography.scss +0 -66
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Checkbox as UICheckbox } from '@faststore/ui'
|
|
2
|
-
import type { CheckboxProps as UICheckboxProps } from '@faststore/ui'
|
|
3
|
-
|
|
4
|
-
import styles from './checkbox.module.scss'
|
|
5
|
-
|
|
6
|
-
export type CheckboxProps = {
|
|
7
|
-
partial?: boolean
|
|
8
|
-
} & UICheckboxProps
|
|
9
|
-
|
|
10
|
-
function Checkbox({ partial, ...otherProps }: CheckboxProps) {
|
|
11
|
-
return (
|
|
12
|
-
<UICheckbox
|
|
13
|
-
className={styles.fsCheckbox}
|
|
14
|
-
data-fs-checkbox-partial={partial}
|
|
15
|
-
{...otherProps}
|
|
16
|
-
/>
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default Checkbox
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
@import "src/styles/scaffold";
|
|
2
|
-
|
|
3
|
-
.fs-checkbox {
|
|
4
|
-
// --------------------------------------------------------
|
|
5
|
-
// Design Tokens for Checkbox
|
|
6
|
-
// --------------------------------------------------------
|
|
7
|
-
|
|
8
|
-
// Default properties
|
|
9
|
-
--fs-checkbox-width : 1.25rem;
|
|
10
|
-
--fs-checkbox-height : var(--fs-checkbox-width);
|
|
11
|
-
|
|
12
|
-
--fs-checkbox-border-width : var(--fs-border-width);
|
|
13
|
-
--fs-checkbox-border-radius : var(--fs-border-radius);
|
|
14
|
-
--fs-checkbox-border-color : var(--fs-border-color);
|
|
15
|
-
--fs-checkbox-border-color-hover : var(--fs-border-color-active);
|
|
16
|
-
|
|
17
|
-
--fs-checkbox-transition : border var(--fs-transition-timing) var(--fs-transition-function), background-color var(--fs-transition-timing) var(--fs-transition-function), box-shadow var(--fs-transition-timing) var(--fs-transition-function);
|
|
18
|
-
|
|
19
|
-
--fs-checkbox-bkg-color-hover : var(--fs-color-primary-bkg-light);
|
|
20
|
-
--fs-checkbox-shadow-hover : 0 0 0 var(--fs-checkbox-border-width) var(--fs-border-color-active);
|
|
21
|
-
|
|
22
|
-
// Checked
|
|
23
|
-
--fs-checkbox-checked-bkg-color : var(--fs-color-primary-bkg);
|
|
24
|
-
--fs-checkbox-checked-bkg-color-hover : var(--fs-color-primary-bkg-hover);
|
|
25
|
-
--fs-checkbox-checked-border-color-hover : var(--fs-border-color-hover);
|
|
26
|
-
--fs-checkbox-checked-shadow-hover : 0 0 0 var(--fs-checkbox-border-width) var(--fs-checkbox-checked-border-color-hover);
|
|
27
|
-
|
|
28
|
-
// Disabled
|
|
29
|
-
--fs-checkbox-disabled-bkg-color : var(--fs-color-disabled-bkg);
|
|
30
|
-
--fs-checkbox-disabled-border-width : var(--fs-checkbox-border-width);
|
|
31
|
-
--fs-checkbox-disabled-border-color : var(--fs-border-color-disabled);
|
|
32
|
-
--fs-checkbox-disabled-text-color : var(--fs-color-disabled-text);
|
|
33
|
-
|
|
34
|
-
// Partial
|
|
35
|
-
--fs-checkbox-partial-bkg-color : var(--fs-color-body-bkg);
|
|
36
|
-
--fs-checkbox-partial-bkg-color-hover : var(--fs-color-primary-bkg-light);
|
|
37
|
-
--fs-checkbox-partial-border-width : var(--fs-checkbox-border-width);
|
|
38
|
-
--fs-checkbox-partial-border-color : var(--fs-color-primary-bkg);
|
|
39
|
-
|
|
40
|
-
// --------------------------------------------------------
|
|
41
|
-
// Structural Styles
|
|
42
|
-
// --------------------------------------------------------
|
|
43
|
-
|
|
44
|
-
position: relative;
|
|
45
|
-
display: flex;
|
|
46
|
-
align-items: center;
|
|
47
|
-
justify-content: center;
|
|
48
|
-
width: var(--fs-checkbox-width);
|
|
49
|
-
height: var(--fs-checkbox-height);
|
|
50
|
-
cursor: pointer;
|
|
51
|
-
border: var(--fs-checkbox-border-width) solid var(--fs-checkbox-border-color);
|
|
52
|
-
border-radius: var(--fs-checkbox-border-radius);
|
|
53
|
-
outline: none;
|
|
54
|
-
transition: var(--fs-checkbox-transition);
|
|
55
|
-
appearance: none;
|
|
56
|
-
|
|
57
|
-
@include input-focus-ring;
|
|
58
|
-
|
|
59
|
-
&::before {
|
|
60
|
-
position: absolute;
|
|
61
|
-
top: 0.188rem;
|
|
62
|
-
width: 0.375rem;
|
|
63
|
-
height: 0.625rem;
|
|
64
|
-
content: "";
|
|
65
|
-
border: var(--fs-border-width-thick) solid var(--fs-color-text-inverse);
|
|
66
|
-
border-top: 0;
|
|
67
|
-
border-left: 0;
|
|
68
|
-
border-radius: var(--fs-border-width);
|
|
69
|
-
opacity: 0;
|
|
70
|
-
transform: rotate(45deg);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
&:hover:not(:disabled) {
|
|
74
|
-
background-color: var(--fs-checkbox-bkg-color-hover);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
&:hover:not(:disabled):not(:focus-visible):not(:focus) {
|
|
78
|
-
border-color: var(--fs-checkbox-border-color-hover);
|
|
79
|
-
box-shadow: var(--fs-checkbox-shadow-hover);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
&:checked {
|
|
83
|
-
background-color: var(--fs-checkbox-checked-bkg-color);
|
|
84
|
-
border: none;
|
|
85
|
-
|
|
86
|
-
&::before {
|
|
87
|
-
opacity: 1;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
&:hover:not(:disabled) {
|
|
91
|
-
background-color: var(--fs-checkbox-checked-bkg-color-hover);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
&:hover:not(:disabled):not(:focus-visible):not(:focus) {
|
|
95
|
-
border-color: var(--fs-checkbox-checked-border-color-hover);
|
|
96
|
-
box-shadow: var(--fs-checkbox-checked-shadow-hover);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
&:disabled {
|
|
101
|
-
cursor: not-allowed;
|
|
102
|
-
background-color: var(--fs-checkbox-disabled-bkg-color);
|
|
103
|
-
border: var(--fs-checkbox-disabled-border-width) solid var(--fs-checkbox-disabled-border-color);
|
|
104
|
-
|
|
105
|
-
&::before {
|
|
106
|
-
border-color: var(--fs-checkbox-disabled-border-color);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
&:hover {
|
|
110
|
-
background-color: var(--fs-checkbox-disabled-bkg-color);
|
|
111
|
-
border: var(--fs-checkbox-disabled-border-width) solid var(--fs-checkbox-disabled-border-color);
|
|
112
|
-
box-shadow: none;
|
|
113
|
-
|
|
114
|
-
&::before {
|
|
115
|
-
border-color: var(--fs-checkbox-disabled-border-color);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
+ label {
|
|
120
|
-
color: var(--fs-checkbox-disabled-text-color);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
&[data-fs-checkbox-partial="true"] {
|
|
125
|
-
background-color: var(--fs-checkbox-partial-bkg-color);
|
|
126
|
-
border: var(--fs-checkbox-partial-border-width) solid var(--fs-checkbox-partial-border-color);
|
|
127
|
-
|
|
128
|
-
&::before {
|
|
129
|
-
position: absolute;
|
|
130
|
-
top: auto;
|
|
131
|
-
width: 0.625rem;
|
|
132
|
-
height: 0;
|
|
133
|
-
content: "";
|
|
134
|
-
border-width: 0;
|
|
135
|
-
border-bottom: var(--fs-checkbox-border-width) solid var(--fs-color-primary-bkg);
|
|
136
|
-
border-radius: var(--fs-border-width);
|
|
137
|
-
opacity: 1;
|
|
138
|
-
transform: rotate(0deg);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
&:checked {
|
|
142
|
-
&:hover:not(:disabled) {
|
|
143
|
-
background-color: var(--fs-checkbox-partial-bkg-color-hover);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
&:hover {
|
|
148
|
-
background-color: var(--fs-checkbox-partial-bkg-color-hover);
|
|
149
|
-
box-shadow: var(--fs-checkbox-shadow-hover);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
&:disabled {
|
|
153
|
-
background-color: var(--fs-checkbox-disabled-bkg-color);
|
|
154
|
-
border: var(--fs-checkbox-disabled-border-width) solid var(--fs-checkbox-disabled-border-color);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs'
|
|
2
|
-
|
|
3
|
-
import InputText from '.'
|
|
4
|
-
import {
|
|
5
|
-
TokenTable,
|
|
6
|
-
TokenRow,
|
|
7
|
-
TokenDivider,
|
|
8
|
-
BestPractices,
|
|
9
|
-
BestPracticesRule,
|
|
10
|
-
} from 'src/../.storybook/components'
|
|
11
|
-
|
|
12
|
-
<Meta
|
|
13
|
-
title="Atoms/InputText"
|
|
14
|
-
component={InputText}
|
|
15
|
-
argTypes={{
|
|
16
|
-
actionable: {
|
|
17
|
-
type: { name: 'boolean' },
|
|
18
|
-
},
|
|
19
|
-
disabled: {
|
|
20
|
-
type: { name: 'boolean' },
|
|
21
|
-
},
|
|
22
|
-
id: {
|
|
23
|
-
type: { name: 'string', required: true },
|
|
24
|
-
},
|
|
25
|
-
inputRef: {
|
|
26
|
-
control: { disable: true },
|
|
27
|
-
},
|
|
28
|
-
}}
|
|
29
|
-
/>
|
|
30
|
-
|
|
31
|
-
export const Template = (args) => {
|
|
32
|
-
return <InputText {...args} />
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
<header>
|
|
36
|
-
|
|
37
|
-
# Input Text
|
|
38
|
-
|
|
39
|
-
Input Text are text fields used to get user inputs.
|
|
40
|
-
|
|
41
|
-
</header>
|
|
42
|
-
|
|
43
|
-
## Overview
|
|
44
|
-
|
|
45
|
-
The `InputText` component uses [FastStore UI Input Text](https://www.faststore.dev/reference/ui/atoms/Input) as base.
|
|
46
|
-
|
|
47
|
-
<Canvas isColumn>
|
|
48
|
-
<Story
|
|
49
|
-
name="overview-default"
|
|
50
|
-
args={{
|
|
51
|
-
id: 'overview-default',
|
|
52
|
-
label: 'Label',
|
|
53
|
-
}}
|
|
54
|
-
>
|
|
55
|
-
{Template.bind({})}
|
|
56
|
-
</Story>
|
|
57
|
-
<Story
|
|
58
|
-
name="overview-error"
|
|
59
|
-
args={{
|
|
60
|
-
id: 'overview-error',
|
|
61
|
-
label: 'Input w/ Error Message',
|
|
62
|
-
error: 'Error Message',
|
|
63
|
-
disabled: false,
|
|
64
|
-
}}
|
|
65
|
-
>
|
|
66
|
-
{Template.bind({})}
|
|
67
|
-
</Story>
|
|
68
|
-
<Story
|
|
69
|
-
name="overview-actionable"
|
|
70
|
-
args={{
|
|
71
|
-
id: 'overview-actionable',
|
|
72
|
-
label: 'Input w/ Action',
|
|
73
|
-
actionable: true,
|
|
74
|
-
disabled: false,
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
77
|
-
{Template.bind({})}
|
|
78
|
-
</Story>
|
|
79
|
-
<Story
|
|
80
|
-
name="overview-actionable-error"
|
|
81
|
-
args={{
|
|
82
|
-
id: 'overview-actionable-error',
|
|
83
|
-
label: 'Input w/ Action and Error',
|
|
84
|
-
actionable: true,
|
|
85
|
-
error: 'Error Message',
|
|
86
|
-
disabled: false,
|
|
87
|
-
}}
|
|
88
|
-
>
|
|
89
|
-
{Template.bind({})}
|
|
90
|
-
</Story>
|
|
91
|
-
<Story
|
|
92
|
-
name="overview-disabled"
|
|
93
|
-
args={{
|
|
94
|
-
id: 'overview-disabled',
|
|
95
|
-
label: 'Input Disabled',
|
|
96
|
-
actionable: false,
|
|
97
|
-
disabled: true,
|
|
98
|
-
value: 'Input Text',
|
|
99
|
-
}}
|
|
100
|
-
>
|
|
101
|
-
{Template.bind({})}
|
|
102
|
-
</Story>
|
|
103
|
-
</Canvas>
|
|
104
|
-
|
|
105
|
-
---
|
|
106
|
-
|
|
107
|
-
## Usage
|
|
108
|
-
|
|
109
|
-
`import InputText from '../components/ui/InputText'`
|
|
110
|
-
|
|
111
|
-
<Canvas>
|
|
112
|
-
<Story
|
|
113
|
-
name="input-default"
|
|
114
|
-
args={{
|
|
115
|
-
id: 'input-default',
|
|
116
|
-
label: 'Label',
|
|
117
|
-
}}
|
|
118
|
-
>
|
|
119
|
-
{Template.bind({})}
|
|
120
|
-
</Story>
|
|
121
|
-
</Canvas>
|
|
122
|
-
|
|
123
|
-
<ArgsTable story="input-default" />
|
|
124
|
-
|
|
125
|
-
<TokenTable>
|
|
126
|
-
<TokenRow
|
|
127
|
-
token="--fs-input-padding"
|
|
128
|
-
value="var(--fs-spacing-2) var(--fs-spacing-2) 0"
|
|
129
|
-
/>
|
|
130
|
-
<TokenRow token="--fs-input-height" value="var(--fs-control-tap-size)" />
|
|
131
|
-
<TokenDivider />
|
|
132
|
-
<TokenRow token="--fs-input-box-shadow" value="none" />
|
|
133
|
-
<TokenRow
|
|
134
|
-
token="--fs-input-box-shadow-hover"
|
|
135
|
-
value="0 0 0 var(--fs-border-width) var(--fs-border-color-active)"
|
|
136
|
-
/>
|
|
137
|
-
<TokenDivider />
|
|
138
|
-
<TokenRow token="--fs-input-border-radius" value="var(--fs-border-radius)" />
|
|
139
|
-
<TokenRow token="--fs-input-border-width" value="var(--fs-border-width)" />
|
|
140
|
-
<TokenRow
|
|
141
|
-
token="--fs-input-border-color"
|
|
142
|
-
value="var(--fs-border-color)"
|
|
143
|
-
isColor
|
|
144
|
-
/>
|
|
145
|
-
<TokenRow
|
|
146
|
-
token="--fs-input-border-color-hover"
|
|
147
|
-
value="var(--fs-border-color-active)"
|
|
148
|
-
isColor
|
|
149
|
-
/>
|
|
150
|
-
<TokenDivider />
|
|
151
|
-
<TokenRow
|
|
152
|
-
token="--fs-input-text-color"
|
|
153
|
-
value="var(--fs-color-text)"
|
|
154
|
-
isColor
|
|
155
|
-
/>
|
|
156
|
-
<TokenRow token="--fs-input-text-size" value="var(--fs-text-size-body)" />
|
|
157
|
-
<TokenDivider />
|
|
158
|
-
<TokenRow token="--fs-input-line-height" value="1.25" />
|
|
159
|
-
<TokenDivider />
|
|
160
|
-
<TokenRow
|
|
161
|
-
token="--fs-input-transition-function"
|
|
162
|
-
value="var(--fs-transition-function)"
|
|
163
|
-
/>
|
|
164
|
-
<TokenRow
|
|
165
|
-
token="--fs-input-transition-property"
|
|
166
|
-
value="var(--fs-transition-property)"
|
|
167
|
-
/>
|
|
168
|
-
<TokenRow
|
|
169
|
-
token="--fs-input-transition-timing"
|
|
170
|
-
value="var(--fs-transition-timing)"
|
|
171
|
-
/>
|
|
172
|
-
</TokenTable>
|
|
173
|
-
|
|
174
|
-
---
|
|
175
|
-
|
|
176
|
-
## Nested Elements
|
|
177
|
-
|
|
178
|
-
### Label
|
|
179
|
-
|
|
180
|
-
<TokenTable>
|
|
181
|
-
<TokenRow token="--fs-input-label-padding" value="0 var(--fs-spacing-2)" />
|
|
182
|
-
<TokenRow
|
|
183
|
-
token="--fs-input-label-color"
|
|
184
|
-
value="var(--fs-color-text-light)"
|
|
185
|
-
isColor
|
|
186
|
-
/>
|
|
187
|
-
<TokenRow token="--fs-input-label-size" value="var(--fs-text-size-tiny)" />
|
|
188
|
-
</TokenTable>
|
|
189
|
-
|
|
190
|
-
---
|
|
191
|
-
|
|
192
|
-
## Variants
|
|
193
|
-
|
|
194
|
-
### Actionable
|
|
195
|
-
|
|
196
|
-
<Canvas>
|
|
197
|
-
<Story
|
|
198
|
-
name="input-actionable"
|
|
199
|
-
args={{
|
|
200
|
-
id: 'input-actionable',
|
|
201
|
-
disabled: false,
|
|
202
|
-
label: 'Input w/ Action',
|
|
203
|
-
actionable: true,
|
|
204
|
-
}}
|
|
205
|
-
>
|
|
206
|
-
{Template.bind({})}
|
|
207
|
-
</Story>
|
|
208
|
-
</Canvas>
|
|
209
|
-
|
|
210
|
-
### Actionable w/ Error
|
|
211
|
-
|
|
212
|
-
<Canvas>
|
|
213
|
-
<Story
|
|
214
|
-
name="input-actionable-error"
|
|
215
|
-
args={{
|
|
216
|
-
id: 'input-actionable-error',
|
|
217
|
-
disabled: false,
|
|
218
|
-
label: 'Input w/ Action and Error',
|
|
219
|
-
error: 'Error Message',
|
|
220
|
-
actionable: true,
|
|
221
|
-
}}
|
|
222
|
-
>
|
|
223
|
-
{Template.bind({})}
|
|
224
|
-
</Story>
|
|
225
|
-
</Canvas>
|
|
226
|
-
|
|
227
|
-
### Error
|
|
228
|
-
|
|
229
|
-
<Canvas>
|
|
230
|
-
<Story
|
|
231
|
-
name="input-error"
|
|
232
|
-
args={{
|
|
233
|
-
id: 'input-error',
|
|
234
|
-
disabled: false,
|
|
235
|
-
label: 'Input w/ Error Message',
|
|
236
|
-
error: 'Error Message',
|
|
237
|
-
}}
|
|
238
|
-
>
|
|
239
|
-
{Template.bind({})}
|
|
240
|
-
</Story>
|
|
241
|
-
</Canvas>
|
|
242
|
-
|
|
243
|
-
<TokenTable>
|
|
244
|
-
<TokenRow
|
|
245
|
-
token="--fs-input-error-message-margin-top"
|
|
246
|
-
value="var(--fs-spacing-0)"
|
|
247
|
-
/>
|
|
248
|
-
<TokenRow
|
|
249
|
-
token="--fs-input-error-message-size"
|
|
250
|
-
value="var(--fs-text-size-legend)"
|
|
251
|
-
/>
|
|
252
|
-
<TokenRow token="--fs-input-error-message-line-height" value="1.1" />
|
|
253
|
-
<TokenRow
|
|
254
|
-
token="--fs-input-error-message-color"
|
|
255
|
-
value="var(--fs-color-danger-text)"
|
|
256
|
-
isColor
|
|
257
|
-
/>
|
|
258
|
-
|
|
259
|
-
<TokenDivider />
|
|
260
|
-
<TokenRow
|
|
261
|
-
token="--fs-input-error-border-color"
|
|
262
|
-
value="var(--fs-color-danger-border)"
|
|
263
|
-
isColor
|
|
264
|
-
/>
|
|
265
|
-
<TokenRow
|
|
266
|
-
token="--fs-input-error-box-shadow"
|
|
267
|
-
value="0 0 0 var(--fs-border-width) var(--fs-input-error-border-color)"
|
|
268
|
-
/>
|
|
269
|
-
<TokenRow
|
|
270
|
-
token="--fs-input-error-focus-ring"
|
|
271
|
-
value="var(--fs-color-focus-ring-danger)"
|
|
272
|
-
isColor
|
|
273
|
-
/>
|
|
274
|
-
</TokenTable>
|
|
275
|
-
|
|
276
|
-
### Disabled
|
|
277
|
-
|
|
278
|
-
<Canvas>
|
|
279
|
-
<Story
|
|
280
|
-
name="input-disabled"
|
|
281
|
-
args={{
|
|
282
|
-
id: 'input-disabled',
|
|
283
|
-
disabled: true,
|
|
284
|
-
label: 'Disabled Input',
|
|
285
|
-
}}
|
|
286
|
-
>
|
|
287
|
-
{Template.bind({})}
|
|
288
|
-
</Story>
|
|
289
|
-
</Canvas>
|
|
290
|
-
|
|
291
|
-
<TokenTable>
|
|
292
|
-
<TokenRow
|
|
293
|
-
token="--fs-input-disabled-bkg-color"
|
|
294
|
-
value="var(--fs-color-disabled-bkg)"
|
|
295
|
-
isColor
|
|
296
|
-
/>
|
|
297
|
-
<TokenRow
|
|
298
|
-
token="--fs-input-disabled-text-color"
|
|
299
|
-
value="var(--fs-color-disabled-text)"
|
|
300
|
-
isColor
|
|
301
|
-
/>
|
|
302
|
-
<TokenRow
|
|
303
|
-
token="--fs-input-disabled-border-width"
|
|
304
|
-
value="var(--fs-border-width)"
|
|
305
|
-
/>
|
|
306
|
-
<TokenRow
|
|
307
|
-
token="--fs-input-disabled-border-color"
|
|
308
|
-
value="var(--fs-border-color)"
|
|
309
|
-
isColor
|
|
310
|
-
/>
|
|
311
|
-
</TokenTable>
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { Input as UIInput, Label as UILabel } from '@faststore/ui'
|
|
2
|
-
import type { MutableRefObject } from 'react'
|
|
3
|
-
import type { InputProps } from '@faststore/ui'
|
|
4
|
-
|
|
5
|
-
import Button from 'src/components/ui/Button'
|
|
6
|
-
import Icon from 'src/components/ui/Icon'
|
|
7
|
-
|
|
8
|
-
import styles from './input-text.module.scss'
|
|
9
|
-
|
|
10
|
-
type DefaultProps = {
|
|
11
|
-
/**
|
|
12
|
-
* ID to identify input and corresponding label.
|
|
13
|
-
*/
|
|
14
|
-
id: string
|
|
15
|
-
/**
|
|
16
|
-
* The text displayed to identify input text.
|
|
17
|
-
*/
|
|
18
|
-
label: string
|
|
19
|
-
/**
|
|
20
|
-
* The error message is displayed when an error occurs.
|
|
21
|
-
*/
|
|
22
|
-
error?: string
|
|
23
|
-
/**
|
|
24
|
-
* Component's ref.
|
|
25
|
-
*/
|
|
26
|
-
inputRef?: MutableRefObject<HTMLInputElement | null>
|
|
27
|
-
/**
|
|
28
|
-
* Specifies that the whole input component should be disabled.
|
|
29
|
-
*/
|
|
30
|
-
disabled?: boolean
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type ActionableInputText =
|
|
34
|
-
| {
|
|
35
|
-
actionable?: never
|
|
36
|
-
onSubmit?: never
|
|
37
|
-
onClear?: never
|
|
38
|
-
buttonActionText?: string
|
|
39
|
-
displayClearButton?: never
|
|
40
|
-
}
|
|
41
|
-
| {
|
|
42
|
-
/**
|
|
43
|
-
* Adds a Button to the component.
|
|
44
|
-
*/
|
|
45
|
-
actionable: true
|
|
46
|
-
/**
|
|
47
|
-
* Callback function when button is clicked. Required for actionable input.
|
|
48
|
-
*/
|
|
49
|
-
onSubmit: () => void
|
|
50
|
-
/**
|
|
51
|
-
* Callback function when clear button is clicked. Required for actionable input.
|
|
52
|
-
*/
|
|
53
|
-
onClear: () => void
|
|
54
|
-
/**
|
|
55
|
-
* The text displayed on the Button. Suggestion: maximum 9 characters.
|
|
56
|
-
*/
|
|
57
|
-
buttonActionText?: string
|
|
58
|
-
/**
|
|
59
|
-
* Boolean that controls the clear button.
|
|
60
|
-
*/
|
|
61
|
-
displayClearButton?: boolean
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export type InputTextProps = DefaultProps &
|
|
65
|
-
Omit<InputProps, 'disabled' | 'onSubmit'> &
|
|
66
|
-
ActionableInputText
|
|
67
|
-
|
|
68
|
-
const InputText = ({
|
|
69
|
-
id,
|
|
70
|
-
label,
|
|
71
|
-
type = 'text',
|
|
72
|
-
error,
|
|
73
|
-
displayClearButton,
|
|
74
|
-
actionable,
|
|
75
|
-
buttonActionText = 'Apply',
|
|
76
|
-
onSubmit,
|
|
77
|
-
onClear,
|
|
78
|
-
placeholder = ' ', // initializes with an empty space to style float label using `placeholder-shown`
|
|
79
|
-
inputRef,
|
|
80
|
-
disabled,
|
|
81
|
-
value,
|
|
82
|
-
...otherProps
|
|
83
|
-
}: InputTextProps) => {
|
|
84
|
-
const shouldDisplayError = !disabled && error && error !== ''
|
|
85
|
-
const shouldDisplayButton = actionable && !disabled && value !== ''
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<div
|
|
89
|
-
className={styles.fsInputText}
|
|
90
|
-
data-fs-input-text
|
|
91
|
-
data-fs-input-text-actionable={actionable}
|
|
92
|
-
data-fs-input-text-error={error && error !== ''}
|
|
93
|
-
>
|
|
94
|
-
<UIInput
|
|
95
|
-
id={id}
|
|
96
|
-
type={type}
|
|
97
|
-
value={value}
|
|
98
|
-
ref={inputRef}
|
|
99
|
-
disabled={disabled}
|
|
100
|
-
placeholder={placeholder}
|
|
101
|
-
{...otherProps}
|
|
102
|
-
/>
|
|
103
|
-
<UILabel htmlFor={id}>{label}</UILabel>
|
|
104
|
-
|
|
105
|
-
{shouldDisplayButton &&
|
|
106
|
-
(displayClearButton || error ? (
|
|
107
|
-
<Button
|
|
108
|
-
data-fs-button-size="small"
|
|
109
|
-
aria-label="Clear Field"
|
|
110
|
-
icon={<Icon name="XCircle" width={20} height={20} />}
|
|
111
|
-
onClick={() => {
|
|
112
|
-
onClear?.()
|
|
113
|
-
inputRef?.current?.focus()
|
|
114
|
-
}}
|
|
115
|
-
/>
|
|
116
|
-
) : (
|
|
117
|
-
<Button variant="tertiary" size="small" onClick={onSubmit}>
|
|
118
|
-
{buttonActionText}
|
|
119
|
-
</Button>
|
|
120
|
-
))}
|
|
121
|
-
{shouldDisplayError && (
|
|
122
|
-
<span data-fs-input-text-error-message>{error}</span>
|
|
123
|
-
)}
|
|
124
|
-
</div>
|
|
125
|
-
)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export default InputText
|