Skip to content

Commit

Permalink
Add subcategories for Cart and Caching utilities, and Media component…
Browse files Browse the repository at this point in the history
…s. (#2158)

Caching subcategory

Remove component cart subcat

Media subcat

Media for Hydrogen
  • Loading branch information
gfscott committed May 29, 2024
1 parent 64a0203 commit da7c4d0
Show file tree
Hide file tree
Showing 36 changed files with 2,290 additions and 422 deletions.
14 changes: 13 additions & 1 deletion packages/hydrogen-react/docs/generated/generated_docs_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
"name": "AddToCartButton",
"category": "components",
"subCategory": "cart",
"isVisualComponent": false,
"related": [],
"description": "The `AddToCartButton` component renders a button that adds an item to the cart when pressed.\n\nIt must be a descendent of the `CartProvider` component.",
Expand Down Expand Up @@ -229,6 +230,7 @@
{
"name": "CartCheckoutButton",
"category": "components",
"subCategory": "cart",
"isVisualComponent": false,
"related": [],
"description": "The `CartCheckoutButton` component renders a button that redirects to the checkout URL for the cart.\n\nMust be a descendent of a `CartProvider` component.\n ",
Expand Down Expand Up @@ -303,6 +305,7 @@
{
"name": "CartCost",
"category": "components",
"subCategory": "cart",
"isVisualComponent": false,
"related": [],
"description": "\n The `CartCost` component renders a `Money` component with the cost associated with the `amountType` prop.\n\nIf no `amountType` prop is specified, then it defaults to `totalAmount`.\n\nDepends on `useCart()` and must be a child of `<CartProvider/>`\n ",
Expand Down Expand Up @@ -402,6 +405,7 @@
{
"name": "CartLineProvider",
"category": "components",
"subCategory": "cart",
"isVisualComponent": false,
"related": [
{
Expand Down Expand Up @@ -473,6 +477,7 @@
{
"name": "CartLineQuantity",
"category": "components",
"subCategory": "cart",
"isVisualComponent": false,
"related": [
{
Expand Down Expand Up @@ -535,6 +540,7 @@
{
"name": "CartLineQuantityAdjustButton",
"category": "components",
"subCategory": "cart",
"isVisualComponent": false,
"related": [
{
Expand Down Expand Up @@ -597,6 +603,7 @@
{
"name": "CartProvider",
"category": "components",
"subCategory": "cart",
"isVisualComponent": false,
"related": [
{
Expand Down Expand Up @@ -835,6 +842,7 @@
{
"name": "ExternalVideo",
"category": "components",
"subCategory": "media",
"isVisualComponent": false,
"related": [
{
Expand Down Expand Up @@ -1234,6 +1242,7 @@
{
"name": "Image",
"category": "components",
"subCategory": "media",
"isVisualComponent": false,
"related": [
{
Expand Down Expand Up @@ -1458,6 +1467,7 @@
{
"name": "MediaFile",
"category": "components",
"subCategory": "media",
"isVisualComponent": false,
"related": [
{
Expand Down Expand Up @@ -3900,6 +3910,7 @@
{
"name": "ModelViewer",
"category": "components",
"subCategory": "media",
"isVisualComponent": false,
"related": [
{
Expand Down Expand Up @@ -4629,6 +4640,7 @@
{
"name": "Video",
"category": "components",
"subCategory": "media",
"isVisualComponent": false,
"related": [
{
Expand Down Expand Up @@ -7660,7 +7672,7 @@
"name": "void",
"value": "void"
},
"value": "export function useShopifyCookies(options?: UseShopifyCookiesOptions): void {\n const {hasUserConsent = false, domain = ''} = options || {};\n useEffect(() => {\n const cookies = getShopifyCookies(document.cookie);\n\n /**\n * Set user and session cookies and refresh the expiry time\n */\n if (hasUserConsent) {\n setCookie(\n SHOPIFY_Y,\n cookies[SHOPIFY_Y] || buildUUID(),\n longTermLength,\n domain,\n );\n setCookie(\n SHOPIFY_S,\n cookies[SHOPIFY_S] || buildUUID(),\n shortTermLength,\n domain,\n );\n } else {\n setCookie(SHOPIFY_Y, '', 0, domain);\n setCookie(SHOPIFY_S, '', 0, domain);\n }\n }, [options, hasUserConsent, domain]);\n}"
"value": "export function useShopifyCookies(options?: UseShopifyCookiesOptions): void {\n const {hasUserConsent = false, domain = ''} = options || {};\n useEffect(() => {\n const cookies = getShopifyCookies(document.cookie);\n\n /**\n * Setting cookie with domain\n *\n * If no domain is provided, the cookie will be set for the current host.\n * For Shopify, we need to ensure this domain is set with a leading dot.\n */\n\n // Use override domain or current host\n let currentDomain = domain || window.document.location.host;\n\n // Reset domain if localhost\n if (/^localhost/.test(currentDomain)) currentDomain = '';\n\n // Shopify checkout only consumes cookies set with leading dot domain\n const domainWithLeadingDot = currentDomain\n ? /^\\./.test(currentDomain)\n ? currentDomain\n : `.${currentDomain}`\n : '';\n\n /**\n * Set user and session cookies and refresh the expiry time\n */\n if (hasUserConsent) {\n setCookie(\n SHOPIFY_Y,\n cookies[SHOPIFY_Y] || buildUUID(),\n longTermLength,\n domainWithLeadingDot,\n );\n setCookie(\n SHOPIFY_S,\n cookies[SHOPIFY_S] || buildUUID(),\n shortTermLength,\n domainWithLeadingDot,\n );\n } else {\n setCookie(SHOPIFY_Y, '', 0, domainWithLeadingDot);\n setCookie(SHOPIFY_S, '', 0, domainWithLeadingDot);\n }\n }, [options, hasUserConsent, domain]);\n}"
},
"UseShopifyCookiesOptions": {
"filePath": "/useShopifyCookies.tsx",
Expand Down
1 change: 1 addition & 0 deletions packages/hydrogen-react/src/AddToCartButton.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'AddToCartButton',
category: 'components',
subCategory: 'cart',
isVisualComponent: false,
related: [],
description: `The \`AddToCartButton\` component renders a button that adds an item to the cart when pressed.\n\nIt must be a descendent of the \`CartProvider\` component.`,
Expand Down
1 change: 1 addition & 0 deletions packages/hydrogen-react/src/CartCheckoutButton.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'CartCheckoutButton',
category: 'components',
subCategory: 'cart',
isVisualComponent: false,
related: [],
description: `The \`CartCheckoutButton\` component renders a button that redirects to the checkout URL for the cart.\n\nMust be a descendent of a \`CartProvider\` component.
Expand Down
1 change: 1 addition & 0 deletions packages/hydrogen-react/src/CartCost.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'CartCost',
category: 'components',
subCategory: 'cart',
isVisualComponent: false,
related: [],
description: `
Expand Down
1 change: 1 addition & 0 deletions packages/hydrogen-react/src/CartLineProvider.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'CartLineProvider',
category: 'components',
subCategory: 'cart',
isVisualComponent: false,
related: [
{
Expand Down
1 change: 1 addition & 0 deletions packages/hydrogen-react/src/CartLineQuantity.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'CartLineQuantity',
category: 'components',
subCategory: 'cart',
isVisualComponent: false,
related: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'CartLineQuantityAdjustButton',
category: 'components',
subCategory: 'cart',
isVisualComponent: false,
related: [
{
Expand Down
1 change: 1 addition & 0 deletions packages/hydrogen-react/src/CartProvider.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'CartProvider',
category: 'components',
subCategory: 'cart',
isVisualComponent: false,
related: [
{
Expand Down
1 change: 1 addition & 0 deletions packages/hydrogen-react/src/ExternalVideo.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'ExternalVideo',
category: 'components',
subCategory: 'media',
isVisualComponent: false,
// put a name in for 'image', and it will look in the docs/screenshots/ folder automatically.
// image: "",
Expand Down
1 change: 1 addition & 0 deletions packages/hydrogen-react/src/Image.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'Image',
category: 'components',
subCategory: 'media',
isVisualComponent: false,
related: [
{
Expand Down
1 change: 1 addition & 0 deletions packages/hydrogen-react/src/MediaFile.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'MediaFile',
category: 'components',
subCategory: 'media',
isVisualComponent: false,
related: [
{
Expand Down
1 change: 1 addition & 0 deletions packages/hydrogen-react/src/ModelViewer.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'ModelViewer',
category: 'components',
subCategory: 'media',
isVisualComponent: false,
related: [
{
Expand Down
1 change: 1 addition & 0 deletions packages/hydrogen-react/src/Video.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
const data: ReferenceEntityTemplateSchema = {
name: 'Video',
category: 'components',
subCategory: 'media',
isVisualComponent: false,
related: [
{
Expand Down
Loading

0 comments on commit da7c4d0

Please sign in to comment.