Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update docs and cleanup references (#127)
Browse files Browse the repository at this point in the history
frehner authored Jan 19, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent f47933b commit 5c5c6b6
Showing 46 changed files with 116 additions and 235 deletions.
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -39,6 +39,19 @@ If you need a helper function that is shared between the tests and stories files
- The function can't go into the test file, because when the story file imports it, it will also import Vitest and cause things to break
- The function can't go into the story file, because when you export it, it shows up as a story in the storybook/ladle navigation

## Writing Docs

Documentation lives in the `*.doc.ts` files, and uses a Shopify library called `@shopify/generate-docs` to pull the TypeScript type info from the source code and generate the output for the Shopify website into the `docs/` folder.

After adding or updating docs, you'll need to:

1. `cd` into `packages/react` folder
1. Run `yarn build-docs`

Which will update the generated output, and then will be picked up by the Shopify website on a regular cadence.

Docs can (and should, when possible) include two examples; one in plain JavaScript and one in TypeScript, using the format `{name}.example.(t|j)sx`.

## Package Exports Notes:

- Until ESLint can resolve package.exports, we added `storefront-kit` to `.eslintrc.js`->`node/no-missing-import.allowModules`
2 changes: 1 addition & 1 deletion apps/nextjs/pages/collection.tsx
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@ export default function Collection({

<footer className={styles.footer}>
<a
href="https://vercel.com?utm_source=hydrogen-react-monorepo"
href="https://vercel.com?utm_source=storefront-kit-monorepo"
target="_blank"
rel="noopener noreferrer"
>
2 changes: 1 addition & 1 deletion apps/nextjs/pages/product.tsx
Original file line number Diff line number Diff line change
@@ -121,7 +121,7 @@ export default function Product({

<footer className={styles.footer}>
<a
href="https://vercel.com?utm_source=hydrogen-react-monorepo"
href="https://vercel.com?utm_source=storefront-kit-monorepo"
target="_blank"
rel="noopener noreferrer"
>
2 changes: 1 addition & 1 deletion apps/nextjs/pages/search.tsx
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ export default function Search({

<footer className={styles.footer}>
<a
href="https://vercel.com?utm_source=hydrogen-react-monorepo"
href="https://vercel.com?utm_source=storefront-kit-monorepo"
target="_blank"
rel="noopener noreferrer"
>
2 changes: 1 addition & 1 deletion packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @shopify/hydrogen-react
# @shopify/storefront-kit-react

## 2023.1.3

2 changes: 1 addition & 1 deletion packages/react/README.md
Original file line number Diff line number Diff line change
@@ -187,7 +187,7 @@ Improve your development experience by using Storefront Kit's generated Types an
Storefront Kit ships with generated TypeScript types that match the Storefront API and its objects. Import them from the `/storefront-api-types` package path:

```ts
import type {Product} from '@shopify/hydrogen-react/storefront-api-types';
import type {Product} from '@shopify/storefront-kit-react/storefront-api-types';
const product: Product = {};
```
162 changes: 51 additions & 111 deletions packages/react/docs/generated/generated_docs_data.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/react/docs/generated/generated_static_pages.json
Original file line number Diff line number Diff line change
@@ -38,17 +38,17 @@
"tabs": [
{
"title": "Primitive Component",
"code": "import {createStorefrontClient} from '@shopify/hydrogen-react';\n\nexport const storefrontClient = createStorefrontClient({});\n",
"code": "import {createStorefrontClient} from '@shopify/storefront-kit-react';\n\nexport const storefrontClient = createStorefrontClient({});\n",
"language": "javascript"
},
{
"title": "Hook Example",
"code": "import {createStorefrontClient} from '@shopify/hydrogen-react';\n\nexport const storefrontClient = createStorefrontClient({});\n",
"code": "import {createStorefrontClient} from '@shopify/storefront-kit-react';\n\nexport const storefrontClient = createStorefrontClient({});\n",
"language": "javascript"
},
{
"title": "Utility Function Example",
"code": "import {createStorefrontClient} from '@shopify/hydrogen-react';\n\nexport const storefrontClient = createStorefrontClient({});\n",
"code": "import {createStorefrontClient} from '@shopify/storefront-kit-react';\n\nexport const storefrontClient = createStorefrontClient({});\n",
"language": "javascript"
}
]
2 changes: 1 addition & 1 deletion packages/react/docs/staticPages/homepage.example.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {createStorefrontClient} from '@shopify/hydrogen-react';
import {createStorefrontClient} from '@shopify/storefront-kit-react';

export const storefrontClient = createStorefrontClient({});
2 changes: 1 addition & 1 deletion packages/react/src/ExternalVideo.doc.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'ExternalVideo',
category: 'components',
isVisualComponent: true,
isVisualComponent: false,
// put a name in for 'image', and it will look in the docs/screenshots/ folder automatically.
// image: "",
related: [
2 changes: 1 addition & 1 deletion packages/react/src/ExternalVideo.example.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ExternalVideo} from '@shopify/hydrogen-react';
import {ExternalVideo} from '@shopify/storefront-kit-react';

export default function MyProductVideo({products}) {
const firstMediaElement = products.nodes[0].media.nodes[0];
4 changes: 2 additions & 2 deletions packages/react/src/ExternalVideo.example.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ExternalVideo} from '@shopify/hydrogen-react';
import type {ProductConnection} from '@shopify/hydrogen-react/storefront-api-types';
import {ExternalVideo} from '@shopify/storefront-kit-react';
import type {ProductConnection} from '@shopify/storefront-kit-react/storefront-api-types';

export default function MyProductVideo({
products,
2 changes: 1 addition & 1 deletion packages/react/src/Image.doc.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'Image',
category: 'components',
isVisualComponent: true,
isVisualComponent: false,
related: [
{
name: 'MediaFile',
2 changes: 1 addition & 1 deletion packages/react/src/Image.example.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Image} from '@shopify/hydrogen-react';
import {Image} from '@shopify/storefront-kit-react';

export default function ProductImage({product}) {
const image = product.featuredImage;
4 changes: 2 additions & 2 deletions packages/react/src/Image.example.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Image} from '@shopify/hydrogen-react';
import type {Product} from '@shopify/hydrogen-react/storefront-api-types';
import {Image} from '@shopify/storefront-kit-react';
import type {Product} from '@shopify/storefront-kit-react/storefront-api-types';

export default function ProductImage({product}: {product: Product}) {
const image = product.featuredImage;
2 changes: 1 addition & 1 deletion packages/react/src/MediaFile.doc.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'MediaFile',
category: 'components',
isVisualComponent: true,
isVisualComponent: false,
related: [
{
name: 'Image',
2 changes: 1 addition & 1 deletion packages/react/src/MediaFile.example.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {MediaFile} from '@shopify/hydrogen-react';
import {MediaFile} from '@shopify/storefront-kit-react';

export function ProductsMediaFiles({products}) {
return (
4 changes: 2 additions & 2 deletions packages/react/src/MediaFile.example.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {MediaFile} from '@shopify/hydrogen-react';
import type {ProductConnection} from '@shopify/hydrogen-react/storefront-api-types';
import {MediaFile} from '@shopify/storefront-kit-react';
import type {ProductConnection} from '@shopify/storefront-kit-react/storefront-api-types';

export function ProductsMediaFiles({products}: {products: ProductConnection}) {
return (
49 changes: 0 additions & 49 deletions packages/react/src/Metafield.doc.ts

This file was deleted.

11 changes: 0 additions & 11 deletions packages/react/src/Metafield.example.jsx

This file was deleted.

12 changes: 0 additions & 12 deletions packages/react/src/Metafield.example.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/react/src/ModelViewer.doc.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'ModelViewer',
category: 'components',
isVisualComponent: true,
isVisualComponent: false,
related: [
{
name: 'MediaFile',
2 changes: 1 addition & 1 deletion packages/react/src/ModelViewer.example.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ModelViewer} from '@shopify/hydrogen-react';
import {ModelViewer} from '@shopify/storefront-kit-react';

export default function MyProductModel({products}) {
const firstMediaElement = products.nodes[0].media.nodes[0];
4 changes: 2 additions & 2 deletions packages/react/src/ModelViewer.example.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ModelViewer} from '@shopify/hydrogen-react';
import type {ProductConnection} from '@shopify/hydrogen-react/storefront-api-types';
import {ModelViewer} from '@shopify/storefront-kit-react';
import type {ProductConnection} from '@shopify/storefront-kit-react/storefront-api-types';

export default function MyProductModel({
products,
2 changes: 1 addition & 1 deletion packages/react/src/Money.doc.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'money',
category: 'components',
isVisualComponent: true,
isVisualComponent: false,
related: [
{
name: 'useMoney',
2 changes: 1 addition & 1 deletion packages/react/src/Money.example.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Money} from '@shopify/hydrogen-react';
import {Money} from '@shopify/storefront-kit-react';

export default function ProductMoney({product}) {
const price = product.variants.nodes[0].price;
4 changes: 2 additions & 2 deletions packages/react/src/Money.example.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Money} from '@shopify/hydrogen-react';
import type {Product} from '@shopify/hydrogen-react/storefront-api-types';
import {Money} from '@shopify/storefront-kit-react';
import type {Product} from '@shopify/storefront-kit-react/storefront-api-types';

export default function ProductMoney({product}: {product: Product}) {
const price = product.variants.nodes[0].price;
2 changes: 1 addition & 1 deletion packages/react/src/ProductPrice.doc.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'ProductPrice',
category: 'components',
isVisualComponent: true,
isVisualComponent: false,
related: [
{
name: 'ProductProvider',
2 changes: 1 addition & 1 deletion packages/react/src/ProductPrice.example.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ProductPrice} from '@shopify/hydrogen-react';
import {ProductPrice} from '@shopify/storefront-kit-react';

export function ProductPricing({product}) {
return <ProductPrice data={product} priceType="compareAt" valueType="max" />;
4 changes: 2 additions & 2 deletions packages/react/src/ProductPrice.example.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ProductPrice} from '@shopify/hydrogen-react';
import type {Product} from '@shopify/hydrogen-react/storefront-api-types';
import {ProductPrice} from '@shopify/storefront-kit-react';
import type {Product} from '@shopify/storefront-kit-react/storefront-api-types';

export function ProductPricing({product}: {product: Product}) {
return <ProductPrice data={product} priceType="compareAt" valueType="max" />;
2 changes: 1 addition & 1 deletion packages/react/src/ProductProvider.doc.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'ProductProvider',
category: 'components',
isVisualComponent: true,
isVisualComponent: false,
related: [
{
name: 'useProductOptions',
2 changes: 1 addition & 1 deletion packages/react/src/ProductProvider.example.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ProductProvider} from '@shopify/hydrogen-react';
import {ProductProvider} from '@shopify/storefront-kit-react';

export function Product({product}) {
return (
4 changes: 2 additions & 2 deletions packages/react/src/ProductProvider.example.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ProductProvider} from '@shopify/hydrogen-react';
import type {Product} from '@shopify/hydrogen-react/storefront-api-types';
import {ProductProvider} from '@shopify/storefront-kit-react';
import type {Product} from '@shopify/storefront-kit-react/storefront-api-types';

export function Product({product}: {product: Product}) {
return (
2 changes: 1 addition & 1 deletion packages/react/src/ShopPayButton.doc.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'ShopPayButton',
category: 'components',
isVisualComponent: true,
isVisualComponent: false,
related: [
{
name: 'CartShopPayButton',
2 changes: 1 addition & 1 deletion packages/react/src/ShopPayButton.example.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ShopPayButton} from '@shopify/hydrogen-react';
import {ShopPayButton} from '@shopify/storefront-kit-react';

export function AddVariantQuantity1({variantId}) {
return <ShopPayButton variantIds={[variantId]} />;
2 changes: 1 addition & 1 deletion packages/react/src/ShopPayButton.example.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ShopPayButton} from '@shopify/hydrogen-react';
import {ShopPayButton} from '@shopify/storefront-kit-react';

export function AddVariantQuantity1({variantId}: {variantId: string}) {
return <ShopPayButton variantIds={[variantId]} />;
2 changes: 1 addition & 1 deletion packages/react/src/ShopifyProvider.doc.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'ShopifyProvider',
category: 'components',
isVisualComponent: true,
isVisualComponent: false,
related: [],
/* Ren note: In this topic, the related items are pages to /custom-storefronts/hydrogen, so they don't have a type. */

2 changes: 1 addition & 1 deletion packages/react/src/ShopifyProvider.example.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ShopifyProvider} from '@shopify/hydrogen-react';
import {ShopifyProvider} from '@shopify/storefront-kit-react';

export default function App() {
return (
2 changes: 1 addition & 1 deletion packages/react/src/ShopifyProvider.example.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ShopifyProvider} from '@shopify/hydrogen-react';
import {ShopifyProvider} from '@shopify/storefront-kit-react';

export default function App() {
return (
2 changes: 1 addition & 1 deletion packages/react/src/Video.doc.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'video',
category: 'components',
isVisualComponent: true,
isVisualComponent: false,
related: [
{
name: 'MediaFile',
2 changes: 1 addition & 1 deletion packages/react/src/Video.example.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Video} from '@shopify/hydrogen-react';
import {Video} from '@shopify/storefront-kit-react';

export default function MyProductVideo({products}) {
const firstMediaElement = products.edges[0].node.media.edges[0].node;
4 changes: 2 additions & 2 deletions packages/react/src/Video.example.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Video} from '@shopify/hydrogen-react';
import type {ProductConnection} from '@shopify/hydrogen-react/storefront-api-types';
import {Video} from '@shopify/storefront-kit-react';
import type {ProductConnection} from '@shopify/storefront-kit-react/storefront-api-types';

export default function MyProductVideo({
products,
2 changes: 1 addition & 1 deletion packages/react/src/analytics.ts
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ import {
* import {
* sendShopifyAnalytics,
* AnalyticsEventName,
* } from '@shopify/hydrogen-react';
* } from '@shopify/storefront-kit-react';
*
* sendShopifyAnalytics({
* eventName: AnalyticsEventName.PAGE_VIEW,
2 changes: 1 addition & 1 deletion packages/react/src/useCartActions.doc.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'cart',
category: 'hooks',
isVisualComponent: true,
isVisualComponent: false,
related: [],
description: '',
type: 'hook',
2 changes: 1 addition & 1 deletion packages/react/src/useShopifyCookies.tsx
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ const shortTermLength = 60 * 30; // 30 mins
* @param domain - The domain scope of the cookie
* @example
* ```tsx
* import {useShopifyCookies} from '@shopify/hydrogen-react';
* import {useShopifyCookies} from '@shopify/storefront-kit-react';
*
* useShopifyCookies(true, 'my-shop.com')
* ```
4 changes: 2 additions & 2 deletions packages/react/tsconfig.examples.json
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@
"jsx": "react-jsx",
"baseUrl": "src",
"paths": {
"@shopify/hydrogen-react": ["index.ts"],
"@shopify/hydrogen-react/storefront-api-types": [
"@shopify/storefront-kit-react": ["index.ts"],
"@shopify/storefront-kit-react/storefront-api-types": [
"storefront-api-types.d.ts"
]
}

0 comments on commit 5c5c6b6

Please sign in to comment.