@graphcommerce/docs 3.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +4 -0
- package/CHANGELOG.md +160 -0
- package/components/Layout/LayoutFull.tsx +85 -0
- package/components/Layout/Logo.tsx +19 -0
- package/components/Layout/graphcommerce.svg +34 -0
- package/components/Search.tsx +37 -0
- package/components/SearchForm.tsx +110 -0
- package/components/SidebarMenu/index.tsx +101 -0
- package/components/prism.css +274 -0
- package/components/rehype-prism-plus.css +49 -0
- package/components/theme.ts +410 -0
- package/content/framework/deployment.md +56 -0
- package/content/framework/environment-variables.md +61 -0
- package/content/framework/favicon.md +38 -0
- package/content/framework/graphcms.md +66 -0
- package/content/framework/icons.md +255 -0
- package/content/framework/readme.md +79 -0
- package/content/framework/seo.md +64 -0
- package/content/framework/static-file-serving.md +44 -0
- package/content/framework/static-generation.md +221 -0
- package/content/framework/theming.md +258 -0
- package/content/framework/translations.md +112 -0
- package/content/framework/troubleshooting.md +67 -0
- package/content/framework/typography.md +143 -0
- package/content/getting-started/create.md +152 -0
- package/content/getting-started/graphcms-component.md +240 -0
- package/content/getting-started/header.md +224 -0
- package/content/getting-started/pages.md +290 -0
- package/content/getting-started/readme.md +294 -0
- package/content/getting-started/start-building.md +160 -0
- package/content/getting-started/vscode.md +48 -0
- package/content/readme.md +124 -0
- package/content/roadmap.md +31 -0
- package/lib/DocumentIndexer.ts +59 -0
- package/lib/files.ts +168 -0
- package/lib/instantSearch.ts +26 -0
- package/lib/typesense/IndexerHandler.ts +47 -0
- package/lib/typesense/Leaves.ts +37 -0
- package/lib/typesense/SearchIndexer.ts +64 -0
- package/lib/typesense/batchInterable.ts +13 -0
- package/lib/typesense/createInstantSearchProps.ts +36 -0
- package/lib/typesense/typesenseClientConf.ts +23 -0
- package/lib/typesense/typesenseIndexerHandler.ts +23 -0
- package/next-env.d.ts +5 -0
- package/next.config.js +21 -0
- package/package.json +56 -0
- package/pages/[[...url]].tsx +391 -0
- package/pages/_app.tsx +26 -0
- package/pages/_document.tsx +22 -0
- package/pages/api/reindex.ts +4 -0
- package/pages/menu/[[...url]].tsx +69 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/favicon.svg +12 -0
- package/public/link.svg +4 -0
- package/public/manifest/favicon-192.png +0 -0
- package/public/manifest/favicon-512.png +0 -0
- package/public/manifest.webmanifest +20 -0
- package/tsconfig.json +5 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
---
|
|
2
|
+
menu: Overview
|
|
3
|
+
order: create,start-building,header,pages,graphcms-component
|
|
4
|
+
metaTitle:
|
|
5
|
+
Start your Reactjs Ecommerce project with the GraphCommerce React Magento 2
|
|
6
|
+
Template
|
|
7
|
+
metaDescription:
|
|
8
|
+
'Overview of the magento-graphcms example, the GraphCommerce reactjs ecommerce
|
|
9
|
+
template for Magento storefronts'
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
> **Developer preview**
|
|
13
|
+
> This is a developer preview of GraphCommerce. The documentation will be
|
|
14
|
+
> updated as GraphCommerce introduces
|
|
15
|
+
> [new features and refines existing functionality](https://github.com/ho-nl/m2-pwa/releases).
|
|
16
|
+
|
|
17
|
+
# GraphCommerce magento-graphcms example overview
|
|
18
|
+
|
|
19
|
+
GraphCommerce offers a magento-graphcms example that provides an approachable
|
|
20
|
+
path to building GraphCommerce custom Magento e-commerce storefront. This guide
|
|
21
|
+
describes what's included in the magento-graphcms example and how you can begin
|
|
22
|
+
exploring it.
|
|
23
|
+
|
|
24
|
+
## How it works
|
|
25
|
+
|
|
26
|
+
Most of the files that you'll work on within your GraphCommerce project are
|
|
27
|
+
located in the /components or /pages directories.
|
|
28
|
+
|
|
29
|
+
- A minimal set of components you would most likely modify for your project
|
|
30
|
+
- The main layout component, which renders header, navigation, and footer
|
|
31
|
+
- A set of boilerplate pages, which handle URL routing
|
|
32
|
+
- Basic global styles in theme.ts provided by
|
|
33
|
+
[Mui ↗](https://mui.com/customization/default-theme/)
|
|
34
|
+
- Interface translation files
|
|
35
|
+
|
|
36
|
+
```txt
|
|
37
|
+
File structure of the graphcommerce-magento example
|
|
38
|
+
|
|
39
|
+
├── components
|
|
40
|
+
└── Layout
|
|
41
|
+
└── Footer.tsx
|
|
42
|
+
└── LayoutFull.tsx
|
|
43
|
+
└── GraphCMS
|
|
44
|
+
└── Asset
|
|
45
|
+
└── RowHeroBanner
|
|
46
|
+
└── RowQuote
|
|
47
|
+
└── theme.ts
|
|
48
|
+
└── ...
|
|
49
|
+
├── graphql
|
|
50
|
+
└── CategoryPage.graphql
|
|
51
|
+
└── PageLink.graphql
|
|
52
|
+
└── ...
|
|
53
|
+
├── pages
|
|
54
|
+
└── product
|
|
55
|
+
└── [url].jsx
|
|
56
|
+
└── ...
|
|
57
|
+
└── page
|
|
58
|
+
└── [...url].jsx
|
|
59
|
+
└── [...url].tsx
|
|
60
|
+
└── [cart].tsx
|
|
61
|
+
└── _app.tsx
|
|
62
|
+
└── _document.tsx
|
|
63
|
+
└── ...
|
|
64
|
+
├── locales
|
|
65
|
+
└── en.po
|
|
66
|
+
└── nl.po
|
|
67
|
+
└── ...
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Components
|
|
71
|
+
|
|
72
|
+
The GraphCommerce magento-graphcms example provides a series of components that
|
|
73
|
+
you can use as a starting point for development. These components query the
|
|
74
|
+
Magento GraphQL API for efficient data-fetching. Most components have a .graphql
|
|
75
|
+
file that contains the GraphQL query fragment.
|
|
76
|
+
|
|
77
|
+
### Modifying components
|
|
78
|
+
|
|
79
|
+
By default, the components that you would most likely modify are located in the
|
|
80
|
+
`/components` directory. You can directly modify these components and customize
|
|
81
|
+
styles.
|
|
82
|
+
|
|
83
|
+
Others components are imported where needed, and can be recognized by their
|
|
84
|
+
namespace `@graphcommerce/`. There are different ways to
|
|
85
|
+
[customize styles](https://mui.com/customization/how-to-customize/) of importend
|
|
86
|
+
components. The most common way is by adding an sx prop: `sx={{color:'red'}}`.
|
|
87
|
+
|
|
88
|
+
If you want to extend a component's behavior or built your own, you can
|
|
89
|
+
duplicate a `@graphcommerce/` component to your /components directory. You'll
|
|
90
|
+
need to update all imports with the new location of your local component. This
|
|
91
|
+
also applies if you want to modify a component's or
|
|
92
|
+
[page's query](../getting-started/start-building.md).
|
|
93
|
+
|
|
94
|
+
### Component overview
|
|
95
|
+
|
|
96
|
+
| Local | | |
|
|
97
|
+
| ----------------- | --------------------------------------------------------------------------- | --------------- |
|
|
98
|
+
| /Asset | [Source](../../../../examples/magento-graphcms/components/GraphCMS/Asset) | [Documentation] |
|
|
99
|
+
| /Blog | [Source](../../../../examples/magento-graphcms/components/Blog) | [Documentation] |
|
|
100
|
+
| /Layout | [Source](../../../../examples/magento-graphcms/components/Layout) | [Documentation] |
|
|
101
|
+
| /ProductListItems | [Source](../../../../examples/magento-graphcms/components/ProductListItems) | [Documentation] |
|
|
102
|
+
| /Usps | [Source](../../../../examples/magento-graphcms/components/Usps) | [Documentation] |
|
|
103
|
+
|
|
104
|
+
| Packages (/node_modules directory/) | |
|
|
105
|
+
| -------------------------------------------- | ---------------------------------------------------------- |
|
|
106
|
+
| @graphcommerce/framer-next-pages | [Source](../../../packages/framer-next-pages/) |
|
|
107
|
+
| @graphcommerce/googleanalytics | [Source](../../../packages/googleanalytics/) |
|
|
108
|
+
| @graphcommerce/googlerecaptcha | [Source](../../../packages/googlerecaptcha/) |
|
|
109
|
+
| @graphcommerce/googletagmanager | [Source](../../../packages/googletagmanager/) |
|
|
110
|
+
| @graphcommerce/graphcms-ui | [Source](../../../packages/graphcms-ui/) |
|
|
111
|
+
| @graphcommerce/graphql | [Source](../../../packages/graphql/) |
|
|
112
|
+
| @graphcommerce/graphql-mesh | [Source](../../../packages/graphql-mesh/) |
|
|
113
|
+
| @graphcommerce/image | [Source](../../../packages/image/) |
|
|
114
|
+
| @graphcommerce/lingui-next | [Source](../../../packages/lingui-next/) |
|
|
115
|
+
| @graphcommerce/magento-cart | [Source](../../../packages/magento-cart/) |
|
|
116
|
+
| @graphcommerce/magento-cart-billing-address | [Source](../../../packages/magento-cart-billing-address/) |
|
|
117
|
+
| @graphcommerce/magento-cart-checkout | [Source](../../../packages/magento-cart-checkout/) |
|
|
118
|
+
| @graphcommerce/magento-cart-coupon | [Source](../../../packages/magento-cart-coupon/) |
|
|
119
|
+
| @graphcommerce/magento-cart-email | [Source](../../../packages/magento-cart-email/) |
|
|
120
|
+
| @graphcommerce/magento-cart-items | [Source](../../../packages/magento-cart-items/) |
|
|
121
|
+
| @graphcommerce/magento-cart-payment-method | [Source](../../../packages/magento-cart-payment-method/) |
|
|
122
|
+
| @graphcommerce/magento-cart-shipping-address | [Source](../../../packages/magento-cart-shipping-address/) |
|
|
123
|
+
| @graphcommerce/magento-cart-shipping-method | [Source](../../../packages/magento-cart-shipping-method/) |
|
|
124
|
+
| @graphcommerce/magento-category | [Source](../../../packages/magento-category/) |
|
|
125
|
+
| @graphcommerce/magento-cms | [Source](../../../packages/magento-cms/) |
|
|
126
|
+
| @graphcommerce/magento-customer | [Source](../../../packages/magento-customer/) |
|
|
127
|
+
| @graphcommerce/magento-customer-account | [Source](../../../packages/magento-customer-account/) |
|
|
128
|
+
| @graphcommerce/magento-customer-order | [Source](../../../packages/magento-customer-order/) |
|
|
129
|
+
| @graphcommerce/magento-graphql | [Source](../../../packages/magento-graphql/) |
|
|
130
|
+
| @graphcommerce/magento-newsletter | [Source](../../../packages/magento-newsletter/) |
|
|
131
|
+
| @graphcommerce/magento-payment-included | [Source](../../../packages/magento-payment-included/) |
|
|
132
|
+
| @graphcommerce/magento-product | [Source](../../../packages/magento-product/) |
|
|
133
|
+
| @graphcommerce/magento-product-bundle | [Source](../../../packages/magento-product-bundle/) |
|
|
134
|
+
| @graphcommerce/magento-product-configurable | [Source](../../../packages/magento-product-configurable/) |
|
|
135
|
+
| @graphcommerce/magento-product-downloadable | [Source](../../../packages/magento-product-downloadable/) |
|
|
136
|
+
| @graphcommerce/magento-product-grouped | [Source](../../../packages/magento-product-grouped/) |
|
|
137
|
+
| @graphcommerce/magento-product-simple | [Source](../../../packages/magento-product-simple/) |
|
|
138
|
+
| @graphcommerce/magento-product-virtual | [Source](../../../packages/magento-product-virtual/) |
|
|
139
|
+
| @graphcommerce/magento-review | [Source](../../../packages/magento-review/) |
|
|
140
|
+
| @graphcommerce/magento-search | [Source](../../../packages/magento-search/) |
|
|
141
|
+
| @graphcommerce/magento-store | [Source](../../../packages/magento-store/) |
|
|
142
|
+
| @graphcommerce/browserslist-config-pwa | |
|
|
143
|
+
| @graphcommerce/eslint-config-pwa | |
|
|
144
|
+
| @graphcommerce/next-config | |
|
|
145
|
+
| @graphcommerce/next-ui | |
|
|
146
|
+
| @graphcommerce/prettier-config-pwa | |
|
|
147
|
+
| @graphcommerce/react-hook-form | |
|
|
148
|
+
| @graphcommerce/typescript-config-pwa | |
|
|
149
|
+
|
|
150
|
+
## GraphCMS
|
|
151
|
+
|
|
152
|
+
GraphCMS is integrated as a Content Management System. It is used to store all
|
|
153
|
+
static content and provides a user-friendly interface for managing it.
|
|
154
|
+
|
|
155
|
+
The magento-graphcms example offers a number of components to render this
|
|
156
|
+
content in different ways, for example in the form of a page-wide hero banner, a
|
|
157
|
+
list of USPs or grid of text columns.
|
|
158
|
+
|
|
159
|
+
To [get started](../getting-started/create.md) with the magento-graphcms
|
|
160
|
+
example, cloning the demo GraphCMS project GraphQL schema and its content is
|
|
161
|
+
recommended.
|
|
162
|
+
|
|
163
|
+
## Pages
|
|
164
|
+
|
|
165
|
+
GraphCommerce uses Next.js
|
|
166
|
+
[file-based routing ↗](https://nextjs.org/docs/routing/introduction), built on
|
|
167
|
+
the concept of pages. A page is a React Component exported from a `.tsx` file in
|
|
168
|
+
the /pages directory. When a file is added to the /pages directory, it's
|
|
169
|
+
automatically available as a route.
|
|
170
|
+
|
|
171
|
+
All routes of the app contain a URL segment that corresponds with a directory in
|
|
172
|
+
the /pages directory. Magento category routes are handled by the
|
|
173
|
+
`/pages/[...url].tsx` page and therefore do not contain a URL segment. As a
|
|
174
|
+
result, the category URL structure of the app matches your default Magento
|
|
175
|
+
frontend 1-on-1.
|
|
176
|
+
|
|
177
|
+
```txt
|
|
178
|
+
Page structure of the graphcommerce-magento example
|
|
179
|
+
|
|
180
|
+
├── pages
|
|
181
|
+
└── about
|
|
182
|
+
└── account
|
|
183
|
+
└── api
|
|
184
|
+
└── blog
|
|
185
|
+
└── checkout
|
|
186
|
+
└── customer
|
|
187
|
+
└── modal
|
|
188
|
+
└── page
|
|
189
|
+
└── product
|
|
190
|
+
└── search
|
|
191
|
+
└── service
|
|
192
|
+
├── _app.tsx
|
|
193
|
+
├── _document.tsx
|
|
194
|
+
├── [...url].tsx
|
|
195
|
+
├── 404.tsx
|
|
196
|
+
├── cart.tsx
|
|
197
|
+
├── index.tsx
|
|
198
|
+
├── switch-stores.tsx
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## GraphQL API
|
|
202
|
+
|
|
203
|
+
GraphCommerce is built and optimized to use data coming from Magento's GraphQL
|
|
204
|
+
API. GraphCommerce uses GraphQL Mesh, which adds the ability to add extra
|
|
205
|
+
(micro)services as data sources. In the magento-graphcms example, a headless CMS
|
|
206
|
+
called [GraphCMS](../getting-started/../framework/graphcms.md) is integrated.
|
|
207
|
+
|
|
208
|
+
By default, the GraphQL Mesh endpoint runs on route /api/grapql. You can query
|
|
209
|
+
both the Magento GraphQL schema and the GraphCMS GraphQL schema. Try out the
|
|
210
|
+
GraphCommerce demo
|
|
211
|
+
[GraphQL Explorer ↗](https://graphcommerce.vercel.app/api/graphql) with the
|
|
212
|
+
following example query:
|
|
213
|
+
|
|
214
|
+
```graphql
|
|
215
|
+
query {
|
|
216
|
+
products(search: "sock", pageSize: 3) {
|
|
217
|
+
items {
|
|
218
|
+
url_key
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
availableStores {
|
|
222
|
+
store_name
|
|
223
|
+
store_code
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Query fragments
|
|
229
|
+
|
|
230
|
+
Every component that requires data from Magento or GraphCMS has its own
|
|
231
|
+
`.graphql` file, containing a GraphQL query fragment. GraphQL Code Generator
|
|
232
|
+
(codegen) is used to convert query fragments to both the GraphQL document (query
|
|
233
|
+
or mutation) and Typescript type definitions, both captured in `.gql(.ts)`
|
|
234
|
+
files. `.gql(.ts)` are generated at build time.
|
|
235
|
+
|
|
236
|
+
Pages run queries in the getStaticProps function and pass the response as props.
|
|
237
|
+
Pages have a single page query, that combines multiple query fragments from
|
|
238
|
+
components. These accumulating page queries are located in the
|
|
239
|
+
/components/GraphQL directory.
|
|
240
|
+
|
|
241
|
+
With the use of fragments and GraphQL Mesh, GraphCommerce retrieves all data
|
|
242
|
+
from both Magento and GraphCMS in a single GraphQL query. This improves
|
|
243
|
+
performance.
|
|
244
|
+
|
|
245
|
+
```txt
|
|
246
|
+
GraphQL queries in the graphcommerce-magento example
|
|
247
|
+
|
|
248
|
+
├── GraphQL
|
|
249
|
+
└── CategoryPage.graphql
|
|
250
|
+
└── PageLink.graphql
|
|
251
|
+
└── DefaultPage.graphql
|
|
252
|
+
└── PagesStaticPaths.graphql
|
|
253
|
+
└── FooterQueryFragment.graphql
|
|
254
|
+
└── PageContentQueryFragment.graphql
|
|
255
|
+
└── ProductPage.graphql
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## FAQ
|
|
259
|
+
|
|
260
|
+
<div>
|
|
261
|
+
<details>
|
|
262
|
+
<summary>What are the benefits of choosing GraphCommerce for a react ecommerce project?</summary>
|
|
263
|
+
|
|
264
|
+
### What are the benefits of choosing GraphCommerce for a reactjs ecommerce project?
|
|
265
|
+
|
|
266
|
+
React is a very suitable framework for magento reactjs ecommerce projects.
|
|
267
|
+
Magento 2 is a well established, widely used open source e-commerce solution.
|
|
268
|
+
GraphCommerce brings the best of both, and includes the structure, components,
|
|
269
|
+
and tooling you need to get started with react ecommerce. Using GraphCommerce
|
|
270
|
+
minimizes the development effort required to launch a full featured reactjs
|
|
271
|
+
e-commerce storefront with features like cart, search, layered navigation and
|
|
272
|
+
category, product, account, checkout pages.
|
|
273
|
+
|
|
274
|
+
</details>
|
|
275
|
+
|
|
276
|
+
<details>
|
|
277
|
+
<summary> Why use the GraphCommerce magento reactjs ecommerce template</summary>
|
|
278
|
+
|
|
279
|
+
### Why use the GraphCommerce magento-graphcms reactjs ecommerce template
|
|
280
|
+
|
|
281
|
+
The GraphCommerce magento-graphcms template contains all needed components like
|
|
282
|
+
cart, search, and layered navigation for a full-featured e-commerce storefront.
|
|
283
|
+
It's easy to customize and includes the structure, components, and tooling you
|
|
284
|
+
need to get started. With the extensive documentation, it is more efficient to
|
|
285
|
+
understand and customize the template for your next react Magento 2 project,
|
|
286
|
+
than to start from scratch.
|
|
287
|
+
|
|
288
|
+
</details>
|
|
289
|
+
</div>
|
|
290
|
+
|
|
291
|
+
## Next steps
|
|
292
|
+
|
|
293
|
+
- [Get started](../getting-started/create.md) with GraphCommerce and begin
|
|
294
|
+
building a custom storefront.
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
---
|
|
2
|
+
menu: 2. Customize a storefront
|
|
3
|
+
metaTitle: Customize a storefront
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
> **Developer preview**
|
|
7
|
+
> This is a developer preview of GraphCommerce. The documentation will be
|
|
8
|
+
> updated as GraphCommerce introduces
|
|
9
|
+
> [new features and refines existing functionality](https://github.com/ho-nl/m2-pwa/releases).
|
|
10
|
+
|
|
11
|
+
# Start building a GraphCommerce custom storefront
|
|
12
|
+
|
|
13
|
+
Previously, you [created a new GraphCommerce app](../getting-started/create.md).
|
|
14
|
+
You're now ready to start working on your GraphCommerce custom storefront.
|
|
15
|
+
|
|
16
|
+
In this tutorial, you'll complete a series of tasks to add some specific
|
|
17
|
+
functionality to your GraphCommerce app. Your final modification will be simple,
|
|
18
|
+
but you’ll learn where to find resources to build more complex features on your
|
|
19
|
+
own.
|
|
20
|
+
|
|
21
|
+
### What you'll learn
|
|
22
|
+
|
|
23
|
+
After you've finished this tutorial, you'll have accomplished the following:
|
|
24
|
+
|
|
25
|
+
- Customized text and component styles
|
|
26
|
+
- Fetched data from server components
|
|
27
|
+
- Made changes to GraphQL queries
|
|
28
|
+
|
|
29
|
+
### Requirements
|
|
30
|
+
|
|
31
|
+
You're using the most recent version of GraphCommerce. We recommend using the
|
|
32
|
+
latest release to get the benefits of performance, new components, and other
|
|
33
|
+
best practices.
|
|
34
|
+
|
|
35
|
+
You've completed the
|
|
36
|
+
[Create a GraphCommerce app tutorial](../getting-started/create.md).
|
|
37
|
+
|
|
38
|
+
## Step 1: Make customizations
|
|
39
|
+
|
|
40
|
+
### Add text
|
|
41
|
+
|
|
42
|
+
- Make sure your development environment is running at http://localhost:3000
|
|
43
|
+
- In /pages/page/[url].tsx, add:
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
<Typography variant='h1' gutterBottom sx={{ textAlign: 'center' }}>
|
|
47
|
+
Hello
|
|
48
|
+
</Typography>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- Add `import { Typography } from '@mui/material'` to the list of imports at the
|
|
52
|
+
top of the file
|
|
53
|
+
- Save the file to see your changes updated in real-time
|
|
54
|
+
|
|
55
|
+
<figure>
|
|
56
|
+
|
|
57
|
+
https://user-images.githubusercontent.com/1251986/154980151-2039c027-c31f-4b99-86f2-8c2420053da8.mp4
|
|
58
|
+
|
|
59
|
+
<video width="100%" controls autoPlay loop muted>
|
|
60
|
+
<source src="https://user-images.githubusercontent.com/1251986/154980151-2039c027-c31f-4b99-86f2-8c2420053da8.mp4" type="video/mp4"/>
|
|
61
|
+
</video>
|
|
62
|
+
|
|
63
|
+
</figure>
|
|
64
|
+
|
|
65
|
+
### Change a component's style
|
|
66
|
+
|
|
67
|
+
- After you've finished step 1, in /pages/page/[url].tsx find the following
|
|
68
|
+
code:
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
<Typography variant='h1' gutterBottom sx={{ textAlign: 'center' }}>
|
|
72
|
+
Hello
|
|
73
|
+
</Typography>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
- Make the background color red for the Hello text:
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
<Typography
|
|
80
|
+
variant='h1'
|
|
81
|
+
gutterBottom
|
|
82
|
+
sx={{ textAlign: 'center', backgroundColor: 'red' }}
|
|
83
|
+
>
|
|
84
|
+
Hello
|
|
85
|
+
</Typography>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
<figure>
|
|
89
|
+
|
|
90
|
+
https://user-images.githubusercontent.com/1251986/154980686-3d2bf587-16d7-412b-b05f-8b0f7b40cbfd.mp4
|
|
91
|
+
|
|
92
|
+
<video width="100%" controls autoPlay loop muted>
|
|
93
|
+
|
|
94
|
+
<source src="https://user-images.githubusercontent.com/1251986/154980686-3d2bf587-16d7-412b-b05f-8b0f7b40cbfd.mp4" type="video/mp4"/>
|
|
95
|
+
</video>
|
|
96
|
+
|
|
97
|
+
<figcaption>Change a component's style in your GraphCommerce app</figcaption>
|
|
98
|
+
</figure>
|
|
99
|
+
|
|
100
|
+
## Step 2: Make GraphQL changes
|
|
101
|
+
|
|
102
|
+
You might want to make changes to a GraphQL query to fetch data from Magento for
|
|
103
|
+
a specific need. For example, if you want to display a certain category
|
|
104
|
+
property, you need to modify a query.
|
|
105
|
+
|
|
106
|
+
- In /graphql/CategoryPage.graphql, `...CategoryQueryFragment` is included as a
|
|
107
|
+
fragment
|
|
108
|
+
- Open the fragment's file
|
|
109
|
+
/node_modules/@graphcommerce/magento-category/queries/CategoryQueryFragment.graphql,
|
|
110
|
+
and copy it's contents
|
|
111
|
+
- In /graphql/CategoryPage.graphql, paste the contents of
|
|
112
|
+
`...CategoryQueryFragment` and add `children_count` property:
|
|
113
|
+
|
|
114
|
+
```graphql
|
|
115
|
+
query CategoryPage($url: String!, $rootCategory: String!) {
|
|
116
|
+
...MenuQueryFragment
|
|
117
|
+
...FooterQueryFragment
|
|
118
|
+
...PageContentQueryFragment
|
|
119
|
+
...CategoryQueryFragment
|
|
120
|
+
|
|
121
|
+
categories(filters: { url_path: { eq: $url } }) {
|
|
122
|
+
items {
|
|
123
|
+
uid
|
|
124
|
+
children_count
|
|
125
|
+
...CategoryBreadcrumb
|
|
126
|
+
...CategoryDescription
|
|
127
|
+
...CategoryChildren
|
|
128
|
+
...CategoryMeta
|
|
129
|
+
...CategoryHeroNav
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- Save the file. /graphql/CategoryPage.gql.ts should be regenerated, and contain
|
|
136
|
+
the following addition:
|
|
137
|
+
|
|
138
|
+
```json
|
|
139
|
+
{ "kind": "Field", "name": { "kind": "Name", "value": "children_count" } }
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
- In /pages/[...url].tsx, show the children_count next to category title (3
|
|
143
|
+
occurrences):
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
{category?.name} - ({category?.children_count})
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Step 3: Interactive GraphQL interface
|
|
150
|
+
|
|
151
|
+
You can explore the Storefront API and run test queries in your GraphCommerce
|
|
152
|
+
app. When you're running the GraphCommerce local development environment, you
|
|
153
|
+
can visit the following URL to load the GraphQL Explorer:
|
|
154
|
+
|
|
155
|
+
http://localhost:3000/api/graphql
|
|
156
|
+
|
|
157
|
+
## Next steps
|
|
158
|
+
|
|
159
|
+
- Learn how to [build a custom header](../getting-started/header.md) in
|
|
160
|
+
GraphCommerce
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
menu: Setup VS Code
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Visual Studio Code
|
|
6
|
+
|
|
7
|
+
GraphCommerce is a front-end web development framework written in Typescript,
|
|
8
|
+
which is JavaScript with syntax for types.
|
|
9
|
+
|
|
10
|
+
[Visual Studio Code ↗](https://code.visualstudio.com/) is a code editor
|
|
11
|
+
redefined and optimized for building and debugging modern web applications such
|
|
12
|
+
as GraphCommerce. Visual Studio Code is free and available on all platforms.
|
|
13
|
+
This guide covers which useful VS Code extensions to install for an optimal
|
|
14
|
+
development experience.
|
|
15
|
+
|
|
16
|
+
Recommended extensions
|
|
17
|
+
|
|
18
|
+
- [ESLint ↗](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) -
|
|
19
|
+
Linter tool for identifying and reporting on patterns in JavaScript
|
|
20
|
+
- [Prettier ↗](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) -
|
|
21
|
+
Opinionated code formatter
|
|
22
|
+
- [GraphQL ↗](https://marketplace.visualstudio.com/items?itemName=GraphQL.vscode-graphql) -
|
|
23
|
+
Adds syntax highlighting, validation, hover information and autocompletion for
|
|
24
|
+
graphql files
|
|
25
|
+
- [DotENV ↗](https://marketplace.visualstudio.com/items?itemName=mikestead.dotenv) -
|
|
26
|
+
Adds support for dotenv file syntax
|
|
27
|
+
- [JavaScript Booster ↗](https://marketplace.visualstudio.com/items?itemName=sburg.vscode-javascript-booster) -
|
|
28
|
+
Advanced JavaScript/TypeScript refactorings and commands
|
|
29
|
+
- [gettext ↗](https://marketplace.visualstudio.com/items?itemName=mrorz.language-gettext) -
|
|
30
|
+
Adds syntax highlight to po translation files
|
|
31
|
+
|
|
32
|
+
Optional extentions
|
|
33
|
+
|
|
34
|
+
- [Color Highlight ↗](https://marketplace.visualstudio.com/items?itemName=naumovs.color-highlight)
|
|
35
|
+
- [Material Theme ↗](https://marketplace.visualstudio.com/items?itemName=Equinusocio.vsc-material-theme)
|
|
36
|
+
- [Material Theme Icons ↗](https://marketplace.visualstudio.com/items?itemName=Equinusocio.vsc-material-theme-icons)
|
|
37
|
+
- [Output Colorizer ↗](https://marketplace.visualstudio.com/items?itemName=IBM.output-colorizer)
|
|
38
|
+
- [Readability Check ↗](https://marketplace.visualstudio.com/items?itemName=jemcclin.readabilitycheck)
|
|
39
|
+
- [Github Actions ↗](https://marketplace.visualstudio.com/items?itemName=me-dutour-mathieu.vscode-github-actions)
|
|
40
|
+
- [MDX ↗](https://marketplace.visualstudio.com/items?itemName=silvenon.mdx)
|
|
41
|
+
- [Markdown Preview Github Styling ↗](https://marketplace.visualstudio.com/items?itemName=bierner.markdown-preview-github-styles)
|
|
42
|
+
- [Yaml ↗](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml)
|
|
43
|
+
|
|
44
|
+
## Next steps
|
|
45
|
+
|
|
46
|
+
- [Start building a GraphCommerce custom storefront](../getting-started/start-building.md)
|
|
47
|
+
by customizing text and component styles, fetching data from server
|
|
48
|
+
components, and making changes to GraphQL queries.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
menu: Overview
|
|
3
|
+
order: getting-started,framework
|
|
4
|
+
metaTitle: Start React, Next.js Magento PWA development here - GraphCommerce
|
|
5
|
+
metaDescription:
|
|
6
|
+
'GraphCommerce is the open-source PWA Studio Magento 2 alternative.
|
|
7
|
+
GraphCommerce is a full-featured PWA storefront, not a Magento 2 PWA
|
|
8
|
+
extension.'
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
> **Developer preview**
|
|
12
|
+
> This is a developer preview of GraphCommerce. The documentation will be
|
|
13
|
+
> updated as GraphCommerce introduces
|
|
14
|
+
> [new features and refines existing functionality](https://github.com/ho-nl/m2-pwa/releases).
|
|
15
|
+
|
|
16
|
+
# GraphCommerce
|
|
17
|
+
|
|
18
|
+
GraphCommerce is a front-end framework used for building headless Magento
|
|
19
|
+
e-commerce storefronts in React. It includes the structure, components, and
|
|
20
|
+
tooling you need to get started so you can spend your time styling and designing
|
|
21
|
+
high-end e-commerce progressive web apps (PWA).
|
|
22
|
+
|
|
23
|
+
<figure>
|
|
24
|
+
|
|
25
|
+
https://user-images.githubusercontent.com/1251986/154977573-4015e77c-43e7-481e-ab97-60c365c6b746.mp4
|
|
26
|
+
|
|
27
|
+
<video width="100%" controls autoPlay loop muted>
|
|
28
|
+
<source src="https://user-images.githubusercontent.com/1251986/154977573-4015e77c-43e7-481e-ab97-60c365c6b746.mp4" type="video/mp4"/>
|
|
29
|
+
</video>
|
|
30
|
+
|
|
31
|
+
<figcaption>GraphCommerce magento-graphcms example demo</figcaption>
|
|
32
|
+
</figure>
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
### Stack
|
|
37
|
+
|
|
38
|
+
- Typescript
|
|
39
|
+
- React
|
|
40
|
+
- Nextjs
|
|
41
|
+
- GraphQL
|
|
42
|
+
- Mui
|
|
43
|
+
- Apollo
|
|
44
|
+
- GraphQL Code Generator
|
|
45
|
+
- Framer Motion
|
|
46
|
+
|
|
47
|
+
## Getting Started
|
|
48
|
+
|
|
49
|
+
GraphCommerce offers a [magento-graphcms](./getting-started/readme.md) example
|
|
50
|
+
that provides a full-featured storefront. The example integrates with your
|
|
51
|
+
Magento backend and provides a full purchase journey out-of-the-box. It uses
|
|
52
|
+
GraphCMS to enrich pages with multiple content components, like the homepage.
|
|
53
|
+
|
|
54
|
+
The magento-graphcms example is styled using the Mui component library. You can
|
|
55
|
+
start styling by making changes to the [theme](./framework/theming.md).
|
|
56
|
+
|
|
57
|
+
## Features
|
|
58
|
+
|
|
59
|
+
GraphCommerce features include:
|
|
60
|
+
|
|
61
|
+
- App-like e-commerce UI
|
|
62
|
+
- Magento e-commerce component library including cart, search, layered
|
|
63
|
+
navigation components and category, product, account, checkout pages
|
|
64
|
+
- Optimized front-end performance, including bundling, image optimization, CDN
|
|
65
|
+
caching
|
|
66
|
+
- Predictive URL prefetching and caching
|
|
67
|
+
- Hybrid Static Site Generation (SSG)
|
|
68
|
+
- SEO optimized, including accessibility, sitemap.xml, canonicals, metadata
|
|
69
|
+
- Data fetching from multiple sources with the included GraphQL Mesh (composable
|
|
70
|
+
commerce)
|
|
71
|
+
- Passing Google Core Web Vitals audits
|
|
72
|
+
- PWA out-of-the-box
|
|
73
|
+
- Magento multi-language support, a store switcher component, and framework
|
|
74
|
+
translations EN, ES, FR, DE, NL, IT
|
|
75
|
+
- Deployments to Vercel
|
|
76
|
+
|
|
77
|
+
## Build high-end Magento storefronts faster
|
|
78
|
+
|
|
79
|
+
GraphCommerce accelerates the Magento front-end development process by using a
|
|
80
|
+
carefully chosen, industry standard, tech stack. It includes Magento-specific
|
|
81
|
+
React components, pages, and utilities for e-commerce. They're accessible,
|
|
82
|
+
performant, and ready for use. They also help to reduce the initial complexity
|
|
83
|
+
and boilerplate needed for building a custom storefront.
|
|
84
|
+
|
|
85
|
+
## FAQ
|
|
86
|
+
|
|
87
|
+
<div>
|
|
88
|
+
<details>
|
|
89
|
+
<summary>Is GraphCommerce a Magento PWA theme?</summary>
|
|
90
|
+
|
|
91
|
+
### Is GraphCommerce a Magento PWA theme?
|
|
92
|
+
|
|
93
|
+
GraphCommerce is not a Magento PWA theme, nor is it a Magento 2 PWA extension. A
|
|
94
|
+
Magento theme is tightly integrated in the Magento codebase, where a
|
|
95
|
+
GraphCommerce storefront runs as a separate application.
|
|
96
|
+
|
|
97
|
+
GraphCommerce can be deployed on the same or a different server than the Magento
|
|
98
|
+
backend is hosted on. All data is fetched from the Magento 2 GraphQL API. Once
|
|
99
|
+
you finish GraphCommerce Magento PWA development and you are ready to launch,
|
|
100
|
+
the regular Magento front-end (theme and extensions) can be decommissioned.
|
|
101
|
+
|
|
102
|
+
</details>
|
|
103
|
+
|
|
104
|
+
<details>
|
|
105
|
+
<summary>Is GraphCommerce a PWA Studio Magento 2 alternative?</summary>
|
|
106
|
+
|
|
107
|
+
### Is GraphCommerce a PWA Studio Magento 2 alternative?
|
|
108
|
+
|
|
109
|
+
Yes, GraphCommerce is suitable as an alternative to Magento 2 PWA Studio.
|
|
110
|
+
GraphCommerce is built with modern, open-source javascript frameworks and
|
|
111
|
+
libraries. Unlike PWA Studio for Magento 2, it features an app-like e-commerce
|
|
112
|
+
user interface, Hybrid Static Site Generation (SSG) and has the ability to fetch
|
|
113
|
+
data from multiple sources (composable commerce).
|
|
114
|
+
[Get started](./getting-started/create.md) with GraphCommerce if you're looking
|
|
115
|
+
for a PWA Studio Magento 2 alternative and would like to start with Magento PWA
|
|
116
|
+
development.
|
|
117
|
+
|
|
118
|
+
</details>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
## Next steps
|
|
122
|
+
|
|
123
|
+
- [Get started](./getting-started/create.md) with GraphCommerce and begin
|
|
124
|
+
building a custom storefront.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
menu: Roadmap
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Roadmap
|
|
6
|
+
|
|
7
|
+
The following overview contains the status of items on the GraphCommerce roadmap
|
|
8
|
+
(items are subject to change):
|
|
9
|
+
|
|
10
|
+
## In progress
|
|
11
|
+
|
|
12
|
+
- [x] Framework updates (Mui5)
|
|
13
|
+
- [x] Translation updates (DE, NL, ES, FR, IT)
|
|
14
|
+
- [ ] Documentation and installation guide
|
|
15
|
+
- [ ] Quality improvements (Reduce components, naming)
|
|
16
|
+
|
|
17
|
+
## Planned
|
|
18
|
+
|
|
19
|
+
- [ ] Search integration (external service)
|
|
20
|
+
- [ ] Checkout UI and accessibility improvements
|
|
21
|
+
- [ ] Payment service provider integration
|
|
22
|
+
|
|
23
|
+
## Future
|
|
24
|
+
|
|
25
|
+
- [ ] `magento` example without GraphCMS
|
|
26
|
+
|
|
27
|
+
## Next steps
|
|
28
|
+
|
|
29
|
+
- Refer to the
|
|
30
|
+
[Changelog](https://github.com/ho-nl/m2-pwa/blob/master/CHANGELOG.md) to see
|
|
31
|
+
what's new
|