@faststore/core 2.0.153-alpha.0 → 2.0.154-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.
- package/.turbo/turbo-build.log +5 -7
- package/CHANGELOG.md +6 -0
- package/cms/faststore/sections.json +3 -8
- package/package.json +4 -4
- package/src/components/cms/GlobalSections.tsx +3 -25
- package/src/components/cms/RenderSections.tsx +37 -2
- package/src/components/sections/CrossSellingShelf/CrossSellingShelf.tsx +17 -3
- package/src/components/sections/ProductShelf/ProductShelf.tsx +7 -76
- package/src/components/sections/Section/section.scss +0 -7
- package/src/components/{sections → ui}/ProductShelf/Overrides.tsx +2 -2
- package/src/components/ui/ProductShelf/ProductShelf.tsx +106 -0
- package/src/components/ui/ProductShelf/index.ts +2 -0
- package/src/pages/[...slug].tsx +1 -7
- package/.next/BUILD_ID +0 -1
- package/.next/build-manifest.json +0 -132
- package/.next/cache/.tsbuildinfo +0 -1
- package/.next/cache/config.json +0 -7
- package/.next/cache/eslint/.cache_1gneedd +0 -1
- package/.next/cache/next-server.js.nft.json +0 -1
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/export-marker.json +0 -1
- package/.next/images-manifest.json +0 -1
- package/.next/next-server.js.nft.json +0 -1
- package/.next/package.json +0 -1
- package/.next/prerender-manifest.json +0 -1
- package/.next/react-loadable-manifest.json +0 -48
- package/.next/required-server-files.json +0 -1
- package/.next/routes-manifest.json +0 -1
- package/.next/server/chunks/104.js +0 -703
- package/.next/server/chunks/123.js +0 -58
- package/.next/server/chunks/143.js +0 -106
- package/.next/server/chunks/183.js +0 -80
- package/.next/server/chunks/247.js +0 -61
- package/.next/server/chunks/280.js +0 -324
- package/.next/server/chunks/287.js +0 -58
- package/.next/server/chunks/289.js +0 -229
- package/.next/server/chunks/312.js +0 -697
- package/.next/server/chunks/336.js +0 -821
- package/.next/server/chunks/350.js +0 -142
- package/.next/server/chunks/368.js +0 -253
- package/.next/server/chunks/401.js +0 -7241
- package/.next/server/chunks/431.js +0 -7241
- package/.next/server/chunks/502.js +0 -600
- package/.next/server/chunks/557.js +0 -132
- package/.next/server/chunks/576.js +0 -80
- package/.next/server/chunks/597.js +0 -169
- package/.next/server/chunks/608.js +0 -644
- package/.next/server/chunks/644.js +0 -235
- package/.next/server/chunks/664.js +0 -3401
- package/.next/server/chunks/676.js +0 -32
- package/.next/server/chunks/701.js +0 -87
- package/.next/server/chunks/74.js +0 -2690
- package/.next/server/chunks/82.js +0 -371
- package/.next/server/chunks/854.js +0 -72
- package/.next/server/chunks/859.js +0 -959
- package/.next/server/chunks/874.js +0 -487
- package/.next/server/chunks/886.js +0 -120
- package/.next/server/chunks/907.js +0 -1803
- package/.next/server/chunks/98.js +0 -124
- package/.next/server/chunks/font-manifest.json +0 -1
- package/.next/server/font-manifest.json +0 -1
- package/.next/server/middleware-build-manifest.js +0 -1
- package/.next/server/middleware-manifest.json +0 -6
- package/.next/server/middleware-react-loadable-manifest.js +0 -1
- package/.next/server/pages/404.js +0 -393
- package/.next/server/pages/404.js.nft.json +0 -1
- package/.next/server/pages/500.js +0 -395
- package/.next/server/pages/500.js.nft.json +0 -1
- package/.next/server/pages/[...slug].js +0 -733
- package/.next/server/pages/[...slug].js.nft.json +0 -1
- package/.next/server/pages/[slug]/p.js +0 -2458
- package/.next/server/pages/[slug]/p.js.nft.json +0 -1
- package/.next/server/pages/_app.js +0 -368
- package/.next/server/pages/_app.js.nft.json +0 -1
- package/.next/server/pages/_document.js +0 -304
- package/.next/server/pages/_document.js.nft.json +0 -1
- package/.next/server/pages/_error.js +0 -164
- package/.next/server/pages/_error.js.nft.json +0 -1
- package/.next/server/pages/account.js +0 -370
- package/.next/server/pages/account.js.nft.json +0 -1
- package/.next/server/pages/api/graphql.js +0 -315
- package/.next/server/pages/api/graphql.js.nft.json +0 -1
- package/.next/server/pages/api/preview.js +0 -118
- package/.next/server/pages/api/preview.js.nft.json +0 -1
- package/.next/server/pages/checkout.js +0 -370
- package/.next/server/pages/checkout.js.nft.json +0 -1
- package/.next/server/pages/en-US/404.html +0 -81
- package/.next/server/pages/en-US/404.json +0 -1
- package/.next/server/pages/en-US/500.html +0 -81
- package/.next/server/pages/en-US/500.json +0 -1
- package/.next/server/pages/en-US/account.html +0 -81
- package/.next/server/pages/en-US/account.json +0 -1
- package/.next/server/pages/en-US/checkout.html +0 -81
- package/.next/server/pages/en-US/checkout.json +0 -1
- package/.next/server/pages/en-US/login.html +0 -81
- package/.next/server/pages/en-US/login.json +0 -1
- package/.next/server/pages/en-US/s.html +0 -81
- package/.next/server/pages/en-US/s.json +0 -1
- package/.next/server/pages/en-US.html +0 -81
- package/.next/server/pages/en-US.json +0 -1
- package/.next/server/pages/index.js +0 -966
- package/.next/server/pages/index.js.nft.json +0 -1
- package/.next/server/pages/login.js +0 -375
- package/.next/server/pages/login.js.nft.json +0 -1
- package/.next/server/pages/s.js +0 -473
- package/.next/server/pages/s.js.nft.json +0 -1
- package/.next/server/pages-manifest.json +0 -16
- package/.next/server/webpack-api-runtime.js +0 -229
- package/.next/server/webpack-runtime.js +0 -229
- package/.next/static/Jdc52lXcDWIk2D0wQ-Z4p/_buildManifest.js +0 -1
- package/.next/static/Jdc52lXcDWIk2D0wQ-Z4p/_ssgManifest.js +0 -1
- package/.next/static/chunks/0-0e3914d9fc148f74.js +0 -1
- package/.next/static/chunks/143.dd8a556e6957baa1.js +0 -1
- package/.next/static/chunks/226.b57e10ad9932f88c.js +0 -1
- package/.next/static/chunks/336.0846f48eccce57e4.js +0 -1
- package/.next/static/chunks/366-c0bfd9890048babf.js +0 -1
- package/.next/static/chunks/377-b3616792e1f5f651.js +0 -1
- package/.next/static/chunks/391-47b923ef44945418.js +0 -1
- package/.next/static/chunks/495.0ecd099878b2a36d.js +0 -1
- package/.next/static/chunks/502.ae82de1669112b15.js +0 -1
- package/.next/static/chunks/545-1d3d08edfd2ee4c6.js +0 -1
- package/.next/static/chunks/597.c5cf3fbeae5ceb63.js +0 -1
- package/.next/static/chunks/64.ebbe1d2b40f980c7.js +0 -1
- package/.next/static/chunks/651.7142f31ce1e052b3.js +0 -1
- package/.next/static/chunks/741.52f7fb873418346f.js +0 -1
- package/.next/static/chunks/98.97381d2021f86cd9.js +0 -1
- package/.next/static/chunks/framework-dfd14d7ce6600b03.js +0 -1
- package/.next/static/chunks/main-fd466221927468fd.js +0 -1
- package/.next/static/chunks/pages/404-459452495a0df278.js +0 -1
- package/.next/static/chunks/pages/500-008e30c48eceebed.js +0 -1
- package/.next/static/chunks/pages/[...slug]-bd1885159f7dfbba.js +0 -1
- package/.next/static/chunks/pages/[slug]/p-fa35dd93d53f75f6.js +0 -1
- package/.next/static/chunks/pages/_app-3e4e7e579cb0681a.js +0 -1
- package/.next/static/chunks/pages/_error-a7a0c1d9bfbb4f38.js +0 -1
- package/.next/static/chunks/pages/account-46263f0c100c3eae.js +0 -1
- package/.next/static/chunks/pages/checkout-20bb3710b24df3b6.js +0 -1
- package/.next/static/chunks/pages/index-49b7ee570f7cc4b7.js +0 -1
- package/.next/static/chunks/pages/login-f9d316d261fcc062.js +0 -1
- package/.next/static/chunks/pages/s-1cbe740b5b781d28.js +0 -1
- package/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js +0 -1
- package/.next/static/chunks/webpack-eb5ed34c93d07fac.js +0 -1
- package/.next/static/css/1323734429a8aa40.css +0 -1
- package/.next/static/css/13a4da555ff5e3be.css +0 -1
- package/.next/static/css/2e00f7ba49c754b3.css +0 -1
- package/.next/static/css/7d822a137c54a781.css +0 -1
- package/.next/static/css/a0feab89b7648c5c.css +0 -1
- package/.next/static/css/a13a9f9cd349d906.css +0 -1
- package/.next/static/css/a45618030b16a245.css +0 -1
- package/.next/static/css/bde408cc006e64f8.css +0 -1
- package/.next/static/css/d462d9478ce00021.css +0 -1
- package/.next/static/css/e02cdad8fc000339.css +0 -1
- package/.next/trace +0 -69
- package/public/~partytown/debug/partytown-atomics.js +0 -556
- package/public/~partytown/debug/partytown-media.js +0 -374
- package/public/~partytown/debug/partytown-sandbox-sw.js +0 -543
- package/public/~partytown/debug/partytown-sw.js +0 -59
- package/public/~partytown/debug/partytown-ww-atomics.js +0 -1789
- package/public/~partytown/debug/partytown-ww-sw.js +0 -1781
- package/public/~partytown/debug/partytown.js +0 -72
- package/public/~partytown/partytown-atomics.js +0 -2
- package/public/~partytown/partytown-media.js +0 -2
- package/public/~partytown/partytown-sw.js +0 -2
- package/public/~partytown/partytown.js +0 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -16,18 +16,16 @@ info - Collecting page data...
|
|
|
16
16
|
info - Generating static pages (0/7)
|
|
17
17
|
info - Generating static pages (1/7)
|
|
18
18
|
info - Generating static pages (3/7)
|
|
19
|
-
warn - CallToAction not found. Add a new component for this section or remove it from the CMS
|
|
20
|
-
warn - IncentivesHeader not found. Add a new component for this section or remove it from the CMS
|
|
21
19
|
info - Generating static pages (5/7)
|
|
22
20
|
info - Generating static pages (7/7)
|
|
23
21
|
info - Finalizing page optimization...
|
|
24
22
|
|
|
25
23
|
Route (pages) Size First Load JS
|
|
26
|
-
┌ ● /
|
|
24
|
+
┌ ● / 3.09 kB 126 kB
|
|
27
25
|
├ └ css/13a4da555ff5e3be.css 7.19 kB
|
|
28
26
|
├ /_app 0 B 77.9 kB
|
|
29
|
-
├ ● /[...slug] 10 kB
|
|
30
|
-
├ └ css/
|
|
27
|
+
├ ● /[...slug] 10.1 kB 133 kB
|
|
28
|
+
├ └ css/6e41f1b6078c14c1.css 7.9 kB
|
|
31
29
|
├ ● /[slug]/p 11.7 kB 135 kB
|
|
32
30
|
├ └ css/d462d9478ce00021.css 10.9 kB
|
|
33
31
|
├ ○ /404 1.09 kB 113 kB
|
|
@@ -42,8 +40,8 @@ Route (pages) Size First Load JS
|
|
|
42
40
|
├ chunks/framework-dfd14d7ce6600b03.js 45.3 kB
|
|
43
41
|
├ chunks/main-fd466221927468fd.js 23.9 kB
|
|
44
42
|
├ chunks/pages/_app-3e4e7e579cb0681a.js 6.43 kB
|
|
45
|
-
├ chunks/webpack-
|
|
46
|
-
└ css/
|
|
43
|
+
├ chunks/webpack-90918babbeee4949.js 2.26 kB
|
|
44
|
+
└ css/47d82dcec9a7dbc2.css 2.78 kB
|
|
47
45
|
|
|
48
46
|
λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
|
|
49
47
|
○ (Static) automatically rendered as static HTML (uses no initial props)
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.0.154-alpha.0](https://github.com/vtex/faststore/compare/v2.0.153-alpha.0...v2.0.154-alpha.0) (2023-05-23)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- Adjust `ProductShelf` for CMS ([#1766](https://github.com/vtex/faststore/issues/1766)) ([1798536](https://github.com/vtex/faststore/commit/1798536f60a508997616350f0b4ac6c11878dc04))
|
|
11
|
+
|
|
6
12
|
## [2.0.153-alpha.0](https://github.com/vtex/faststore/compare/v2.0.152-alpha.0...v2.0.153-alpha.0) (2023-05-23)
|
|
7
13
|
|
|
8
14
|
### Features
|
|
@@ -834,8 +834,8 @@
|
|
|
834
834
|
],
|
|
835
835
|
"enumNames": [
|
|
836
836
|
"Discount: higher to lower",
|
|
837
|
-
"Name: Z-A",
|
|
838
837
|
"Name: A-Z",
|
|
838
|
+
"Name: Z-A",
|
|
839
839
|
"Orders: higher to lower",
|
|
840
840
|
"Price: lower to higher",
|
|
841
841
|
"Price: higher to lower",
|
|
@@ -879,15 +879,10 @@
|
|
|
879
879
|
"type": "boolean",
|
|
880
880
|
"default": true
|
|
881
881
|
},
|
|
882
|
-
"
|
|
883
|
-
"title": "
|
|
882
|
+
"bordered": {
|
|
883
|
+
"title": "Cards should be bordered?",
|
|
884
884
|
"type": "boolean",
|
|
885
885
|
"default": true
|
|
886
|
-
},
|
|
887
|
-
"buyButtonTitle": {
|
|
888
|
-
"title": "Buy Button Text",
|
|
889
|
-
"type": "string",
|
|
890
|
-
"default": "Buy"
|
|
891
886
|
}
|
|
892
887
|
}
|
|
893
888
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.154-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"browserslist": "supports es6-module and not dead",
|
|
6
6
|
"scripts": {
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"@envelop/graphql-jit": "^1.1.1",
|
|
30
30
|
"@envelop/parser-cache": "^2.2.0",
|
|
31
31
|
"@envelop/validation-cache": "^2.2.0",
|
|
32
|
-
"@faststore/api": "^2.0.
|
|
32
|
+
"@faststore/api": "^2.0.154-alpha.0",
|
|
33
33
|
"@faststore/components": "^2.0.152-alpha.0",
|
|
34
34
|
"@faststore/graphql-utils": "^2.0.3-alpha.0",
|
|
35
35
|
"@faststore/sdk": "^2.0.118-alpha.0",
|
|
36
|
-
"@faststore/ui": "^2.0.
|
|
36
|
+
"@faststore/ui": "^2.0.154-alpha.0",
|
|
37
37
|
"@types/react": "^18.0.14",
|
|
38
38
|
"@vtex/client-cms": "^0.2.12",
|
|
39
39
|
"autoprefixer": "^10.4.0",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"msw": {
|
|
109
109
|
"workerDirectory": "public"
|
|
110
110
|
},
|
|
111
|
-
"gitHead": "
|
|
111
|
+
"gitHead": "f2f4fe80c11a4523ef1dd6827e6c1cf998908c24"
|
|
112
112
|
}
|
|
@@ -27,41 +27,19 @@ const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
|
27
27
|
...CUSTOM_COMPONENTS,
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const useDividedSections = (sections: Section[]) => {
|
|
31
|
-
return useMemo(() => {
|
|
32
|
-
const indexChildren = sections.findIndex(({ name }) => name === 'Children')
|
|
33
|
-
const hasChildren = indexChildren > -1
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
hasChildren,
|
|
37
|
-
firstSections: hasChildren ? sections.slice(0, indexChildren) : sections,
|
|
38
|
-
...(hasChildren && { lastSections: sections.slice(indexChildren + 1) }),
|
|
39
|
-
}
|
|
40
|
-
}, [sections])
|
|
41
|
-
}
|
|
42
|
-
|
|
43
30
|
function GlobalSections({
|
|
44
31
|
children,
|
|
45
|
-
|
|
32
|
+
...otherProps
|
|
46
33
|
}: PropsWithChildren<GlobalSectionsData>) {
|
|
47
|
-
const { hasChildren, firstSections, lastSections } =
|
|
48
|
-
useDividedSections(sections)
|
|
49
|
-
|
|
50
34
|
return (
|
|
51
|
-
|
|
52
|
-
<RenderSections sections={firstSections} components={COMPONENTS} />
|
|
53
|
-
|
|
35
|
+
<RenderSections components={COMPONENTS} {...otherProps}>
|
|
54
36
|
<Toast />
|
|
55
37
|
|
|
56
38
|
<main>
|
|
57
39
|
<RegionBar className="display-mobile" />
|
|
58
40
|
{children}
|
|
59
41
|
</main>
|
|
60
|
-
|
|
61
|
-
{hasChildren && (
|
|
62
|
-
<RenderSections sections={lastSections} components={COMPONENTS} />
|
|
63
|
-
)}
|
|
64
|
-
</>
|
|
42
|
+
</RenderSections>
|
|
65
43
|
)
|
|
66
44
|
}
|
|
67
45
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
|
-
import { ComponentType } from 'react'
|
|
2
|
+
import { ComponentType, PropsWithChildren, useMemo } from 'react'
|
|
3
3
|
|
|
4
4
|
import SectionBoundary from './SectionBoundary'
|
|
5
|
+
import { Section } from '@vtex/client-cms'
|
|
5
6
|
|
|
6
7
|
interface Props {
|
|
7
8
|
components: Record<string, ComponentType<any>>
|
|
@@ -9,7 +10,20 @@ interface Props {
|
|
|
9
10
|
context?: unknown
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
+
const useDividedSections = (sections: Section[]) => {
|
|
14
|
+
return useMemo(() => {
|
|
15
|
+
const indexChildren = sections.findIndex(({ name }) => name === 'Children')
|
|
16
|
+
const hasChildren = indexChildren > -1
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
hasChildren,
|
|
20
|
+
firstSections: hasChildren ? sections.slice(0, indexChildren) : sections,
|
|
21
|
+
...(hasChildren && { lastSections: sections.slice(indexChildren + 1) }),
|
|
22
|
+
}
|
|
23
|
+
}, [sections])
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const RenderSectionsBase = ({ sections = [], context, components }: Props) => {
|
|
13
27
|
return (
|
|
14
28
|
<>
|
|
15
29
|
{sections.map(({ name, data }, index) => {
|
|
@@ -36,4 +50,25 @@ const RenderSections = ({ sections = [], context, components }: Props) => {
|
|
|
36
50
|
)
|
|
37
51
|
}
|
|
38
52
|
|
|
53
|
+
function RenderSections({
|
|
54
|
+
children,
|
|
55
|
+
sections,
|
|
56
|
+
...otherProps
|
|
57
|
+
}: PropsWithChildren<Props>) {
|
|
58
|
+
const { hasChildren, firstSections, lastSections } =
|
|
59
|
+
useDividedSections(sections)
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<>
|
|
63
|
+
<RenderSectionsBase sections={firstSections} {...otherProps} />
|
|
64
|
+
|
|
65
|
+
{children}
|
|
66
|
+
|
|
67
|
+
{hasChildren && (
|
|
68
|
+
<RenderSectionsBase sections={lastSections} {...otherProps} />
|
|
69
|
+
)}
|
|
70
|
+
</>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
39
74
|
export default RenderSections
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useMemo } from 'react'
|
|
2
2
|
|
|
3
3
|
import type { ProductDetailsFragment_ProductFragment } from '@generated/graphql'
|
|
4
|
-
|
|
5
|
-
import
|
|
4
|
+
import UIProductShelf from 'src/components/ui/ProductShelf'
|
|
5
|
+
import { useInView } from 'react-intersection-observer'
|
|
6
|
+
import styles from '../ProductShelf/section.module.scss'
|
|
7
|
+
import Section from '../Section'
|
|
6
8
|
|
|
7
9
|
interface Props {
|
|
8
10
|
items: number
|
|
@@ -12,13 +14,25 @@ interface Props {
|
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
const CrossSellingShelf = ({ items, title, context, kind }: Props) => {
|
|
17
|
+
const { ref, inView } = useInView()
|
|
18
|
+
|
|
15
19
|
const selectedFacets = useMemo(
|
|
16
20
|
() => [{ key: kind, value: context.isVariantOf.productGroupID }],
|
|
17
21
|
[kind, context.isVariantOf.productGroupID]
|
|
18
22
|
)
|
|
19
23
|
|
|
20
24
|
return (
|
|
21
|
-
<
|
|
25
|
+
<Section
|
|
26
|
+
className={`${styles.section} section-product-shelf layout__section`}
|
|
27
|
+
ref={ref}
|
|
28
|
+
>
|
|
29
|
+
<UIProductShelf
|
|
30
|
+
inView={inView}
|
|
31
|
+
first={items}
|
|
32
|
+
title={title}
|
|
33
|
+
selectedFacets={selectedFacets}
|
|
34
|
+
/>
|
|
35
|
+
</Section>
|
|
22
36
|
)
|
|
23
37
|
}
|
|
24
38
|
|
|
@@ -1,91 +1,22 @@
|
|
|
1
|
-
import { useEffect, useId, useRef } from 'react'
|
|
2
1
|
import { useInView } from 'react-intersection-observer'
|
|
3
|
-
|
|
4
|
-
import { ProductShelf as UIProductShelf } from '@faststore/ui'
|
|
5
|
-
|
|
6
|
-
import type { ProductsQueryQueryVariables } from '@generated/graphql'
|
|
7
|
-
import ProductShelfSkeleton from 'src/components/skeletons/ProductShelfSkeleton'
|
|
8
|
-
import { useViewItemListEvent } from 'src/sdk/analytics/hooks/useViewItemListEvent'
|
|
9
|
-
import { useProductsQuery } from 'src/sdk/product/useProductsQuery'
|
|
10
|
-
import { textToKebabCase } from 'src/utils/utilities'
|
|
11
|
-
|
|
12
|
-
import Carousel from '../../ui/Carousel'
|
|
13
2
|
import Section from '../Section'
|
|
14
|
-
import { Components } from './Overrides'
|
|
15
|
-
const { ProductCard } = Components
|
|
16
3
|
|
|
17
4
|
import styles from './section.module.scss'
|
|
5
|
+
import ProductShelf, { ProductShelfProps } from 'src/components/ui/ProductShelf'
|
|
18
6
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function ProductShelf({
|
|
25
|
-
title,
|
|
26
|
-
withDivisor = false,
|
|
27
|
-
...variables
|
|
28
|
-
}: ProductShelfProps) {
|
|
29
|
-
const titleId = textToKebabCase(title)
|
|
30
|
-
const id = useId()
|
|
31
|
-
const viewedOnce = useRef(false)
|
|
7
|
+
function ProductShelfSection({
|
|
8
|
+
...otherProps
|
|
9
|
+
}: Omit<ProductShelfProps, 'inView'>) {
|
|
32
10
|
const { ref, inView } = useInView()
|
|
33
|
-
const products = useProductsQuery(variables)
|
|
34
|
-
const productEdges = products?.edges ?? []
|
|
35
|
-
const aspectRatio = 1
|
|
36
|
-
|
|
37
|
-
const { sendViewItemListEvent } = useViewItemListEvent({
|
|
38
|
-
products: productEdges,
|
|
39
|
-
title,
|
|
40
|
-
page: 0,
|
|
41
|
-
pageSize: 0,
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
if (inView && !viewedOnce.current && productEdges.length) {
|
|
46
|
-
sendViewItemListEvent()
|
|
47
|
-
|
|
48
|
-
viewedOnce.current = true
|
|
49
|
-
}
|
|
50
|
-
}, [inView, productEdges.length, sendViewItemListEvent])
|
|
51
|
-
|
|
52
|
-
if (products?.edges.length === 0) {
|
|
53
|
-
return null
|
|
54
|
-
}
|
|
55
11
|
|
|
56
12
|
return (
|
|
57
13
|
<Section
|
|
58
|
-
className={`${styles.section} section-product-shelf layout__section
|
|
59
|
-
withDivisor ? 'section__divisor' : ''
|
|
60
|
-
}`}
|
|
14
|
+
className={`${styles.section} section-product-shelf layout__section`}
|
|
61
15
|
ref={ref}
|
|
62
16
|
>
|
|
63
|
-
<
|
|
64
|
-
<ProductShelfSkeleton
|
|
65
|
-
aspectRatio={aspectRatio}
|
|
66
|
-
loading={products === undefined}
|
|
67
|
-
>
|
|
68
|
-
<UIProductShelf>
|
|
69
|
-
<Carousel id={titleId || id}>
|
|
70
|
-
{productEdges.map((product, idx) => (
|
|
71
|
-
<ProductCard
|
|
72
|
-
bordered
|
|
73
|
-
key={`${product.node.id}`}
|
|
74
|
-
product={product.node}
|
|
75
|
-
index={idx + 1}
|
|
76
|
-
aspectRatio={aspectRatio}
|
|
77
|
-
imgProps={{
|
|
78
|
-
width: 216,
|
|
79
|
-
height: 216,
|
|
80
|
-
sizes: '(max-width: 768px) 42vw, 30vw',
|
|
81
|
-
}}
|
|
82
|
-
/>
|
|
83
|
-
))}
|
|
84
|
-
</Carousel>
|
|
85
|
-
</UIProductShelf>
|
|
86
|
-
</ProductShelfSkeleton>
|
|
17
|
+
<ProductShelf inView={inView} {...otherProps} />
|
|
87
18
|
</Section>
|
|
88
19
|
)
|
|
89
20
|
}
|
|
90
21
|
|
|
91
|
-
export default
|
|
22
|
+
export default ProductShelfSection
|
|
@@ -3,8 +3,8 @@ import ProductCard from 'src/components/product/ProductCard'
|
|
|
3
3
|
import ProductShelfCustomizations from 'src/customizations/components/overrides/ProductShelf'
|
|
4
4
|
|
|
5
5
|
const Components = {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
ProductCard,
|
|
7
|
+
...ProductShelfCustomizations.components,
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export { Components }
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { useEffect, useId, useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { ProductShelf as UIProductShelf } from '@faststore/ui'
|
|
4
|
+
|
|
5
|
+
import ProductShelfSkeleton from 'src/components/skeletons/ProductShelfSkeleton'
|
|
6
|
+
import { useViewItemListEvent } from 'src/sdk/analytics/hooks/useViewItemListEvent'
|
|
7
|
+
import { useProductsQuery } from 'src/sdk/product/useProductsQuery'
|
|
8
|
+
import { textToKebabCase } from 'src/utils/utilities'
|
|
9
|
+
|
|
10
|
+
import Carousel from '../../ui/Carousel'
|
|
11
|
+
|
|
12
|
+
import { Components } from 'src/components/ui/ProductShelf/Overrides'
|
|
13
|
+
|
|
14
|
+
const { ProductCard } = Components
|
|
15
|
+
|
|
16
|
+
type Sort =
|
|
17
|
+
| 'discount_desc'
|
|
18
|
+
| 'name_asc'
|
|
19
|
+
| 'name_desc'
|
|
20
|
+
| 'orders_desc'
|
|
21
|
+
| 'price_asc'
|
|
22
|
+
| 'price_desc'
|
|
23
|
+
| 'release_desc'
|
|
24
|
+
| 'score_desc'
|
|
25
|
+
|
|
26
|
+
export type ProductShelfProps = {
|
|
27
|
+
title: string
|
|
28
|
+
first?: number
|
|
29
|
+
after?: string
|
|
30
|
+
sort?: Sort
|
|
31
|
+
term?: string
|
|
32
|
+
selectedFacets?: {
|
|
33
|
+
key: string
|
|
34
|
+
value: string
|
|
35
|
+
}[]
|
|
36
|
+
productCardConfiguration?: {
|
|
37
|
+
showDiscountBadge: boolean
|
|
38
|
+
bordered: boolean
|
|
39
|
+
}
|
|
40
|
+
inView: boolean
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function ProductShelf({
|
|
44
|
+
title,
|
|
45
|
+
inView,
|
|
46
|
+
productCardConfiguration,
|
|
47
|
+
...variables
|
|
48
|
+
}: ProductShelfProps) {
|
|
49
|
+
const titleId = textToKebabCase(title)
|
|
50
|
+
const id = useId()
|
|
51
|
+
const viewedOnce = useRef(false)
|
|
52
|
+
const products = useProductsQuery(variables)
|
|
53
|
+
const productEdges = products?.edges ?? []
|
|
54
|
+
const aspectRatio = 1
|
|
55
|
+
|
|
56
|
+
const { sendViewItemListEvent } = useViewItemListEvent({
|
|
57
|
+
products: productEdges,
|
|
58
|
+
title,
|
|
59
|
+
page: 0,
|
|
60
|
+
pageSize: 0,
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (inView && !viewedOnce.current && productEdges.length) {
|
|
65
|
+
sendViewItemListEvent()
|
|
66
|
+
|
|
67
|
+
viewedOnce.current = true
|
|
68
|
+
}
|
|
69
|
+
}, [inView, productEdges.length, sendViewItemListEvent])
|
|
70
|
+
|
|
71
|
+
if (products?.edges.length === 0) {
|
|
72
|
+
return null
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<>
|
|
77
|
+
<h2 className="text__title-section layout__content">{title}</h2>
|
|
78
|
+
<ProductShelfSkeleton
|
|
79
|
+
aspectRatio={aspectRatio}
|
|
80
|
+
loading={products === undefined}
|
|
81
|
+
>
|
|
82
|
+
<UIProductShelf>
|
|
83
|
+
<Carousel id={titleId || id}>
|
|
84
|
+
{productEdges.map((product, idx) => (
|
|
85
|
+
<ProductCard
|
|
86
|
+
bordered={productCardConfiguration?.bordered}
|
|
87
|
+
showDiscountBadge={productCardConfiguration?.showDiscountBadge}
|
|
88
|
+
key={`${product.node.id}`}
|
|
89
|
+
product={product.node}
|
|
90
|
+
index={idx + 1}
|
|
91
|
+
aspectRatio={aspectRatio}
|
|
92
|
+
imgProps={{
|
|
93
|
+
width: 216,
|
|
94
|
+
height: 216,
|
|
95
|
+
sizes: '(max-width: 768px) 42vw, 30vw',
|
|
96
|
+
}}
|
|
97
|
+
/>
|
|
98
|
+
))}
|
|
99
|
+
</Carousel>
|
|
100
|
+
</UIProductShelf>
|
|
101
|
+
</ProductShelfSkeleton>
|
|
102
|
+
</>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export default ProductShelf
|
package/src/pages/[...slug].tsx
CHANGED
|
@@ -49,6 +49,7 @@ const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
|
49
49
|
Breadcrumb,
|
|
50
50
|
Hero,
|
|
51
51
|
ProductGallery,
|
|
52
|
+
ProductShelf,
|
|
52
53
|
...CUSTOM_COMPONENTS,
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -143,13 +144,6 @@ function Page({
|
|
|
143
144
|
components={COMPONENTS}
|
|
144
145
|
/>
|
|
145
146
|
|
|
146
|
-
<ProductShelf
|
|
147
|
-
first={ITEMS_PER_SECTION}
|
|
148
|
-
sort="score_desc"
|
|
149
|
-
title="You might also like"
|
|
150
|
-
withDivisor
|
|
151
|
-
/>
|
|
152
|
-
|
|
153
147
|
<ScrollToTopButton />
|
|
154
148
|
</SearchProvider>
|
|
155
149
|
</GlobalSections>
|
package/.next/BUILD_ID
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Jdc52lXcDWIk2D0wQ-Z4p
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"polyfillFiles": [
|
|
3
|
-
"static/chunks/polyfills-c67a75d1b6f99dc8.js"
|
|
4
|
-
],
|
|
5
|
-
"devFiles": [],
|
|
6
|
-
"ampDevFiles": [],
|
|
7
|
-
"lowPriorityFiles": [
|
|
8
|
-
"static/Jdc52lXcDWIk2D0wQ-Z4p/_buildManifest.js",
|
|
9
|
-
"static/Jdc52lXcDWIk2D0wQ-Z4p/_ssgManifest.js"
|
|
10
|
-
],
|
|
11
|
-
"rootMainFiles": [],
|
|
12
|
-
"pages": {
|
|
13
|
-
"/": [
|
|
14
|
-
"static/chunks/webpack-eb5ed34c93d07fac.js",
|
|
15
|
-
"static/chunks/framework-dfd14d7ce6600b03.js",
|
|
16
|
-
"static/chunks/main-fd466221927468fd.js",
|
|
17
|
-
"static/chunks/391-47b923ef44945418.js",
|
|
18
|
-
"static/chunks/545-1d3d08edfd2ee4c6.js",
|
|
19
|
-
"static/css/a13a9f9cd349d906.css",
|
|
20
|
-
"static/chunks/377-b3616792e1f5f651.js",
|
|
21
|
-
"static/css/a45618030b16a245.css",
|
|
22
|
-
"static/chunks/366-c0bfd9890048babf.js",
|
|
23
|
-
"static/css/13a4da555ff5e3be.css",
|
|
24
|
-
"static/chunks/pages/index-49b7ee570f7cc4b7.js"
|
|
25
|
-
],
|
|
26
|
-
"/404": [
|
|
27
|
-
"static/chunks/webpack-eb5ed34c93d07fac.js",
|
|
28
|
-
"static/chunks/framework-dfd14d7ce6600b03.js",
|
|
29
|
-
"static/chunks/main-fd466221927468fd.js",
|
|
30
|
-
"static/chunks/391-47b923ef44945418.js",
|
|
31
|
-
"static/chunks/545-1d3d08edfd2ee4c6.js",
|
|
32
|
-
"static/css/a13a9f9cd349d906.css",
|
|
33
|
-
"static/chunks/377-b3616792e1f5f651.js",
|
|
34
|
-
"static/css/e02cdad8fc000339.css",
|
|
35
|
-
"static/chunks/pages/404-459452495a0df278.js"
|
|
36
|
-
],
|
|
37
|
-
"/500": [
|
|
38
|
-
"static/chunks/webpack-eb5ed34c93d07fac.js",
|
|
39
|
-
"static/chunks/framework-dfd14d7ce6600b03.js",
|
|
40
|
-
"static/chunks/main-fd466221927468fd.js",
|
|
41
|
-
"static/chunks/391-47b923ef44945418.js",
|
|
42
|
-
"static/chunks/545-1d3d08edfd2ee4c6.js",
|
|
43
|
-
"static/css/a13a9f9cd349d906.css",
|
|
44
|
-
"static/chunks/377-b3616792e1f5f651.js",
|
|
45
|
-
"static/css/e02cdad8fc000339.css",
|
|
46
|
-
"static/chunks/pages/500-008e30c48eceebed.js"
|
|
47
|
-
],
|
|
48
|
-
"/[...slug]": [
|
|
49
|
-
"static/chunks/webpack-eb5ed34c93d07fac.js",
|
|
50
|
-
"static/chunks/framework-dfd14d7ce6600b03.js",
|
|
51
|
-
"static/chunks/main-fd466221927468fd.js",
|
|
52
|
-
"static/chunks/391-47b923ef44945418.js",
|
|
53
|
-
"static/chunks/545-1d3d08edfd2ee4c6.js",
|
|
54
|
-
"static/css/a13a9f9cd349d906.css",
|
|
55
|
-
"static/chunks/377-b3616792e1f5f651.js",
|
|
56
|
-
"static/css/a0feab89b7648c5c.css",
|
|
57
|
-
"static/chunks/0-0e3914d9fc148f74.js",
|
|
58
|
-
"static/css/1323734429a8aa40.css",
|
|
59
|
-
"static/chunks/pages/[...slug]-bd1885159f7dfbba.js"
|
|
60
|
-
],
|
|
61
|
-
"/[slug]/p": [
|
|
62
|
-
"static/chunks/webpack-eb5ed34c93d07fac.js",
|
|
63
|
-
"static/chunks/framework-dfd14d7ce6600b03.js",
|
|
64
|
-
"static/chunks/main-fd466221927468fd.js",
|
|
65
|
-
"static/chunks/391-47b923ef44945418.js",
|
|
66
|
-
"static/chunks/545-1d3d08edfd2ee4c6.js",
|
|
67
|
-
"static/css/a13a9f9cd349d906.css",
|
|
68
|
-
"static/chunks/377-b3616792e1f5f651.js",
|
|
69
|
-
"static/css/a45618030b16a245.css",
|
|
70
|
-
"static/chunks/366-c0bfd9890048babf.js",
|
|
71
|
-
"static/css/d462d9478ce00021.css",
|
|
72
|
-
"static/chunks/pages/[slug]/p-fa35dd93d53f75f6.js"
|
|
73
|
-
],
|
|
74
|
-
"/_app": [
|
|
75
|
-
"static/chunks/webpack-eb5ed34c93d07fac.js",
|
|
76
|
-
"static/chunks/framework-dfd14d7ce6600b03.js",
|
|
77
|
-
"static/chunks/main-fd466221927468fd.js",
|
|
78
|
-
"static/css/bde408cc006e64f8.css",
|
|
79
|
-
"static/chunks/pages/_app-3e4e7e579cb0681a.js"
|
|
80
|
-
],
|
|
81
|
-
"/_error": [
|
|
82
|
-
"static/chunks/webpack-eb5ed34c93d07fac.js",
|
|
83
|
-
"static/chunks/framework-dfd14d7ce6600b03.js",
|
|
84
|
-
"static/chunks/main-fd466221927468fd.js",
|
|
85
|
-
"static/chunks/pages/_error-a7a0c1d9bfbb4f38.js"
|
|
86
|
-
],
|
|
87
|
-
"/account": [
|
|
88
|
-
"static/chunks/webpack-eb5ed34c93d07fac.js",
|
|
89
|
-
"static/chunks/framework-dfd14d7ce6600b03.js",
|
|
90
|
-
"static/chunks/main-fd466221927468fd.js",
|
|
91
|
-
"static/chunks/391-47b923ef44945418.js",
|
|
92
|
-
"static/chunks/545-1d3d08edfd2ee4c6.js",
|
|
93
|
-
"static/css/a13a9f9cd349d906.css",
|
|
94
|
-
"static/chunks/377-b3616792e1f5f651.js",
|
|
95
|
-
"static/chunks/pages/account-46263f0c100c3eae.js"
|
|
96
|
-
],
|
|
97
|
-
"/checkout": [
|
|
98
|
-
"static/chunks/webpack-eb5ed34c93d07fac.js",
|
|
99
|
-
"static/chunks/framework-dfd14d7ce6600b03.js",
|
|
100
|
-
"static/chunks/main-fd466221927468fd.js",
|
|
101
|
-
"static/chunks/391-47b923ef44945418.js",
|
|
102
|
-
"static/chunks/545-1d3d08edfd2ee4c6.js",
|
|
103
|
-
"static/css/a13a9f9cd349d906.css",
|
|
104
|
-
"static/chunks/377-b3616792e1f5f651.js",
|
|
105
|
-
"static/chunks/pages/checkout-20bb3710b24df3b6.js"
|
|
106
|
-
],
|
|
107
|
-
"/login": [
|
|
108
|
-
"static/chunks/webpack-eb5ed34c93d07fac.js",
|
|
109
|
-
"static/chunks/framework-dfd14d7ce6600b03.js",
|
|
110
|
-
"static/chunks/main-fd466221927468fd.js",
|
|
111
|
-
"static/chunks/391-47b923ef44945418.js",
|
|
112
|
-
"static/chunks/545-1d3d08edfd2ee4c6.js",
|
|
113
|
-
"static/css/a13a9f9cd349d906.css",
|
|
114
|
-
"static/chunks/377-b3616792e1f5f651.js",
|
|
115
|
-
"static/css/e02cdad8fc000339.css",
|
|
116
|
-
"static/chunks/pages/login-f9d316d261fcc062.js"
|
|
117
|
-
],
|
|
118
|
-
"/s": [
|
|
119
|
-
"static/chunks/webpack-eb5ed34c93d07fac.js",
|
|
120
|
-
"static/chunks/framework-dfd14d7ce6600b03.js",
|
|
121
|
-
"static/chunks/main-fd466221927468fd.js",
|
|
122
|
-
"static/chunks/391-47b923ef44945418.js",
|
|
123
|
-
"static/chunks/545-1d3d08edfd2ee4c6.js",
|
|
124
|
-
"static/css/a13a9f9cd349d906.css",
|
|
125
|
-
"static/chunks/377-b3616792e1f5f651.js",
|
|
126
|
-
"static/css/a0feab89b7648c5c.css",
|
|
127
|
-
"static/chunks/0-0e3914d9fc148f74.js",
|
|
128
|
-
"static/chunks/pages/s-1cbe740b5b781d28.js"
|
|
129
|
-
]
|
|
130
|
-
},
|
|
131
|
-
"ampFirstPages": []
|
|
132
|
-
}
|