@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,192 +0,0 @@
1
- import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs'
2
-
3
- import PriceRange from '.'
4
- import {
5
- TokenTable,
6
- TokenRow,
7
- TokenDivider,
8
- BestPractices,
9
- BestPracticesRule,
10
- } from 'src/../.storybook/components'
11
-
12
- <Meta
13
- title="Molecules/PriceRange"
14
- argTypes={{
15
- min: { control: { disable: true } },
16
- max: { control: { disable: true } },
17
- testId: {
18
- table: {
19
- disable: true,
20
- },
21
- },
22
- className: {
23
- table: {
24
- disable: true,
25
- },
26
- },
27
- onChange: {
28
- table: {
29
- disable: true,
30
- },
31
- },
32
- variant: {
33
- table: {
34
- disable: true,
35
- },
36
- },
37
- step: {
38
- control: 'number',
39
- table: { type: 'number', summary: 10 },
40
- },
41
- }}
42
- component={PriceRange}
43
- />
44
-
45
- export const defaultArgs = {
46
- min: {
47
- absolute: 0,
48
- selected: 0,
49
- },
50
- max: {
51
- absolute: 12400,
52
- selected: 12400,
53
- },
54
- }
55
-
56
- export const Template = (args) => {
57
- return (
58
- <PriceRange {...defaultArgs} {...args} />
59
- )
60
- }
61
-
62
- <header>
63
-
64
- # Price Range
65
-
66
- PriceRange allows you to implement filters on PLP so users have a high control over product prices.
67
-
68
- </header>
69
-
70
- ## Overview
71
-
72
- The `PriceRange` component uses [FastStore UI Price Range](https://www.faststore.dev/reference/ui/molecules/PriceRange) as base.
73
-
74
- ---
75
-
76
- ## Usage
77
-
78
- `import PriceRange from '../components/ui/PriceRange'`
79
-
80
- <Canvas isColumn>
81
- <Story name="overview-default" args={defaultArgs}>
82
- {Template.bind({})}
83
- </Story>
84
- </Canvas>
85
-
86
- <ArgsTable story="overview-default" />
87
-
88
- <TokenTable>
89
- <TokenRow token="--fs-price-range-height" value="var(--fs-spacing-2)" />
90
- <TokenRow
91
- token="--fs-price-range-border-radius"
92
- value="var(--fs-border-radius-pill)"
93
- />
94
- <TokenRow
95
- token="--fs-price-range-margin-bottom"
96
- value="var(--fs-spacing-3)"
97
- />
98
- <TokenDivider />
99
- <TokenRow
100
- token="--fs-price-range-transition-function"
101
- value="var(--fs-transition-function)"
102
- />
103
- <TokenRow
104
- token="--fs-price-range-transition-property"
105
- value="varvar(--fs-transition-property)"
106
- />
107
- <TokenRow
108
- token="--fs-price-range-transition-timing"
109
- value="var(--fs-transition-timing)"
110
- />
111
- </TokenTable>
112
-
113
- ---
114
-
115
- ## Nested Elements
116
-
117
- ### Slider
118
-
119
- <TokenTable>
120
- <TokenRow
121
- token="--fs-price-range-slider-bkg-color"
122
- value="var(--fs-color-neutral-bkg)"
123
- isColor
124
- />
125
- <TokenRow
126
- token="--fs-price-range-slider-selection-bkg-color"
127
- value="var(--fs-color-primary-bkg-light-active)"
128
- isColor
129
- />
130
- </TokenTable>
131
-
132
- ### Value Label
133
-
134
- <TokenTable>
135
- <TokenRow
136
- token="--fs-price-range-value-label-bottom"
137
- value="var(--fs-spacing-3)"
138
- />
139
- <TokenRow
140
- token="--fs-price-range-value-label-bkg-color"
141
- value="var(--fs-color-body-bkg)"
142
- isColor
143
- />
144
- </TokenTable>
145
-
146
- ### Absolute Values
147
-
148
- <TokenTable>
149
- <TokenRow
150
- token="--fs-price-range-absolute-values-text-color"
151
- value="var(--fs-color-disabled-text)"
152
- isColor
153
- />
154
- </TokenTable>
155
-
156
- ### Thumb
157
-
158
- <TokenTable>
159
- <TokenRow token="--fs-price-range-thumb-size" value="var(--fs-spacing-4)" />
160
- <TokenDivider />
161
- <TokenRow
162
- token="--fs-price-range-thumb-bkg-color"
163
- value="var(--fs-color-primary-bkg)"
164
- isColor
165
- />
166
- <TokenRow
167
- token="--fs-price-range-thumb-bkg-color-hover"
168
- value="var(--fs-color-primary-bkg-hover)"
169
- isColor
170
- />
171
- <TokenDivider />
172
- <TokenRow
173
- token="--fs-price-range-thumb-border-radius"
174
- value="var(--fs-border-radius-circle)"
175
- />
176
- <TokenRow
177
- token="--fs-price-range-thumb-border-color"
178
- value="var(--fs-price-range-thumb-bkg-color)"
179
- globalValue="var(--fs-color-primary-bkg)"
180
- isColor
181
- />
182
- <TokenRow
183
- token="--fs-price-range-thumb-border-color-hover"
184
- value="var(--fs-price-range-thumb-bkg-color-hover)"
185
- globalValue="var(--fs-color-primary-bkg-hover)"
186
- isColor
187
- />
188
- <TokenRow
189
- token="--fs-price-range-thumb-border-width"
190
- value="var(--fs-border-width)"
191
- />
192
- </TokenTable>
@@ -1,140 +0,0 @@
1
- import { useState, useRef } from 'react'
2
- import {
3
- PriceRange as UIPriceRange,
4
- InputField as UIInputField,
5
- } from '@faststore/ui'
6
- import type { PriceRangeProps } from '@faststore/ui'
7
-
8
- import {
9
- usePriceFormatter,
10
- useFormattedPrice,
11
- } from 'src/sdk/product/useFormattedPrice'
12
-
13
- import styles from './price-range.module.scss'
14
-
15
- type Props = Omit<
16
- PriceRangeProps,
17
- 'formatter' | 'minValueLabelComponent' | 'maxValueLabelComponent'
18
- >
19
-
20
- function PriceRange({ min, max, onEnd, step = 10, ...otherProps }: Props) {
21
- const formatter = usePriceFormatter({ decimals: false })
22
- const minAbsoluteFormatted = useFormattedPrice(Math.round(min.absolute))
23
- const maxAbsoluteFormatted = useFormattedPrice(Math.ceil(max.absolute))
24
-
25
- const inputMinRef = useRef<HTMLInputElement>(null)
26
- const inputMaxRef = useRef<HTMLInputElement>(null)
27
- const priceRangeRef = useRef<{
28
- setPriceRangeValues: (values: { min: number; max: number }) => void
29
- }>()
30
-
31
- const [inputMinError, setInputMinError] = useState<string>()
32
- const [inputMaxError, setInputMaxError] = useState<string>()
33
- const [priceRange, setPriceRange] = useState<{ min: number; max: number }>({
34
- min: Math.round(min.selected),
35
- max: Math.ceil(max.selected),
36
- })
37
-
38
- function onChangePriceRange(value: { min: number; max: number }) {
39
- setInputMinError(undefined)
40
- setInputMaxError(undefined)
41
- setPriceRange({ min: value.min, max: value.max })
42
-
43
- if (inputMinRef.current?.value) {
44
- inputMinRef.current.value = String(value.min)
45
- }
46
-
47
- if (inputMaxRef.current?.value) {
48
- inputMaxRef.current.value = String(value.max)
49
- }
50
- }
51
-
52
- function onChangeInputMin(value: string) {
53
- setInputMinError(undefined)
54
-
55
- if (Number(value) < min.absolute) {
56
- return
57
- }
58
-
59
- if (Number(value) > priceRange.max) {
60
- setInputMinError(`Min price can't be greater than max`)
61
- }
62
-
63
- setPriceRange({ ...priceRange, min: Number(value) })
64
- priceRangeRef.current?.setPriceRangeValues({
65
- ...priceRange,
66
- min: Number(value),
67
- })
68
- }
69
-
70
- function onChangeInputMax(value: string) {
71
- setInputMaxError(undefined)
72
-
73
- if (Number(value) > max.absolute) {
74
- return
75
- }
76
-
77
- if (Number(value) < priceRange.min) {
78
- setInputMaxError(`Max price can't be smaller than min`)
79
- }
80
-
81
- setPriceRange({ ...priceRange, max: Number(value) })
82
- priceRangeRef.current?.setPriceRangeValues({
83
- ...priceRange,
84
- max: Number(value),
85
- })
86
- }
87
-
88
- return (
89
- <div className={styles.fsPriceRange} data-fs-price-range>
90
- <div data-fs-price-range-absolute-values>
91
- <span>{minAbsoluteFormatted}</span>
92
- <span>{maxAbsoluteFormatted}</span>
93
- </div>
94
- <UIPriceRange
95
- ref={priceRangeRef}
96
- min={min}
97
- max={max}
98
- formatter={formatter}
99
- className={styles.fsPriceRange}
100
- onEnd={(value) => {
101
- onEnd?.(value)
102
- onChangePriceRange(value)
103
- }}
104
- {...otherProps}
105
- />
106
- <div data-fs-price-range-inputs>
107
- <UIInputField
108
- id="price-range-min"
109
- step={step}
110
- label="Min"
111
- type="number"
112
- inputMode="numeric"
113
- error={inputMinError}
114
- inputRef={inputMinRef}
115
- min={Math.round(min.absolute)}
116
- max={Math.ceil(priceRange.max)}
117
- value={Math.round(priceRange.min)}
118
- onChange={(e) => onChangeInputMin(e.target.value)}
119
- onBlur={() => !inputMinError && onEnd?.(priceRange)}
120
- />
121
- <UIInputField
122
- id="price-range-max"
123
- label="Max"
124
- step={step}
125
- type="number"
126
- inputMode="numeric"
127
- error={inputMaxError}
128
- inputRef={inputMaxRef}
129
- max={Math.ceil(max.absolute)}
130
- min={Math.round(priceRange.min)}
131
- value={Math.ceil(priceRange.max)}
132
- onChange={(e) => onChangeInputMax(e.target.value)}
133
- onBlur={() => !inputMaxError && onEnd?.(priceRange)}
134
- />
135
- </div>
136
- </div>
137
- )
138
- }
139
-
140
- export default PriceRange
@@ -1 +0,0 @@
1
- export { default } from './PriceRange'
@@ -1,176 +0,0 @@
1
- .fs-price-range {
2
- // --------------------------------------------------------
3
- // Design Tokens for Price Range
4
- // --------------------------------------------------------
5
-
6
- // Default properties
7
- --fs-price-range-height : var(--fs-spacing-2);
8
- --fs-price-range-border-radius : var(--fs-border-radius-pill);
9
- --fs-price-range-margin-bottom : var(--fs-spacing-3);
10
-
11
- --fs-price-range-transition-function : var(--fs-transition-function);
12
- --fs-price-range-transition-property : var(--fs-transition-property);
13
- --fs-price-range-transition-timing : var(--fs-transition-timing);
14
-
15
- // Slider
16
- --fs-price-range-slider-bkg-color : var(--fs-color-neutral-bkg);
17
- --fs-price-range-slider-selection-bkg-color : var(--fs-color-primary-bkg-light-active);
18
-
19
- // Value Label
20
- --fs-price-range-value-label-bottom : var(--fs-spacing-3);
21
- --fs-price-range-value-label-bkg-color : var(--fs-color-body-bkg);
22
-
23
- // Absolute Values
24
- --fs-price-range-absolute-values-text-color : var(--fs-color-disabled-text);
25
-
26
- // Thumb
27
- --fs-price-range-thumb-size : var(--fs-spacing-4);
28
- --fs-price-range-thumb-bkg-color : var(--fs-color-primary-bkg);
29
- --fs-price-range-thumb-bkg-color-hover : var(--fs-color-primary-bkg-hover);
30
- --fs-price-range-thumb-border-radius : var(--fs-border-radius-circle);
31
- --fs-price-range-thumb-border-color : var(--fs-price-range-thumb-bkg-color);
32
- --fs-price-range-thumb-border-color-hover : var(--fs-price-range-thumb-bkg-color-hover);
33
- --fs-price-range-thumb-border-width : var(--fs-border-width);
34
-
35
- // --------------------------------------------------------
36
- // Structural Styles
37
- // --------------------------------------------------------
38
-
39
- [data-fs-slider] {
40
- position: relative;
41
- width: 100%;
42
- height: var(--fs-price-range-height);
43
- margin-bottom: var(--fs-price-range-margin-bottom);
44
- background-color: var(--fs-price-range-slider-bkg-color);
45
- border-radius: var(--fs-price-range-border-radius);
46
- }
47
-
48
- [data-slider-range] {
49
- position: absolute;
50
- height: var(--fs-price-range-height);
51
- background-color: var(--fs-price-range-slider-selection-bkg-color);
52
- border-radius: var(--fs-price-range-border-radius);
53
- }
54
-
55
- [data-price-range-value-label="min"],
56
- [data-price-range-value-label="max"] {
57
- bottom: var(--fs-price-range-value-label-bottom);
58
- padding: var(--fs-spacing-1);
59
- background-color: var(--fs-price-range-value-label-bkg-color);
60
- opacity: 0;
61
- transition: opacity var(--fs-price-range-transition-timing) var(--fs-price-range-transition-function);
62
-
63
- &:hover {
64
- opacity: 1;
65
- }
66
- }
67
-
68
- [data-price-range-value-label="min"] {
69
- text-align: left;
70
- transform: translateX(-1rem);
71
- }
72
-
73
- [data-price-range-value-label="max"] {
74
- text-align: right;
75
- transform: translateX(calc(-100% + 1.25rem));
76
- }
77
-
78
- // Thumb styles for Webkit based browsers (Chrome, Edge)
79
- [data-slider-thumb],
80
- [data-slider-thumb]::-webkit-slider-thumb {
81
- width: var(--fs-price-range-thumb-size);
82
- height: var(--fs-price-range-thumb-size);
83
- pointer-events: auto;
84
- cursor: col-resize;
85
- background-color: var(--fs-price-range-thumb-bkg-color);
86
- border: var(--fs-price-range-thumb-border-width) solid var(--fs-price-range-thumb-border-color);
87
- border-radius: var(--fs-price-range-thumb-border-radius);
88
- -webkit-tap-highlight-color: transparent;
89
- appearance: none;
90
- transition: var(--fs-price-range-transition-property) var(--fs-price-range-transition-timing) var(--fs-price-range-transition-function);
91
-
92
- &:hover {
93
- background-color: var(--fs-price-range-thumb-bkg-color-hover);
94
- border-color: var(--fs-price-range-thumb-border-color-hover);
95
- }
96
- }
97
-
98
- // Thumb styles for Mozilla
99
- [data-slider-thumb]::-moz-range-thumb {
100
- width: var(--fs-price-range-thumb-size);
101
- height: var(--fs-price-range-thumb-size);
102
- pointer-events: auto;
103
- cursor: col-resize;
104
- background-color: var(--fs-price-range-thumb-bkg-color);
105
- border: var(--fs-price-range-thumb-border-width) solid var(--fs-price-range-thumb-border-color);
106
- border-radius: var(--fs-price-range-thumb-radius);
107
- }
108
-
109
- [data-slider-thumb] {
110
- position: absolute;
111
- width: inherit;
112
- height: 0;
113
- margin: calc(var(--fs-price-range-height) / 2) 0;
114
- pointer-events: none;
115
- border: none;
116
- }
117
-
118
- [data-slider-thumb="left"] {
119
- z-index: 1;
120
-
121
- &:hover + [data-price-range-value-label="min"] {
122
- opacity: 1;
123
- }
124
- }
125
-
126
- [data-slider-thumb="right"] {
127
- z-index: 2;
128
-
129
- &:hover + [data-price-range-value-label="max"] {
130
- opacity: 1;
131
- }
132
- }
133
-
134
- [data-price-range-values] {
135
- display: flex;
136
- justify-content: space-between;
137
- margin-top: var(--fs-spacing-3);
138
- margin-bottom: var(--fs-spacing-3);
139
- }
140
-
141
- [data-fs-price-range-inputs] {
142
- display: flex;
143
-
144
- [data-fs-input-field] {
145
- width: 50%;
146
-
147
- input:hover,
148
- input:focus-visible,
149
- input:focus {
150
- z-index: 1;
151
- + label { z-index: 1; }
152
- }
153
-
154
- &:first-of-type {
155
- margin-right: -1px;
156
-
157
- input {
158
- border-top-right-radius: 0;
159
- border-bottom-right-radius: 0;
160
- }
161
- }
162
-
163
- &:last-of-type input {
164
- border-top-left-radius: 0;
165
- border-bottom-left-radius: 0;
166
- }
167
- }
168
- }
169
-
170
- [data-fs-price-range-absolute-values] {
171
- display: flex;
172
- justify-content: space-between;
173
- margin-bottom: var(--fs-spacing-2);
174
- color: var(--fs-price-range-absolute-values-text-color);
175
- }
176
- }