@faststore/core 0.3.16 → 2.0.65-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/.storybook/storybook.css +1 -0
  2. package/.turbo/turbo-build.log +50 -0
  3. package/.turbo/turbo-lint.log +2 -0
  4. package/@generated/graphql/index.ts +27 -3
  5. package/@generated/graphql/persisted.json +1 -1
  6. package/CHANGELOG.md +127 -169
  7. package/README.md +2 -2
  8. package/cypress/integration/analytics.test.js +4 -4
  9. package/cypress/integration/cart.test.js +2 -2
  10. package/cypress/integration/plp.test.js +9 -9
  11. package/package.json +9 -10
  12. package/src/Layout.tsx +7 -2
  13. package/src/components/cart/CartItem/CartItem.tsx +30 -71
  14. package/src/components/cart/CartSidebar/CartSidebar.stories.mdx +1 -1
  15. package/src/components/cart/CartSidebar/CartSidebar.tsx +13 -17
  16. package/src/components/cart/CartSidebar/cart-sidebar.module.scss +2 -0
  17. package/src/components/common/Alert/Alert.tsx +6 -22
  18. package/src/components/common/Footer/Footer.stories.mdx +1 -1
  19. package/src/components/common/Footer/Footer.tsx +5 -38
  20. package/src/components/common/Footer/FooterFlags.tsx +23 -0
  21. package/src/components/common/Footer/FooterLinks.tsx +16 -12
  22. package/src/components/common/Footer/footer.module.scss +2 -28
  23. package/src/components/common/Footer/index.ts +1 -0
  24. package/src/components/common/Navbar/NavLinks.stories.mdx +1 -1
  25. package/src/components/common/Navbar/Navbar.stories.mdx +1 -1
  26. package/src/components/common/Navbar/Navbar.tsx +1 -1
  27. package/src/components/common/Navbar/NavbarSlider.stories.mdx +1 -1
  28. package/src/components/common/Navbar/NavbarSlider.tsx +2 -2
  29. package/src/components/common/Toast/Toast.tsx +1 -1
  30. package/src/components/product/ProductCard/ProductCard.tsx +44 -59
  31. package/src/components/product/ProductGrid/ProductGrid.tsx +7 -1
  32. package/src/components/regionalization/Regionalization.stories.mdx +24 -6
  33. package/src/components/regionalization/RegionalizationBar/RegionalizationBar.stories.mdx +1 -1
  34. package/src/components/regionalization/RegionalizationBar/RegionalizationBar.tsx +1 -1
  35. package/src/components/regionalization/RegionalizationButton/RegionalizationButton.tsx +1 -1
  36. package/src/components/regionalization/RegionalizationModal/RegionalizationModal.stories.mdx +17 -4
  37. package/src/components/regionalization/RegionalizationModal/RegionalizationModal.tsx +4 -5
  38. package/src/components/regionalization/RegionalizationModal/RegionalizationModalContent.tsx +19 -26
  39. package/src/components/regionalization/RegionalizationModal/regionalization-modal-body.module.scss +25 -0
  40. package/src/components/search/Filter/Facets.stories.mdx +10 -10
  41. package/src/components/search/Filter/Facets.tsx +69 -61
  42. package/src/components/search/Filter/Filter.stories.mdx +1 -1
  43. package/src/components/search/Filter/Filter.tsx +1 -1
  44. package/src/components/search/Filter/FilterSlider.stories.mdx +1 -1
  45. package/src/components/search/Filter/FilterSlider.tsx +2 -2
  46. package/src/components/search/Filter/facets.module.scss +16 -16
  47. package/src/components/search/Search.stories.mdx +28 -24
  48. package/src/components/search/SearchDropdown/SearchDropdown.stories.mdx +0 -1
  49. package/src/components/search/SearchInput/SearchInput.stories.mdx +0 -1
  50. package/src/components/search/SearchTop/SearchTop.stories.mdx +0 -1
  51. package/src/components/sections/Newsletter/Newsletter.stories.mdx +1 -1
  52. package/src/components/sections/Newsletter/Newsletter.tsx +1 -1
  53. package/src/components/sections/ProducDetailsContent/ProductDetailsContent.tsx +146 -146
  54. package/src/components/sections/ProductDetails/ProductDetails.tsx +4 -4
  55. package/src/components/sections/ProductGallery/ProductGallery.tsx +18 -18
  56. package/src/components/sections/ProductShelf/ProductShelf.tsx +10 -2
  57. package/src/components/sections/ProductTiles/ProductTiles.tsx +2 -2
  58. package/src/components/skeletons/FilterSkeleton/FilterSkeleton.stories.mdx +1 -1
  59. package/src/components/skeletons/FilterSkeleton/FilterSkeleton.tsx +20 -8
  60. package/src/components/skeletons/FilterSkeleton/filter-skeleton.module.scss +2 -2
  61. package/src/components/skeletons/ProductCardSkeleton/ProductCardSkeleton.stories.mdx +6 -69
  62. package/src/components/skeletons/ProductCardSkeleton/ProductCardSkeleton.tsx +36 -9
  63. package/src/components/skeletons/ProductCardSkeleton/product-card-skeleton.module.scss +16 -55
  64. package/src/components/skeletons/ProductGridSkeleton/ProductGridSkeleton.tsx +3 -1
  65. package/src/components/skeletons/ProductShelfSkeleton/ProductShelfSkeleton.tsx +3 -1
  66. package/src/components/skeletons/ProductTilesSkeleton/ProductTileSkeleton/ProductTileSkeleton.tsx +18 -17
  67. package/src/components/skeletons/ProductTilesSkeleton/ProductTileSkeleton/product-tile-skeleton.module.scss +37 -174
  68. package/src/components/skeletons/ProductTilesSkeleton/ProductTilesSkeleton.tsx +18 -3
  69. package/src/components/ui/Breadcrumb/Breadcrumb.tsx +17 -16
  70. package/src/components/ui/Gift/Gift.tsx +18 -27
  71. package/src/components/ui/SkuSelector/sku-selector.module.scss +1 -1
  72. package/src/components/ui/SlideOver/SlideOver.stories.mdx +2 -2
  73. package/src/components/ui/SlideOver/SlideOver.tsx +1 -0
  74. package/src/components/ui/Tiles/Tiles.stories.mdx +1 -3
  75. package/src/components/ui/Tiles/tiles.module.scss +11 -13
  76. package/src/components/ui/Toast/Toast.stories.mdx +1 -1
  77. package/src/components/ui/Toast/Toast.tsx +1 -1
  78. package/src/pages/_app.tsx +1 -1
  79. package/src/sdk/cart/index.ts +5 -0
  80. package/src/sdk/cart/useBuyButton.ts +1 -1
  81. package/src/sdk/cart/useCartToggleButton.ts +1 -1
  82. package/src/styles/vendors/include-media.scss +1 -1
  83. package/tsconfig.json +4 -6
  84. package/.eslintrc.json +0 -3
  85. package/.github/CODEOWNERS +0 -2
  86. package/.github/workflows/release.yml +0 -42
  87. package/.release-it.json +0 -32
  88. package/src/components/cart/CartItem/cart-item.module.scss +0 -68
  89. package/src/components/product/ProductCard/product-card.module.scss +0 -254
  90. package/src/components/regionalization/RegionalizationModal/regionalization-modal-content.module.scss +0 -79
  91. package/src/components/skeletons/Shimmer/Shimmer.tsx +0 -11
  92. package/src/components/skeletons/Shimmer/index.ts +0 -1
  93. package/src/components/skeletons/Shimmer/shimmer.module.scss +0 -43
  94. package/src/components/skeletons/Skeleton/Skeleton.tsx +0 -49
  95. package/src/components/skeletons/Skeleton/index.ts +0 -1
  96. package/src/components/skeletons/Skeleton/skeleton.module.scss +0 -77
  97. package/src/components/skeletons/Skeletons.stories.mdx +0 -177
  98. package/src/components/ui/Accordion/Accordion.stories.mdx +0 -222
  99. package/src/components/ui/Accordion/Accordion.tsx +0 -39
  100. package/src/components/ui/Accordion/AccordionItem.stories.mdx +0 -116
  101. package/src/components/ui/Accordion/AccordionItem.tsx +0 -82
  102. package/src/components/ui/Accordion/accordion.module.scss +0 -65
  103. package/src/components/ui/Accordion/index.ts +0 -2
  104. package/src/components/ui/Alert/Alert.stories.mdx +0 -164
  105. package/src/components/ui/Alert/Alert.tsx +0 -81
  106. package/src/components/ui/Alert/alert.module.scss +0 -93
  107. package/src/components/ui/Alert/index.ts +0 -1
  108. package/src/components/ui/Dropdown/Dropdown.stories.mdx +0 -232
  109. package/src/components/ui/Dropdown/Dropdown.tsx +0 -12
  110. package/src/components/ui/Dropdown/DropdownButton.tsx +0 -20
  111. package/src/components/ui/Dropdown/DropdownItem.stories.mdx +0 -139
  112. package/src/components/ui/Dropdown/DropdownItem.tsx +0 -26
  113. package/src/components/ui/Dropdown/DropdownMenu.stories.mdx +0 -115
  114. package/src/components/ui/Dropdown/DropdownMenu.tsx +0 -34
  115. package/src/components/ui/Dropdown/dropdown.module.scss +0 -101
  116. package/src/components/ui/Dropdown/index.ts +0 -4
  117. package/src/components/ui/Gift/Gift.stories.mdx +0 -99
  118. package/src/components/ui/Gift/gift.module.scss +0 -94
  119. package/src/components/ui/Modal/Modal.stories.mdx +0 -144
  120. package/src/components/ui/Modal/Modal.tsx +0 -43
  121. package/src/components/ui/Modal/index.ts +0 -1
  122. package/src/components/ui/Modal/modal.module.scss +0 -46
  123. package/src/components/ui/PriceRange/PriceRange.stories.mdx +0 -192
  124. package/src/components/ui/PriceRange/PriceRange.tsx +0 -140
  125. package/src/components/ui/PriceRange/index.ts +0 -1
  126. package/src/components/ui/PriceRange/price-range.module.scss +0 -176
  127. package/src/components/ui/ProductTitle/ProductTitle.stories.mdx +0 -105
  128. package/src/components/ui/ProductTitle/ProductTitle.tsx +0 -11
  129. package/src/components/ui/ProductTitle/index.ts +0 -1
  130. package/src/components/ui/ProductTitle/product-title.module.scss +0 -48
  131. package/src/components/ui/QuantitySelector/QuantitySelector.stories.mdx +0 -246
  132. package/src/components/ui/QuantitySelector/QuantitySelector.tsx +0 -103
  133. package/src/components/ui/QuantitySelector/index.ts +0 -1
  134. package/src/components/ui/QuantitySelector/quantity-selector.module.scss +0 -155
  135. package/src/sdk/ui/Provider.tsx +0 -151
  136. package/src/sdk/ui/useFadeEffect.ts +0 -21
