@shopify/create-hydrogen 0.2.1 → 0.3.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/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public",
5
5
  "@shopify:registry": "https://registry.npmjs.org"
6
6
  },
7
- "version": "0.2.1",
7
+ "version": "0.3.0",
8
8
  "main": "index.js",
9
9
  "license": "MIT",
10
10
  "bin": {
@@ -24,5 +24,5 @@
24
24
  "kolorist": "^1.4.0",
25
25
  "minimist": "^1.2.5"
26
26
  },
27
- "gitHead": "8d764811b4e1420ea00e90fb1e1e4b5412de990e"
27
+ "gitHead": "79eec7e076abe074755bbe42bc62f7f96dcd2ff8"
28
28
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dev",
3
3
  "description": "This is a dev environment for Hydrogen",
4
- "version": "0.2.1",
4
+ "version": "0.3.0",
5
5
  "license": "MIT",
6
6
  "private": true,
7
7
  "scripts": {
@@ -31,7 +31,7 @@
31
31
  "vite": "^2.6.0"
32
32
  },
33
33
  "dependencies": {
34
- "@shopify/hydrogen": "^0.2.1",
34
+ "@shopify/hydrogen": "^0.3.0",
35
35
  "compression": "^1.7.4",
36
36
  "express": "^4.17.1",
37
37
  "focus-trap-react": "^8.8.1",
@@ -22,7 +22,7 @@ export default function CartProvider({children, cart, numCartLines}) {
22
22
  function Provider({children, cart, numCartLines}) {
23
23
  const {openCart} = useCartUI();
24
24
 
25
- const onCartLineAdd = useCallback(() => {
25
+ const open = useCallback(() => {
26
26
  openCart();
27
27
  }, [openCart]);
28
28
 
@@ -31,7 +31,8 @@ function Provider({children, cart, numCartLines}) {
31
31
  <ShopifyCartProvider
32
32
  cart={cart}
33
33
  numCartLines={numCartLines}
34
- onLineAdd={onCartLineAdd}
34
+ onLineAdd={open}
35
+ onCreate={open}
35
36
  >
36
37
  {children}
37
38
  </ShopifyCartProvider>
@@ -7,14 +7,14 @@ import {
7
7
  } from '@shopify/hydrogen/client';
8
8
 
9
9
  export default function ProductCard({product}) {
10
- const firstVariant = product?.variants?.edges[0]?.node;
11
-
12
10
  if (!product) return null;
13
11
 
12
+ const firstVariant = product.variants?.edges[0]?.node;
13
+
14
14
  return (
15
15
  <ProductProvider product={product} initialVariantId={firstVariant.id}>
16
16
  <Link to={`/products/${product.handle}`}>
17
- <SelectedVariantImage className="rounded-md bg-gray-100 h-80 w-96 mb-2" />
17
+ <SelectedVariantImage className="rounded-md bg-gray-100 h-80 w-96 mb-2 object-cover" />
18
18
  <ProductTitle className="text-gray-900 font-medium" />
19
19
  </Link>
20
20
  <div className="flex items-center">
@@ -1,18 +1,15 @@
1
- import {Product} from '@shopify/hydrogen/client';
1
+ import {Product, flattenConnection} from '@shopify/hydrogen/client';
2
2
 
3
- import Layout from './Layout.client';
4
3
  import ProductOptions from './ProductOptions.client';
5
4
  import Gallery from './Gallery.client';
6
5
  import Seo from './Seo.client';
7
6
 
8
- export default function ProductDetails({data}) {
7
+ export default function ProductDetails({product}) {
8
+ const initialVariant = flattenConnection(product.variants)[0];
9
9
  return (
10
- <Layout>
11
- <Seo product={data.product} />
12
- <Product
13
- product={data.product}
14
- initialVariantId={data.product.variants.edges[0].node.id}
15
- >
10
+ <>
11
+ <Seo product={product} />
12
+ <Product product={product} initialVariantId={initialVariant.id}>
16
13
  <div className="py-4 md:grid md:grid-cols-2 lg:grid-cols-3 gap-12">
17
14
  <div className="md:hidden pb-4 flex justify-between items-top">
18
15
  <Product.Title as="h1" className="font-bold text-2xl" />
@@ -179,6 +176,6 @@ export default function ProductDetails({data}) {
179
176
  </section>
180
177
  </div>
181
178
  </Product>
182
- </Layout>
179
+ </>
183
180
  );
184
181
  }
@@ -5,7 +5,7 @@ import {
5
5
  } from '@shopify/hydrogen';
6
6
  import gql from 'graphql-tag';
7
7
 
8
- import HighlightedProduct from '../components/HightlightedProduct.client';
8
+ import HighlightedProduct from '../components/HighlightedProduct.client';
9
9
  import Layout from '../components/Layout.client';
10
10
  import ProductCard from '../components/ProductCard.client';
11
11
  import MediaPlaceholder from '../components/MediaPlaceholder';
@@ -4,6 +4,7 @@ import gql from 'graphql-tag';
4
4
 
5
5
  import ProductDetails from '../../components/ProductDetails.client';
6
6
  import NotFound from '../../components/NotFound.server';
7
+ import Layout from '../../components/Layout.client';
7
8
 
8
9
  export default function Product() {
9
10
  const {handle} = useParams();
@@ -26,7 +27,11 @@ export default function Product() {
26
27
  return <NotFound />;
27
28
  }
28
29
 
29
- return <ProductDetails data={data} />;
30
+ return (
31
+ <Layout>
32
+ <ProductDetails product={data.product} />
33
+ </Layout>
34
+ );
30
35
  }
31
36
 
32
37
  const QUERY = gql`