@faststore/core 0.3.15 → 0.3.17

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/cypress/integration/analytics.test.js +3 -3
  3. package/cypress/integration/plp.test.js +1 -1
  4. package/package.json +4 -4
  5. package/src/Layout.tsx +6 -1
  6. package/src/components/cart/CartItem/CartItem.tsx +2 -2
  7. package/src/components/cart/CartSidebar/CartSidebar.tsx +5 -6
  8. package/src/components/cart/CartSidebar/cart-sidebar.module.scss +2 -0
  9. package/src/components/common/Alert/Alert.tsx +6 -22
  10. package/src/components/common/Footer/Footer.stories.mdx +1 -1
  11. package/src/components/common/Footer/FooterLinks.tsx +16 -12
  12. package/src/components/search/Filter/Facets.stories.mdx +9 -9
  13. package/src/components/search/Filter/Facets.tsx +69 -61
  14. package/src/components/search/Filter/facets.module.scss +16 -16
  15. package/src/components/search/Search.stories.mdx +28 -24
  16. package/src/components/search/SearchDropdown/SearchDropdown.stories.mdx +0 -1
  17. package/src/components/search/SearchInput/SearchInput.stories.mdx +0 -1
  18. package/src/components/search/SearchTop/SearchTop.stories.mdx +0 -1
  19. package/src/components/sections/ProducDetailsContent/ProductDetailsContent.tsx +147 -149
  20. package/src/components/sections/ProductDetails/ProductDetails.tsx +2 -2
  21. package/src/components/ui/Breadcrumb/Breadcrumb.tsx +17 -16
  22. package/src/components/ui/Gift/Gift.tsx +7 -13
  23. package/src/components/ui/ShippingSimulation/ShippingSimulation.stories.mdx +0 -27
  24. package/src/components/ui/ShippingSimulation/ShippingSimulation.tsx +6 -13
  25. package/src/components/ui/ShippingSimulation/shipping-simulation.module.scss +0 -39
  26. package/src/components/ui/SkuSelector/sku-selector.module.scss +1 -1
  27. package/tsconfig.json +1 -1
  28. package/src/components/sections/ProducDetailsContent/product-details-content.module.scss +0 -41
  29. package/src/components/ui/Accordion/Accordion.stories.mdx +0 -222
  30. package/src/components/ui/Accordion/Accordion.tsx +0 -39
  31. package/src/components/ui/Accordion/AccordionItem.stories.mdx +0 -116
  32. package/src/components/ui/Accordion/AccordionItem.tsx +0 -82
  33. package/src/components/ui/Accordion/accordion.module.scss +0 -65
  34. package/src/components/ui/Accordion/index.ts +0 -2
  35. package/src/components/ui/Alert/Alert.stories.mdx +0 -164
  36. package/src/components/ui/Alert/Alert.tsx +0 -81
  37. package/src/components/ui/Alert/alert.module.scss +0 -93
  38. package/src/components/ui/Alert/index.ts +0 -1
  39. package/src/components/ui/Dropdown/Dropdown.stories.mdx +0 -232
  40. package/src/components/ui/Dropdown/Dropdown.tsx +0 -12
  41. package/src/components/ui/Dropdown/DropdownButton.tsx +0 -20
  42. package/src/components/ui/Dropdown/DropdownItem.stories.mdx +0 -139
  43. package/src/components/ui/Dropdown/DropdownItem.tsx +0 -26
  44. package/src/components/ui/Dropdown/DropdownMenu.stories.mdx +0 -115
  45. package/src/components/ui/Dropdown/DropdownMenu.tsx +0 -34
  46. package/src/components/ui/Dropdown/dropdown.module.scss +0 -101
  47. package/src/components/ui/Dropdown/index.ts +0 -4
  48. package/src/components/ui/Gift/Gift.stories.mdx +0 -99
  49. package/src/components/ui/Gift/gift.module.scss +0 -94
  50. package/src/components/ui/PriceRange/PriceRange.stories.mdx +0 -192
  51. package/src/components/ui/PriceRange/PriceRange.tsx +0 -140
  52. package/src/components/ui/PriceRange/index.ts +0 -1
  53. package/src/components/ui/PriceRange/price-range.module.scss +0 -176
  54. package/src/components/ui/QuantitySelector/QuantitySelector.stories.mdx +0 -246
  55. package/src/components/ui/QuantitySelector/QuantitySelector.tsx +0 -103
  56. package/src/components/ui/QuantitySelector/index.ts +0 -1
  57. package/src/components/ui/QuantitySelector/quantity-selector.module.scss +0 -155