@@ -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
- }
@@ -1,151 +0,0 @@
1
- import { createContext, useContext, useMemo, useReducer } from 'react'
2
- import type { PropsWithChildren } from 'react'
3
-
4
- interface Toast {
5
- message: string
6
- status: 'ERROR' | 'WARNING' | 'INFO'
7
- title?: string
8
- icon?: string
9
- }
10
-
11
- interface State {
12
- /** Cart sidebar */
13
- cart: boolean
14
- /** Region modal */
15
- modal: boolean
16
- /** Menu slider */
17
- navbar: boolean
18
- /** Search page filter slider */
19
- filter: boolean
20
- toasts: Toast[]
21
- }
22
-
23
- type UIElement = 'navbar' | 'cart' | 'modal' | 'filter'
24
-
25
- type Action =
26
- | {
27
- type: 'open'
28
- payload: UIElement
29
- }
30
- | {
31
- type: 'close'
32
- payload: UIElement
33
- }
34
- | {
35
- type: 'pushToast'
36
- payload: Toast
37
- }
38
- | {
39
- type: 'popToast'
40
- }
41
-
42
- const reducer = (state: State, action: Action): State => {
43
- const { type } = action
44
-
45
- switch (type) {
46
- case 'open': {
47
- const { payload } = action
48
-
49
- document.body.classList.add('no-scroll')
50
-
51
- return {
52
- ...state,
53
- [payload]: true,
54
- }
55
- }
56
-
57
- case 'close': {
58
- const { payload } = action
59
-
60
- document.body.classList.remove('no-scroll')
61
-
62
- return {
63
- ...state,
64
- [payload]: false,
65
- }
66
- }
67
-
68
- case 'pushToast': {
69
- return {
70
- ...state,
71
- toasts: [...state.toasts, action.payload],
72
- }
73
- }
74
-
75
- case 'popToast': {
76
- return {
77
- ...state,
78
- toasts: state.toasts.slice(1),
79
- }
80
- }
81
-
82
- default:
83
- throw new Error(`Action ${type} not implemented`)
84
- }
85
- }
86
-
87
- const initializer = (): State => ({
88
- cart: false,
89
- modal: false,
90
- navbar: false,
91
- filter: false,
92
- toasts: [],
93
- })
94
-
95
- interface Context extends State {
96
- closeNavbar: () => void
97
- openNavbar: () => void
98
- closeFilter: () => void
99
- openFilter: () => void
100
- openCart: () => void
101
- closeCart: () => void
102
- openModal: () => void
103
- closeModal: () => void
104
- pushToast: (data: Toast) => void
105
- popToast: () => void
106
- }
107
-
108
- const UIContext = createContext<Context | undefined>(undefined)
109
-
110
- function UIProvider({ children }: PropsWithChildren) {
111
- const [ui, dispatch] = useReducer(reducer, undefined, initializer)
112
-
113
- const callbacks = useMemo(
114
- () => ({
115
- openFilter: () => dispatch({ type: 'open', payload: 'filter' }),
116
- closeFilter: () => dispatch({ type: 'close', payload: 'filter' }),
117
- openNavbar: () => dispatch({ type: 'open', payload: 'navbar' }),
118
- closeNavbar: () => dispatch({ type: 'close', payload: 'navbar' }),
119
- openCart: () => dispatch({ type: 'open', payload: 'cart' }),
120
- closeCart: () => dispatch({ type: 'close', payload: 'cart' }),
121
- openModal: () => dispatch({ type: 'open', payload: 'modal' }),
122
- closeModal: () => dispatch({ type: 'close', payload: 'modal' }),
123
- pushToast: (toast: Toast) =>
124
- dispatch({ type: 'pushToast', payload: toast }),
125
- popToast: () => dispatch({ type: 'popToast' }),
126
- }),
127
- []
128
- )
129
-
130
- const value = useMemo(
131
- () => ({
132
- ...ui,
133
- ...callbacks,
134
- }),
135
- [callbacks, ui]
136
- )
137
-
138
- return <UIContext.Provider value={value}>{children}</UIContext.Provider>
139
- }
140
-
141
- export function useUI() {
142
- const context = useContext(UIContext)
143
-
144
- if (context === undefined) {
145
- throw new Error('Missing UI context on React tree')
146
- }
147
-
148
- return context
149
- }
150
-
151
- export default UIProvider
@@ -1,21 +0,0 @@
1
- import { useState, useCallback, useEffect } from 'react'
2
-
3
- export const useFadeEffect = () => {
4
- const [fade, setFade] = useState<'in' | 'out'>('out')
5
- const fadeOut = useCallback(() => setFade('out'), [])
6
- const fadeIn = useCallback(() => setFade('in'), [])
7
-
8
- useEffect(() => {
9
- fadeIn()
10
-
11
- return () => {
12
- fadeOut()
13
- }
14
- }, [fadeIn, fadeOut])
15
-
16
- return {
17
- fade,
18
- fadeIn,
19
- fadeOut,
20
- }
21
- }