@shopify/create-hydrogen 1.0.0-alpha.23 → 1.0.4

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 (102) hide show
  1. package/CHANGELOG.md +256 -0
  2. package/bin/run.cmd +3 -0
  3. package/bin/run.js +7 -0
  4. package/dist/commands/init.js +157943 -0
  5. package/dist/commands/init.js.map +1 -0
  6. package/dist/index.js +151598 -0
  7. package/dist/index.js.map +1 -0
  8. package/package.json +64 -16
  9. package/templates/template-hydrogen-default/.devcontainer/devcontainer.json +18 -0
  10. package/templates/template-hydrogen-default/.eslintrc.js +3 -0
  11. package/templates/template-hydrogen-default/.gitignore +7 -0
  12. package/{template-hydrogen → templates/template-hydrogen-default}/.stylelintrc.js +1 -1
  13. package/templates/template-hydrogen-default/.vscode/extensions.json +8 -0
  14. package/{template-hydrogen → templates/template-hydrogen-default}/README.md +11 -2
  15. package/{template-hydrogen → templates/template-hydrogen-default}/_gitignore +0 -0
  16. package/templates/template-hydrogen-default/index.html +20 -0
  17. package/templates/template-hydrogen-default/package.json.liquid +48 -0
  18. package/{template-hydrogen → templates/template-hydrogen-default}/postcss.config.js +0 -0
  19. package/templates/template-hydrogen-default/public/favicon.ico +0 -0
  20. package/{template-hydrogen → templates/template-hydrogen-default}/shopify.config.js +1 -2
  21. package/templates/template-hydrogen-default/src/App.server.jsx +27 -0
  22. package/templates/template-hydrogen-default/src/components/Button.client.jsx +65 -0
  23. package/templates/template-hydrogen-default/src/components/Cart.client.jsx +265 -0
  24. package/templates/template-hydrogen-default/src/components/CartIcon.jsx +33 -0
  25. package/templates/template-hydrogen-default/src/components/CartIconWithItems.client.jsx +28 -0
  26. package/templates/template-hydrogen-default/src/components/CartProvider.client.jsx +35 -0
  27. package/templates/template-hydrogen-default/src/components/CartToggle.client.jsx +30 -0
  28. package/templates/template-hydrogen-default/src/components/CartUIProvider.client.jsx +45 -0
  29. package/templates/template-hydrogen-default/src/components/CountrySelector.client.jsx +116 -0
  30. package/templates/template-hydrogen-default/src/components/DefaultSeo.server.jsx +36 -0
  31. package/templates/template-hydrogen-default/src/components/FeaturedCollection.jsx +26 -0
  32. package/templates/template-hydrogen-default/src/components/Footer.server.jsx +103 -0
  33. package/templates/template-hydrogen-default/src/components/Gallery.client.jsx +66 -0
  34. package/templates/template-hydrogen-default/src/components/Header.client.jsx +62 -0
  35. package/templates/template-hydrogen-default/src/components/Layout.server.jsx +86 -0
  36. package/templates/template-hydrogen-default/src/components/LoadMoreProducts.client.jsx +56 -0
  37. package/templates/template-hydrogen-default/src/components/LoadingFallback.jsx +26 -0
  38. package/templates/template-hydrogen-default/src/components/MobileCountrySelector.client.jsx +64 -0
  39. package/templates/template-hydrogen-default/src/components/MobileNavigation.client.jsx +98 -0
  40. package/templates/template-hydrogen-default/src/components/MoneyCompareAtPrice.client.jsx +14 -0
  41. package/templates/template-hydrogen-default/src/components/MoneyPrice.client.jsx +15 -0
  42. package/templates/template-hydrogen-default/src/components/Navigation.client.jsx +23 -0
  43. package/templates/template-hydrogen-default/src/components/NotFound.server.jsx +93 -0
  44. package/templates/template-hydrogen-default/src/components/OpenIcon.jsx +33 -0
  45. package/templates/template-hydrogen-default/src/components/ProductCard.jsx +50 -0
  46. package/templates/template-hydrogen-default/src/components/ProductDetails.client.jsx +233 -0
  47. package/{template-hydrogen → templates/template-hydrogen-default}/src/components/ProductOptions.client.jsx +7 -4
  48. package/templates/template-hydrogen-default/src/components/Welcome.server.jsx +188 -0
  49. package/{template-hydrogen → templates/template-hydrogen-default}/src/index.css +31 -0
  50. package/templates/template-hydrogen-default/src/pages/collections/[handle].server.jsx +105 -0
  51. package/templates/template-hydrogen-default/src/pages/index.server.jsx +241 -0
  52. package/{template-hydrogen → templates/template-hydrogen-default}/src/pages/pages/[handle].server.jsx +14 -5
  53. package/templates/template-hydrogen-default/src/pages/products/[handle].server.jsx +66 -0
  54. package/templates/template-hydrogen-default/src/pages/redirect.server.jsx +4 -0
  55. package/templates/template-hydrogen-default/src/pages/robots.txt.server.js +40 -0
  56. package/templates/template-hydrogen-default/src/pages/sitemap.xml.server.jsx +151 -0
  57. package/templates/template-hydrogen-default/src/routes/collections/[handle].server.jsx +105 -0
  58. package/templates/template-hydrogen-default/src/routes/index.server.jsx +241 -0
  59. package/templates/template-hydrogen-default/src/routes/pages/[handle].server.jsx +37 -0
  60. package/templates/template-hydrogen-default/src/routes/products/[handle].server.jsx +66 -0
  61. package/templates/template-hydrogen-default/src/routes/redirect.server.jsx +4 -0
  62. package/templates/template-hydrogen-default/src/routes/robots.txt.server.js +40 -0
  63. package/templates/template-hydrogen-default/src/routes/sitemap.xml.server.jsx +151 -0
  64. package/templates/template-hydrogen-default/tailwind.config.js +26 -0
  65. package/{template-hydrogen → templates/template-hydrogen-default}/vite.config.js +1 -0
  66. package/templates/template-hydrogen-minimal/README.md +8 -0
  67. package/templates/template-hydrogen-minimal/package.json +14 -0
  68. package/index.js +0 -201
  69. package/scripts/tmp-copy-template-from-dev.js +0 -21
  70. package/scripts/utils.js +0 -29
  71. package/template-hydrogen/.eslintrc.js +0 -41
  72. package/template-hydrogen/.vscode/extensions.json +0 -3
  73. package/template-hydrogen/Dockerfile +0 -15
  74. package/template-hydrogen/index.html +0 -14
  75. package/template-hydrogen/package.json +0 -43
  76. package/template-hydrogen/server.js +0 -40
  77. package/template-hydrogen/src/App.server.jsx +0 -42
  78. package/template-hydrogen/src/components/Cart.client.jsx +0 -287
  79. package/template-hydrogen/src/components/CartProvider.client.jsx +0 -15
  80. package/template-hydrogen/src/components/DefaultSeo.server.jsx +0 -22
  81. package/template-hydrogen/src/components/Footer.jsx +0 -12
  82. package/template-hydrogen/src/components/Gallery.client.jsx +0 -36
  83. package/template-hydrogen/src/components/Header.client.jsx +0 -46
  84. package/template-hydrogen/src/components/HightlightedProduct.client.jsx +0 -54
  85. package/template-hydrogen/src/components/Layout.client.jsx +0 -61
  86. package/template-hydrogen/src/components/MediaPlaceholder.jsx +0 -21
  87. package/template-hydrogen/src/components/NotFound.server.jsx +0 -104
  88. package/template-hydrogen/src/components/ProductCard.client.jsx +0 -39
  89. package/template-hydrogen/src/components/ProductDetails.client.jsx +0 -184
  90. package/template-hydrogen/src/components/Seo.client.jsx +0 -75
  91. package/template-hydrogen/src/entry-client.jsx +0 -12
  92. package/template-hydrogen/src/entry-server.jsx +0 -7
  93. package/template-hydrogen/src/favicon.svg +0 -15
  94. package/template-hydrogen/src/pages/Index.server.jsx +0 -186
  95. package/template-hydrogen/src/pages/blogs/[handle]/[articleHandle].server.jsx +0 -49
  96. package/template-hydrogen/src/pages/blogs/[handle].server.jsx +0 -76
  97. package/template-hydrogen/src/pages/collections/[handle].server.jsx +0 -69
  98. package/template-hydrogen/src/pages/products/[handle].server.jsx +0 -56
  99. package/template-hydrogen/src/pages/search.server.jsx +0 -107
  100. package/template-hydrogen/src/pages/sitemap.xml.server.jsx +0 -64
  101. package/template-hydrogen/tailwind.config.js +0 -9
  102. package/template-hydrogen/worker.js +0 -22