@@ -1,246 +0,0 @@
1
- import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs'
2
-
3
- import QuantitySelector from '.'
4
- import {
5
- TokenTable,
6
- TokenRow,
7
- TokenDivider,
8
- } from 'src/../.storybook/components'
9
-
10
- <Meta
11
- title="Molecules/QuantitySelector"
12
- component={QuantitySelector}
13
- argTypes={{
14
- max: {
15
- type: {
16
- name: 'number',
17
- },
18
- defaultValue: 10,
19
- },
20
- min: {
21
- type: {
22
- name: 'number',
23
- },
24
- defaultValue: 1,
25
- },
26
- initial: {
27
- type: {
28
- name: 'number',
29
- },
30
- defaultValue: 5,
31
- },
32
- disabled: {
33
- type: {
34
- name: 'boolean',
35
- },
36
- defaultValue: false,
37
- },
38
- }}
39
- />
40
-
41
- export const Template = (args) => <QuantitySelector {...args} />
42
-
43
- <header>
44
-
45
- # Quantity Selector
46
-
47
- It's a component that shows a quantity selector, commonly used to add a product to the shopping cart.
48
-
49
- </header>
50
-
51
- ## Overview
52
-
53
- The `QuantitySelector` component uses [FastStore UI QuantitySelector](https://www.faststore.dev/reference/ui/molecules/QuantitySelector) as base.
54
-
55
- <Canvas>
56
- <Story name="Overview-QuantitySelector">{Template.bind({})}</Story>
57
- <Story
58
- name="Overview-Disabled"
59
- args={{
60
- disabled: true,
61
- }}
62
- >
63
- {Template.bind({})}
64
- </Story>
65
- </Canvas>
66
-
67
- ---
68
-
69
- ## Usage
70
-
71
- `import QuantitySelector from '../components/sections/QuantitySelector'`
72
-
73
- <Canvas>
74
- <Story name="QuantitySelector">{Template.bind({})}</Story>
75
- </Canvas>
76
-
77
- <ArgsTable story="QuantitySelector" />
78
-
79
- <TokenTable>
80
- <TokenRow
81
- token="--fs-qty-selector-width"
82
- value="calc(var(--fs-control-tap-size) * 2.7)"
83
- />
84
- <TokenRow
85
- token="--fs-qty-selector-height"
86
- value="calc(var(--fs-control-tap-size) + (var(--fs-qty-selector-border-width) * 2))"
87
- />
88
- <TokenDivider />
89
- <TokenRow token="--fs-qty-selector-shadow" value="none" />
90
- <TokenRow
91
- token="--fs-qty-selector-shadow-hover"
92
- value="0 0 0 var(--fs-border-width) var(--fs-border-color-active)"
93
- />
94
- <TokenDivider />
95
- <TokenRow
96
- token="--fs-qty-selector-bkg-color"
97
- value="var(--fs-color-body-bkg)"
98
- isColor
99
- />
100
- <TokenRow
101
- token="--fs-qty-selector-bkg-color-hover"
102
- value="var(--fs-qty-selector-bkg-color)"
103
- isColor
104
- />
105
- <TokenDivider />
106
- <TokenRow
107
- token="--fs-qty-selector-border-radius"
108
- value="var(--fs-border-radius)"
109
- />
110
- <TokenRow
111
- token="--fs-qty-selector-border-width"
112
- value="var(--fs-border-width)"
113
- />
114
- <TokenRow
115
- token="--fs-qty-selector-border-width-hover"
116
- value="var(--fs-border-width)"
117
- />
118
- <TokenRow
119
- token="--fs-qty-selector-border-color"
120
- value="var(--fs-border-color)"
121
- isColor
122
- />
123
- <TokenRow
124
- token="--fs-qty-selector-border-color-hover"
125
- value="var(--fs-border-color-active)"
126
- isColor
127
- />
128
- <TokenDivider />
129
- <TokenRow
130
- token="--fs-qty-selector-transition-function"
131
- value="var(--fs-transition-function)"
132
- />
133
- <TokenRow
134
- token="--fs-qty-selector-transition-property"
135
- value="var(--fs-transition-property)"
136
- />
137
- <TokenRow
138
- token="--fs-qty-selector-transition-timing "
139
- value="var(--fs-transition-timing)"
140
- />
141
- </TokenTable>
142
-
143
- ---
144
-
145
- ## Nested Elements
146
-
147
- ### Text
148
-
149
- <TokenTable>
150
- <TokenRow
151
- token="--fs-qty-selector-text-size"
152
- value="var(--fs-text-size-base)"
153
- />
154
- <TokenRow
155
- token="--fs-qty-selector-text-color"
156
- value="var(--fs-color-text)"
157
- isColor
158
- />
159
- <TokenRow
160
- token="--fs-qty-selector-text-color-hover"
161
- value="var(--fs-qty-selector-text-color)"
162
- isColor
163
- />
164
- </TokenTable>
165
-
166
- ### Icon
167
-
168
- <TokenTable>
169
- <TokenRow
170
- token="--fs-qty-selector-icon-color"
171
- value="var(--fs-color-link)"
172
- isColor
173
- />
174
- <TokenRow
175
- token="--fs-qty-selector-icon-color-hover"
176
- value="var(--fs-border-color-active)"
177
- isColor
178
- />
179
- </TokenTable>
180
-
181
- ### Button
182
-
183
- <TokenTable>
184
- <TokenRow token="--fs-qty-selector-button-shadow" value="none" />
185
- <TokenRow token="--fs-qty-selector-button-shadow-hover" value="none" />
186
- <TokenRow token="--fs-qty-selector-button-bkg-color" value="transparent" />
187
- <TokenRow
188
- token="--fs-qty-selector-button-bkg-color-hover"
189
- value="var(--fs-color-primary-bkg-light)"
190
- isColor
191
- />
192
- <TokenRow
193
- token="--fs-qty-selector-button-bkg-color-focus"
194
- value="var(--fs-qty-selector-button-bkg-color-hover)"
195
- isColor
196
- />
197
- <TokenRow
198
- token="--fs-qty-selector-button-border-radius"
199
- value="var(--fs-qty-selector-border-radius)"
200
- />
201
- </TokenTable>
202
-
203
- ---
204
-
205
- ## Variants
206
-
207
- ### Disabled
208
-
209
- <Canvas>
210
- <Story
211
- name="Disabled"
212
- args={{
213
- disabled: true,
214
- }}
215
- >
216
- {Template.bind({})}
217
- </Story>
218
- </Canvas>
219
-
220
- <TokenTable>
221
- <TokenRow
222
- token="--fs-qty-selector-disabled-bkg-color"
223
- value="var(--fs-color-disabled-bkg)"
224
- isColor
225
- />
226
- <TokenRow
227
- token="--fs-qty-selector-disabled-text-color"
228
- value="var(--fs-color-disabled-text)"
229
- isColor
230
- />
231
- <TokenRow
232
- token="--fs-qty-selector-disabled-icon-color"
233
- value="var(--fs-border-color-light-disabled)"
234
- isColor
235
- />
236
- <TokenRow
237
- token="--fs-qty-selector-disabled-border-color"
238
- value="var(--fs-qty-selector-disabled-bkg-color)"
239
- isColor
240
- />
241
- <TokenRow
242
- token="--fs-qty-selector-disabled-button-bkg-color"
243
- value="var(--fs-qty-selector-button-bkg-color-hover)"
244
- isColor
245
- />
246
- </TokenTable>
@@ -1,103 +0,0 @@
1
- import { QuantitySelector as UIQuantitySelector } from '@faststore/ui'
2
- import { memo, useEffect, useState } from 'react'
3
-
4
- import Icon from 'src/components/ui/Icon'
5
-
6
- import styles from './quantity-selector.module.scss'
7
-
8
- interface QuantitySelectorProps {
9
- /**
10
- * The maximum value the quantity selector can receive
11
- */
12
- max?: number
13
- /**
14
- * The minimum value the quantity selector can receive
15
- */
16
- min?: number
17
- /**
18
- * The initial value for quantity selector
19
- */
20
- initial?: number
21
- /**
22
- * Specifies that the whole quantity selector component should be disabled.
23
- */
24
- disabled?: boolean
25
- /**
26
- * Event emitted when value is changed
27
- */
28
- onChange?: (value: number) => void
29
- }
30
-
31
- export function QuantitySelector({
32
- max,
33
- min = 1,
34
- initial,
35
- disabled = false,
36
- onChange,
37
- }: QuantitySelectorProps) {
38
- const [quantity, setQuantity] = useState<number>(initial ?? min)
39
- const isLeftDisabled = quantity === min
40
- const isRightDisabled = quantity === max
41
-
42
- const changeQuantity = (increaseValue: number) => {
43
- const quantityValue = validateQuantityBounds(quantity + increaseValue)
44
-
45
- onChange?.(quantityValue)
46
- setQuantity(quantityValue)
47
- }
48
-
49
- const increase = () => changeQuantity(1)
50
-
51
- const decrease = () => changeQuantity(-1)
52
-
53
- function validateQuantityBounds(n: number): number {
54
- const maxValue = min ? Math.max(n, min) : n
55
-
56
- return max ? Math.min(maxValue, max) : maxValue
57
- }
58
-
59
- function validateInput(e: React.FormEvent<HTMLInputElement>) {
60
- const val = e.currentTarget.value
61
-
62
- if (!Number.isNaN(Number(val))) {
63
- setQuantity(() => {
64
- const quantityValue = validateQuantityBounds(Number(val))
65
-
66
- onChange?.(quantityValue)
67
-
68
- return quantityValue
69
- })
70
- }
71
- }
72
-
73
- useEffect(() => {
74
- initial && setQuantity(initial)
75
- }, [initial])
76
-
77
- return (
78
- <UIQuantitySelector
79
- data-fs-quantity-selector={disabled ? 'disabled' : 'true'}
80
- className={styles.fsQuantitySelector}
81
- quantity={quantity}
82
- leftButtonProps={{
83
- onClick: decrease,
84
- disabled: isLeftDisabled || disabled,
85
- icon: <Icon name="Minus" width={16} height={16} weight="bold" />,
86
- testId: 'store-quantity-selector-left',
87
- }}
88
- rightButtonProps={{
89
- onClick: increase,
90
- disabled: isRightDisabled || disabled,
91
- icon: <Icon name="Plus" width={16} height={16} weight="bold" />,
92
- testId: 'store-quantity-selector-right',
93
- }}
94
- inputProps={{
95
- onChange: validateInput,
96
- readOnly: false,
97
- disabled,
98
- }}
99
- />
100
- )
101
- }
102
-
103
- export default memo(QuantitySelector)
@@ -1 +0,0 @@
1
- export { default } from './QuantitySelector'
@@ -1,155 +0,0 @@
1
- @import "src/styles/scaffold";
2
-
3
- .fs-quantity-selector {
4
- // --------------------------------------------------------
5
- // Design Tokens for Quantity Selector
6
- // --------------------------------------------------------
7
-
8
- // Default properties
9
- --fs-qty-selector-width : calc(var(--fs-control-tap-size) * 2.7);
10
- --fs-qty-selector-height : calc(var(--fs-control-tap-size) + (var(--fs-qty-selector-border-width) * 2));
11
-
12
- --fs-qty-selector-shadow : none;
13
- --fs-qty-selector-shadow-hover : 0 0 0 var(--fs-border-width) var(--fs-border-color-active);
14
-
15
- --fs-qty-selector-bkg-color : var(--fs-color-body-bkg);
16
- --fs-qty-selector-bkg-color-hover : var(--fs-qty-selector-bkg-color);
17
-
18
- --fs-qty-selector-text-size : var(--fs-text-size-base);
19
- --fs-qty-selector-text-color : var(--fs-color-text);
20
- --fs-qty-selector-text-color-hover : var(--fs-qty-selector-text-color);
21
-
22
- --fs-qty-selector-icon-color : var(--fs-color-link);
23
- --fs-qty-selector-icon-color-hover : var(--fs-border-color-active);
24
-
25
- --fs-qty-selector-border-radius : var(--fs-border-radius);
26
- --fs-qty-selector-border-width : var(--fs-border-width);
27
- --fs-qty-selector-border-width-hover : var(--fs-border-width);
28
- --fs-qty-selector-border-color : var(--fs-border-color);
29
- --fs-qty-selector-border-color-hover : var(--fs-border-color-active);
30
-
31
- --fs-qty-selector-button-shadow : none;
32
- --fs-qty-selector-button-shadow-hover : none;
33
- --fs-qty-selector-button-bkg-color : transparent;
34
- --fs-qty-selector-button-bkg-color-hover : var(--fs-color-primary-bkg-light);
35
- --fs-qty-selector-button-bkg-color-focus : var(--fs-qty-selector-button-bkg-color-hover);
36
- --fs-qty-selector-button-border-radius : var(--fs-qty-selector-border-radius);
37
-
38
- // Disabled properties
39
- --fs-qty-selector-disabled-bkg-color : var(--fs-color-disabled-bkg);
40
- --fs-qty-selector-disabled-text-color : var(--fs-color-disabled-text);
41
- --fs-qty-selector-disabled-icon-color : var(--fs-border-color-light-disabled);
42
- --fs-qty-selector-disabled-border-color : var(--fs-qty-selector-disabled-bkg-color);
43
- --fs-qty-selector-disabled-button-bkg-color : var(--fs-qty-selector-button-bkg-color-hover);
44
-
45
- // --------------------------------------------------------
46
- // Structural Styles
47
- // --------------------------------------------------------
48
-
49
- position: relative;
50
- display: flex;
51
- flex-direction: row;
52
- align-items: center;
53
- justify-content: center;
54
- width: var(--fs-qty-selector-width);
55
- height: var(--fs-qty-selector-height);
56
- border-radius: var(--fs-qty-selector-border-radius);
57
- box-shadow: var(--fs-qty-selector-shadow);
58
-
59
- [data-fs-icon] {
60
- margin: 0;
61
- line-height: 0;
62
- color: var(--fs-qty-selector-icon-color);
63
- }
64
-
65
- [data-quantity-selector-input] {
66
- width: 100%;
67
- height: 100%;
68
- padding: 0;
69
- font-size: var(--fs-qty-selector-text-size);
70
- color: var(--fs-qty-selector-text-color);
71
- text-align: center;
72
- }
73
-
74
- [data-quantity-selector-button] {
75
- position: absolute;
76
- background-color: var(--fs-qty-selector-button-bkg-color);
77
-
78
- [data-fs-icon] {
79
- width: 100%;
80
- height: 100%;
81
- border-radius: var(--fs-qty-selector-button-border-radius);
82
- box-shadow: var(--fs-qty-selector-button-shadow);
83
- transition:
84
- var(--fs-qty-selector-transition-property)
85
- var(--fs-qty-selector-transition-timing)
86
- var(--fs-qty-selector-transition-function);
87
- }
88
-
89
- &[data-fs-icon-button] {
90
- padding: var(--fs-spacing-1);
91
- }
92
-
93
- &:first-of-type { left: 0; }
94
-
95
- &:last-of-type { right: 0; }
96
-
97
- &:hover:not(:disabled) [data-fs-icon] {
98
- background-color: var(--fs-qty-selector-button-bkg-color-hover);
99
- box-shadow: var(--fs-qty-selector-button-shadow-hover);
100
- }
101
-
102
- &:disabled {
103
- cursor: not-allowed;
104
- background-color: var(--fs-qty-selector-button-bkg-color);
105
-
106
- &:hover, &:focus-visible {
107
- background-color: var(--fs-qty-selector-button-bkg-color);
108
- }
109
-
110
- [data-fs-icon] {
111
- color: var(--fs-qty-selector-disabled-icon-color);
112
- }
113
- }
114
-
115
- &:hover:not(:disabled) {
116
- background-color: transparent;
117
- box-shadow: none;
118
- }
119
-
120
- &:focus:not(:disabled) {
121
- background-color: transparent;
122
- box-shadow: none;
123
- }
124
-
125
- &:focus-visible {
126
- background-color: var(--fs-qty-selector-button-bkg-color);
127
- outline: none;
128
- box-shadow: none;
129
-
130
- [data-fs-icon] {
131
- @include focus-ring;
132
-
133
- background-color: var(--fs-qty-selector-button-bkg-color-focus);
134
- }
135
- }
136
- }
137
-
138
- &:hover {
139
- [data-quantity-selector-input]:not(:disabled):not(:focus) {
140
- color: var(--fs-qty-selector-text-color-hover);
141
- background-color: var(--fs-qty-selector-bkg-color-hover);
142
- border-color: var(--fs-qty-selector-border-color-hover);
143
- border-width: var(--fs-qty-selector-border-width-hover);
144
- box-shadow: var(--fs-qty-selector-shadow-hover);
145
- }
146
- }
147
-
148
- // --------------------------------------------------------
149
- // Variants Styles
150
- // --------------------------------------------------------
151
-
152
- &[data-fs-quantity-selector="disabled"] {
153
- [data-quantity-selector-button]:hover [data-fs-icon] { background-color: transparent; }
154
- }
155
- }