@faststore/core 0.3.5 → 0.3.7
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/.github/workflows/release.yml +1 -1
- 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,57 +0,0 @@
|
|
|
1
|
-
import { memo } from 'react'
|
|
2
|
-
|
|
3
|
-
import { useDiscountPercent } from 'src/sdk/product/useDiscountPercent'
|
|
4
|
-
|
|
5
|
-
import Badge from './Badge'
|
|
6
|
-
|
|
7
|
-
export type DiscountBadgeProps = {
|
|
8
|
-
/**
|
|
9
|
-
* Specifies price without discount applied.
|
|
10
|
-
*/
|
|
11
|
-
listPrice: number
|
|
12
|
-
/**
|
|
13
|
-
* Specifies current price with discount applied.
|
|
14
|
-
*/
|
|
15
|
-
spotPrice: number
|
|
16
|
-
/**
|
|
17
|
-
* Sets the component size as big.
|
|
18
|
-
*/
|
|
19
|
-
big?: boolean
|
|
20
|
-
/**
|
|
21
|
-
* Sets the limit percentage value to consider a low discount.
|
|
22
|
-
*/
|
|
23
|
-
thresholdLow?: number
|
|
24
|
-
/**
|
|
25
|
-
* Sets the limit percentage value to consider a high discount.
|
|
26
|
-
*/
|
|
27
|
-
thresholdHigh?: number
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const DiscountBadge = ({
|
|
31
|
-
listPrice,
|
|
32
|
-
spotPrice,
|
|
33
|
-
big = false,
|
|
34
|
-
thresholdLow = 15,
|
|
35
|
-
thresholdHigh = 40,
|
|
36
|
-
}: DiscountBadgeProps) => {
|
|
37
|
-
const discountPercent = useDiscountPercent(listPrice, spotPrice)
|
|
38
|
-
|
|
39
|
-
if (discountPercent === 0) {
|
|
40
|
-
return <></>
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const discountVariant =
|
|
44
|
-
discountPercent <= thresholdLow
|
|
45
|
-
? 'low'
|
|
46
|
-
: discountPercent <= thresholdHigh
|
|
47
|
-
? 'medium'
|
|
48
|
-
: 'high'
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<Badge big={big} data-fs-discount-badge-variant={discountVariant}>
|
|
52
|
-
{discountPercent}% off
|
|
53
|
-
</Badge>
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export default memo(DiscountBadge)
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
.fs-badge {
|
|
2
|
-
// --------------------------------------------------------
|
|
3
|
-
// Design Tokens for Badges
|
|
4
|
-
// --------------------------------------------------------
|
|
5
|
-
|
|
6
|
-
// Default properties
|
|
7
|
-
--fs-badge-padding : var(--fs-spacing-0) var(--fs-spacing-2);
|
|
8
|
-
|
|
9
|
-
--fs-badge-border-radius : var(--fs-border-radius-pill);
|
|
10
|
-
--fs-badge-border-width : var(--fs-border-width);
|
|
11
|
-
--fs-badge-border-color : transparent;
|
|
12
|
-
|
|
13
|
-
--fs-badge-bkg-color : var(--fs-color-neutral-bkg);
|
|
14
|
-
|
|
15
|
-
--fs-badge-text-color : var(--fs-color-text);
|
|
16
|
-
--fs-badge-text-size : var(--fs-text-size-tiny);
|
|
17
|
-
--fs-badge-text-weight : var(--fs-text-weight-bold);
|
|
18
|
-
|
|
19
|
-
--fs-badge-transition-function : var(--fs-transition-function);
|
|
20
|
-
--fs-badge-transition-property : var(--fs-transition-property);
|
|
21
|
-
--fs-badge-transition-timing : var(--fs-transition-timing);
|
|
22
|
-
|
|
23
|
-
// Neutral
|
|
24
|
-
--fs-badge-neutral-bkg-color : var(--fs-color-neutral-bkg);
|
|
25
|
-
--fs-badge-neutral-text-color : var(--fs-badge-text-color);
|
|
26
|
-
--fs-badge-neutral-border-color : var(--fs-color-neutral-bkg);
|
|
27
|
-
|
|
28
|
-
// Success
|
|
29
|
-
--fs-badge-success-bkg-color : var(--fs-color-success-bkg);
|
|
30
|
-
--fs-badge-success-text-color : var(--fs-badge-text-color);
|
|
31
|
-
--fs-badge-success-border-color : var(--fs-color-success-bkg);
|
|
32
|
-
|
|
33
|
-
// Highlighted
|
|
34
|
-
--fs-badge-highlighted-bkg-color : var(--fs-color-highlighted-bkg);
|
|
35
|
-
--fs-badge-highlighted-text-color : var(--fs-color-highlighted-text);
|
|
36
|
-
--fs-badge-highlighted-border-color : var(--fs-color-highlighted-bkg);
|
|
37
|
-
|
|
38
|
-
// Info
|
|
39
|
-
--fs-badge-info-bkg-color : var(--fs-color-info-bkg);
|
|
40
|
-
--fs-badge-info-text-color : var(--fs-color-info-text);
|
|
41
|
-
--fs-badge-info-border-color : var(--fs-color-info-bkg);
|
|
42
|
-
|
|
43
|
-
// Warning
|
|
44
|
-
--fs-badge-warning-bkg-color : var(--fs-color-warning-bkg);
|
|
45
|
-
--fs-badge-warning-text-color : var(--fs-color-warning-text);
|
|
46
|
-
--fs-badge-warning-border-color : var(--fs-color-warning-bkg);
|
|
47
|
-
|
|
48
|
-
// Danger
|
|
49
|
-
--fs-badge-danger-bkg-color : var(--fs-color-danger-bkg);
|
|
50
|
-
--fs-badge-danger-text-color : var(--fs-badge-text-color);
|
|
51
|
-
--fs-badge-danger-border-color : var(--fs-color-danger-bkg);
|
|
52
|
-
|
|
53
|
-
// Discount
|
|
54
|
-
--fs-badge-discount-low-bkg-color : var(--fs-badge-success-bkg-color);
|
|
55
|
-
--fs-badge-discount-low-text-color : var(--fs-badge-success-text-color);
|
|
56
|
-
--fs-badge-discount-low-border-color : var(--fs-badge-success-border-color);
|
|
57
|
-
|
|
58
|
-
--fs-badge-discount-medium-bkg-color : var(--fs-badge-warning-bkg-color);
|
|
59
|
-
--fs-badge-discount-medium-text-color : var(--fs-badge-warning-text-color);
|
|
60
|
-
--fs-badge-discount-medium-border-color : var(--fs-badge-warning-border-color);
|
|
61
|
-
|
|
62
|
-
--fs-badge-discount-high-bkg-color : var(--fs-badge-danger-bkg-color);
|
|
63
|
-
--fs-badge-discount-high-text-color : var(--fs-badge-danger-text-color);
|
|
64
|
-
--fs-badge-discount-high-border-color : var(--fs-badge-danger-border-color);
|
|
65
|
-
|
|
66
|
-
// Big
|
|
67
|
-
--fs-badge-big-text-size : var(--fs-text-size-legend);
|
|
68
|
-
--fs-badge-big-padding : var(--fs-spacing-1) var(--fs-spacing-2);
|
|
69
|
-
|
|
70
|
-
// --------------------------------------------------------
|
|
71
|
-
// Structural Styles
|
|
72
|
-
// --------------------------------------------------------
|
|
73
|
-
|
|
74
|
-
width: fit-content;
|
|
75
|
-
height: fit-content;
|
|
76
|
-
font-size: var(--fs-badge-text-size);
|
|
77
|
-
font-weight: var(--fs-badge-text-weight);
|
|
78
|
-
line-height: 1;
|
|
79
|
-
color: var(--fs-badge-text-color);
|
|
80
|
-
text-transform: uppercase;
|
|
81
|
-
white-space: nowrap;
|
|
82
|
-
border-radius: var(--fs-badge-border-radius);
|
|
83
|
-
|
|
84
|
-
[data-fs-badge-wrapper] {
|
|
85
|
-
padding: var(--fs-badge-padding);
|
|
86
|
-
overflow: hidden;
|
|
87
|
-
border-radius: var(--fs-badge-border-radius);
|
|
88
|
-
|
|
89
|
-
span {
|
|
90
|
-
display: block;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
[data-fs-badge-button] {
|
|
95
|
-
position: absolute;
|
|
96
|
-
right: 0;
|
|
97
|
-
z-index: 1;
|
|
98
|
-
background-color: transparent;
|
|
99
|
-
&:hover + [data-fs-badge-wrapper]::after { filter: brightness(0.95); }
|
|
100
|
-
> span { display: flex; }
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// --------------------------------------------------------
|
|
104
|
-
// Variants Styles
|
|
105
|
-
// --------------------------------------------------------
|
|
106
|
-
|
|
107
|
-
&[data-fs-badge="big"] {
|
|
108
|
-
font-size: var(--fs-badge-big-text-size);
|
|
109
|
-
|
|
110
|
-
[data-fs-badge-wrapper] {
|
|
111
|
-
padding: var(--fs-badge-big-padding);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
&[data-fs-badge-actionable="true"] {
|
|
116
|
-
position: relative;
|
|
117
|
-
display: flex;
|
|
118
|
-
align-items: center;
|
|
119
|
-
height: var(--fs-control-tap-size);
|
|
120
|
-
padding-right: var(--fs-spacing-1);
|
|
121
|
-
|
|
122
|
-
[data-fs-badge-wrapper] {
|
|
123
|
-
position: relative;
|
|
124
|
-
padding-right: var(--fs-spacing-6);
|
|
125
|
-
|
|
126
|
-
&::after {
|
|
127
|
-
--button-hover-size: var(--fs-spacing-5);
|
|
128
|
-
|
|
129
|
-
position: absolute;
|
|
130
|
-
top: 50%;
|
|
131
|
-
right: 0;
|
|
132
|
-
width: var(--button-hover-size);
|
|
133
|
-
height: 100%;
|
|
134
|
-
content: "";
|
|
135
|
-
border-radius: 0 var(--fs-badge-border-radius) var(--fs-badge-border-radius) 0;
|
|
136
|
-
transition: var(--fs-badge-transition-property) var(--fs-badge-transition-timing) var(--fs-badge-transition-function);
|
|
137
|
-
transform: translateY(-50%);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
&[data-fs-badge-variant="neutral"] {
|
|
143
|
-
color: var(--fs-badge-neutral-text-color);
|
|
144
|
-
|
|
145
|
-
[data-fs-badge-wrapper] {
|
|
146
|
-
background-color: var(--fs-badge-neutral-bkg-color);
|
|
147
|
-
border-color: var(--fs-badge-neutral-border-color);
|
|
148
|
-
|
|
149
|
-
&::after {
|
|
150
|
-
background-color: var(--fs-badge-neutral-bkg-color);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
&[data-fs-badge-variant="success"] {
|
|
156
|
-
color: var(--fs-badge-success-text-color);
|
|
157
|
-
|
|
158
|
-
[data-fs-badge-wrapper] {
|
|
159
|
-
background-color: var(--fs-badge-success-bkg-color);
|
|
160
|
-
border-color: var(--fs-badge-success-border-color);
|
|
161
|
-
|
|
162
|
-
&::after {
|
|
163
|
-
background-color: var(--fs-badge-success-bkg-color);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
&[data-fs-badge-variant="highlighted"] {
|
|
169
|
-
color: var(--fs-badge-highlighted-text-color);
|
|
170
|
-
|
|
171
|
-
[data-fs-badge-wrapper] {
|
|
172
|
-
background-color: var(--fs-badge-highlighted-bkg-color);
|
|
173
|
-
border-color: var(--fs-badge-highlighted-border-color);
|
|
174
|
-
|
|
175
|
-
&::after {
|
|
176
|
-
background-color: var(--fs-badge-highlighted-bkg-color);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
&[data-fs-badge-variant="info"] {
|
|
182
|
-
color: var(--fs-badge-info-text-color);
|
|
183
|
-
|
|
184
|
-
[data-fs-badge-wrapper] {
|
|
185
|
-
background-color: var(--fs-badge-info-bkg-color);
|
|
186
|
-
border-color: var(--fs-badge-info-border-color);
|
|
187
|
-
|
|
188
|
-
&::after {
|
|
189
|
-
background-color: var(--fs-badge-info-bkg-color);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
&[data-fs-badge-variant="warning"] {
|
|
195
|
-
color: var(--fs-badge-warning-text-color);
|
|
196
|
-
|
|
197
|
-
[data-fs-badge-wrapper] {
|
|
198
|
-
background-color: var(--fs-badge-warning-bkg-color);
|
|
199
|
-
border-color: var(--fs-badge-warning-border-color);
|
|
200
|
-
|
|
201
|
-
&::after {
|
|
202
|
-
background-color: var(--fs-badge-warning-bkg-color);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
&[data-fs-badge-variant="danger"] {
|
|
208
|
-
color: var(--fs-badge-danger-text-color);
|
|
209
|
-
|
|
210
|
-
[data-fs-badge-wrapper] {
|
|
211
|
-
background-color: var(--fs-badge-danger-bkg-color);
|
|
212
|
-
border-color: var(--fs-badge-danger-border-color);
|
|
213
|
-
|
|
214
|
-
&::after {
|
|
215
|
-
background-color: var(--fs-badge-danger-bkg-color);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
&[data-fs-discount-badge-variant="low"] {
|
|
221
|
-
color: var(--fs-badge-discount-low-text-color);
|
|
222
|
-
|
|
223
|
-
[data-fs-badge-wrapper] {
|
|
224
|
-
background-color: var(--fs-badge-discount-low-bkg-color);
|
|
225
|
-
border-color: var(--fs-badge-discount-low-border-color);
|
|
226
|
-
|
|
227
|
-
&::after {
|
|
228
|
-
background-color: var(--fs-badge-discount-low-bkg-color);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
&[data-fs-discount-badge-variant="medium"] {
|
|
234
|
-
color: var(--fs-badge-discount-medium-text-color);
|
|
235
|
-
|
|
236
|
-
[data-fs-badge-wrapper] {
|
|
237
|
-
background-color: var(--fs-badge-discount-medium-bkg-color);
|
|
238
|
-
border-color: var(--fs-badge-discount-medium-border-color);
|
|
239
|
-
&::after { background-color: var(--fs-badge-discount-medium-bkg-color); }
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
&[data-fs-discount-badge-variant="high"] {
|
|
244
|
-
color: var(--fs-badge-discount-high-text-color);
|
|
245
|
-
|
|
246
|
-
[data-fs-badge-wrapper] {
|
|
247
|
-
background-color: var(--fs-badge-discount-high-bkg-color);
|
|
248
|
-
border-color: var(--fs-badge-discount-high-border-color);
|
|
249
|
-
&::after { background-color: var(--fs-badge-discount-high-bkg-color); }
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { Button as UIButton, Icon as UIIcon } from '@faststore/ui'
|
|
2
|
-
import type { ReactNode, AriaAttributes } from 'react'
|
|
3
|
-
import type { ButtonProps as UIButtonProps } from '@faststore/ui'
|
|
4
|
-
|
|
5
|
-
import styles from './button.module.scss'
|
|
6
|
-
|
|
7
|
-
export type Variant = 'primary' | 'secondary' | 'tertiary'
|
|
8
|
-
export type Size = 'small' | 'regular'
|
|
9
|
-
export type IconPosition = 'left' | 'right'
|
|
10
|
-
|
|
11
|
-
export interface ButtonProps
|
|
12
|
-
extends Omit<UIButtonProps, 'aria-label' | 'disabled'> {
|
|
13
|
-
/**
|
|
14
|
-
* Specifies the component variant
|
|
15
|
-
*/
|
|
16
|
-
variant?: Variant
|
|
17
|
-
/**
|
|
18
|
-
* Specifies the size variant
|
|
19
|
-
*/
|
|
20
|
-
size?: Size
|
|
21
|
-
/**
|
|
22
|
-
* Defines use of inverted colors
|
|
23
|
-
*/
|
|
24
|
-
inverse?: boolean
|
|
25
|
-
/**
|
|
26
|
-
* Icon component
|
|
27
|
-
*/
|
|
28
|
-
icon?: ReactNode
|
|
29
|
-
/**
|
|
30
|
-
* Specifies where the icon should be positioned
|
|
31
|
-
*/
|
|
32
|
-
iconPosition?: IconPosition
|
|
33
|
-
/**
|
|
34
|
-
* Specifies counter badge. Only for button icons
|
|
35
|
-
*/
|
|
36
|
-
counter?: number
|
|
37
|
-
/**
|
|
38
|
-
* For accessibility purposes, defines an ARIA label to the element when no label is provided
|
|
39
|
-
*/
|
|
40
|
-
'aria-label'?: AriaAttributes['aria-label']
|
|
41
|
-
/**
|
|
42
|
-
* Specifies that this button should be disabled
|
|
43
|
-
*/
|
|
44
|
-
disabled?: boolean
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function Button({
|
|
48
|
-
variant,
|
|
49
|
-
size = 'regular',
|
|
50
|
-
inverse,
|
|
51
|
-
icon,
|
|
52
|
-
iconPosition,
|
|
53
|
-
children,
|
|
54
|
-
counter = 0,
|
|
55
|
-
'aria-label': ariaLabel,
|
|
56
|
-
disabled,
|
|
57
|
-
...props
|
|
58
|
-
}: ButtonProps) {
|
|
59
|
-
const isButtonIcon = icon && !iconPosition && !children
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<UIButton
|
|
63
|
-
aria-label={ariaLabel}
|
|
64
|
-
className={styles.fsButton}
|
|
65
|
-
data-fs-button
|
|
66
|
-
data-fs-button-inverse={inverse}
|
|
67
|
-
data-fs-button-size={size}
|
|
68
|
-
data-fs-button-icon={isButtonIcon}
|
|
69
|
-
data-fs-button-variant={isButtonIcon ? 'tertiary' : variant}
|
|
70
|
-
disabled={disabled}
|
|
71
|
-
{...props}
|
|
72
|
-
>
|
|
73
|
-
{(isButtonIcon || iconPosition === 'left') && (
|
|
74
|
-
<>
|
|
75
|
-
{counter > 0 && <span data-fs-button-counter>{counter}</span>}
|
|
76
|
-
<UIIcon component={icon} />
|
|
77
|
-
</>
|
|
78
|
-
)}
|
|
79
|
-
{children}
|
|
80
|
-
{iconPosition === 'right' && <UIIcon component={icon} />}
|
|
81
|
-
</UIButton>
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export default Button
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import Icon from 'src/components/ui/Icon'
|
|
2
|
-
|
|
3
|
-
import Button from '../Button'
|
|
4
|
-
import type { ButtonProps } from '../Button'
|
|
5
|
-
import styles from '../button.module.scss'
|
|
6
|
-
|
|
7
|
-
type Props = ButtonProps
|
|
8
|
-
|
|
9
|
-
function ButtonBuy({ children, ...otherProps }: Props) {
|
|
10
|
-
return (
|
|
11
|
-
<Button
|
|
12
|
-
className={styles.fsButton}
|
|
13
|
-
data-fs-button
|
|
14
|
-
data-fs-button-buy
|
|
15
|
-
data-fs-button-variant="buy"
|
|
16
|
-
{...otherProps}
|
|
17
|
-
>
|
|
18
|
-
<Icon name="ShoppingCart" width={18} height={18} weight="bold" />
|
|
19
|
-
{children}
|
|
20
|
-
</Button>
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default ButtonBuy
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './ButtonBuy'
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs'
|
|
2
|
-
|
|
3
|
-
import Checkbox from '.'
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
TokenTable,
|
|
7
|
-
TokenRow,
|
|
8
|
-
TokenDivider,
|
|
9
|
-
} from 'src/../.storybook/components'
|
|
10
|
-
|
|
11
|
-
<Meta
|
|
12
|
-
title="Atoms/Checkbox"
|
|
13
|
-
component={Checkbox}
|
|
14
|
-
argTypes={{
|
|
15
|
-
disabled: {
|
|
16
|
-
type: {
|
|
17
|
-
name: 'boolean',
|
|
18
|
-
},
|
|
19
|
-
description: '`boolean`',
|
|
20
|
-
defaultValue: false,
|
|
21
|
-
},
|
|
22
|
-
partial: {
|
|
23
|
-
type: {
|
|
24
|
-
name: 'boolean',
|
|
25
|
-
},
|
|
26
|
-
defaultValue: false,
|
|
27
|
-
},
|
|
28
|
-
}}
|
|
29
|
-
/>
|
|
30
|
-
|
|
31
|
-
export const Template = ({ id, ...args }) => (
|
|
32
|
-
<div style={{ display: 'flex' }}>
|
|
33
|
-
<Checkbox id={id} {...args} onChange={() => {}} />
|
|
34
|
-
<label htmlFor={id} style={{ paddingLeft: '1rem' }}>
|
|
35
|
-
label
|
|
36
|
-
</label>
|
|
37
|
-
</div>
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
<header>
|
|
41
|
-
|
|
42
|
-
# Checkbox
|
|
43
|
-
|
|
44
|
-
An input Checkbox that is commonly used on Filter component.
|
|
45
|
-
|
|
46
|
-
</header>
|
|
47
|
-
|
|
48
|
-
## Overview
|
|
49
|
-
|
|
50
|
-
The `Checkbox` component uses [FastStore UI Checkbox](https://www.faststore.dev/reference/ui/atoms/Checkbox) as base.
|
|
51
|
-
|
|
52
|
-
<Canvas>
|
|
53
|
-
<Story
|
|
54
|
-
name="overview-default"
|
|
55
|
-
args={{
|
|
56
|
-
id: 'overview-checkbox-default',
|
|
57
|
-
}}
|
|
58
|
-
>
|
|
59
|
-
{Template.bind({})}
|
|
60
|
-
</Story>
|
|
61
|
-
<Story
|
|
62
|
-
name="overview-checked"
|
|
63
|
-
args={{
|
|
64
|
-
id: 'overview-checkbox-checked',
|
|
65
|
-
checked: true,
|
|
66
|
-
disabled: false,
|
|
67
|
-
partial: false,
|
|
68
|
-
}}
|
|
69
|
-
>
|
|
70
|
-
{Template.bind({})}
|
|
71
|
-
</Story>
|
|
72
|
-
<Story
|
|
73
|
-
name="overview-partial"
|
|
74
|
-
args={{
|
|
75
|
-
id: 'overview-checkbox-partial',
|
|
76
|
-
partial: true,
|
|
77
|
-
disabled: false,
|
|
78
|
-
checked: true,
|
|
79
|
-
}}
|
|
80
|
-
>
|
|
81
|
-
{Template.bind({})}
|
|
82
|
-
</Story>
|
|
83
|
-
<Story
|
|
84
|
-
name="overview-disabled"
|
|
85
|
-
args={{
|
|
86
|
-
id: 'overview-checkbox-disabled',
|
|
87
|
-
disabled: true,
|
|
88
|
-
checked: false,
|
|
89
|
-
partial: false,
|
|
90
|
-
}}
|
|
91
|
-
>
|
|
92
|
-
{Template.bind({})}
|
|
93
|
-
</Story>
|
|
94
|
-
</Canvas>
|
|
95
|
-
|
|
96
|
-
---
|
|
97
|
-
|
|
98
|
-
## Usage
|
|
99
|
-
|
|
100
|
-
`import Checkbox from '../components/ui/Checkbox'`
|
|
101
|
-
|
|
102
|
-
<Canvas>
|
|
103
|
-
<Story
|
|
104
|
-
name="default"
|
|
105
|
-
args={{
|
|
106
|
-
id: 'checkbox-default',
|
|
107
|
-
}}
|
|
108
|
-
>
|
|
109
|
-
{Template.bind({})}
|
|
110
|
-
</Story>
|
|
111
|
-
</Canvas>
|
|
112
|
-
|
|
113
|
-
<ArgsTable story="default" />
|
|
114
|
-
|
|
115
|
-
<TokenTable>
|
|
116
|
-
<TokenRow token="--fs-checkbox-width" value="1.25rem" />
|
|
117
|
-
<TokenRow token="--fs-checkbox-height" value="var(--fs-checkbox-width)" />
|
|
118
|
-
<TokenDivider />
|
|
119
|
-
<TokenRow token="--fs-checkbox-border-width" value="var(--fs-border-width)" />
|
|
120
|
-
<TokenRow
|
|
121
|
-
token="--fs-checkbox-border-radius"
|
|
122
|
-
value="var(--fs-border-radius)"
|
|
123
|
-
/>
|
|
124
|
-
<TokenRow
|
|
125
|
-
token="--fs-checkbox-border-color"
|
|
126
|
-
value="var(--fs-border-color)"
|
|
127
|
-
isColor
|
|
128
|
-
/>
|
|
129
|
-
<TokenRow
|
|
130
|
-
token="--fs-checkbox-border-color-hover"
|
|
131
|
-
value="var(--fs-border-color-active)"
|
|
132
|
-
isColor
|
|
133
|
-
/>
|
|
134
|
-
<TokenDivider />
|
|
135
|
-
<TokenRow
|
|
136
|
-
token="--fs-checkbox-transition"
|
|
137
|
-
value="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)"
|
|
138
|
-
/>
|
|
139
|
-
<TokenDivider />
|
|
140
|
-
<TokenRow
|
|
141
|
-
token="--fs-checkbox-bkg-color-hover"
|
|
142
|
-
value="var(--fs-color-primary-bkg-light)"
|
|
143
|
-
isColor
|
|
144
|
-
/>
|
|
145
|
-
<TokenRow
|
|
146
|
-
token="--fs-checkbox-shadow-hover"
|
|
147
|
-
value="0 0 0 var(--fs-checkbox-border-width) var(--fs-border-color-active)"
|
|
148
|
-
/>
|
|
149
|
-
</TokenTable>
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
## Variants
|
|
154
|
-
|
|
155
|
-
### Checked
|
|
156
|
-
|
|
157
|
-
<Canvas>
|
|
158
|
-
<Story
|
|
159
|
-
name="checked"
|
|
160
|
-
args={{
|
|
161
|
-
id: 'checkbox-checked',
|
|
162
|
-
checked: true,
|
|
163
|
-
disabled: false,
|
|
164
|
-
partial: false,
|
|
165
|
-
}}
|
|
166
|
-
>
|
|
167
|
-
{Template.bind({})}
|
|
168
|
-
</Story>
|
|
169
|
-
</Canvas>
|
|
170
|
-
|
|
171
|
-
<TokenTable>
|
|
172
|
-
<TokenRow
|
|
173
|
-
token="--fs-checkbox-checked-bkg-color"
|
|
174
|
-
value="var(--fs-color-primary-bkg)"
|
|
175
|
-
isColor
|
|
176
|
-
/>
|
|
177
|
-
<TokenRow
|
|
178
|
-
token="--fs-checkbox-checked-bkg-color-hover"
|
|
179
|
-
value="var(--fs-color-primary-bkg-hover)"
|
|
180
|
-
isColor
|
|
181
|
-
/>
|
|
182
|
-
<TokenRow
|
|
183
|
-
token="--fs-checkbox-checked-border-color-hover"
|
|
184
|
-
value="var((--fs-border-color-hover)"
|
|
185
|
-
isColor
|
|
186
|
-
/>
|
|
187
|
-
<TokenRow
|
|
188
|
-
token="--fs-checkbox-checked-shadow-hover"
|
|
189
|
-
value="0 0 0 var(--fs-checkbox-border-width)
|
|
190
|
-
var(--fs-checkbox-checked-border-color-hover)"
|
|
191
|
-
/>
|
|
192
|
-
</TokenTable>
|
|
193
|
-
|
|
194
|
-
### Disabled
|
|
195
|
-
|
|
196
|
-
<Canvas>
|
|
197
|
-
<Story
|
|
198
|
-
name="disabled"
|
|
199
|
-
args={{
|
|
200
|
-
id: 'checkbox-disabled',
|
|
201
|
-
disabled: true,
|
|
202
|
-
checked: false,
|
|
203
|
-
partial: false,
|
|
204
|
-
}}
|
|
205
|
-
>
|
|
206
|
-
{Template.bind({})}
|
|
207
|
-
</Story>
|
|
208
|
-
</Canvas>
|
|
209
|
-
|
|
210
|
-
<TokenTable>
|
|
211
|
-
<TokenRow
|
|
212
|
-
token="--fs-checkbox-disabled-bkg-color"
|
|
213
|
-
value="var(--fs-color-disabled-bkg)"
|
|
214
|
-
isColor
|
|
215
|
-
/>
|
|
216
|
-
<TokenRow
|
|
217
|
-
token="--fs-checkbox-disabled-border-width"
|
|
218
|
-
value="var(--fs-checkbox-border-width)"
|
|
219
|
-
/>
|
|
220
|
-
<TokenRow
|
|
221
|
-
token="--fs-checkbox-disabled-border-color"
|
|
222
|
-
value="var(--fs-border-color-disabled)"
|
|
223
|
-
isColor
|
|
224
|
-
/>
|
|
225
|
-
<TokenRow
|
|
226
|
-
token="--fs-checkbox-disabled-text-color"
|
|
227
|
-
value="var(--fs-color-disabled-text)"
|
|
228
|
-
isColor
|
|
229
|
-
/>
|
|
230
|
-
</TokenTable>
|
|
231
|
-
|
|
232
|
-
### Partial
|
|
233
|
-
|
|
234
|
-
<Canvas>
|
|
235
|
-
<Story
|
|
236
|
-
name="partial"
|
|
237
|
-
args={{
|
|
238
|
-
id: 'checkbox-partial',
|
|
239
|
-
partial: true,
|
|
240
|
-
disabled: false,
|
|
241
|
-
checked: true,
|
|
242
|
-
}}
|
|
243
|
-
>
|
|
244
|
-
{Template.bind({})}
|
|
245
|
-
</Story>
|
|
246
|
-
</Canvas>
|
|
247
|
-
|
|
248
|
-
<TokenTable>
|
|
249
|
-
<TokenRow
|
|
250
|
-
token="--fs-checkbox-partial-bkg-color"
|
|
251
|
-
value="var(--fs-color-body-bkg)"
|
|
252
|
-
isColor
|
|
253
|
-
/>
|
|
254
|
-
<TokenRow
|
|
255
|
-
token="--fs-checkbox-partial-border-width"
|
|
256
|
-
value="var(--fs-checkbox-border-width)"
|
|
257
|
-
/>
|
|
258
|
-
<TokenRow
|
|
259
|
-
token="--fs-checkbox-partial-border-color"
|
|
260
|
-
value="var(--fs-color-primary-bkg)"
|
|
261
|
-
isColor
|
|
262
|
-
/>
|
|
263
|
-
<TokenRow
|
|
264
|
-
token="--fs-checkbox-partial-bkg-color-hover"
|
|
265
|
-
value="var(--fs-color-primary-bkg-light)"
|
|
266
|
-
isColor
|
|
267
|
-
/>
|
|
268
|
-
</TokenTable>
|