@@ -1,69 +0,0 @@
1
- import {MediaFile, useShopQuery} from '@shopify/hydrogen';
2
- import {useParams} from 'react-router-dom';
3
- import gql from 'graphql-tag';
4
-
5
- import Layout from '../../components/Layout.client';
6
- import ProductCard from '../../components/ProductCard.client';
7
-
8
- export default function Collection() {
9
- const {handle} = useParams();
10
- const {data} = useShopQuery({query: QUERY, variables: {handle}});
11
-
12
- const collection = data.collectionByHandle;
13
-
14
- return (
15
- <Layout>
16
- <h1 className="text-2xl font-bold">{collection.title}</h1>
17
-
18
- <ul className="grid lg:grid-cols-3 gap-6 mt-4">
19
- {collection.products.edges.map((edge) => (
20
- <li key={edge.node.id}>
21
- <ProductCard product={edge.node} />
22
- </li>
23
- ))}
24
- </ul>
25
- </Layout>
26
- );
27
- }
28
-
29
- const QUERY = gql`
30
- fragment CollectionProductDetails on Product {
31
- id
32
- title
33
- handle
34
- priceRange {
35
- maxVariantPrice {
36
- amount
37
- currencyCode
38
- }
39
- minVariantPrice {
40
- amount
41
- currencyCode
42
- }
43
- }
44
- media(first: 1) {
45
- edges {
46
- node {
47
- ...MediaFileFragment
48
- }
49
- }
50
- }
51
- }
52
-
53
- query CollectionDetails($handle: String!) {
54
- collectionByHandle(handle: $handle) {
55
- id
56
- title
57
-
58
- products(first: 10) {
59
- edges {
60
- node {
61
- ...CollectionProductDetails
62
- }
63
- }
64
- }
65
- }
66
- }
67
-
68
- ${MediaFile.Fragment}
69
- `;
@@ -1,56 +0,0 @@
1
- import {useShopQuery, ProductProviderFragment} from '@shopify/hydrogen';
2
- import {useParams} from 'react-router-dom';
3
- import gql from 'graphql-tag';
4
-
5
- import ProductDetails from '../../components/ProductDetails.client';
6
- import NotFound from '../../components/NotFound.server';
7
-
8
- export default function Product() {
9
- const {handle} = useParams();
10
-
11
- const {data} = useShopQuery({
12
- query: QUERY,
13
- variables: {
14
- handle,
15
- numProductMetafields: 10,
16
- numProductVariants: 250,
17
- numProductMedia: 6,
18
- numProductVariantMetafields: 10,
19
- },
20
- });
21
-
22
- if (!data.product) {
23
- return <NotFound />;
24
- }
25
-
26
- return <ProductDetails data={data} />;
27
- }
28
-
29
- const QUERY = gql`
30
- query product(
31
- $handle: String!
32
- $numProductMetafields: Int!
33
- $numProductVariants: Int!
34
- $numProductMedia: Int!
35
- $numProductVariantMetafields: Int!
36
- ) {
37
- product: productByHandle(handle: $handle) {
38
- id
39
- vendor
40
- seo {
41
- title
42
- description
43
- }
44
- images(first: 1) {
45
- edges {
46
- node {
47
- originalSrc
48
- }
49
- }
50
- }
51
- ...ProductProviderFragment
52
- }
53
- }
54
-
55
- ${ProductProviderFragment}
56
- `;
@@ -1,107 +0,0 @@
1
- import {useEffect, useMemo, useState} from 'react';
2
- import {useHistory, useLocation} from 'react-router-dom';
3
- import {useShopQuery, MediaFile} from '@shopify/hydrogen';
4
- import gql from 'graphql-tag';
5
-
6
- import Layout from '../components/Layout.client';
7
- import ProductCard from '../components/ProductCard.client';
8
-
9
- /**
10
- * TODO: Refactor to a true server component.
11
- */
12
- export default function Search() {
13
- const {search} = useLocation();
14
- const originalQuery = useMemo(
15
- () => new URLSearchParams(search).get('query'),
16
- [search],
17
- );
18
- const history = useHistory();
19
- const [query, setQuery] = useState(originalQuery);
20
- const [newQuery, setNewQuery] = useState(query);
21
-
22
- useEffect(() => {
23
- if (originalQuery) {
24
- setQuery(originalQuery);
25
- }
26
- }, [originalQuery]);
27
-
28
- return (
29
- <Layout>
30
- <h1 className="text-2xl font-bold">Search</h1>
31
- <form
32
- onSubmit={(event) => {
33
- event.preventDefault();
34
- setQuery(newQuery);
35
- history.push(`/search?query=${newQuery}`);
36
- }}
37
- className="mt-4 space-x-2"
38
- >
39
- <label htmlFor="search">Search Products:</label>
40
- <input
41
- autocomplete="off"
42
- name="search"
43
- id="search"
44
- type="search"
45
- value={newQuery}
46
- onChange={(event) => setNewQuery(event.target.value)}
47
- className="p-1"
48
- />
49
- <button type="submit" className="bg-black text-white font-bold p-1">
50
- Search
51
- </button>
52
- </form>
53
- {query && <SearchResults query={query} />}
54
- </Layout>
55
- );
56
- }
57
-
58
- function SearchResults({query}) {
59
- const {data, fetching} = useShopQuery({query: QUERY, variables: {query}});
60
-
61
- if (fetching) return <p>Loading...</p>;
62
-
63
- return (
64
- <>
65
- <h2 className="text-xl font-medium mt-8">Search results for: {query}</h2>
66
-
67
- {data.products.edges.length ? (
68
- <ul className="grid lg:grid-cols-3 gap-6 mt-4">
69
- {data.products.edges.map((edge) => (
70
- <li key={edge.node.id}>
71
- <ProductCard product={edge.node} />
72
- </li>
73
- ))}
74
- </ul>
75
- ) : (
76
- <p>No results found.</p>
77
- )}
78
- </>
79
- );
80
- }
81
-
82
- const QUERY = gql`
83
- fragment SearchProductDetails on Product {
84
- id
85
- title
86
- handle
87
- media(first: 1) {
88
- edges {
89
- node {
90
- ...MediaFileFragment
91
- }
92
- }
93
- }
94
- }
95
-
96
- query ProductSearch($query: String!) {
97
- products(query: $query, first: 10) {
98
- edges {
99
- node {
100
- ...SearchProductDetails
101
- }
102
- }
103
- }
104
- }
105
-
106
- ${MediaFile.Fragment}
107
- `;
@@ -1,64 +0,0 @@
1
- import {flattenConnection, useShopQuery} from '@shopify/hydrogen';
2
- import gql from 'graphql-tag';
3
-
4
- export default function Sitemap({response}) {
5
- response.doNotStream();
6
-
7
- const {data} = useShopQuery({query: QUERY});
8
-
9
- response.headers.set('content-type', 'application/xml');
10
-
11
- return response.send(shopSitemap(data));
12
- }
13
-
14
- function shopSitemap(data) {
15
- return `
16
- <urlset
17
- xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
18
- xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
19
- >
20
- ${flattenConnection(data.products)
21
- .map((product) => {
22
- return `
23
- <url>
24
- <loc>
25
- https://hydrogen-preview.myshopify.com/products/${product.handle}
26
- </loc>
27
- <lastmod>${product.updatedAt}</lastmod>
28
- <changefreq>daily</changefreq>
29
- <image:image>
30
- <image:loc>
31
- ${product?.images?.edges?.[0]?.node?.originalSrc}
32
- </image:loc>
33
- <image:title>
34
- ${product?.images?.edges?.[0]?.node?.altText ?? ''}
35
- </image:title>
36
- <image:caption />
37
- </image:image>
38
- </url>
39
- `;
40
- })
41
- .join('')}
42
- </urlset>`;
43
- }
44
-
45
- const QUERY = gql`
46
- query Products {
47
- products(first: 100) {
48
- edges {
49
- node {
50
- updatedAt
51
- handle
52
- images(first: 1) {
53
- edges {
54
- node {
55
- originalSrc
56
- altText
57
- }
58
- }
59
- }
60
- }
61
- }
62
- }
63
- }
64
- `;
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- purge: ['./index.html', './src/**/*.{js,jsx,ts,tsx}'],
3
- mode: 'jit',
4
- darkMode: false, // or 'media' or 'class'
5
- variants: {
6
- extend: {},
7
- },
8
- plugins: [require('@tailwindcss/typography')],
9
- };
@@ -1,22 +0,0 @@
1
- import handleEvent from '@shopify/hydrogen/worker';
2
- import entrypoint from './src/entry-server.jsx';
3
- // eslint-disable-next-line node/no-missing-import
4
- import indexHtml from './dist/client/index.html?raw';
5
-
6
- addEventListener('fetch', (event) => {
7
- try {
8
- event.respondWith(
9
- handleEvent(event, {
10
- entrypoint,
11
- indexTemplate: indexHtml,
12
- cache: caches.default,
13
- }),
14
- );
15
- } catch (error) {
16
- event.respondWith(
17
- new Response(error.message || error.toString(), {
18
- status: 500,
19
- }),
20
- );
21
- }
22
- });