-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
copy hydrogen-2 example from vercel/vercel (#1016)
- Loading branch information
1 parent
488603d
commit f3a11a2
Showing
59 changed files
with
20,900 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# The variables added in this file are only available locally in MiniOxygen | ||
|
||
SESSION_SECRET="foobar" | ||
PUBLIC_STORE_DOMAIN="mock.shop" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
build | ||
node_modules | ||
bin | ||
*.d.ts | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @type {import("@types/eslint").Linter.BaseConfig} | ||
*/ | ||
module.exports = { | ||
extends: [ | ||
'@remix-run/eslint-config', | ||
'plugin:hydrogen/recommended', | ||
'plugin:hydrogen/typescript', | ||
], | ||
rules: { | ||
'@typescript-eslint/ban-ts-comment': 'off', | ||
'@typescript-eslint/naming-convention': 'off', | ||
'hydrogen/prefer-image-component': 'off', | ||
'no-useless-escape': 'off', | ||
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off', | ||
'no-case-declarations': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
node_modules | ||
/.cache | ||
/build | ||
/dist | ||
/public/build | ||
/.mf | ||
.env | ||
.shopify | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
schema: node_modules/@shopify/hydrogen-react/storefront.schema.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.cache | ||
dist | ||
.shopify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Hydrogen v2 | ||
|
||
This directory is a brief example of a [Hydrogen v2](https://shopify.dev/custom-storefronts/hydrogen) storefront that can be deployed to Vercel with zero configuration. | ||
|
||
## Deploy Your Own | ||
|
||
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/examples/tree/main/framework-boilerplates/hydrogen-2&template=hydrogen-2) | ||
|
||
_Live Example: https://hydrogen-v2-template.vercel.app_ | ||
|
||
You can also deploy using the [Vercel CLI](https://vercel.com/docs/cli): | ||
|
||
```sh | ||
npm i -g vercel | ||
vercel | ||
``` | ||
|
||
Hydrogen is Shopify’s stack for headless commerce. Hydrogen is designed to dovetail with [Remix](https://remix.run/), Shopify’s full stack web framework. This template contains a **minimal setup** of components, queries and tooling to get started with Hydrogen. | ||
|
||
[Check out Hydrogen docs](https://shopify.dev/custom-storefronts/hydrogen) | ||
[Get familiar with Remix](https://remix.run/docs/en/v1) | ||
|
||
## What's included | ||
|
||
- Remix | ||
- Hydrogen | ||
- Oxygen | ||
- Shopify CLI | ||
- ESLint | ||
- Prettier | ||
- GraphQL generator | ||
- TypeScript and JavaScript flavors | ||
- Minimal setup of components and routes | ||
|
||
## Environment Variables | ||
|
||
Using Hydrogen requires a few [environment variables](https://shopify.dev/docs/custom-storefronts/hydrogen/environment-variables) to be set in order to properly connect to Shopify. For this template, the minimal set of environment variables are defined in the `vercel.json` file, which will be applied to the deployment when deployed to Vercel. However, you should migrate these default environment variables to your Project's Environment Variables configuration in the Vercel dashboard (or using the `vc env` commands), and update them according to your needs (also change the `SESSION_SECRET` to your own value). Once that is done, delete the `vercel.json` file from your project to prevent the environment variables defined there from taking precedence. | ||
|
||
## Local development | ||
|
||
Rename the `.env.example` file to `.env` in order for the Shopify dev server to use those environment variables during local development. If you defined/modified additional environment variables based on the section above, be sure to apply those changes in your `.env` file as well. | ||
|
||
Then run the following commands: | ||
|
||
```bash | ||
npm install | ||
npm run dev | ||
``` |
47 changes: 47 additions & 0 deletions
47
framework-boilerplates/hydrogen-2/app/components/Aside.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* A side bar component with Overlay that works without JavaScript. | ||
* @example | ||
* ```ts | ||
* <Aside id="search-aside" heading="SEARCH">` | ||
* <input type="search" /> | ||
* ... | ||
* </Aside> | ||
* ``` | ||
*/ | ||
export function Aside({ | ||
children, | ||
heading, | ||
id = 'aside', | ||
}: { | ||
children?: React.ReactNode; | ||
heading: React.ReactNode; | ||
id?: string; | ||
}) { | ||
return ( | ||
<div aria-modal className="overlay" id={id} role="dialog"> | ||
<button | ||
className="close-outside" | ||
onClick={() => { | ||
history.go(-1); | ||
window.location.hash = ''; | ||
}} | ||
/> | ||
<aside> | ||
<header> | ||
<h3>{heading}</h3> | ||
<CloseAside /> | ||
</header> | ||
<main>{children}</main> | ||
</aside> | ||
</div> | ||
); | ||
} | ||
|
||
function CloseAside() { | ||
return ( | ||
/* eslint-disable-next-line jsx-a11y/anchor-is-valid */ | ||
<a className="close" href="#" onChange={() => history.go(-1)}> | ||
× | ||
</a> | ||
); | ||
} |
Oops, something went wrong.