@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.
- package/CHANGELOG.md +29 -0
- package/cypress/integration/analytics.test.js +3 -3
- package/cypress/integration/plp.test.js +1 -1
- package/package.json +4 -4
- package/src/Layout.tsx +6 -1
- package/src/components/cart/CartItem/CartItem.tsx +2 -2
- package/src/components/cart/CartSidebar/CartSidebar.tsx +5 -6
- package/src/components/cart/CartSidebar/cart-sidebar.module.scss +2 -0
- package/src/components/common/Alert/Alert.tsx +6 -22
- package/src/components/common/Footer/Footer.stories.mdx +1 -1
- package/src/components/common/Footer/FooterLinks.tsx +16 -12
- package/src/components/search/Filter/Facets.stories.mdx +9 -9
- package/src/components/search/Filter/Facets.tsx +69 -61
- package/src/components/search/Filter/facets.module.scss +16 -16
- package/src/components/search/Search.stories.mdx +28 -24
- package/src/components/search/SearchDropdown/SearchDropdown.stories.mdx +0 -1
- package/src/components/search/SearchInput/SearchInput.stories.mdx +0 -1
- package/src/components/search/SearchTop/SearchTop.stories.mdx +0 -1
- package/src/components/sections/ProducDetailsContent/ProductDetailsContent.tsx +147 -149
- package/src/components/sections/ProductDetails/ProductDetails.tsx +2 -2
- package/src/components/ui/Breadcrumb/Breadcrumb.tsx +17 -16
- package/src/components/ui/Gift/Gift.tsx +7 -13
- package/src/components/ui/ShippingSimulation/ShippingSimulation.stories.mdx +0 -27
- package/src/components/ui/ShippingSimulation/ShippingSimulation.tsx +6 -13
- package/src/components/ui/ShippingSimulation/shipping-simulation.module.scss +0 -39
- package/src/components/ui/SkuSelector/sku-selector.module.scss +1 -1
- package/tsconfig.json +1 -1
- package/src/components/sections/ProducDetailsContent/product-details-content.module.scss +0 -41
- package/src/components/ui/Accordion/Accordion.stories.mdx +0 -222
- package/src/components/ui/Accordion/Accordion.tsx +0 -39
- package/src/components/ui/Accordion/AccordionItem.stories.mdx +0 -116
- package/src/components/ui/Accordion/AccordionItem.tsx +0 -82
- package/src/components/ui/Accordion/accordion.module.scss +0 -65
- package/src/components/ui/Accordion/index.ts +0 -2
- package/src/components/ui/Alert/Alert.stories.mdx +0 -164
- package/src/components/ui/Alert/Alert.tsx +0 -81
- package/src/components/ui/Alert/alert.module.scss +0 -93
- package/src/components/ui/Alert/index.ts +0 -1
- package/src/components/ui/Dropdown/Dropdown.stories.mdx +0 -232
- package/src/components/ui/Dropdown/Dropdown.tsx +0 -12
- package/src/components/ui/Dropdown/DropdownButton.tsx +0 -20
- package/src/components/ui/Dropdown/DropdownItem.stories.mdx +0 -139
- package/src/components/ui/Dropdown/DropdownItem.tsx +0 -26
- package/src/components/ui/Dropdown/DropdownMenu.stories.mdx +0 -115
- package/src/components/ui/Dropdown/DropdownMenu.tsx +0 -34
- package/src/components/ui/Dropdown/dropdown.module.scss +0 -101
- package/src/components/ui/Dropdown/index.ts +0 -4
- package/src/components/ui/Gift/Gift.stories.mdx +0 -99
- package/src/components/ui/Gift/gift.module.scss +0 -94
- package/src/components/ui/PriceRange/PriceRange.stories.mdx +0 -192
- package/src/components/ui/PriceRange/PriceRange.tsx +0 -140
- package/src/components/ui/PriceRange/index.ts +0 -1
- package/src/components/ui/PriceRange/price-range.module.scss +0 -176
- package/src/components/ui/QuantitySelector/QuantitySelector.stories.mdx +0 -246
- package/src/components/ui/QuantitySelector/QuantitySelector.tsx +0 -103
- package/src/components/ui/QuantitySelector/index.ts +0 -1
- package/src/components/ui/QuantitySelector/quantity-selector.module.scss +0 -155
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,35 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Conventional Changelog](https://github.com/conventional-changelog/conventional-changelog),
|
|
6
6
|
and this project adheres to [Calendar Versioning](https://calver.org/).
|
|
7
7
|
|
|
8
|
+
### [0.3.17](https://github.com/vtex-sites/nextjs.store/compare/0.3.16...0.3.17) (2023-01-23)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* Replace `Accordion` FSUI ([#336](https://github.com/vtex-sites/nextjs.store/issues/336)) ([1ebe103](https://github.com/vtex-sites/nextjs.store/commit/1ebe1039a92ab977ba5de1b91f112342973706eb))
|
|
14
|
+
* Replace `Dropdown` FSUI ([#339](https://github.com/vtex-sites/nextjs.store/issues/339)) ([3a541a4](https://github.com/vtex-sites/nextjs.store/commit/3a541a4aab72a1e289a6716ba9c742771905fa7a))
|
|
15
|
+
* Replace `RadioGroup` FSUI ([#345](https://github.com/vtex-sites/nextjs.store/issues/345)) ([2af5559](https://github.com/vtex-sites/nextjs.store/commit/2af5559a8e4b005b78075edecf9c40da1e7e1a2b))
|
|
16
|
+
* Replaces `PriceRange` FSUI ([#348](https://github.com/vtex-sites/nextjs.store/issues/348)) ([546ee17](https://github.com/vtex-sites/nextjs.store/commit/546ee17c0a00e3094f82d8e05c3e38b84114488f))
|
|
17
|
+
* Replaces `QuantitySelector` FSUI ([#344](https://github.com/vtex-sites/nextjs.store/issues/344)) ([6b896fc](https://github.com/vtex-sites/nextjs.store/commit/6b896fcff3e5fdb4841194b05b2a310518eb3857))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* Evergreen `starter.store` build errors. ([#349](https://github.com/vtex-sites/nextjs.store/issues/349)) ([0eedd76](https://github.com/vtex-sites/nextjs.store/commit/0eedd76c65edae710971e3a985065dc30f4de19d))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Chores
|
|
26
|
+
|
|
27
|
+
* Replaces `Alert` FSUI ([#343](https://github.com/vtex-sites/nextjs.store/issues/343)) ([8b3d6b2](https://github.com/vtex-sites/nextjs.store/commit/8b3d6b268da572614334554400ea03129445f787))
|
|
28
|
+
* Replaces `Gift` FSUI ([#347](https://github.com/vtex-sites/nextjs.store/issues/347)) ([7fa049e](https://github.com/vtex-sites/nextjs.store/commit/7fa049e890b0bc6c9e4c3a4911c376014b239321))
|
|
29
|
+
|
|
30
|
+
### [0.3.16](https://github.com/vtex-sites/nextjs.store/compare/0.3.15...0.3.16) (2023-01-09)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Chores
|
|
34
|
+
|
|
35
|
+
* Replace `Table` using FSUI ([#341](https://github.com/vtex-sites/nextjs.store/issues/341)) ([cccf3d5](https://github.com/vtex-sites/nextjs.store/commit/cccf3d5cb1fccc1440b2b019ebc06ddc474fb25f))
|
|
36
|
+
|
|
8
37
|
### 0.3.15 (2023-01-03)
|
|
9
38
|
|
|
10
39
|
|
|
@@ -104,7 +104,7 @@ describe('add_to_cart event', () => {
|
|
|
104
104
|
testAddToCartEvent({ skuId, numberOfEvents: 1 })
|
|
105
105
|
|
|
106
106
|
cy.get(
|
|
107
|
-
'[data-testid=cart-item] [data-testid=
|
|
107
|
+
'[data-testid=cart-item] [data-testid=fs-quantity-selector-right-button]'
|
|
108
108
|
)
|
|
109
109
|
.click()
|
|
110
110
|
.then(() => {
|
|
@@ -193,7 +193,7 @@ describe('remove_from_cart event', () => {
|
|
|
193
193
|
cy.itemsInCart(0)
|
|
194
194
|
|
|
195
195
|
// Add item to cart
|
|
196
|
-
cy.get('[data-testid=
|
|
196
|
+
cy.get('[data-testid=fs-quantity-selector-right-button]')
|
|
197
197
|
.click()
|
|
198
198
|
.then(() => {
|
|
199
199
|
cy.getById('buy-button')
|
|
@@ -209,7 +209,7 @@ describe('remove_from_cart event', () => {
|
|
|
209
209
|
|
|
210
210
|
// Remove the added item
|
|
211
211
|
cy.get(
|
|
212
|
-
'[data-testid=cart-item] [data-testid=
|
|
212
|
+
'[data-testid=cart-item] [data-testid=fs-quantity-selector-left-button]'
|
|
213
213
|
)
|
|
214
214
|
.click()
|
|
215
215
|
.then(() => {
|
|
@@ -23,7 +23,7 @@ describe('Search page Filters and Sorting options', () => {
|
|
|
23
23
|
cy.getById('open-filter-button')
|
|
24
24
|
.click()
|
|
25
25
|
.get(
|
|
26
|
-
`[data-testid=mobile-store-filter-accordion
|
|
26
|
+
`[data-testid=mobile-store-filter-accordion][data-type=StoreFacetBoolean]>[data-testid=mobile-store-filter-accordion-button]`
|
|
27
27
|
)
|
|
28
28
|
.first()
|
|
29
29
|
.click()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"browserslist": "supports es6-module and not dead",
|
|
6
6
|
"scripts": {
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"@envelop/parser-cache": "^2.2.0",
|
|
32
32
|
"@envelop/validation-cache": "^2.2.0",
|
|
33
33
|
"@faststore/api": "^2.0.3-alpha.0",
|
|
34
|
-
"@faststore/components": "2.0.
|
|
34
|
+
"@faststore/components": "^2.0.54-alpha.0",
|
|
35
35
|
"@faststore/graphql-utils": "^2.0.3-alpha.0",
|
|
36
36
|
"@faststore/sdk": "^2.0.3-alpha.0",
|
|
37
|
-
"@faststore/ui": "2.0.
|
|
37
|
+
"@faststore/ui": "^2.0.54-alpha.0",
|
|
38
38
|
"@types/react": "^18.0.14",
|
|
39
39
|
"@vtex/client-cms": "^0.2.12",
|
|
40
40
|
"autoprefixer": "^10.4.0",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"cypress-axe": "^0.13.0",
|
|
81
81
|
"cypress-wait-until": "^1.7.2",
|
|
82
82
|
"dotenv": "^8.2.0",
|
|
83
|
-
"eslint": "^
|
|
83
|
+
"eslint": "^7.32.0",
|
|
84
84
|
"eslint-config-next": "^13.0.7",
|
|
85
85
|
"husky": "^5.2.0",
|
|
86
86
|
"is-ci": "^3.0.0",
|
package/src/Layout.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import Navbar from 'src/components/common/Navbar'
|
|
|
7
7
|
import Toast from 'src/components/common/Toast'
|
|
8
8
|
import RegionalizationBar from 'src/components/regionalization/RegionalizationBar'
|
|
9
9
|
import { useUI } from 'src/sdk/ui/Provider'
|
|
10
|
+
import Icon from 'src/components/ui/Icon'
|
|
10
11
|
|
|
11
12
|
const CartSidebar = lazy(() => import('src/components/cart/CartSidebar'))
|
|
12
13
|
const RegionModal = lazy(
|
|
@@ -18,7 +19,11 @@ function Layout({ children }: PropsWithChildren) {
|
|
|
18
19
|
|
|
19
20
|
return (
|
|
20
21
|
<>
|
|
21
|
-
<Alert
|
|
22
|
+
<Alert
|
|
23
|
+
icon={<Icon name="Bell" />}
|
|
24
|
+
link={{ children: 'Buy now', href: '/office', target: '_self' }}
|
|
25
|
+
dismissible
|
|
26
|
+
>
|
|
22
27
|
Get 10% off today: <span>NEW10</span>
|
|
23
28
|
</Alert>
|
|
24
29
|
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
CartItemContent as UICartItemContent,
|
|
9
9
|
CartItemImage as UICartItemImage,
|
|
10
10
|
Button as UIButton,
|
|
11
|
+
QuantitySelector as UIQuantitySelector,
|
|
11
12
|
} from '@faststore/ui'
|
|
12
13
|
import { useCallback, useMemo } from 'react'
|
|
13
14
|
import type {
|
|
@@ -19,7 +20,6 @@ import type {
|
|
|
19
20
|
import Icon from 'src/components/ui/Icon'
|
|
20
21
|
import { Image } from 'src/components/ui/Image'
|
|
21
22
|
import Price from 'src/components/ui/Price'
|
|
22
|
-
import QuantitySelector from 'src/components/ui/QuantitySelector'
|
|
23
23
|
import { cartStore } from 'src/sdk/cart'
|
|
24
24
|
import { useRemoveButton } from 'src/sdk/cart/useRemoveButton'
|
|
25
25
|
import { useFormattedPrice } from 'src/sdk/product/useFormattedPrice'
|
|
@@ -144,7 +144,7 @@ function CartItem({ item, gift = false }: Props) {
|
|
|
144
144
|
>
|
|
145
145
|
Remove
|
|
146
146
|
</UIButton>
|
|
147
|
-
<
|
|
147
|
+
<UIQuantitySelector
|
|
148
148
|
min={1}
|
|
149
149
|
initial={item.quantity}
|
|
150
150
|
onChange={onQuantityChange}
|
|
@@ -4,11 +4,12 @@ import {
|
|
|
4
4
|
IconButton as UIIconButton,
|
|
5
5
|
Button as UIButton,
|
|
6
6
|
Badge as UIBadge,
|
|
7
|
+
Alert as UIAlert,
|
|
7
8
|
} from '@faststore/ui'
|
|
9
|
+
|
|
8
10
|
import { useEffect } from 'react'
|
|
9
11
|
import type { ViewCartEvent, CurrencyCode } from '@faststore/sdk'
|
|
10
12
|
|
|
11
|
-
import Alert from 'src/components/ui/Alert'
|
|
12
13
|
import Icon from 'src/components/ui/Icon'
|
|
13
14
|
import SlideOver from 'src/components/ui/SlideOver'
|
|
14
15
|
import { useCart } from 'src/sdk/cart'
|
|
@@ -81,9 +82,9 @@ function CartSidebar() {
|
|
|
81
82
|
onClick={fadeOut}
|
|
82
83
|
/>
|
|
83
84
|
</header>
|
|
84
|
-
<
|
|
85
|
+
<UIAlert icon={<Icon name="Truck" />}>
|
|
85
86
|
Free shipping starts at $300
|
|
86
|
-
</
|
|
87
|
+
</UIAlert>
|
|
87
88
|
|
|
88
89
|
{isEmpty ? (
|
|
89
90
|
<EmptyCart onDismiss={fadeOut} />
|
|
@@ -99,9 +100,7 @@ function CartSidebar() {
|
|
|
99
100
|
|
|
100
101
|
{gifts.length > 0 && (
|
|
101
102
|
<>
|
|
102
|
-
<
|
|
103
|
-
Gifts
|
|
104
|
-
</Alert>
|
|
103
|
+
<UIAlert icon={<Icon name="Gift" />}>Gifts</UIAlert>
|
|
105
104
|
<UIList data-fs-cart-sidebar-list>
|
|
106
105
|
{gifts.map((item) => (
|
|
107
106
|
<li key={item.id}>
|
|
@@ -1,30 +1,17 @@
|
|
|
1
1
|
import { useCallback, useState } from 'react'
|
|
2
2
|
import type { ReactNode, PropsWithChildren } from 'react'
|
|
3
3
|
|
|
4
|
-
import UIAlert from '
|
|
4
|
+
import { Alert as UIAlert, AlertProps } from '@faststore/ui'
|
|
5
5
|
import { mark } from 'src/sdk/tests/mark'
|
|
6
|
-
import Icon from 'src/components/ui/Icon'
|
|
7
6
|
|
|
8
|
-
interface Props {
|
|
9
|
-
icon: string
|
|
7
|
+
interface Props extends AlertProps {
|
|
10
8
|
/**
|
|
11
9
|
* For CMS integration purposes, should be used to pass content through it
|
|
12
10
|
* instead pass through children
|
|
13
11
|
*/
|
|
14
12
|
content?: ReactNode
|
|
15
|
-
link?: {
|
|
16
|
-
to: string
|
|
17
|
-
text: string
|
|
18
|
-
}
|
|
19
|
-
dismissible: boolean
|
|
20
13
|
}
|
|
21
|
-
function Alert({
|
|
22
|
-
icon,
|
|
23
|
-
content,
|
|
24
|
-
link,
|
|
25
|
-
dismissible = false,
|
|
26
|
-
children,
|
|
27
|
-
}: PropsWithChildren<Props>) {
|
|
14
|
+
function Alert(args: PropsWithChildren<Props>) {
|
|
28
15
|
const [displayAlert, setDisplayAlert] = useState(true)
|
|
29
16
|
|
|
30
17
|
const onAlertClose = useCallback(
|
|
@@ -36,13 +23,10 @@ function Alert({
|
|
|
36
23
|
return null
|
|
37
24
|
}
|
|
38
25
|
|
|
26
|
+
const { content, children, ...otherProps } = args
|
|
27
|
+
|
|
39
28
|
return (
|
|
40
|
-
<UIAlert
|
|
41
|
-
icon={<Icon name={icon} width={24} height={24} />}
|
|
42
|
-
dismissible={dismissible}
|
|
43
|
-
onClose={onAlertClose}
|
|
44
|
-
link={link}
|
|
45
|
-
>
|
|
29
|
+
<UIAlert onClose={onAlertClose} {...otherProps}>
|
|
46
30
|
{content ?? children}
|
|
47
31
|
</UIAlert>
|
|
48
32
|
)
|
|
@@ -35,7 +35,7 @@ The `Footer` is the final section of every page and has all the meaningful links
|
|
|
35
35
|
|
|
36
36
|
## Overview
|
|
37
37
|
|
|
38
|
-
Footer section is made with `FooterLinks`, [Incentives](?path=/docs/organisms-incentives--incentives), [Links](?path=/docs/atoms-link--default),
|
|
38
|
+
Footer section is made with `FooterLinks`, [Incentives](?path=/docs/organisms-incentives--incentives), [Links](?path=/docs/atoms-link--default), Accordion, and [PaymentMethods](https://www.faststore.dev/reference/ui/molecules/PaymentMethods) (from FastStore UI).
|
|
39
39
|
|
|
40
40
|
---
|
|
41
41
|
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
List as UIList,
|
|
4
|
+
Accordion as UIAccordion,
|
|
5
|
+
AccordionItem as UIAccordionItem,
|
|
6
|
+
AccordionButton as UIAccordionButton,
|
|
7
|
+
AccordionPanel as UIAccordionPanel,
|
|
8
|
+
} from '@faststore/ui'
|
|
3
9
|
|
|
4
10
|
import Link from 'src/components/ui/Link'
|
|
5
|
-
import Accordion, { AccordionItem } from 'src/components/ui/Accordion'
|
|
6
11
|
|
|
7
12
|
import styles from './footer.module.scss'
|
|
8
13
|
|
|
@@ -125,17 +130,16 @@ function FooterLinks() {
|
|
|
125
130
|
return (
|
|
126
131
|
<section className={styles.fsFooter} data-fs-footer-links>
|
|
127
132
|
<div className="display-mobile">
|
|
128
|
-
<
|
|
129
|
-
{links.map((section
|
|
130
|
-
<
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
</AccordionItem>
|
|
133
|
+
<UIAccordion indices={indicesExpanded} onChange={onChange}>
|
|
134
|
+
{links.map((section) => (
|
|
135
|
+
<UIAccordionItem key={section.title}>
|
|
136
|
+
<UIAccordionButton>{section.title}</UIAccordionButton>
|
|
137
|
+
<UIAccordionPanel>
|
|
138
|
+
<LinksList items={section.items} />
|
|
139
|
+
</UIAccordionPanel>
|
|
140
|
+
</UIAccordionItem>
|
|
137
141
|
))}
|
|
138
|
-
</
|
|
142
|
+
</UIAccordion>
|
|
139
143
|
</div>
|
|
140
144
|
|
|
141
145
|
<div className="hidden-mobile">
|
|
@@ -134,7 +134,7 @@ Facets represent the <code>Filter</code> details and allow users to refine their
|
|
|
134
134
|
|
|
135
135
|
## Overview
|
|
136
136
|
|
|
137
|
-
The `Facets` component uses the
|
|
137
|
+
The `Facets` component uses the Accordion, [Checkbox](?path=/docs/atoms-checkbox--overview-default), PriceRange, and [Badge](?path=/docs/molecules-badge--default) components.
|
|
138
138
|
|
|
139
139
|
---
|
|
140
140
|
|
|
@@ -194,30 +194,30 @@ The `Facets` component uses the [Accordion](?path=/docs/molecules-accordion-over
|
|
|
194
194
|
|
|
195
195
|
<TokenTable>
|
|
196
196
|
<TokenRow
|
|
197
|
-
token="--fs-facets-accordion-
|
|
197
|
+
token="--fs-facets-accordion-button-text-size"
|
|
198
198
|
value="var(--fs-text-size-lead)"
|
|
199
199
|
/>
|
|
200
200
|
<TokenRow
|
|
201
|
-
token="--fs-facets-accordion-
|
|
201
|
+
token="--fs-facets-accordion-button-text-weight"
|
|
202
202
|
value="var(--fs-text-weight-regular)"
|
|
203
203
|
/>
|
|
204
|
-
<TokenRow token="--fs-facets-accordion-
|
|
204
|
+
<TokenRow token="--fs-facets-accordion-button-line-height" value="1.5" />
|
|
205
205
|
<TokenDivider />
|
|
206
206
|
<TokenRow
|
|
207
|
-
token="--fs-facets-accordion-
|
|
207
|
+
token="--fs-facets-accordion-button-text-weight-notebook"
|
|
208
208
|
value="var(--fs-text-size-2)"
|
|
209
209
|
/>
|
|
210
210
|
<TokenRow
|
|
211
|
-
token="--fs-facets-accordion-
|
|
211
|
+
token="--fs-facets-accordion-button-line-height-notebook"
|
|
212
212
|
value="1.25"
|
|
213
213
|
/>
|
|
214
214
|
<TokenRow
|
|
215
|
-
token="--fs-facets-accordion-
|
|
215
|
+
token="--fs-facets-accordion-button-padding-right-notebook"
|
|
216
216
|
value="var(--fs-spacing-4)"
|
|
217
217
|
/>
|
|
218
218
|
<TokenRow
|
|
219
|
-
token="--fs-facets-accordion-
|
|
220
|
-
value="var(--fs-facets-accordion-
|
|
219
|
+
token="--fs-facets-accordion-button-padding-left-notebook"
|
|
220
|
+
value="var(--fs-facets-accordion-button-padding-right-notebook)"
|
|
221
221
|
/>
|
|
222
222
|
</TokenTable>
|
|
223
223
|
|
|
@@ -3,14 +3,19 @@ import {
|
|
|
3
3
|
Label as UILabel,
|
|
4
4
|
List as UIList,
|
|
5
5
|
Badge as UIBadge,
|
|
6
|
+
Accordion as UIAccordion,
|
|
7
|
+
AccordionItem as UIAccordionItem,
|
|
8
|
+
AccordionButton as UIAccordionButton,
|
|
9
|
+
AccordionPanel as UIAccordionPanel,
|
|
10
|
+
PriceRange as UIPriceRange,
|
|
6
11
|
} from '@faststore/ui'
|
|
7
12
|
|
|
13
|
+
import { useFormattedPrice } from 'src/sdk/product/useFormattedPrice'
|
|
14
|
+
|
|
8
15
|
import type {
|
|
9
16
|
Filter_FacetsFragment,
|
|
10
17
|
IStoreSelectedFacet,
|
|
11
18
|
} from '@generated/graphql'
|
|
12
|
-
import Accordion, { AccordionItem } from 'src/components/ui/Accordion'
|
|
13
|
-
import PriceRange from 'src/components/ui/PriceRange'
|
|
14
19
|
|
|
15
20
|
import styles from './facets.module.scss'
|
|
16
21
|
|
|
@@ -58,80 +63,83 @@ function Facets({
|
|
|
58
63
|
<h2 className="text__title-mini-alt" data-fs-facets-title>
|
|
59
64
|
Filters
|
|
60
65
|
</h2>
|
|
61
|
-
<
|
|
62
|
-
|
|
66
|
+
<UIAccordion
|
|
67
|
+
indices={indicesExpanded}
|
|
63
68
|
onChange={onAccordionChange}
|
|
64
69
|
data-fs-facets-accordion
|
|
65
70
|
>
|
|
66
71
|
{facets.map((facet, index) => {
|
|
67
72
|
const isExpanded = indicesExpanded.has(index)
|
|
68
73
|
const { __typename: type, label } = facet
|
|
69
|
-
|
|
70
74
|
return (
|
|
71
|
-
<
|
|
75
|
+
<UIAccordionItem
|
|
72
76
|
key={`${label}-${index}`}
|
|
73
77
|
prefixId={testId}
|
|
74
78
|
testId={`${testId}-accordion`}
|
|
75
|
-
isExpanded={isExpanded}
|
|
76
|
-
buttonLabel={label}
|
|
77
79
|
data-type={type}
|
|
78
80
|
data-fs-facets-accordion-item
|
|
79
81
|
>
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
82
|
+
<UIAccordionButton testId={`${testId}-accordion-button`}>
|
|
83
|
+
{label}
|
|
84
|
+
</UIAccordionButton>
|
|
85
|
+
<UIAccordionPanel>
|
|
86
|
+
{type === 'StoreFacetBoolean' && isExpanded && (
|
|
87
|
+
<UIList data-fs-facets-list>
|
|
88
|
+
{facet.values.map((item) => {
|
|
89
|
+
const id = `${testId}-${facet.label}-${item.label}`
|
|
90
|
+
return (
|
|
91
|
+
<li key={id} data-fs-facets-list-item>
|
|
92
|
+
<UICheckbox
|
|
93
|
+
id={id}
|
|
94
|
+
checked={item.selected}
|
|
95
|
+
onChange={() =>
|
|
96
|
+
onFacetChange(
|
|
97
|
+
{ key: facet.key, value: item.value },
|
|
98
|
+
'BOOLEAN'
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
data-fs-facets-list-item-checkbox
|
|
102
|
+
data-testid={`${testId}-accordion-panel-checkbox`}
|
|
103
|
+
data-value={item.value}
|
|
104
|
+
data-quantity={item.quantity}
|
|
105
|
+
/>
|
|
106
|
+
<UILabel
|
|
107
|
+
htmlFor={id}
|
|
108
|
+
className="text__title-mini-alt"
|
|
109
|
+
data-fs-facets-list-item-label
|
|
110
|
+
>
|
|
111
|
+
{item.label}{' '}
|
|
112
|
+
<UIBadge data-fs-facets-list-item-badge>
|
|
113
|
+
{item.quantity}
|
|
114
|
+
</UIBadge>
|
|
115
|
+
</UILabel>
|
|
116
|
+
</li>
|
|
117
|
+
)
|
|
118
|
+
})}
|
|
119
|
+
</UIList>
|
|
120
|
+
)}
|
|
121
|
+
{type === 'StoreFacetRange' && isExpanded && (
|
|
122
|
+
<UIPriceRange
|
|
123
|
+
min={facet.min}
|
|
124
|
+
max={facet.max}
|
|
125
|
+
formatter={useFormattedPrice}
|
|
126
|
+
step={1}
|
|
127
|
+
onEnd={(v) =>
|
|
128
|
+
onFacetChange(
|
|
129
|
+
{
|
|
130
|
+
key: facet.key,
|
|
131
|
+
value: formatRange(v.min, v.max),
|
|
132
|
+
},
|
|
133
|
+
'RANGE'
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
/>
|
|
137
|
+
)}
|
|
138
|
+
</UIAccordionPanel>
|
|
139
|
+
</UIAccordionItem>
|
|
132
140
|
)
|
|
133
141
|
})}
|
|
134
|
-
</
|
|
142
|
+
</UIAccordion>
|
|
135
143
|
</div>
|
|
136
144
|
)
|
|
137
145
|
}
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
--fs-facets-accordion-border-radius-notebook : var(--fs-border-radius);
|
|
16
16
|
|
|
17
17
|
// Accordion Item Button
|
|
18
|
-
--fs-facets-accordion-
|
|
19
|
-
--fs-facets-accordion-
|
|
20
|
-
--fs-facets-accordion-
|
|
21
|
-
--fs-facets-accordion-
|
|
22
|
-
--fs-facets-accordion-
|
|
18
|
+
--fs-facets-accordion-button-text-size : var(--fs-text-size-lead);
|
|
19
|
+
--fs-facets-accordion-button-text-weight : var(--fs-text-weight-regular);
|
|
20
|
+
--fs-facets-accordion-button-line-height : 1.5;
|
|
21
|
+
--fs-facets-accordion-button-padding-right-notebook : var(--fs-spacing-4);
|
|
22
|
+
--fs-facets-accordion-button-padding-left-notebook : var(--fs-facets-accordion-button-padding-right-notebook);
|
|
23
23
|
|
|
24
|
-
--fs-facets-accordion-
|
|
25
|
-
--fs-facets-accordion-
|
|
24
|
+
--fs-facets-accordion-button-text-weight-notebook : var(--fs-text-size-2);
|
|
25
|
+
--fs-facets-accordion-button-line-height-notebook : 1.25;
|
|
26
26
|
|
|
27
27
|
// Accordion Item Panel
|
|
28
28
|
--fs-facets-accordion-item-panel-padding-right-notebook : var(--fs-spacing-4);
|
|
@@ -64,20 +64,20 @@
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
[data-fs-facets-accordion-item] {
|
|
67
|
-
[data-fs-accordion-
|
|
68
|
-
font-size: var(--fs-facets-accordion-
|
|
69
|
-
font-weight: var(--fs-facets-accordion-
|
|
70
|
-
line-height: var(--fs-facets-accordion-
|
|
67
|
+
[data-fs-accordion-button] {
|
|
68
|
+
font-size: var(--fs-facets-accordion-button-text-size);
|
|
69
|
+
font-weight: var(--fs-facets-accordion-button-text-weight);
|
|
70
|
+
line-height: var(--fs-facets-accordion-button-line-height);
|
|
71
71
|
|
|
72
72
|
@include media(">=notebook") {
|
|
73
|
-
padding-right: var(--fs-facets-accordion-
|
|
74
|
-
padding-left: var(--fs-facets-accordion-
|
|
75
|
-
font-size: var(--fs-facets-accordion-
|
|
76
|
-
line-height: var(--fs-facets-accordion-
|
|
73
|
+
padding-right: var(--fs-facets-accordion-button-padding-right-notebook);
|
|
74
|
+
padding-left: var(--fs-facets-accordion-button-padding-left-notebook);
|
|
75
|
+
font-size: var(--fs-facets-accordion-button-text-weight-notebook);
|
|
76
|
+
line-height: var(--fs-facets-accordion-button-line-height-notebook);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
[data-fs-accordion-
|
|
80
|
+
[data-fs-accordion-panel] {
|
|
81
81
|
@include media(">=notebook") {
|
|
82
82
|
padding-right: var(--fs-facets-accordion-item-panel-padding-right-notebook);
|
|
83
83
|
padding-left: var(--fs-facets-accordion-item-panel-padding-left-notebook);
|