@shopify/create-hydrogen 0.2.0 → 0.16.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/CHANGELOG.md +13 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +5 -0
- package/dist/commands/init.js +76397 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/package.json +61 -14
- package/templates/template-hydrogen/.devcontainer/devcontainer.json +18 -0
- package/templates/template-hydrogen/.eslintrc.js +3 -0
- package/templates/template-hydrogen/.gitignore +7 -0
- package/templates/template-hydrogen/.stackblitzrc +4 -0
- package/{template-hydrogen → templates/template-hydrogen}/.stylelintrc.js +1 -1
- package/templates/template-hydrogen/.vscode/extensions.json +8 -0
- package/templates/template-hydrogen/Dockerfile +15 -0
- package/{template-hydrogen → templates/template-hydrogen}/README.md +11 -2
- package/{template-hydrogen → templates/template-hydrogen}/_gitignore +0 -0
- package/templates/template-hydrogen/index.html +20 -0
- package/{template-hydrogen → templates/template-hydrogen}/package.json +20 -16
- package/{template-hydrogen → templates/template-hydrogen}/postcss.config.js +0 -0
- package/{template-hydrogen/src → templates/template-hydrogen/public}/favicon.svg +0 -0
- package/{template-hydrogen → templates/template-hydrogen}/server.js +4 -2
- package/{template-hydrogen → templates/template-hydrogen}/shopify.config.js +1 -2
- package/templates/template-hydrogen/src/App.client.jsx +8 -0
- package/templates/template-hydrogen/src/App.server.jsx +27 -0
- package/templates/template-hydrogen/src/components/Button.client.jsx +65 -0
- package/templates/template-hydrogen/src/components/Cart.client.jsx +265 -0
- package/templates/template-hydrogen/src/components/CartIcon.jsx +33 -0
- package/templates/template-hydrogen/src/components/CartIconWithItems.client.jsx +28 -0
- package/templates/template-hydrogen/src/components/CartProvider.client.jsx +35 -0
- package/templates/template-hydrogen/src/components/CartToggle.client.jsx +30 -0
- package/{template-hydrogen → templates/template-hydrogen}/src/components/CartUIProvider.client.jsx +3 -0
- package/templates/template-hydrogen/src/components/CountrySelector.client.jsx +116 -0
- package/templates/template-hydrogen/src/components/DefaultSeo.server.jsx +35 -0
- package/templates/template-hydrogen/src/components/FeaturedCollection.jsx +26 -0
- package/templates/template-hydrogen/src/components/Footer.server.jsx +103 -0
- package/templates/template-hydrogen/src/components/Gallery.client.jsx +65 -0
- package/templates/template-hydrogen/src/components/Header.client.jsx +62 -0
- package/templates/template-hydrogen/src/components/Layout.server.jsx +87 -0
- package/templates/template-hydrogen/src/components/LoadMoreProducts.client.jsx +56 -0
- package/templates/template-hydrogen/src/components/LoadingFallback.jsx +26 -0
- package/templates/template-hydrogen/src/components/MobileCountrySelector.client.jsx +64 -0
- package/templates/template-hydrogen/src/components/MobileNavigation.client.jsx +98 -0
- package/templates/template-hydrogen/src/components/MoneyCompareAtPrice.client.jsx +14 -0
- package/templates/template-hydrogen/src/components/MoneyPrice.client.jsx +15 -0
- package/templates/template-hydrogen/src/components/Navigation.client.jsx +23 -0
- package/templates/template-hydrogen/src/components/NotFound.server.jsx +93 -0
- package/templates/template-hydrogen/src/components/OpenIcon.jsx +33 -0
- package/templates/template-hydrogen/src/components/ProductCard.jsx +50 -0
- package/templates/template-hydrogen/src/components/ProductDetails.client.jsx +242 -0
- package/{template-hydrogen → templates/template-hydrogen}/src/components/ProductOptions.client.jsx +7 -4
- package/templates/template-hydrogen/src/components/Welcome.server.jsx +188 -0
- package/templates/template-hydrogen/src/entry-client.jsx +7 -0
- package/templates/template-hydrogen/src/entry-server.jsx +6 -0
- package/{template-hydrogen → templates/template-hydrogen}/src/index.css +31 -0
- package/templates/template-hydrogen/src/pages/collections/[handle].server.jsx +105 -0
- package/templates/template-hydrogen/src/pages/index.server.jsx +237 -0
- package/{template-hydrogen → templates/template-hydrogen}/src/pages/pages/[handle].server.jsx +14 -5
- package/templates/template-hydrogen/src/pages/products/[handle].server.jsx +69 -0
- package/templates/template-hydrogen/src/pages/redirect.server.jsx +4 -0
- package/templates/template-hydrogen/src/pages/robots.txt.server.js +10 -0
- package/{template-hydrogen → templates/template-hydrogen}/src/pages/sitemap.xml.server.jsx +2 -2
- package/templates/template-hydrogen/tailwind.config.js +26 -0
- package/{template-hydrogen → templates/template-hydrogen}/vite.config.js +1 -0
- package/{template-hydrogen → templates/template-hydrogen}/worker.js +1 -0
- package/README.md +0 -3
- package/index.js +0 -205
- package/scripts/tmp-copy-template-from-dev.js +0 -21
- package/scripts/utils.js +0 -29
- package/template-hydrogen/.eslintrc.js +0 -41
- package/template-hydrogen/.vscode/extensions.json +0 -3
- package/template-hydrogen/Dockerfile +0 -15
- package/template-hydrogen/index.html +0 -14
- package/template-hydrogen/src/App.server.jsx +0 -42
- package/template-hydrogen/src/components/Cart.client.jsx +0 -296
- package/template-hydrogen/src/components/CartProvider.client.jsx +0 -40
- package/template-hydrogen/src/components/DefaultSeo.server.jsx +0 -22
- package/template-hydrogen/src/components/Footer.jsx +0 -12
- package/template-hydrogen/src/components/Gallery.client.jsx +0 -36
- package/template-hydrogen/src/components/Header.client.jsx +0 -103
- package/template-hydrogen/src/components/HightlightedProduct.client.jsx +0 -54
- package/template-hydrogen/src/components/Layout.client.jsx +0 -41
- package/template-hydrogen/src/components/MediaPlaceholder.jsx +0 -21
- package/template-hydrogen/src/components/NotFound.server.jsx +0 -104
- package/template-hydrogen/src/components/ProductCard.client.jsx +0 -39
- package/template-hydrogen/src/components/ProductDetails.client.jsx +0 -184
- package/template-hydrogen/src/components/Seo.client.jsx +0 -75
- package/template-hydrogen/src/entry-client.jsx +0 -12
- package/template-hydrogen/src/entry-server.jsx +0 -7
- package/template-hydrogen/src/pages/Index.server.jsx +0 -199
- package/template-hydrogen/src/pages/blogs/[handle]/[articleHandle].server.jsx +0 -49
- package/template-hydrogen/src/pages/blogs/[handle].server.jsx +0 -76
- package/template-hydrogen/src/pages/collections/[handle].server.jsx +0 -69
- package/template-hydrogen/src/pages/products/[handle].server.jsx +0 -62
- package/template-hydrogen/src/pages/search.server.jsx +0 -107
- package/template-hydrogen/tailwind.config.js +0 -9
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useShopQuery,
|
|
3
|
+
ProductProviderFragment,
|
|
4
|
+
flattenConnection,
|
|
5
|
+
} from '@shopify/hydrogen';
|
|
6
|
+
import gql from 'graphql-tag';
|
|
7
|
+
|
|
8
|
+
import Layout from './Layout.server';
|
|
9
|
+
import Button from './Button.client';
|
|
10
|
+
import ProductCard from './ProductCard';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A server component that defines the content to display when a page isn't found (404 error)
|
|
14
|
+
*/
|
|
15
|
+
function NotFoundHero() {
|
|
16
|
+
return (
|
|
17
|
+
<div className="py-10 border-b border-gray-200">
|
|
18
|
+
<div className="max-w-3xl text-center mx-4 md:mx-auto">
|
|
19
|
+
<h1 className="font-bold text-4xl md:text-5xl text-gray-900 mb-6 mt-6">
|
|
20
|
+
We've lost this page
|
|
21
|
+
</h1>
|
|
22
|
+
<p className="text-lg m-8 text-gray-500">
|
|
23
|
+
We couldn’t find the page you’re looking for. Try checking the URL or
|
|
24
|
+
heading back to the home page.
|
|
25
|
+
</p>
|
|
26
|
+
<Button
|
|
27
|
+
className="w-full md:mx-auto md:w-96"
|
|
28
|
+
url="/"
|
|
29
|
+
label="Take me to the home page"
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default function NotFound({country = {isoCode: 'US'}}) {
|
|
37
|
+
const {data} = useShopQuery({
|
|
38
|
+
query: QUERY,
|
|
39
|
+
variables: {
|
|
40
|
+
country: country.isoCode,
|
|
41
|
+
numProductMetafields: 0,
|
|
42
|
+
numProductVariants: 250,
|
|
43
|
+
numProductMedia: 0,
|
|
44
|
+
numProductVariantMetafields: 0,
|
|
45
|
+
numProductVariantSellingPlanAllocations: 0,
|
|
46
|
+
numProductSellingPlanGroups: 0,
|
|
47
|
+
numProductSellingPlans: 0,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
const products = data ? flattenConnection(data.products) : [];
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Layout>
|
|
54
|
+
<NotFoundHero />
|
|
55
|
+
<div className="my-8">
|
|
56
|
+
<p className="mb-8 text-lg text-black font-medium uppercase">
|
|
57
|
+
Products you might like
|
|
58
|
+
</p>
|
|
59
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 mb-16">
|
|
60
|
+
{products.map((product) => (
|
|
61
|
+
<div key={product.id}>
|
|
62
|
+
<ProductCard product={product} />
|
|
63
|
+
</div>
|
|
64
|
+
))}
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</Layout>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const QUERY = gql`
|
|
72
|
+
query NotFoundProductDetails(
|
|
73
|
+
$country: CountryCode
|
|
74
|
+
$includeReferenceMetafieldDetails: Boolean = false
|
|
75
|
+
$numProductMetafields: Int!
|
|
76
|
+
$numProductVariants: Int!
|
|
77
|
+
$numProductMedia: Int!
|
|
78
|
+
$numProductVariantMetafields: Int!
|
|
79
|
+
$numProductVariantSellingPlanAllocations: Int!
|
|
80
|
+
$numProductSellingPlanGroups: Int!
|
|
81
|
+
$numProductSellingPlans: Int!
|
|
82
|
+
) @inContext(country: $country) {
|
|
83
|
+
products(first: 3) {
|
|
84
|
+
edges {
|
|
85
|
+
node {
|
|
86
|
+
...ProductProviderFragment
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
${ProductProviderFragment}
|
|
93
|
+
`;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A shared component that specifies the icon to render when opened
|
|
3
|
+
*/
|
|
4
|
+
export default function OpenIcon() {
|
|
5
|
+
return (
|
|
6
|
+
<svg
|
|
7
|
+
width="24"
|
|
8
|
+
height="20"
|
|
9
|
+
viewBox="0 0 24 20"
|
|
10
|
+
fill="none"
|
|
11
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
12
|
+
>
|
|
13
|
+
<path
|
|
14
|
+
fillRule="evenodd"
|
|
15
|
+
clipRule="evenodd"
|
|
16
|
+
d="M0.800049 1.9999C0.800049 1.11625 1.51639 0.399902 2.40005 0.399902H21.6C22.4837 0.399902 23.2001 1.11625 23.2001 1.9999C23.2001 2.88356 22.4837 3.5999 21.6 3.5999H2.40005C1.51639 3.5999 0.800049 2.88356 0.800049 1.9999Z"
|
|
17
|
+
fill="black"
|
|
18
|
+
/>
|
|
19
|
+
<path
|
|
20
|
+
fillRule="evenodd"
|
|
21
|
+
clipRule="evenodd"
|
|
22
|
+
d="M0.800049 9.9999C0.800049 9.11625 1.51639 8.3999 2.40005 8.3999H21.6C22.4837 8.3999 23.2001 9.11625 23.2001 9.9999C23.2001 10.8836 22.4837 11.5999 21.6 11.5999H2.40005C1.51639 11.5999 0.800049 10.8836 0.800049 9.9999Z"
|
|
23
|
+
fill="black"
|
|
24
|
+
/>
|
|
25
|
+
<path
|
|
26
|
+
fillRule="evenodd"
|
|
27
|
+
clipRule="evenodd"
|
|
28
|
+
d="M0.800049 17.9999C0.800049 17.1162 1.51639 16.3999 2.40005 16.3999H21.6C22.4837 16.3999 23.2001 17.1162 23.2001 17.9999C23.2001 18.8836 22.4837 19.5999 21.6 19.5999H2.40005C1.51639 19.5999 0.800049 18.8836 0.800049 17.9999Z"
|
|
29
|
+
fill="black"
|
|
30
|
+
/>
|
|
31
|
+
</svg>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {Image, Link} from '@shopify/hydrogen';
|
|
2
|
+
|
|
3
|
+
import MoneyCompareAtPrice from './MoneyCompareAtPrice.client';
|
|
4
|
+
import MoneyPrice from './MoneyPrice.client';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A shared component that displays a single product to allow buyers to quickly identify a particular item of interest
|
|
8
|
+
*/
|
|
9
|
+
export default function ProductCard({product}) {
|
|
10
|
+
const selectedVariant = product.variants.edges[0].node;
|
|
11
|
+
|
|
12
|
+
if (selectedVariant == null) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div className="text-md mb-4 relative">
|
|
18
|
+
<Link to={`/products/${product.handle}`}>
|
|
19
|
+
<div className="rounded-lg border-2 border-gray-200 mb-2 relative flex items-center justify-center overflow-hidden object-cover h-96">
|
|
20
|
+
{selectedVariant.image ? (
|
|
21
|
+
<Image
|
|
22
|
+
className="bg-white absolute w-full h-full transition-all duration-500 ease-in-out transform bg-center bg-cover object-center object-contain hover:scale-110"
|
|
23
|
+
image={selectedVariant.image}
|
|
24
|
+
/>
|
|
25
|
+
) : null}
|
|
26
|
+
{!selectedVariant?.availableForSale && (
|
|
27
|
+
<div className="absolute top-3 left-3 rounded-3xl text-xs bg-black text-white py-3 px-4">
|
|
28
|
+
Out of stock
|
|
29
|
+
</div>
|
|
30
|
+
)}
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<span className="text-black font-semibold mb-0.5">{product.title}</span>
|
|
34
|
+
|
|
35
|
+
{product.vendor && (
|
|
36
|
+
<p className="text-gray-900 font-medium text-sm mb-0.5">
|
|
37
|
+
{product.vendor}
|
|
38
|
+
</p>
|
|
39
|
+
)}
|
|
40
|
+
|
|
41
|
+
<div className="flex ">
|
|
42
|
+
{selectedVariant.compareAtPriceV2 && (
|
|
43
|
+
<MoneyCompareAtPrice money={selectedVariant.compareAtPriceV2} />
|
|
44
|
+
)}
|
|
45
|
+
<MoneyPrice money={selectedVariant.priceV2} />
|
|
46
|
+
</div>
|
|
47
|
+
</Link>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Product,
|
|
3
|
+
flattenConnection,
|
|
4
|
+
useProduct,
|
|
5
|
+
useMoney,
|
|
6
|
+
useParsedMetafields,
|
|
7
|
+
} from '@shopify/hydrogen/client';
|
|
8
|
+
import ProductOptions from './ProductOptions.client';
|
|
9
|
+
import Gallery from './Gallery.client';
|
|
10
|
+
import {
|
|
11
|
+
BUTTON_PRIMARY_CLASSES,
|
|
12
|
+
BUTTON_SECONDARY_CLASSES,
|
|
13
|
+
} from './Button.client';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A client component that displays detailed information about a product to allow buyers to make informed decisions
|
|
17
|
+
*/
|
|
18
|
+
function ProductPriceMarkup() {
|
|
19
|
+
const product = useProduct();
|
|
20
|
+
const variantPrice = useMoney(product.selectedVariant.priceV2);
|
|
21
|
+
const variantCompareAtPrice = useMoney(
|
|
22
|
+
product.selectedVariant.compareAtPriceV2 ?? product.selectedVariant.priceV2,
|
|
23
|
+
);
|
|
24
|
+
return (
|
|
25
|
+
<div className="flex md:flex-col items-end font-semibold text-lg md:items-start md:mb-4">
|
|
26
|
+
{variantPrice.amount !== variantCompareAtPrice.amount && (
|
|
27
|
+
<span className="text-gray-500 line-through text-lg mr-2.5">
|
|
28
|
+
{variantCompareAtPrice.currencyNarrowSymbol}
|
|
29
|
+
{variantCompareAtPrice.amount}
|
|
30
|
+
</span>
|
|
31
|
+
)}
|
|
32
|
+
<span className="text-gray-900">
|
|
33
|
+
{variantPrice.currencyCode} {variantPrice.currencyNarrowSymbol}
|
|
34
|
+
{variantPrice.amount}
|
|
35
|
+
</span>
|
|
36
|
+
<Product.SelectedVariant.UnitPrice className="text-gray-500">
|
|
37
|
+
{({currencyCode, amount, currencyNarrowSymbol, referenceUnit}) =>
|
|
38
|
+
`${currencyCode} ${currencyNarrowSymbol}${amount}/${referenceUnit}`
|
|
39
|
+
}
|
|
40
|
+
</Product.SelectedVariant.UnitPrice>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function AddToCartMarkup() {
|
|
46
|
+
const {selectedVariant} = useProduct();
|
|
47
|
+
const isOutOfStock = !selectedVariant.availableForSale;
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div className="space-y-2 mb-8">
|
|
51
|
+
<Product.SelectedVariant.AddToCartButton
|
|
52
|
+
className={BUTTON_PRIMARY_CLASSES}
|
|
53
|
+
disabled={isOutOfStock}
|
|
54
|
+
>
|
|
55
|
+
{isOutOfStock ? 'Out of stock' : 'Add to bag'}
|
|
56
|
+
</Product.SelectedVariant.AddToCartButton>
|
|
57
|
+
{isOutOfStock ? (
|
|
58
|
+
<p className="text-black text-center">Available in 2-3 weeks</p>
|
|
59
|
+
) : (
|
|
60
|
+
<Product.SelectedVariant.BuyNowButton
|
|
61
|
+
className={BUTTON_SECONDARY_CLASSES}
|
|
62
|
+
>
|
|
63
|
+
Buy it now
|
|
64
|
+
</Product.SelectedVariant.BuyNowButton>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function SizeChart() {
|
|
71
|
+
return (
|
|
72
|
+
<>
|
|
73
|
+
<h3
|
|
74
|
+
className="text-xl text-black font-semibold mt-8 mb-4"
|
|
75
|
+
id="size-chart"
|
|
76
|
+
>
|
|
77
|
+
Size Chart
|
|
78
|
+
</h3>
|
|
79
|
+
<table className="min-w-full table-fixed text-sm text-center bg-white">
|
|
80
|
+
<thead>
|
|
81
|
+
<tr className="bg-black text-white">
|
|
82
|
+
<th className="w-1/4 py-2 px-4 font-normal">Board Size</th>
|
|
83
|
+
<th className="w-1/4 py-2 px-4 font-normal">154</th>
|
|
84
|
+
<th className="w-1/4 py-2 px-4 font-normal">158</th>
|
|
85
|
+
</tr>
|
|
86
|
+
</thead>
|
|
87
|
+
<tbody>
|
|
88
|
+
<tr>
|
|
89
|
+
<td className="p-3 border border-black">Weight Range</td>
|
|
90
|
+
<td className="p-3 border border-black">120-180 lbs. /54-82kg</td>
|
|
91
|
+
<td className="p-3 border border-black">150-200 lbs. /68-91 kg</td>
|
|
92
|
+
</tr>
|
|
93
|
+
<tr>
|
|
94
|
+
<td className="p-3 border border-black">Waist Width</td>
|
|
95
|
+
<td className="p-3 border border-black">246mm</td>
|
|
96
|
+
<td className="p-3 border border-black">255mm</td>
|
|
97
|
+
</tr>
|
|
98
|
+
<tr>
|
|
99
|
+
<td className="p-3 border border-black">Stance Width</td>
|
|
100
|
+
<td className="p-3 border border-black">-40</td>
|
|
101
|
+
<td className="p-3 border border-black">-40</td>
|
|
102
|
+
</tr>
|
|
103
|
+
<tr>
|
|
104
|
+
<td className="p-3 border border-black">Binding Sizes</td>
|
|
105
|
+
<td className="p-3 border border-black">
|
|
106
|
+
Men’s S/M, Women’s S/M
|
|
107
|
+
</td>
|
|
108
|
+
<td className="p-3 border border-black">
|
|
109
|
+
Men’s L, Women’s L
|
|
110
|
+
</td>
|
|
111
|
+
</tr>
|
|
112
|
+
</tbody>
|
|
113
|
+
</table>
|
|
114
|
+
</>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export default function ProductDetails({product}) {
|
|
119
|
+
const initialVariant = flattenConnection(product.variants)[0];
|
|
120
|
+
|
|
121
|
+
const productMetafields = useParsedMetafields(product.metafields);
|
|
122
|
+
const sizeChartMetafield = productMetafields.find(
|
|
123
|
+
(metafield) =>
|
|
124
|
+
metafield.namespace === 'my_fields' && metafield.key === 'size_chart',
|
|
125
|
+
);
|
|
126
|
+
const sustainableMetafield = productMetafields.find(
|
|
127
|
+
(metafield) =>
|
|
128
|
+
metafield.namespace === 'my_fields' && metafield.key === 'sustainable',
|
|
129
|
+
);
|
|
130
|
+
const lifetimeWarrantyMetafield = productMetafields.find(
|
|
131
|
+
(metafield) =>
|
|
132
|
+
metafield.namespace === 'my_fields' &&
|
|
133
|
+
metafield.key === 'lifetime_warranty',
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<>
|
|
138
|
+
<Product product={product} initialVariantId={initialVariant.id}>
|
|
139
|
+
<div className="grid grid-cols-1 md:grid-cols-[2fr,1fr] gap-x-8 my-16">
|
|
140
|
+
<div className="md:hidden mt-5 mb-8">
|
|
141
|
+
<Product.Title
|
|
142
|
+
as="h1"
|
|
143
|
+
className="text-4xl font-bold text-black mb-4"
|
|
144
|
+
/>
|
|
145
|
+
{product.vendor && (
|
|
146
|
+
<div className="text-sm font-medium mb-2 text-gray-900">
|
|
147
|
+
{product.vendor}
|
|
148
|
+
</div>
|
|
149
|
+
)}
|
|
150
|
+
<span />
|
|
151
|
+
<div className="flex justify-between md:block">
|
|
152
|
+
<ProductPriceMarkup />
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<Gallery />
|
|
157
|
+
|
|
158
|
+
<div>
|
|
159
|
+
<div className="hidden md:block">
|
|
160
|
+
<Product.Title
|
|
161
|
+
as="h1"
|
|
162
|
+
className="text-5xl font-bold text-black mb-4"
|
|
163
|
+
/>
|
|
164
|
+
{product.vendor && (
|
|
165
|
+
<div className="text-sm font-medium mb-2 text-gray-900">
|
|
166
|
+
{product.vendor}
|
|
167
|
+
</div>
|
|
168
|
+
)}
|
|
169
|
+
<ProductPriceMarkup />
|
|
170
|
+
</div>
|
|
171
|
+
{/* Product Options */}
|
|
172
|
+
<div className="mt-8">
|
|
173
|
+
<ProductOptions />
|
|
174
|
+
{sizeChartMetafield?.value && (
|
|
175
|
+
<a
|
|
176
|
+
href="#size-chart"
|
|
177
|
+
className="block underline text-gray-500 text-sm tracking-wide my-4"
|
|
178
|
+
>
|
|
179
|
+
Size Chart
|
|
180
|
+
</a>
|
|
181
|
+
)}
|
|
182
|
+
<AddToCartMarkup />
|
|
183
|
+
<div className="flex items space-x-4">
|
|
184
|
+
{sustainableMetafield?.value && (
|
|
185
|
+
<span className="flex items-center mb-8">
|
|
186
|
+
<svg
|
|
187
|
+
width="24"
|
|
188
|
+
height="24"
|
|
189
|
+
viewBox="0 0 24 24"
|
|
190
|
+
fill="none"
|
|
191
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
192
|
+
className="stroke-current text-blue-600 mr-3"
|
|
193
|
+
>
|
|
194
|
+
<path
|
|
195
|
+
d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364-.7071-.7071M6.34315 6.34315l-.70711-.70711m12.72796.00005-.7071.70711M6.3432 17.6569l-.70711.7071M16 12c0 2.2091-1.7909 4-4 4-2.20914 0-4-1.7909-4-4 0-2.20914 1.79086-4 4-4 2.2091 0 4 1.79086 4 4Z"
|
|
196
|
+
strokeWidth="2"
|
|
197
|
+
strokeLinecap="round"
|
|
198
|
+
strokeLinejoin="round"
|
|
199
|
+
/>
|
|
200
|
+
</svg>
|
|
201
|
+
<span className="text-sm text-gray-900 font-medium">
|
|
202
|
+
Sustainable Material
|
|
203
|
+
</span>
|
|
204
|
+
</span>
|
|
205
|
+
)}
|
|
206
|
+
{lifetimeWarrantyMetafield?.value && (
|
|
207
|
+
<span className="flex items-center mb-8">
|
|
208
|
+
<svg
|
|
209
|
+
width="24"
|
|
210
|
+
height="24"
|
|
211
|
+
viewBox="0 0 24 24"
|
|
212
|
+
fill="none"
|
|
213
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
214
|
+
className="stroke-current text-blue-600 mr-3"
|
|
215
|
+
>
|
|
216
|
+
<path
|
|
217
|
+
d="M9 12L11 14L15 10M20.6179 5.98434C20.4132 5.99472 20.2072 5.99997 20 5.99997C16.9265 5.99997 14.123 4.84453 11.9999 2.94434C9.87691 4.84446 7.07339 5.99985 4 5.99985C3.79277 5.99985 3.58678 5.9946 3.38213 5.98422C3.1327 6.94783 3 7.95842 3 9.00001C3 14.5915 6.82432 19.2898 12 20.622C17.1757 19.2898 21 14.5915 21 9.00001C21 7.95847 20.8673 6.94791 20.6179 5.98434Z"
|
|
218
|
+
strokeWidth="2"
|
|
219
|
+
strokeLinecap="round"
|
|
220
|
+
strokeLinejoin="round"
|
|
221
|
+
/>
|
|
222
|
+
</svg>
|
|
223
|
+
<span className="text-sm text-gray-900 font-medium">
|
|
224
|
+
Lifetime Warranty
|
|
225
|
+
</span>
|
|
226
|
+
</span>
|
|
227
|
+
)}
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
{/* Product Description */}
|
|
231
|
+
<Product.Description className="prose border-t border-gray-200 pt-6 text-black text-md" />
|
|
232
|
+
{sizeChartMetafield?.value && (
|
|
233
|
+
<div className="border-t border-gray-200">
|
|
234
|
+
<SizeChart />
|
|
235
|
+
</div>
|
|
236
|
+
)}
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
</Product>
|
|
240
|
+
</>
|
|
241
|
+
);
|
|
242
|
+
}
|
package/{template-hydrogen → templates/template-hydrogen}/src/components/ProductOptions.client.jsx
RENAMED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import {useProduct} from '@shopify/hydrogen/client';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A client component that tracks a selected variant and/or selling plan state, as well as callbacks for modifying the state
|
|
5
|
+
*/
|
|
3
6
|
export default function ProductOptions() {
|
|
4
7
|
const {options, setSelectedOption, selectedOptions} = useProduct();
|
|
5
8
|
|
|
@@ -7,11 +10,11 @@ export default function ProductOptions() {
|
|
|
7
10
|
<>
|
|
8
11
|
{options.map(({name, values}) => {
|
|
9
12
|
return (
|
|
10
|
-
<fieldset key={name} className="
|
|
11
|
-
<legend className="mb-
|
|
13
|
+
<fieldset key={name} className="mt-8">
|
|
14
|
+
<legend className="mb-4 text-xl font-medium text-gray-900">
|
|
12
15
|
{name}
|
|
13
16
|
</legend>
|
|
14
|
-
<div className="flex items-center flex-wrap gap-
|
|
17
|
+
<div className="flex items-center flex-wrap gap-4">
|
|
15
18
|
{values.map((value) => {
|
|
16
19
|
const checked = selectedOptions[name] === value;
|
|
17
20
|
const id = `option-${name}-${value}`;
|
|
@@ -28,7 +31,7 @@ export default function ProductOptions() {
|
|
|
28
31
|
onChange={() => setSelectedOption(name, value)}
|
|
29
32
|
/>
|
|
30
33
|
<div
|
|
31
|
-
className={`p-2 border
|
|
34
|
+
className={`p-2 border cursor-pointer rounded text-sm md:text-md ${
|
|
32
35
|
checked ? 'bg-gray-900 text-white' : 'text-gray-900'
|
|
33
36
|
}`}
|
|
34
37
|
>
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import {useShopQuery, flattenConnection, Link} from '@shopify/hydrogen';
|
|
2
|
+
import gql from 'graphql-tag';
|
|
3
|
+
import {Suspense} from 'react';
|
|
4
|
+
|
|
5
|
+
function ExternalIcon() {
|
|
6
|
+
return (
|
|
7
|
+
<svg
|
|
8
|
+
className="ml-3"
|
|
9
|
+
width="15"
|
|
10
|
+
height="14"
|
|
11
|
+
viewBox="0 0 15 14"
|
|
12
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
13
|
+
fill="currentColor"
|
|
14
|
+
>
|
|
15
|
+
<path d="M8.11963 0.000976562C7.56734 0.000976562 7.11963 0.448692 7.11963 1.00098C7.11963 1.55326 7.56734 2.00098 8.11963 2.00098H10.7054L4.41252 8.29387C4.022 8.68439 4.022 9.31756 4.41252 9.70808C4.80305 10.0986 5.43621 10.0986 5.82674 9.70808L12.1196 3.41519V6.00098C12.1196 6.55326 12.5673 7.00098 13.1196 7.00098C13.6719 7.00098 14.1196 6.55326 14.1196 6.00098V1.00098C14.1196 0.448692 13.6719 0.000976562 13.1196 0.000976562H8.11963Z" />
|
|
16
|
+
<path d="M2.11963 2.00098C1.01506 2.00098 0.119629 2.89641 0.119629 4.00098V12.001C0.119629 13.1055 1.01506 14.001 2.11963 14.001H10.1196C11.2242 14.001 12.1196 13.1055 12.1196 12.001V9.00098C12.1196 8.44869 11.6719 8.00098 11.1196 8.00098C10.5673 8.00098 10.1196 8.44869 10.1196 9.00098V12.001H2.11963V4.00098L5.11963 4.00098C5.67191 4.00098 6.11963 3.55326 6.11963 3.00098C6.11963 2.44869 5.67191 2.00098 5.11963 2.00098H2.11963Z" />
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function DocsButton({url, label}) {
|
|
22
|
+
return (
|
|
23
|
+
<a
|
|
24
|
+
href={url}
|
|
25
|
+
target="_blank"
|
|
26
|
+
className="bg-white shadow py-2 px-5 rounded-full inline-flex items-center hover:opacity-80"
|
|
27
|
+
rel="noreferrer"
|
|
28
|
+
>
|
|
29
|
+
{label}
|
|
30
|
+
<ExternalIcon />
|
|
31
|
+
</a>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function BoxFallback() {
|
|
36
|
+
return (
|
|
37
|
+
<div className="bg-white p-12 shadow-xl rounded-xl text-gray-900 h-60"></div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function StorefrontInfo() {
|
|
42
|
+
const {data} = useShopQuery({query: QUERY});
|
|
43
|
+
const shopName = data ? data.shop.name : '';
|
|
44
|
+
const products = data && flattenConnection(data.products);
|
|
45
|
+
const collections = data && flattenConnection(data.collections);
|
|
46
|
+
const totalProducts = products && products.length;
|
|
47
|
+
const totalCollections = collections && collections.length;
|
|
48
|
+
|
|
49
|
+
const pluralize = (count, noun, suffix = 's') =>
|
|
50
|
+
`${count} ${noun}${count === 1 ? '' : suffix}`;
|
|
51
|
+
return (
|
|
52
|
+
<div className="bg-white p-12 shadow-xl rounded-xl text-gray-900">
|
|
53
|
+
<p className="text-md font-medium uppercase mb-4">Connected Storefront</p>
|
|
54
|
+
<h2 className="text-2xl font-bold mb-4">{shopName}</h2>
|
|
55
|
+
<p className="text-md">
|
|
56
|
+
{pluralize(totalProducts, 'Product')}
|
|
57
|
+
{', '}
|
|
58
|
+
{pluralize(totalCollections, 'Collection')}
|
|
59
|
+
</p>
|
|
60
|
+
{totalProducts === 0 && totalCollections === 0 && (
|
|
61
|
+
<div className="py-2 px-3 bg-red-100 text-md">
|
|
62
|
+
Use the{' '}
|
|
63
|
+
<a
|
|
64
|
+
href="https://shopify.dev/apps/tools/cli/getting-started"
|
|
65
|
+
className="text-primary font-mono font-bold underline"
|
|
66
|
+
target="_blank"
|
|
67
|
+
rel="noreferrer"
|
|
68
|
+
>
|
|
69
|
+
Shopify CLI
|
|
70
|
+
</a>{' '}
|
|
71
|
+
to populate sample products and collections.
|
|
72
|
+
</div>
|
|
73
|
+
)}
|
|
74
|
+
<hr className="my-4" />
|
|
75
|
+
<a
|
|
76
|
+
href="https://shopify.dev/custom-storefronts/hydrogen/getting-started/create#step-2-update-information-about-your-shopify-storefront"
|
|
77
|
+
className="text-md inline-flex items-center text-blue-700 font-medium hover:underline"
|
|
78
|
+
target="_blank"
|
|
79
|
+
rel="noreferrer"
|
|
80
|
+
>
|
|
81
|
+
Change your storefront access token
|
|
82
|
+
<ExternalIcon />
|
|
83
|
+
</a>
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function TemplateLinks() {
|
|
89
|
+
const {data} = useShopQuery({query: QUERY});
|
|
90
|
+
const products = data && flattenConnection(data.products);
|
|
91
|
+
const collections = data && flattenConnection(data.collections);
|
|
92
|
+
|
|
93
|
+
const firstProduct = products && products.length ? products[0].handle : '';
|
|
94
|
+
const firstCollection = collections[0] ? collections[0].handle : '';
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<div className="bg-white p-12 md:p-12 shadow-xl rounded-xl text-gray-900">
|
|
98
|
+
<p className="text-md font-medium uppercase mb-4">
|
|
99
|
+
Explore the templates
|
|
100
|
+
</p>
|
|
101
|
+
<ul>
|
|
102
|
+
<li className="mb-4">
|
|
103
|
+
<Link
|
|
104
|
+
to={`/collections/${firstCollection}`}
|
|
105
|
+
className="text-md font-medium text-blue-700 hover:underline"
|
|
106
|
+
>
|
|
107
|
+
Collection template
|
|
108
|
+
</Link>
|
|
109
|
+
</li>
|
|
110
|
+
<li className="mb-4">
|
|
111
|
+
<Link
|
|
112
|
+
to={`/products/${firstProduct}`}
|
|
113
|
+
className="text-md font-medium text-blue-700 hover:underline"
|
|
114
|
+
>
|
|
115
|
+
Product template
|
|
116
|
+
</Link>
|
|
117
|
+
</li>
|
|
118
|
+
<li>
|
|
119
|
+
<Link
|
|
120
|
+
to="/error-page"
|
|
121
|
+
className="text-md font-medium text-blue-700 hover:underline"
|
|
122
|
+
>
|
|
123
|
+
404 template
|
|
124
|
+
</Link>
|
|
125
|
+
</li>
|
|
126
|
+
</ul>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* A server component that displays the content on the homepage of the Hydrogen app
|
|
133
|
+
*/
|
|
134
|
+
export default function Welcome() {
|
|
135
|
+
return (
|
|
136
|
+
<div className="text-gray-900 pt-16 rounded-[40px] my-16 px-4 xl:px-12 bg-gradient-to-b from-white -mx-4 xl:-mx-12">
|
|
137
|
+
<div className="text-center mb-16">
|
|
138
|
+
<h1 className="font-extrabold mb-4 text-5xl md:text-7xl">
|
|
139
|
+
Hello, Hydrogen
|
|
140
|
+
</h1>
|
|
141
|
+
<p className="text-lg mb-8">
|
|
142
|
+
Welcome to your custom storefront. Let’s get building.
|
|
143
|
+
</p>
|
|
144
|
+
<div className="flex flex-col lg:flex-row justify-center items-center gap-8 text-gray-700">
|
|
145
|
+
<DocsButton
|
|
146
|
+
url="https://shopify.dev/custom-storefronts/hydrogen"
|
|
147
|
+
label="Browse Hydrogen documentation"
|
|
148
|
+
/>
|
|
149
|
+
<DocsButton url="/graphql" label="Open the GraphiQL explorer" />
|
|
150
|
+
<DocsButton
|
|
151
|
+
url="https://github.com/Shopify/hydrogen-examples"
|
|
152
|
+
label="Explore Hydrogen examples"
|
|
153
|
+
/>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8 lg:gap-16">
|
|
157
|
+
<Suspense fallback={<BoxFallback />}>
|
|
158
|
+
<StorefrontInfo />
|
|
159
|
+
</Suspense>
|
|
160
|
+
<Suspense fallback={<BoxFallback />}>
|
|
161
|
+
<TemplateLinks />
|
|
162
|
+
</Suspense>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const QUERY = gql`
|
|
169
|
+
query welcomeContent {
|
|
170
|
+
shop {
|
|
171
|
+
name
|
|
172
|
+
}
|
|
173
|
+
products(first: 250) {
|
|
174
|
+
edges {
|
|
175
|
+
node {
|
|
176
|
+
handle
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
collections(first: 250) {
|
|
181
|
+
edges {
|
|
182
|
+
node {
|
|
183
|
+
handle
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
`;
|