@gem-sdk/pages 1.7.13 → 1.8.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.
@@ -9,11 +9,11 @@ const Footer = ()=>{
9
9
  const layoutSetting = core.useShopStore((s)=>s.layoutSettings);
10
10
  if (!layoutSetting?.showFooter) return null;
11
11
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
12
- className: "bg-[#D6D6D6] h-40 flex items-center justify-center",
12
+ className: "flex h-40 items-center justify-center bg-[#D6D6D6]",
13
13
  children: /*#__PURE__*/ jsxRuntime.jsx("div", {
14
- className: "bg-[#E2E2E2] h-6 rounded p-1 flex items-center justify-center",
14
+ className: "flex h-6 items-center justify-center rounded bg-[#E2E2E2] p-1",
15
15
  children: /*#__PURE__*/ jsxRuntime.jsx("span", {
16
- className: "text-[#252525] font-xs",
16
+ className: "font-xs text-[#252525]",
17
17
  children: "Shopify theme’s footer"
18
18
  })
19
19
  })
@@ -7,18 +7,19 @@ var core = require('@gem-sdk/core');
7
7
 
8
8
  const Header = ()=>{
9
9
  const layoutSetting = core.useShopStore((s)=>s.layoutSettings);
10
- if (!layoutSetting?.showHeader) return null;
11
10
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
12
- className: "bg-[#D6D6D6] h-12 flex items-center justify-center",
11
+ className: core.cls('flex h-12 items-center justify-center bg-[#D6D6D6]', {
12
+ hidden: !layoutSetting?.showHeader
13
+ }),
13
14
  children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
14
- className: "gp-header group bg-[#E2E2E2] children:hover:block cursor-pointer h-6 rounded p-1 flex items-center justify-center",
15
+ className: "gp-header children:hover:block group flex h-6 cursor-pointer items-center justify-center rounded bg-[#E2E2E2] p-1",
15
16
  children: [
16
17
  /*#__PURE__*/ jsxRuntime.jsx("span", {
17
- className: "text-[#252525] font-xs ",
18
+ className: "font-xs text-[#252525] ",
18
19
  children: "Shopify theme’s header"
19
20
  }),
20
21
  /*#__PURE__*/ jsxRuntime.jsxs("svg", {
21
- className: "w-0 group-hover:w-auto ml-[5px]",
22
+ className: "ml-[5px] w-0 group-hover:w-auto",
22
23
  width: "16",
23
24
  height: "16",
24
25
  viewBox: "0 0 16 16",
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var core = require('@gem-sdk/core');
7
+ var dynamic = require('next/dynamic');
8
+
9
+ const CollectionProvider = dynamic(()=>import('@gem-sdk/core').then((m)=>m.CollectionProvider));
10
+ const CollectionGlobalProvider = ({ children })=>{
11
+ const { data: collections , isValidating , error } = core.useCollectionsQuery({
12
+ first: 1,
13
+ orderBy: {
14
+ direction: 'DESC',
15
+ field: 'UPDATED_AT'
16
+ },
17
+ where: {
18
+ isSample: false
19
+ }
20
+ });
21
+ const collection = collections?.collections?.edges?.[0]?.node;
22
+ return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
23
+ children: isValidating ? /*#__PURE__*/ jsxRuntime.jsx("div", {
24
+ children: "Loading..."
25
+ }) : error ? /*#__PURE__*/ jsxRuntime.jsxs("div", {
26
+ children: [
27
+ "Error: ",
28
+ error?.message
29
+ ]
30
+ }) : !collection ? /*#__PURE__*/ jsxRuntime.jsx("div", {
31
+ children: "Collection not found"
32
+ }) : /*#__PURE__*/ jsxRuntime.jsx(CollectionProvider, {
33
+ collection: collection,
34
+ children: children
35
+ })
36
+ });
37
+ };
38
+
39
+ exports.default = CollectionGlobalProvider;
@@ -8,8 +8,9 @@ var react = require('react');
8
8
  var Toolbox = require('../components/builder/Toolbox.js');
9
9
  var Header = require('../components/Header.js');
10
10
  var Footer = require('../components/Footer.js');
11
+ var CollectionGlobalProvider = require('./CollectionGlobalProvider.js');
11
12
 
12
- const BuilderPage = ({ components , seo , themeStyle , fontStyle , sectionData })=>{
13
+ const BuilderPage = ({ components , seo , themeStyle , fontStyle , sectionData , pageType })=>{
13
14
  const [loadSuccess, setLoadSuccess] = react.useState(false);
14
15
  const initState = {
15
16
  ROOT: {
@@ -22,6 +23,29 @@ const BuilderPage = ({ components , seo , themeStyle , fontStyle , sectionData
22
23
  react.useEffect(()=>{
23
24
  setLoadSuccess(true);
24
25
  }, []);
26
+ const sectionProvider = /*#__PURE__*/ jsxRuntime.jsx(core.SectionProvider, {
27
+ data: sectionData,
28
+ children: /*#__PURE__*/ jsxRuntime.jsxs(core.BuilderPreviewProvider, {
29
+ state: initState,
30
+ children: [
31
+ /*#__PURE__*/ jsxRuntime.jsx(Toolbox.default, {}),
32
+ loadSuccess && /*#__PURE__*/ jsxRuntime.jsxs("div", {
33
+ className: "builder",
34
+ children: [
35
+ /*#__PURE__*/ jsxRuntime.jsx("div", {
36
+ id: "storefront",
37
+ children: /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
38
+ uid: "ROOT"
39
+ })
40
+ }),
41
+ /*#__PURE__*/ jsxRuntime.jsx("div", {
42
+ id: "visual-content"
43
+ })
44
+ ]
45
+ })
46
+ ]
47
+ }, "preview")
48
+ });
25
49
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
26
50
  children: [
27
51
  /*#__PURE__*/ jsxRuntime.jsx(nextSeo.NextSeo, {
@@ -48,29 +72,9 @@ const BuilderPage = ({ components , seo , themeStyle , fontStyle , sectionData
48
72
  /*#__PURE__*/ jsxRuntime.jsx(Header.default, {}),
49
73
  /*#__PURE__*/ jsxRuntime.jsx(core.BuilderComponentProvider, {
50
74
  components: components,
51
- children: /*#__PURE__*/ jsxRuntime.jsx(core.SectionProvider, {
52
- data: sectionData,
53
- children: /*#__PURE__*/ jsxRuntime.jsxs(core.BuilderPreviewProvider, {
54
- state: initState,
55
- children: [
56
- /*#__PURE__*/ jsxRuntime.jsx(Toolbox.default, {}),
57
- loadSuccess && /*#__PURE__*/ jsxRuntime.jsxs("div", {
58
- className: "builder",
59
- children: [
60
- /*#__PURE__*/ jsxRuntime.jsx("div", {
61
- id: "storefront",
62
- children: /*#__PURE__*/ jsxRuntime.jsx(core.RenderPreview, {
63
- uid: "ROOT"
64
- })
65
- }),
66
- /*#__PURE__*/ jsxRuntime.jsx("div", {
67
- id: "visual-content"
68
- })
69
- ]
70
- })
71
- ]
72
- }, "preview")
73
- })
75
+ children: pageType === 'GP_COLLECTION' ? /*#__PURE__*/ jsxRuntime.jsx(CollectionGlobalProvider.default, {
76
+ children: sectionProvider
77
+ }) : sectionProvider
74
78
  }),
75
79
  /*#__PURE__*/ jsxRuntime.jsx(Footer.default, {})
76
80
  ]
@@ -5,11 +5,11 @@ const Footer = ()=>{
5
5
  const layoutSetting = useShopStore((s)=>s.layoutSettings);
6
6
  if (!layoutSetting?.showFooter) return null;
7
7
  return /*#__PURE__*/ jsx("div", {
8
- className: "bg-[#D6D6D6] h-40 flex items-center justify-center",
8
+ className: "flex h-40 items-center justify-center bg-[#D6D6D6]",
9
9
  children: /*#__PURE__*/ jsx("div", {
10
- className: "bg-[#E2E2E2] h-6 rounded p-1 flex items-center justify-center",
10
+ className: "flex h-6 items-center justify-center rounded bg-[#E2E2E2] p-1",
11
11
  children: /*#__PURE__*/ jsx("span", {
12
- className: "text-[#252525] font-xs",
12
+ className: "font-xs text-[#252525]",
13
13
  children: "Shopify theme’s footer"
14
14
  })
15
15
  })
@@ -1,20 +1,21 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { useShopStore } from '@gem-sdk/core';
2
+ import { useShopStore, cls } from '@gem-sdk/core';
3
3
 
4
4
  const Header = ()=>{
5
5
  const layoutSetting = useShopStore((s)=>s.layoutSettings);
6
- if (!layoutSetting?.showHeader) return null;
7
6
  return /*#__PURE__*/ jsx("div", {
8
- className: "bg-[#D6D6D6] h-12 flex items-center justify-center",
7
+ className: cls('flex h-12 items-center justify-center bg-[#D6D6D6]', {
8
+ hidden: !layoutSetting?.showHeader
9
+ }),
9
10
  children: /*#__PURE__*/ jsxs("div", {
10
- className: "gp-header group bg-[#E2E2E2] children:hover:block cursor-pointer h-6 rounded p-1 flex items-center justify-center",
11
+ className: "gp-header children:hover:block group flex h-6 cursor-pointer items-center justify-center rounded bg-[#E2E2E2] p-1",
11
12
  children: [
12
13
  /*#__PURE__*/ jsx("span", {
13
- className: "text-[#252525] font-xs ",
14
+ className: "font-xs text-[#252525] ",
14
15
  children: "Shopify theme’s header"
15
16
  }),
16
17
  /*#__PURE__*/ jsxs("svg", {
17
- className: "w-0 group-hover:w-auto ml-[5px]",
18
+ className: "ml-[5px] w-0 group-hover:w-auto",
18
19
  width: "16",
19
20
  height: "16",
20
21
  viewBox: "0 0 16 16",
@@ -0,0 +1,35 @@
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
+ import { useCollectionsQuery } from '@gem-sdk/core';
3
+ import dynamic from 'next/dynamic';
4
+
5
+ const CollectionProvider = dynamic(()=>import('@gem-sdk/core').then((m)=>m.CollectionProvider));
6
+ const CollectionGlobalProvider = ({ children })=>{
7
+ const { data: collections , isValidating , error } = useCollectionsQuery({
8
+ first: 1,
9
+ orderBy: {
10
+ direction: 'DESC',
11
+ field: 'UPDATED_AT'
12
+ },
13
+ where: {
14
+ isSample: false
15
+ }
16
+ });
17
+ const collection = collections?.collections?.edges?.[0]?.node;
18
+ return /*#__PURE__*/ jsx(Fragment, {
19
+ children: isValidating ? /*#__PURE__*/ jsx("div", {
20
+ children: "Loading..."
21
+ }) : error ? /*#__PURE__*/ jsxs("div", {
22
+ children: [
23
+ "Error: ",
24
+ error?.message
25
+ ]
26
+ }) : !collection ? /*#__PURE__*/ jsx("div", {
27
+ children: "Collection not found"
28
+ }) : /*#__PURE__*/ jsx(CollectionProvider, {
29
+ collection: collection,
30
+ children: children
31
+ })
32
+ });
33
+ };
34
+
35
+ export { CollectionGlobalProvider as default };
@@ -6,8 +6,9 @@ import { useState, useEffect } from 'react';
6
6
  import Toolbox from '../components/builder/Toolbox.js';
7
7
  import Header from '../components/Header.js';
8
8
  import Footer from '../components/Footer.js';
9
+ import CollectionGlobalProvider from './CollectionGlobalProvider.js';
9
10
 
10
- const BuilderPage = ({ components , seo , themeStyle , fontStyle , sectionData })=>{
11
+ const BuilderPage = ({ components , seo , themeStyle , fontStyle , sectionData , pageType })=>{
11
12
  const [loadSuccess, setLoadSuccess] = useState(false);
12
13
  const initState = {
13
14
  ROOT: {
@@ -20,6 +21,29 @@ const BuilderPage = ({ components , seo , themeStyle , fontStyle , sectionData
20
21
  useEffect(()=>{
21
22
  setLoadSuccess(true);
22
23
  }, []);
24
+ const sectionProvider = /*#__PURE__*/ jsx(SectionProvider, {
25
+ data: sectionData,
26
+ children: /*#__PURE__*/ jsxs(BuilderPreviewProvider, {
27
+ state: initState,
28
+ children: [
29
+ /*#__PURE__*/ jsx(Toolbox, {}),
30
+ loadSuccess && /*#__PURE__*/ jsxs("div", {
31
+ className: "builder",
32
+ children: [
33
+ /*#__PURE__*/ jsx("div", {
34
+ id: "storefront",
35
+ children: /*#__PURE__*/ jsx(RenderPreview, {
36
+ uid: "ROOT"
37
+ })
38
+ }),
39
+ /*#__PURE__*/ jsx("div", {
40
+ id: "visual-content"
41
+ })
42
+ ]
43
+ })
44
+ ]
45
+ }, "preview")
46
+ });
23
47
  return /*#__PURE__*/ jsxs(Fragment, {
24
48
  children: [
25
49
  /*#__PURE__*/ jsx(NextSeo, {
@@ -46,29 +70,9 @@ const BuilderPage = ({ components , seo , themeStyle , fontStyle , sectionData
46
70
  /*#__PURE__*/ jsx(Header, {}),
47
71
  /*#__PURE__*/ jsx(BuilderComponentProvider, {
48
72
  components: components,
49
- children: /*#__PURE__*/ jsx(SectionProvider, {
50
- data: sectionData,
51
- children: /*#__PURE__*/ jsxs(BuilderPreviewProvider, {
52
- state: initState,
53
- children: [
54
- /*#__PURE__*/ jsx(Toolbox, {}),
55
- loadSuccess && /*#__PURE__*/ jsxs("div", {
56
- className: "builder",
57
- children: [
58
- /*#__PURE__*/ jsx("div", {
59
- id: "storefront",
60
- children: /*#__PURE__*/ jsx(RenderPreview, {
61
- uid: "ROOT"
62
- })
63
- }),
64
- /*#__PURE__*/ jsx("div", {
65
- id: "visual-content"
66
- })
67
- ]
68
- })
69
- ]
70
- }, "preview")
71
- })
73
+ children: pageType === 'GP_COLLECTION' ? /*#__PURE__*/ jsx(CollectionGlobalProvider, {
74
+ children: sectionProvider
75
+ }) : sectionProvider
72
76
  }),
73
77
  /*#__PURE__*/ jsx(Footer, {})
74
78
  ]
@@ -113,6 +113,7 @@ type BuilderPageProps = {
113
113
  storefrontHandle?: string | null;
114
114
  shopToken?: string | null;
115
115
  mode?: RenderMode;
116
+ pageType: ShopType.PublishedThemePageType;
116
117
  };
117
118
  declare const BuilderPage: React.FC<BuilderPageProps>;
118
119
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/pages",
3
- "version": "1.7.13",
3
+ "version": "1.8.0",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",