Compare commits

...

103 commits
v0.6.1 ... main

Author SHA1 Message Date
Fran Dios 2a8fc362f5 v0.6.4 2021-11-11 17:33:32 +09:00
Fran Dios b1b5ba2ad8
Merge pull request #198 from Shopify/fd-fix-public-assets
fix: run Hydrogen middleware after Vite handles static assets
2021-11-11 17:24:54 +09:00
Fran Dios 474a63af44
Merge branch 'main' into fd-fix-public-assets 2021-11-11 13:24:33 +09:00
Fran Dios ffb98a66d5
Merge pull request #199 from Shopify/fd-fix-wire-newline
fix: new lines in hydration response
2021-11-11 13:23:34 +09:00
Fran Dios 996b71f639 fix: remove favicon.ico check 2021-11-11 13:19:27 +09:00
Fran Dios 17801a9d9e
Merge branch 'main' into fd-fix-wire-newline 2021-11-11 13:07:08 +09:00
Fran Dios 451971980d refactor: move favicon in all projects to public directories 2021-11-11 12:59:11 +09:00
Fran Dios 164d317438 test: client handles new lines in hydration response 2021-11-11 12:52:06 +09:00
Bret Little 4078e37ad4
Merge pull request #214 from Shopify/bl-fix-changelog
chore: fix changelog
2021-11-10 17:13:03 -05:00
Bret Little 8df3c8f8d4
chore: fix changelog 2021-11-10 17:12:17 -05:00
Bret Little 68f7a79365
Merge pull request #213 from sahilmob/fix-pageload-scrolling
fix(dev): fix scroll to top on app first load
2021-11-10 17:08:59 -05:00
Sahil H. Mobaidin ade416ff1b fix(dev): fix scroll to top on app first load 2021-11-10 23:32:01 +02:00
Bret Little b3c86723c7
Merge pull request #197 from Eastonco/eastonco/readme
docs(readme): center title and add href to logo
2021-11-10 16:29:38 -05:00
Bret Little 5ad569165b
Merge pull request #210 from Shopify/jl-request-more-repros
chore: request more repros in bug reports
2021-11-10 16:02:17 -05:00
Bret Little 935ebc81a9
Merge pull request #204 from Shopify/bl-201
fix(#201): normalize POSIX separators to support windows
2021-11-10 15:59:28 -05:00
Bret Little 6f2e86e85f
chore: update changelog 2021-11-10 15:52:50 -05:00
Josh Larson b0a0ce3b83
chore: request more repros in bug reports
We got StackBlitz. Let's use it to our advantage! 80% of the time when people go to reproduce the bug fix, they will find the true cause of the issue (and sometimes it's not Hydrogen related).
2021-11-10 14:31:40 -06:00
Bret Little 193a601975
fix: add a unit test to validate vite middleware transforms 2021-11-10 13:45:15 -05:00
Josh Larson 69576610c4
chore: improve Stackblitz publishing flow (#203)
* chore: hoist local flag to root project

* chore: publish to stackblitz branch with new release

* chore: rename gitignore for stackblitz

* chore: use correct path

* chore: include `.stackblitzrc` file to ensure dev server starts
2021-11-10 12:01:53 -06:00
Bret Little 79f32c52ad
fix(#201): normalize POSIX separators to support windows 2021-11-10 12:19:16 -05:00
Fran Dios 4302cf2ff9 test: remove new lines in wire response 2021-11-10 17:15:55 +09:00
Fran Dios 1f45f15a24 chore: update changelog 2021-11-10 17:08:56 +09:00
Fran Dios e2326b9756 fix: new lines in wire response 2021-11-10 17:08:03 +09:00
Fran Dios c8e601d374 chore: update changelog 2021-11-10 16:13:47 +09:00
Fran Dios ccc44c8e80 fix: run Hydrogen middleware after Vite handles static assets 2021-11-10 16:11:07 +09:00
Fran Dios 11737be41d refactor: move favicon to public directory 2021-11-10 16:10:09 +09:00
Fran Dios 0b8a73d712 v0.6.3 2021-11-10 14:31:52 +09:00
Fran Dios 2b82a45293
Merge pull request #196 from Shopify/fd-user-glob-fix
Fd user glob fix
2021-11-10 14:25:54 +09:00
Fran Dios 6682fd714d chore: update changelog 2021-11-10 14:20:12 +09:00
Connor Easton 8d1d59c604 docs(readme): center title and add href to logo 2021-11-09 22:19:33 -07:00
Fran Dios b021d8558e fix: add trailing slash to user components glob 2021-11-10 14:05:52 +09:00
Fran Dios 609a697d6c refactor: change old function name 2021-11-10 14:04:46 +09:00
Fran Dios 0a303c6549 v0.6.2 2021-11-10 12:19:42 +09:00
Michelle Vinci 208a988833
Merge pull request #194 from Shopify/hydrogen-regen-docs
[Hydrogen reference docs]: Regenerate docs
2021-11-09 18:29:37 -08:00
Michelle Vinci 74a7cfbd67 feat: regen docs 2021-11-09 18:20:09 -08:00
Fran Dios 165451980d
Merge pull request #168 from Shopify/fd-fix-router-switch
fix: should not use switch outside a router
2021-11-10 11:13:38 +09:00
Fran Dios 7f1e21c6f3 fix: move LocalizationProvider up in the Layout tree 2021-11-10 11:05:37 +09:00
Michelle Vinci 58afc97bae
Merge pull request #193 from Shopify/hydrogen-rsc
[Hydrogren reference docs]: Re-organize and refine React Server Component docs
2021-11-09 17:16:35 -08:00
Michelle Vinci f9161bd7d1 fix: remove comment 2021-11-09 17:10:13 -08:00
Michelle Vinci 355cd7f6e0 fix: comment and link 2021-11-09 17:03:36 -08:00
Michelle Vinci 1901ae7e35 fix: docpath 2021-11-09 16:50:05 -08:00
Michelle Vinci b60156985c fix: link 2021-11-09 16:45:47 -08:00
Michelle Vinci 0618710e91 feat: re-org rsc docs 2021-11-09 16:41:07 -08:00
Josh Larson e083295d49
feat: bump Vite deps to latest version (#191) 2021-11-09 16:38:33 -06:00
Josh Larson 5948cb9157 chore: update changelog 2021-11-09 16:33:03 -06:00
Josh Larson 5263bfd090 chore: Merge remote-tracking branch 'origin/main' into fd-fix-router-switch 2021-11-09 16:32:30 -06:00
Ben Wolfram d5232a8cfa
fix: Safari Product Image Gallery (#162)
* fix: gallery safari grid layout

* Update CHANGELOG.md

Co-authored-by: Josh Larson <josh.larson@shopify.com>
2021-11-09 16:31:55 -06:00
Josh Larson 01dd715da6
fix: eliminate use of client component re-exports (#181) 2021-11-09 15:52:25 -06:00
Josh Larson 33c5d05e49
chore: tell linter to ignore auto-gen types file which is super noisy (#180) 2021-11-09 13:17:50 -06:00
Matt Seccafien aa78095c0d
Merge pull request #174 from Shopify/@cartogram/hide-cli-docs
fix: hide CLI docs for shopify.dev
2021-11-09 18:18:29 +01:00
Matt Seccafien acc8788f7c
Merge pull request #153 from Shopify/@cartogram/tophat-script
feat: Adds tophat script
2021-11-09 16:11:26 +01:00
Matt Seccafien 73b5164f2f fix: hide CLI docs in generator 2021-11-09 16:04:27 +01:00
Cathryn Griffiths 97cc958324
Merge pull request #151 from Shopify/cathryn/buy-now-button-improvements
Remove `CartProvider` from the `BuyNowButton`
2021-11-09 09:49:14 -05:00
cathryngriffiths 9f69edc2f0 chore: update changelog 2021-11-09 09:43:05 -05:00
cathryngriffiths bbd16eaf55 fix: remove CartProvider from BuyNowButton 2021-11-09 09:42:19 -05:00
Josh Larson 4fe7ea70a8
chore: remove more logs that I missed (#159) 2021-11-09 08:23:08 -06:00
Fran Dios 2e1bc02e6a
Merge pull request #7 from Shopify/fd-fix-client-components-import
Fix client component imports and duplicated files/contexts in browser
2021-11-09 14:04:43 +09:00
Fran Dios 2b445c9170 fix: should not use switch outside a router 2021-11-09 12:00:30 +09:00
Fran Dios bebf05e40a
Merge pull request #144 from Shopify/fd-fix-headers-override
fix: delay writing error response until headers are set
2021-11-09 11:26:21 +09:00
Josh Larson 3aa230cfd9 chore: update changelogs 2021-11-08 19:30:52 -06:00
Josh Larson 2adc9767cb chore: Merge remote-tracking branch 'origin/main' into fd-fix-client-components-import 2021-11-08 19:30:00 -06:00
Josh Larson 075e9c1c18 chore: remove old build step in react shim 2021-11-08 19:27:25 -06:00
Josh Larson 03232127c2 fix: make MoneyPrice and MoneyCompareAtPrice client components 2021-11-08 19:22:21 -06:00
Michelle Vinci ea93b8d556
Merge pull request #165 from Shopify/update-comments
[Hydrogen reference docs]: Specify `/hydrogen` repo in comments
2021-11-08 16:10:06 -08:00
Michelle Vinci f4703dd90a fix: specify hydrogen repo 2021-11-08 16:02:51 -08:00
Matt Seccafien cacc141061 Update docs/contributing.md
Co-authored-by: Josh Larson <josh.larson@shopify.com>
2021-11-08 22:53:43 +01:00
Matt Seccafien 4165ffd3cc Update scripts/tophat.js
Co-authored-by: Josh Larson <josh.larson@shopify.com>
2021-11-08 22:53:43 +01:00
Matt Seccafien 159a64565f Update scripts/tophat.js
Co-authored-by: Josh Larson <josh.larson@shopify.com>
2021-11-08 22:53:43 +01:00
Matt Seccafien 84631b29bd feat: tophat script, reluctantly 2021-11-08 22:53:41 +01:00
Matt Seccafien a16039324d
Merge pull request #156 from Shopify/@cartogram/lint-changelogs
feat: Lint changelogs for "Keep a changelog" semantics
2021-11-08 22:51:55 +01:00
Matt Seccafien 1435a58be9
Merge pull request #148 from Shopify/@cartogram/cli-debug-logger
feat: Pass instantiated Debug logger to cli command Env
2021-11-08 19:37:39 +01:00
Matt Seccafien 1ae093804d
Update tests/changelogs.test.ts
Co-authored-by: Josh Larson <josh.larson@shopify.com>
2021-11-08 19:32:38 +01:00
Matt Seccafien fce5864370
Update tests/changelogs.test.ts
Co-authored-by: Josh Larson <josh.larson@shopify.com>
2021-11-08 19:32:33 +01:00
Matt Seccafien cff98fa76c
Merge pull request #147 from Shopify/@cartogram/eslint-fixes
fix: ESLint config fixes
2021-11-08 19:31:45 +01:00
Matt Seccafien 22d70ebf64
Merge pull request #157 from Shopify/@cartogram/dont-generate-shopify-dev-docs-without-flag
fix: Don't generate docs without flag
2021-11-08 19:10:34 +01:00
Matt Seccafien 7d75091db8 fix: Don't generate docs without flag 2021-11-08 18:43:02 +01:00
Matt Seccafien 8a9d2108fd
Merge pull request #150 from Shopify/@cartogram/cli-explicit-root
feat: Support explicit root in the CLI
2021-11-08 18:17:56 +01:00
Matt Seccafien 545bd40f7d feat: Lint changelogs for "Keep a changelog" semantics 2021-11-08 18:09:34 +01:00
Bret Little e85227a0b9
Merge pull request #154 from Shopify/fix-changelog
fix: changelog
2021-11-08 10:58:59 -05:00
Bret Little 493e16d63e
fix: changelog 2021-11-08 10:56:51 -05:00
Bret Little 72c9c5dee5
Merge pull request #152 from Shopify/fix-null
fix: where react props can be null, yet still technically an "object"
2021-11-08 10:54:41 -05:00
Bret Little 50b4d03f06
fix: where react props can be null, yet still technically an "object"
Thank you JavaScript
2021-11-08 10:54:09 -05:00
Matt Seccafien 11c492e69b feat: support explicit root in the cli 2021-11-08 16:09:38 +01:00
Matt Seccafien 737d815d6b fix: Eslint changelogs entries 2021-11-08 15:46:41 +01:00
Matt Seccafien d2adf78dcc fix: various eslint config issues 2021-11-08 15:42:02 +01:00
Josh Larson ce3d010901
chore: remove deprecated package 2021-11-08 08:07:38 -06:00
Josh Larson c332189eb2
chore: add note about dev preview (#146) 2021-11-08 08:06:59 -06:00
Fran Dios 3abfd67e7b chore: update changelog 2021-11-08 20:50:05 +09:00
Fran Dios 06dabb7961 fix: delay writing error response until headers are set 2021-11-08 20:45:19 +09:00
Fran Dios 57520ae0b2 test: mock Vite import.glob 2021-11-08 16:27:43 +09:00
Matt Seccafien fea2208a37 feat: pass debug logger to cli commands 2021-11-08 08:26:05 +01:00
Fran Dios 8279d4c558 feat: Use Vite import in prod for client components 2021-11-08 16:02:56 +09:00
Fran Dios 8392037e68 test: remove unnecessary query-string 2021-11-08 15:52:31 +09:00
Fran Dios b82fc47292 Merge branch 'main' into fd-fix-client-components-import 2021-11-08 15:13:17 +09:00
Fran Dios f88ee1c05e test: fix query-string 2021-11-05 12:30:49 +09:00
Fran Dios ac5caae87e chore: update changelog 2021-11-05 12:28:20 +09:00
Fran Dios fc39a5979c fix: optimize @headlessui/react 2021-11-05 12:08:41 +09:00
Fran Dios e9165db04b refactor: remove old workaround for context dedup 2021-11-05 12:07:15 +09:00
Fran Dios 22d3932fa2 fix: use Vite imports in dev to avoid duplicated files in browser 2021-11-05 11:52:06 +09:00
Fran Dios 88041f7ce0 fix: change strategy to wrap client components in ClientMarker 2021-11-05 11:45:08 +09:00
Fran Dios 15cd3f6d80 fix: add a runtime check to wrap only React components in ClientMarker 2021-11-05 11:33:35 +09:00
Fran Dios e52b43baf0 fix: do not import client logic in GraphiQL 2021-11-05 11:25:06 +09:00
Fran Dios c90a0d120d fix: export Link as a client component 2021-11-05 11:24:08 +09:00
176 changed files with 1425 additions and 1038 deletions

View file

@ -2,6 +2,7 @@
const {defineConfig} = require('eslint-define-config');
module.exports = defineConfig({
ignorePatterns: ['**/graphql/types/types.ts'],
root: true,
plugins: ['eslint-plugin-tsdoc'],
extends: [

View file

@ -10,7 +10,11 @@ assignees: ''
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behaviour:
- Provide a link to a [StackBlitz sandbox](https://hydrogen.new) which reproduces the issue
- OR: provide a link to a repository that reproduces the issue
If you cannot do one of the above, list steps to reproduce the behaviour below:
1. Go to '...'
2. Click on '....'

View file

@ -0,0 +1,21 @@
name: Publish to Stackblitz
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
name: Publish latest release to Stackblitz
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Rename gitignore
run: |
mv packages/dev/_gitignore packages/dev/.gitignore
- name: Push to stackblitz branch
uses: EndBug/add-and-commit@v7.4.0
with:
push: 'origin stackblitz --force'

View file

@ -1,11 +1,21 @@
![Hydrogen logo](/docs/images/HydrogenLogo.png)
<p align="center">
<a href="https://hydrogen.shopify.dev">
<img src="./docs/images/HydrogenLogo.png"/>
</a>
</p>
📚 [Docs](https://shopify.dev/custom-storefronts/hydrogen) | 🗣 [Discord](https://discord.gg/Hefq6w5c5d) | 💬 [Discussions](https://github.com/Shopify/hydrogen/discussions) | 📝 [Changelog](./packages/hydrogen/CHANGELOG.md)
<div align="center">
📚 [Docs](https://shopify.dev/custom-storefronts/hydrogen) | 🗣 [Discord](https://discord.gg/Hefq6w5c5d) | 💬 [Discussions](https://github.com/Shopify/hydrogen/discussions) | 📝 [Changelog](./packages/hydrogen/CHANGELOG.md)
</div>
Hydrogen is a **React-based framework** for building dynamic, **Shopify-powered** custom storefronts.
Spin up a Hydrogen app in your browser with our [playground](https://hydrogen.new/) or set up your local environment with the instructions below ⬇️
**This is a developer preview of Hydrogen**. The documentation will be updated as Shopify [introduces new features and refines existing functionality](https://github.com/Shopify/hydrogen/releases). Production launches of Hydrogen custom storefronts aren't yet supported as Shopify is evolving the Hydrogen framework.
## Getting Started
**Requirements:**
@ -63,4 +73,3 @@ Learn more about [getting started with Hydrogen](https://shopify.dev/custom-stor
- [`@shopify/hydrogen-plugin-sanity`](https://www.npmjs.com/package/@shopify/hydrogen-plugin-sanity)
- [`create-hydrogen-app`](https://www.npmjs.com/package/create-hydrogen-app)
- [`eslint-plugin-hydrogen`](https://www.npmjs.com/package/eslint-plugin-hydrogen)
- [`@shopify/create-hydrogen` (deprecated)](https://www.npmjs.com/package/@shopify/create-hydrogen)

View file

@ -182,3 +182,16 @@ When finished, push up your changes.
Next, visit the Shipit page for Hydrogen and click **Deploy**.
After Shipit has released your version, visit the [releases page on GitHub](https://github.com/Shopify/hydrogen/releases), click on the version number you just released, and select "Create release from tag." Then, select "Auto-generate release notes." At this point, edit the release notes as you see fit (e.g. call out any breaking changes or upgrade guides). Finally, click "Publish release."
## Testing changes in another project
From the root of the repo, run:
```bash
yarn tophat ../PATH/TO/PROJECT --packages [...PACKAGES_LIST]
# example
yarn tophat ../cartogram/hydrogen-shop --packages cli hydrogen eslint-plugin
```

View file

@ -3,7 +3,7 @@
"packages": [
"packages/*"
],
"version": "0.6.1",
"version": "0.6.4",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {}

View file

@ -12,7 +12,7 @@
},
"scripts": {
"dev-lib": "yarn workspace @shopify/hydrogen dev",
"dev-server": "VITE_INSPECT=1 yarn workspace dev dev",
"dev-server": "LOCAL_DEV=true VITE_INSPECT=1 yarn workspace dev dev",
"build": "run-s build-lib build-dev build-cli",
"build-lib": "yarn workspace @shopify/hydrogen build",
"build-cli": "yarn workspace @shopify/hydrogen-cli build",
@ -30,7 +30,8 @@
"h2": "./packages/cli/bin/hydrogen",
"update-docs-on-version": "ts-node --project ./tsconfig.json ./scripts/update-docs-on-version.ts",
"generate-docs": "ts-node --project ./tsconfig.json ./scripts/generate-docs.ts",
"generate-docs:debug": "node --inspect-brk ./node_modules/.bin/ts-node --project ./tsconfig.json ./scripts/generate-docs.ts"
"generate-docs:debug": "node --inspect-brk ./node_modules/.bin/ts-node --project ./tsconfig.json ./scripts/generate-docs.ts",
"tophat": "node ./scripts/tophat"
},
"devDependencies": {
"@shopify/prettier-config": "^1.1.2",
@ -64,8 +65,10 @@
"ts-jest": "^26.5.4",
"ts-node": "^10.2.1",
"typescript": "^4.2.3",
"vite": "^2.6.0",
"yorkie": "^2.0.0"
"vite": "^2.6.14",
"yorkie": "^2.0.0",
"glob": "^7.2.0",
"shelljs": "^0.8.4"
},
"gitHooks": {
"pre-commit": "lint-staged",

View file

@ -7,6 +7,14 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
<!-- ## Unreleased -->
## 0.6.4 - 2021-11-11
- No updates. Transitive dependency bump.
## 0.6.2 - 2021-11-10
- Add ability to explicitly set the root for the running command using the `--root` flag
## 0.6.0 - 2021-11-05
- Add create page command [#810](https://github.com/Shopify/hydrogen/pull/810)

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/cli and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/cli and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
## `@shopify/hydrogen-cli`

View file

@ -1,6 +1,6 @@
{
"name": "@shopify/hydrogen-cli",
"version": "0.6.0",
"version": "0.6.4",
"description": "Command line interface for hydrogen",
"license": "MIT",
"engines": {
@ -52,7 +52,7 @@
"playwright-chromium": "^1.13.0",
"sirv": "^1.0.14",
"typescript": "^4.2.3",
"vite": "^2.6.0"
"vite": "^2.6.14"
},
"files": [
"dist",

View file

@ -99,7 +99,7 @@ export async function app(env: Env<{name: string}>) {
workspace.install('react-dom', {version: '18.0.0-alpha-e6be2d531'});
workspace.install('react-router-dom', {version: '^5.2.0'});
workspace.install('@shopify/hydrogen');
workspace.install('vite', {dev: true, version: '^2.6.0'});
workspace.install('vite', {dev: true, version: '^2.6.14'});
workspace.install('@vitejs/plugin-react-refresh', {
dev: true,
version: '^1.3.2',

View file

@ -7,7 +7,7 @@ export default function ({ifFeature}: TemplateOptions) {
<html>
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
${ifFeature(

View file

@ -13,7 +13,7 @@ export enum Template {
* Create a new `@shopify/hydrogen` app.
*/
export async function init(env: Env) {
const {ui, fs, workspace} = env;
const {ui, fs, workspace, ...passThroughEnv} = env;
const name = await ui.ask('What do you want to name this app?', {
validate: validateProjectName,
@ -43,8 +43,8 @@ export async function init(env: Env) {
);
if (template === Template.None) {
const context = {name};
await app({ui, fs, workspace, context});
const context = {name, ...passThroughEnv.context};
await app({...passThroughEnv, ui, fs, workspace, context});
}
if (template === Template.Default) {

View file

@ -4,9 +4,14 @@ import {Cli} from './ui';
import {Workspace} from './workspace';
import {Fs} from './fs';
import {loadConfig} from './config';
import {Env} from './types';
const logger = debug('hydrogen');
interface ModuleType {
default: (env: Env) => Promise<void>;
}
(async () => {
const rawInputs = process.argv.slice(2);
const {command, root} = parseCliArguments(rawInputs);
@ -22,10 +27,23 @@ const logger = debug('hydrogen');
throw new InputError();
}
async function runModule(module: ModuleType) {
logger('Run start');
await module.default({
ui,
fs,
workspace,
logger: debug(`hydrogen/${command}`),
});
logger('Run end');
}
try {
const module = await import(`./commands/${command}`);
await module.default({ui, fs, workspace});
await runModule(module);
} catch (error) {
logger(error);
@ -36,7 +54,9 @@ const logger = debug('hydrogen');
ui.printFile(file);
}
await workspace.commit();
if (command === 'init') {
await workspace.commit();
}
})().catch((error) => {
logger(error);
process.exitCode = 1;

View file

@ -1,3 +1,4 @@
import debug from 'debug';
import {Workspace} from './workspace';
import {Ui} from './ui';
import {Fs} from './fs';
@ -9,6 +10,7 @@ export interface Env<Context = {}> {
workspace: Workspace;
fs: Fs;
context?: Context;
logger: debug.Debugger;
}
export enum ComponentType {

View file

@ -1,4 +1,4 @@
import {join, resolve} from 'path';
import {resolve} from 'path';
import minimist from 'minimist';
@ -15,10 +15,8 @@ const DEFAULT_SUBCOMMANDS = {
export function parseCliArguments(rawInputs?: string[]) {
const inputs = minimist(rawInputs || []);
const command = inputs._[0];
const root =
command === 'create' && inputs._[2]
? join(process.cwd(), inputs._[2])
: process.cwd();
const root = inputs.root || process.cwd();
const subcommand =
inputs._[1] || DEFAULT_SUBCOMMANDS[command as 'create' | 'version'];
const {debug} = inputs;

View file

@ -7,6 +7,21 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
<!-- ## Unreleased -->
## 0.6.4 - 2021-11-11
- No updates. Transitive dependency bump.
## 0.6.3 - 2021-11-10
- No updates. Transitive dependency bump.
## 0.6.2 - 2021-11-10
- Wrap instances of `<Money>` in client components due to render prop usage
- Eliminate use of `Link` client re-exports
- fix: gallery safari grid layout
- fix: Move `LocalizationProvider` to `Layout.server` to prevent issues with React Router & Suspense
## 0.6.1 - 2021-11-08
- Wrap LocalizationProvider in a proper Suspense boundary

View file

@ -4,7 +4,7 @@
"access": "public",
"@shopify:registry": "https://registry.npmjs.org"
},
"version": "0.6.1",
"version": "0.6.4",
"main": "index.js",
"license": "MIT",
"bin": {

View file

@ -12,7 +12,7 @@ const {copy} = require('./utils');
const devPath = path.resolve(__dirname, '..', '..', 'dev');
const templatePath = path.resolve(__dirname, '..', './template-hydrogen');
const skipFiles = ['node_modules', 'dist'];
const skipFiles = ['node_modules', 'dist', '.stackblitzrc'];
// Remove the symlink and replace it with a folder
fs.unlinkSync(templatePath);

View file

@ -0,0 +1,4 @@
{
"installDependencies": true,
"startCommand": "npm run dev"
}

View file

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hydrogen App</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />

View file

@ -1,11 +1,11 @@
{
"name": "dev",
"description": "This is a dev environment for Hydrogen",
"version": "0.6.1",
"version": "0.6.4",
"license": "MIT",
"private": true,
"scripts": {
"dev": "LOCAL_DEV=true vite",
"dev": "vite",
"lint": "npm-run-all lint:*",
"lint:js": "eslint --no-error-on-unmatched-pattern --ext .js,.ts,.jsx,.tsx src",
"lint:css": "stylelint ./src/**/*.{css,sass,scss}",
@ -28,11 +28,11 @@
"prettier": "^2.3.2",
"stylelint": "^13.13.0",
"tailwindcss": "^2.2.4",
"vite": "^2.6.0"
"vite": "^2.6.14"
},
"dependencies": {
"@headlessui/react": "^1.4.1",
"@shopify/hydrogen": "^0.6.1",
"@shopify/hydrogen": "^0.6.4",
"compression": "^1.7.4",
"express": "^4.17.1",
"graphql-tag": "^2.12.4",

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -1,8 +1,4 @@
import {
ShopifyServerProvider,
DefaultRoutes,
LocalizationProvider,
} from '@shopify/hydrogen';
import {ShopifyServerProvider, DefaultRoutes} from '@shopify/hydrogen';
import {Switch} from 'react-router-dom';
import {Suspense} from 'react';
@ -19,18 +15,16 @@ export default function App({...serverState}) {
return (
<Suspense fallback={<LoadingFallback />}>
<ShopifyServerProvider shopifyConfig={shopifyConfig} {...serverState}>
<LocalizationProvider>
<CartProvider>
<DefaultSeo />
<Switch>
<DefaultRoutes
pages={pages}
serverState={serverState}
fallback={<NotFound />}
/>
</Switch>
</CartProvider>
</LocalizationProvider>
<CartProvider>
<DefaultSeo />
<Switch>
<DefaultRoutes
pages={pages}
serverState={serverState}
fallback={<NotFound />}
/>
</Switch>
</CartProvider>
</ShopifyServerProvider>
</Suspense>
);

View file

@ -1,6 +1,4 @@
import {Image} from '@shopify/hydrogen/client';
import {Link} from './Link.client';
import {Image, Link} from '@shopify/hydrogen/client';
export default function FeaturedCollection({collection}) {
return collection ? (

View file

@ -1,4 +1,4 @@
import {Link} from './Link.client';
import {Link} from '@shopify/hydrogen';
export default function Footer({collection, product}) {
return (

View file

@ -26,7 +26,7 @@ export default function Gallery() {
className="gap-4 flex md:grid md:grid-cols-2 overflow-x-scroll no-scrollbar scroll-snap-x scroll-smooth h-[485px] md:h-auto place-content-start"
tabIndex="-1"
>
<SelectedVariantImage className="w-[80vw] md:w-full h-full object-cover object-center flex-shrink-0 md:flex-shrink-none snap-start md:col-span-2 border border-gray-200 rounded-lg" />
<SelectedVariantImage className="w-[80vw] md:w-full h-full md:h-auto object-cover object-center flex-shrink-0 md:flex-shrink-none snap-start md:col-span-2 border border-gray-200 rounded-lg" />
{galleryMedia.map((med) => {
let extraProps = {};

View file

@ -1,4 +1,9 @@
import {useShopQuery, flattenConnection, Image} from '@shopify/hydrogen';
import {
Image,
useShopQuery,
flattenConnection,
LocalizationProvider,
} from '@shopify/hydrogen';
import gql from 'graphql-tag';
import Header from './Header.client';
@ -23,7 +28,7 @@ export default function Layout({children, hero}) {
const storeName = data ? data.shop.name : '';
return (
<>
<LocalizationProvider>
<div className="absolute top-0 left-0">
<a
href="#mainContent"
@ -52,7 +57,7 @@ export default function Layout({children, hero}) {
</main>
<Footer collection={collections[0]} product={products[0]} />
</div>
</>
</LocalizationProvider>
);
}

View file

@ -1 +0,0 @@
export {Link} from '@shopify/hydrogen/client';

View file

@ -0,0 +1,14 @@
import {Money} from '@shopify/hydrogen/client';
export default function MoneyCompareAtPrice({money}) {
return (
<Money money={money}>
{({amount, currencyNarrowSymbol}) => (
<span className="line-through text-lg mr-2.5 text-gray-500">
{currencyNarrowSymbol}
{amount}
</span>
)}
</Money>
);
}

View file

@ -0,0 +1,15 @@
import {Money} from '@shopify/hydrogen/client';
export default function MoneyPrice({money}) {
return (
<Money className="text-black text-md" money={money}>
{({amount, currencyNarrowSymbol, currencyCode}) => (
<>
{currencyCode}
{currencyNarrowSymbol}
{amount}
</>
)}
</Money>
);
}

View file

@ -1,6 +1,7 @@
import {Image, Money} from '@shopify/hydrogen';
import {Image, Link} from '@shopify/hydrogen';
import {Link} from './Link.client';
import MoneyCompareAtPrice from './MoneyCompareAtPrice.client';
import MoneyPrice from './MoneyPrice.client';
export default function ProductCard({product}) {
const selectedVariant = product.variants.edges[0].node;
@ -36,24 +37,9 @@ export default function ProductCard({product}) {
<div className="flex ">
{selectedVariant.compareAtPriceV2 && (
<Money money={selectedVariant.compareAtPriceV2}>
{({amount, currencyNarrowSymbol}) => (
<span className="line-through text-lg mr-2.5 text-gray-500">
{currencyNarrowSymbol}
{amount}
</span>
)}
</Money>
<MoneyCompareAtPrice money={selectedVariant.compareAtPriceV2} />
)}
<Money className="text-black text-md" money={selectedVariant.priceV2}>
{({amount, currencyNarrowSymbol, currencyCode}) => (
<>
{currencyCode}
{currencyNarrowSymbol}
{amount}
</>
)}
</Money>
<MoneyPrice money={selectedVariant.priceV2} />
</div>
</Link>
</div>

View file

@ -1,8 +1,6 @@
import {useShopQuery, flattenConnection} from '@shopify/hydrogen';
import {useShopQuery, flattenConnection, Link} from '@shopify/hydrogen';
import gql from 'graphql-tag';
import {Link} from './Link.client';
function ExternalIcon() {
return (
<svg

View file

@ -3,10 +3,10 @@ import {
flattenConnection,
ProductProviderFragment,
Image,
Link,
} from '@shopify/hydrogen';
import gql from 'graphql-tag';
import {Link} from '../components/Link.client';
import Layout from '../components/Layout.server';
import FeaturedCollection from '../components/FeaturedCollection.server';
import ProductCard from '../components/ProductCard.server';

View file

@ -7,6 +7,12 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
<!-- ## Unreleased -->
## 0.6.2 - 2021-11-10
- Added new `hydrogen/typescript` config
- Added `env#node: true` and `parserOptions#sourceType: 'module'` to core config
- Fixed issue requiring typescript to be install on non-typescript projects
## 0.6.0 - 2021-11-05
- No updates. Transitive dependency bump.

View file

@ -1,6 +1,6 @@
{
"name": "eslint-plugin-hydrogen",
"version": "0.6.0",
"version": "0.6.2",
"description": "Eslint rules for hydrogen",
"license": "MIT",
"main": "./dist/index.js",
@ -12,7 +12,8 @@
"test": "jest",
"dev": "yarn build -w",
"build": "tsc -p .",
"prepack": "yarn build"
"prepack": "yarn build",
"tophat": "node ./scripts/tophat"
},
"repository": {
"type": "git",
@ -42,7 +43,6 @@
"ts-jest": "^26.5.4"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": ">= 4",
"eslint": ">=5"
}
}

View file

@ -1,12 +0,0 @@
import rules from './rules';
export default {
plugins: ['hydrogen'],
extends: [
'plugin:@shopify/typescript',
'plugin:@shopify/react',
'plugin:@shopify/node',
'plugin:@shopify/prettier',
],
rules,
};

View file

@ -1,12 +0,0 @@
import rules from './rules';
export default {
plugins: ['hydrogen'],
extends: [
'plugin:@shopify/esnext',
'plugin:@shopify/react',
'plugin:@shopify/node',
'plugin:@shopify/prettier',
],
rules,
};

View file

@ -1,4 +0,0 @@
export default {
'hydrogen/no-state-in-server-components': 'error',
'hydrogen/prefer-image-component': 'error',
};

View file

@ -1,5 +0,0 @@
import {deepMerge} from '@typescript-eslint/experimental-utils/dist/eslint-utils';
import overrides from './overrides';
import hydrogen from './hydrogen';
export default deepMerge(hydrogen, overrides);

View file

@ -1,45 +0,0 @@
export default {
// TODO: We may want to change the configuration for the following 3 rules
'jsx-a11y/click-events-have-key-events': 'off',
'jsx-a11y/no-noninteractive-element-interactions': 'off',
'react/jsx-filename-extension': ['error', {extensions: ['.tsx', '.jsx']}],
/**
* Rules below this line are intentionally disabled for different reasons
*/
// The following 2 rules are very strict and disabled here to lessen developer frustration
'@shopify/jsx-no-hardcoded-content': 'off',
'@shopify/jsx-no-complex-expressions': 'off',
/**
* eslint overrides
*/
// We often define GraphQL queries at the bottom of the file which would be a violation for this rule
'no-use-before-define': 'off',
// We agree that warning comments acceptable
'no-warning-comments': 'off',
/**
* react overrides
*/
// Following Next.js and likely this will be the default in most frameworks
'react/react-in-jsx-scope': 'off',
// We default to typescript for typing, non typescript projects can override this rule if they want
'react/prop-types': 'off',
/**
* import overrides
*/
// TODO: We should turn these on, at least partially
// 'import/no-unresolved': ['off'],
// 'import/extensions': ['off'],
// These two rules result in a significant number of false positives so we
// need to keep them disabled.
'jsx-a11y/label-has-for': 'off',
'jsx-a11y/control-has-associated-label': 'off',
};

View file

@ -11,6 +11,7 @@ export default {
env: {
es2021: true,
browser: true,
node: true,
},
settings: {
react: {
@ -21,6 +22,7 @@ export default {
ecmaFeatures: {
jsx: true,
},
sourceType: 'module',
},
rules: {
'no-console': 'warn',
@ -39,54 +41,6 @@ export default {
},
ignorePatterns: ['node_modules/', 'build/', '*.graphql.d.ts', '*.graphql.ts'],
overrides: [
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended'],
rules: {
'react/prop-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/ban-types': [
'error',
{
types: {
String: {message: 'Use string instead', fixWith: 'string'},
Boolean: {message: 'Use boolean instead', fixWith: 'boolean'},
Number: {message: 'Use number instead', fixWith: 'number'},
Object: {message: 'Use object instead', fixWith: 'object'},
Array: {message: 'Provide a more specific type'},
ReadonlyArray: {message: 'Provide a more specific type'},
},
},
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
leadingUnderscore: 'allowSingleOrDouble',
trailingUnderscore: 'allowSingleOrDouble',
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
{
selector: 'typeParameter',
format: ['PascalCase'],
leadingUnderscore: 'allow',
},
{
selector: 'interface',
format: ['PascalCase'],
},
],
},
},
{
files: ['*.test.*'],
plugins: ['jest'],

View file

@ -0,0 +1,52 @@
export default {
overrides: [
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended'],
rules: {
'react/prop-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/ban-types': [
'error',
{
types: {
String: {message: 'Use string instead', fixWith: 'string'},
Boolean: {message: 'Use boolean instead', fixWith: 'boolean'},
Number: {message: 'Use number instead', fixWith: 'number'},
Object: {message: 'Use object instead', fixWith: 'object'},
Array: {message: 'Provide a more specific type'},
ReadonlyArray: {message: 'Provide a more specific type'},
},
},
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
leadingUnderscore: 'allowSingleOrDouble',
trailingUnderscore: 'allowSingleOrDouble',
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
{
selector: 'typeParameter',
format: ['PascalCase'],
leadingUnderscore: 'allow',
},
{
selector: 'interface',
format: ['PascalCase'],
},
],
},
},
],
};

View file

@ -1,9 +1,11 @@
import recommended from './configs/recommended';
import hydrogen from './configs/hydrogen';
import typescript from './configs/typescript';
export {rules} from './rules';
export const configs = {
recommended,
hydrogen,
typescript,
};

View file

@ -1,6 +1,6 @@
{
"name": "@shopify/generate-docs",
"version": "0.6.0",
"version": "0.6.2",
"description": "Command line interface for generating docs from code comments",
"license": "MIT",
"private": true,

View file

@ -142,10 +142,11 @@ export class DocsGen {
await componentResult.docs(componentEntryBase);
await Promise.all([
componentResult.writeReadme(componentEntryBase),
componentResult.writeDevDoc(componentPaths.output),
]);
await componentResult.writeReadme(componentEntryBase);
if (this.writeDocs) {
componentResult.writeDevDoc(componentPaths.output);
}
listItems.push({
name: `<a href="${componentUrl}">${name}</a>`,

View file

@ -24,8 +24,9 @@ export class FileResult {
public async writeDevDoc(path: string) {
const result = inPageAnchors(this.staged.join(''));
const docPath = "https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md"
const comment = `<!-- This file is generated from the source code and any changes you make here will be overwritten. -->`;
const comment = `<!-- This file is generated from source code in the Shopify/hydrogen repo. Any changes you make here will be overwritten. For more information, refer to ${docPath}. -->`;
await this.write(path, [this.frontMatter, comment, result].join('\n\n'));
}
@ -37,8 +38,9 @@ export class FileResult {
}
const localPath = path.replace(resolve('.'), '');
const docPath = "https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md"
const finalPath = resolve(path, 'README.md');
const comment = `<!-- This file is generated from the source code. Edit the files in ${localPath} and run 'yarn generate-docs' at the root of this repo. -->`;
const comment = `<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in ${localPath} and run 'yarn generate-docs' at the root of this repo. For more information, refer to ${docPath}. -->`;
await this.write(
finalPath,
[comment, ...this.staged].join('\n\n').trim()

View file

@ -7,6 +7,18 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
<!-- ## Unreleased -->
## 0.6.4 - 2021-11-11
- No updates. Transitive dependency bump.
## 0.6.3 - 2021-11-10
- No updates. Transitive dependency bump.
## 0.6.2 - 2021-11-10
- No updates. Transitive dependency bump.
## 0.6.1 - 2021-11-08
- No updates. Transitive dependency bump.

View file

@ -1,6 +1,6 @@
{
"name": "@shopify/hydrogen-plugin-sanity",
"version": "0.6.1",
"version": "0.6.4",
"description": "Hydrogen plugins for integrating with Sanity",
"main": "dist/esnext/index.js",
"publishConfig": {
@ -17,7 +17,7 @@
"prepack": "yarn build"
},
"devDependencies": {
"@shopify/hydrogen": "^0.6.1"
"@shopify/hydrogen": "^0.6.4"
},
"peerDependencies": {
"@shopify/hydrogen": "^0.4.0"

View file

@ -7,10 +7,30 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
<!-- ## Unreleased -->
## 0.6.4 - 2021-11-11
- fix: let Vite handle public assets in development
- fix: new lines in hydration request break JSON.parse
- fix(#201): normalize POSIX separators to support windows
- fix: scroll to top on app first load
## 0.6.3 - 2021-11-10
- fix: add trailing slash to user components glob
## 0.6.2 - 2021-11-10
- fix: remove CartProvider from BuyNowButton
- fix: reading property of null for component props
- fix: transform deeply-imported client components
- fix: duplicated files and contexts in browser
## 0.6.1 - 2021-11-08
- No updates. Transitive dependency bump.
- fix: do not set headers after they are sent to client
## 0.6.0 - 2021-11-05
- feat: disable the quantity adjust button when the cart is not idle

View file

@ -1 +1 @@
export {ClientMarker} from './dist/esnext/framework/ClientMarker';
export * from './dist/esnext/framework/ClientMarker';

View file

@ -4,7 +4,7 @@
"access": "public",
"@shopify:registry": "https://registry.npmjs.org"
},
"version": "0.6.1",
"version": "0.6.4",
"description": "Modern custom Shopify storefronts",
"license": "MIT",
"main": "dist/esnext/index.js",
@ -78,16 +78,18 @@
"react": "^18",
"react-dom": "^18",
"react-router-dom": "^5.2.0",
"vite": "^2.6.0"
"vite": "^2.6.14"
},
"dependencies": {
"@vitejs/plugin-react": "^1.0.0",
"@vitejs/plugin-react": "^1.0.8",
"connect": "^3.7.0",
"es-module-lexer": "^0.9.0",
"fast-glob": "^3.2.5",
"graphql": "^15.5.0",
"html-dom-parser": "^1.0.1",
"html-react-parser": "^1.2.6",
"isomorphic-dompurify": "^0.13.0",
"magic-string": "^0.25.7",
"node-fetch": "^2.6.1",
"react-error-boundary": "^3.1.3",
"react-helmet-async": "^1.0.9",

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/AddToCartButton and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/AddToCartButton and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `AddToCartButton` component renders a button that adds an item to the cart when pressed.
It must be a descendent of the `CartProvider` component.

View file

@ -1,6 +1,6 @@
import React, {useEffect, ElementType, useState, useCallback} from 'react';
import type {ReactNode} from 'react';
import {CartProvider, useInstantCheckout} from '../CartProvider';
import {useInstantCheckout} from '../CartProvider';
import {Props} from '../types';
export interface BuyNowButtonProps {
@ -22,16 +22,6 @@ export type BuyNowButtonPropsWeControl = 'onClick';
/** The `BuyNowButton` component renders a button that adds an item to the cart and redirects the customer to checkout. */
export function BuyNowButton<TTag extends ElementType = 'button'>(
props: Props<TTag, BuyNowButtonPropsWeControl> & BuyNowButtonProps
) {
return (
<CartProvider>
<Button {...props} />
</CartProvider>
);
}
function Button<TTag extends ElementType = 'button'>(
props: Props<TTag, BuyNowButtonPropsWeControl> & BuyNowButtonProps
) {
const {createInstantCheckout, checkoutUrl} = useInstantCheckout();
const [loading, setLoading] = useState<boolean>(false);

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/BuyNowButton and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/BuyNowButton and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `BuyNowButton` component renders a button that adds an item to the cart and redirects the customer to checkout.

View file

@ -1,8 +1,4 @@
---
gid: c7df6e06-3c6c-4c35-b6fe-82bfac8b6b95
title: CartCheckoutButton
description: Use the CartCheckoutButton to render a button that redirects to checkoutUrl for the cart.
---
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/CartCheckoutButton and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `CartCheckoutButton` component renders a button that redirects to the checkout URL for the cart.
@ -33,9 +29,9 @@ export class MyComponent() {
## Props
| Name | Required | Description |
| ---- | -------- | ----------- |
| `children` | Yes | A `ReactNode` element. |
| Name | Required | Description |
| ---------- | -------- | ---------------------- |
| `children` | Yes | A `ReactNode` element. |
## Related components

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/CartEstimatedCost and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/CartEstimatedCost and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The [CartEstimatedCost](/api/storefront/reference/cart/cartestimatedcost) component renders a `Money` component with the
cost associated with the `amountType` prop. If no `amountType` prop is specified, then it defaults to `totalAmount`.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/CartLineAttributes and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/CartLineAttributes and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `CartLineAttributes` component takes a function as a child and calls that function for each of the
cart line's attributes. It must be a descendent of a `CartLineProvider` component.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/CartLineImage and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/CartLineImage and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `CartLineImage` component renders an `Image` component for the cart line merchandise's image.
It must be a descendent of a `CartLineProvider` component.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/CartLinePrice and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/CartLinePrice and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `CartLinePrice` component renders a `Money` component for the cart line merchandise's price or
compare at price. It must be a descendent of a `CartLineProvider` component.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/CartLineProductTitle and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/CartLineProductTitle and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `CartLineProductTitle` component renders a `span` element (or the type of HTML element specified by
the `as` prop) with the cart line merchandise's title. It must be a descendent of a `CartLineProvider` component.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/CartLineProvider and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/CartLineProvider and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `useCartLine` hook provides access to the cart line object. It must be a descendent of a `CartProvider` component.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/CartLineQuantity and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/CartLineQuantity and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `CartLineQuantity` component renders a `span` element (or the type of HTML element
specified by the `as` prop) with the cart line's quantity. It must be a descendent of a `CartLineProvider` component.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/CartLineQuantityAdjustButton and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/CartLineQuantityAdjustButton and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `CartLineQuantityAdjustButton` component renders a button that adjusts the cart line's quantity when pressed.
It must be a descendent of a `CartLineProvider` component.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/CartLineSelectedOptions and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/CartLineSelectedOptions and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `CartLineSelectedOptions` component takes a function as a child and calls that function
for each of the cart line merchandise's selected options. It must be a descendent of a `CartLineProvider` component.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/CartLines and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/CartLines and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `CartLines` component iterates over each cart line and renders its `children` within
a `CartLineProvider` for each cart line. It also provides render props in the case where `children` is a function.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/CartProvider and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/CartProvider and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
## Example code

View file

@ -1,4 +1,4 @@
import React from 'react';
import React, {useState} from 'react';
import {useShop} from '../../foundation';
import {flattenConnection} from '../../utilities';
import {CartInput} from '../../graphql/types/types';
@ -47,10 +47,9 @@ export function useCartFetch() {
}
export function useInstantCheckout() {
const [cart, updateCart] = React.useState<Cart | undefined>();
const [checkoutUrl, updateCheckoutUrl] =
React.useState<Cart['checkoutUrl']>();
const [error, updateError] = React.useState<string | undefined>();
const [cart, updateCart] = useState<Cart | undefined>();
const [checkoutUrl, updateCheckoutUrl] = useState<Cart['checkoutUrl']>();
const [error, updateError] = useState<string | undefined>();
const fetch = useCartFetch();

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/CartShopPayButton and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/CartShopPayButton and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `CartShopPayButton` component renders a `ShopPayButton` for the items in the cart.
It must be a descendent of a `CartProvider` component.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/ExternalVideo and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/ExternalVideo and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `ExternalVideo` component renders an embedded video for the Storefront
API's [`ExternalVideo` object](/api/storefront/reference/products/externalvideo).

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/Image and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/Image and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `Image` component renders an image for the Storefront API's
[`Image` object](/api/storefront/reference/common-objects/image).

View file

@ -0,0 +1 @@
export {Link} from './Link.client';

View file

@ -9,16 +9,5 @@ export interface LocalizationContextValue {
setCountry(country: Localization['country']): void;
}
/**
* This is a workaround to support exposing context from within a server component
* exported from Hydrogen.
*/
declare global {
var __localizationContext: any;
}
export const LocalizationContext =
globalThis.__localizationContext ||
createContext<LocalizationContextValue | null>(null);
globalThis.__localizationContext = LocalizationContext;

View file

@ -1,8 +1,4 @@
---
gid: 2d9f4930-fafe-11eb-9a03-0242ac130003
title: LocalizationProvider
description: Use a LocalizationProvider component to automatically query the Storefront API's localization field for the ISO code, name of the country, and available countries, and keep this information in a context.
---
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/LocalizationProvider and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `LocalizationProvider` component automatically queries the Storefront API's [`localization`](/api/storefront/reference/common-objects/queryroot) field for the `isoCode` and `name` of the `country` and `availableCountries` and keeps this information in a context.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/MediaFile and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/MediaFile and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `MediaFile` component renders the media for the Storefront API's
[Media object](/api/storefront/reference/products/media). It renders an `Image`, a

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/Metafield and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/Metafield and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `Metafield` component renders the value of a Storefront
API's [Metafield object](/api/storefront/reference/common-objects/metafield).

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/Model3D and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/Model3D and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `Model3D` component renders a 3D model (with the `model-viewer` tag) for
the Storefront API's [`Model3d` object](/api/storefront/reference/products/model3d).

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /Users/michellevinci/src/github.com/Shopify/hydrogen/packages/hydrogen/src/components/Money and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/Money and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `Money` component renders a string of the Storefront API's
[`MoneyV2` object](/api/storefront/reference/common-objects/moneyv2) according to the

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/ProductDescription and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/ProductDescription and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `ProductDescription` component renders a `RawHtml` component with
the product's [`descriptionHtml`](/api/storefront/reference/products/product).

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/ProductMetafield and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/ProductMetafield and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `ProductMetafield` component renders a
[`Metafield`](/api/hydrogen/components/primitive/metafield) component with the product metafield.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/ProductPrice and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/ProductPrice and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `ProductPrice` component renders a `Money` component with the product
[`priceRange`](/api/storefront/reference/products/productpricerange)'s `maxVariantPrice`

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/ProductProvider and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/ProductProvider and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `useProduct` hook returns the product object of the nearest `ProductProvider`. It must be a descendent of
a `ProductProvider` component.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/ProductTitle and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/ProductTitle and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `ProductTitle` component renders a `span` element (or the type of
HTML element specified by the `as` prop) with the product's [`title`](/api/storefront/reference/products/product).

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/RawHtml and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/RawHtml and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `RawHtml` component renders an HTML string as HTML DOM elements. This should be used for
displaying rich text-like descriptions associated with a product.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/SelectedVariantAddToCartButton and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/SelectedVariantAddToCartButton and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `SelectedVariantAddToCartButton` component renders a `AddToCartButton` for the product's
selected variant. Clicking this button automatically adds the selected variant to the cart.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/SelectedVariantBuyNowButton and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/SelectedVariantBuyNowButton and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `SelectedVariantBuyNowButton` component renders a `BuyNowButton` for the product's selected variant.
Clicking this button automatically adds the selected variant to the cart and redirect the customer to checkout.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/SelectedVariantImage and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/SelectedVariantImage and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `SelectedVariantImage` component renders an `Image` component for the product's selected variant's image.
It must be a descendent of a `ProductProvider` component.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/SelectedVariantMetafield and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/SelectedVariantMetafield and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `SelectedVariantMetafield` component renders a [`Metafield`](/api/hydrogen/components/primitive/metafield)
component with the selected product's metafield.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/SelectedVariantPrice and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/SelectedVariantPrice and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `SelectedVariantPrice` component renders a `Money` component for the product's selected variant's price or compare at price.
It must be a descendent of a `ProductProvider` component.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/SelectedVariantShopPayButton and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/SelectedVariantShopPayButton and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `SelectedVariantShopPayButton` component renders a `ShopPayButton` for the product's selected variant.
It must be a descendent of a `ProductProvider` component.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/SelectedVariantUnitPrice and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/SelectedVariantUnitPrice and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `SelectedVariantUnitPrice` component renders a `UnitPrice` component for the product's selected variant's unit price.
It must be a descendent of a `ProductProvider`.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/ShopPayButton and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/ShopPayButton and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/UnitPrice and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/UnitPrice and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `UnitPrice` component renders a string with a [UnitPrice](/themes/pricing-payments/unit-pricing) as the
[Storefront API's `MoneyV2` object](/api/storefront/reference/common-objects/moneyv2) with a reference unit from

View file

@ -1,4 +1,4 @@
<!-- This file is generated from the source code. Edit the files in /packages/hydrogen/src/components/Video and run 'yarn generate-docs' at the root of this repo. -->
<!-- This file is generated from source code in the Shopify/hydrogen repo. Edit the files in /packages/hydrogen/src/components/Video and run 'yarn generate-docs' at the root of this repo. For more information, refer to https://github.com/Shopify/shopify-dev/blob/master/content/internal/operations/hydrogen-reference-docs.md. -->
The `Video` component renders a `video` for the Storefront API's [`Video` object](/api/storefront/reference/products/video).

View file

@ -1,4 +1,4 @@
export {Link} from 'react-router-dom';
export {Link} from './Link';
export type {MediaFileProps} from './MediaFile';
export {MediaFile, MediaFileFragment} from './MediaFile';
export type {VideoProps} from './Video';

View file

@ -19,8 +19,8 @@ Components can be customized using passthrough props and render props:
- **Passthrough props**: You can pass attributes as props to the Hydrogen component, and the Hydrogen component will pass them through to the rendered HTML tag.
> Note:
> Any attributes supported by the component's outputted HTML tag are supported, except for those explicitly controlled by the component (for example, `src` for the `Image` component and `dangerouslySetInnerHtml` for the `RawHtml` component).
> Note:
> Any attributes supported by the component's outputted HTML tag are supported, except for those explicitly controlled by the component (for example, `src` for the `Image` component and `dangerouslySetInnerHtml` for the `RawHtml` component).
- **Render props**: You can pass a function that returns JSX as a child to the Hydrogen component.

View file

@ -97,7 +97,7 @@ const renderHydrogen: ServerHandler = (App, hook) => {
console.error('Fatal', error);
});
let didError = false;
let didError: Error | undefined;
const head = template.match(/<head>(.+?)<\/head>/s)![1];
@ -124,6 +124,11 @@ const renderHydrogen: ServerHandler = (App, hook) => {
response.setHeader('Content-type', 'text/html');
response.write('<!DOCTYPE html>');
startWriting();
if (dev && didError) {
// This error was delayed until the headers were properly sent.
response.write(getErrorMarkup(didError));
}
},
onCompleteAll() {
if (componentResponse.canStream()) return;
@ -148,9 +153,11 @@ const renderHydrogen: ServerHandler = (App, hook) => {
}
},
onError(error: any) {
didError = true;
didError = error;
if (dev) {
if (dev && response.headersSent) {
// Calling write would flush headers automatically.
// Delay this error until headers are properly sent.
response.write(getErrorMarkup(error));
}
@ -183,7 +190,7 @@ const renderHydrogen: ServerHandler = (App, hook) => {
console.error('Fatal', error);
});
let didError = false;
let didError: Error | undefined;
const writer = new HydrationWriter();
@ -212,7 +219,7 @@ const renderHydrogen: ServerHandler = (App, hook) => {
response.end(generateWireSyntaxFromRenderedHtml(writer.toString()));
},
onError(error: any) {
didError = true;
didError = error;
console.error(error);
},
}

View file

@ -9,13 +9,16 @@ import {useServerState} from '../useServerState';
* server state, which in turn fetches the correct server component.
*/
export function ServerStateRouter() {
const {setServerState, pending} = useServerState() as ServerStateContextValue;
const {setServerState, pending, serverState} =
useServerState() as ServerStateContextValue;
const [isNavigating, setIsNavigating] = useState(false);
const location = useLocation();
useEffect(() => {
setIsNavigating(true);
setServerState('pathname', location.pathname);
if (serverState.pathname !== location.pathname) {
setIsNavigating(true);
setServerState('pathname', location.pathname);
}
}, [location.pathname, setServerState]);
useEffect(() => {

View file

@ -16,17 +16,7 @@ export interface ServerStateContextValue {
pending: any;
}
/**
* This is a workaround to support exposing context from within a server component
* exported from Hydrogen.
*/
declare global {
var __serverStateContext: any;
}
export const ServerStateContext =
globalThis.__serverStateContext || createContext<any>(null);
globalThis.__serverStateContext = ServerStateContext;
export const ServerStateContext = createContext<any>(null);
interface Props {
serverState: Record<string, any>;

Some files were not shown because too many files have changed in this diff Show more