@faststore/core 3.0.5 → 3.0.7

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.
Files changed (38) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +13 -13
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/config.json +3 -3
  5. package/.next/cache/eslint/.cache_1gneedd +1 -1
  6. package/.next/cache/webpack/client-production/0.pack +0 -0
  7. package/.next/cache/webpack/client-production/index.pack +0 -0
  8. package/.next/cache/webpack/server-production/0.pack +0 -0
  9. package/.next/cache/webpack/server-production/index.pack +0 -0
  10. package/.next/next-minimal-server.js.nft.json +1 -1
  11. package/.next/next-server.js.nft.json +1 -1
  12. package/.next/prerender-manifest.js +1 -1
  13. package/.next/prerender-manifest.json +1 -1
  14. package/.next/react-loadable-manifest.json +1 -1
  15. package/.next/routes-manifest.json +1 -1
  16. package/.next/server/chunks/247.js +1 -1
  17. package/.next/server/middleware-build-manifest.js +1 -1
  18. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  19. package/.next/server/pages/en-US/404.html +2 -2
  20. package/.next/server/pages/en-US/500.html +2 -2
  21. package/.next/server/pages/en-US/account.html +2 -2
  22. package/.next/server/pages/en-US/checkout.html +2 -2
  23. package/.next/server/pages/en-US/login.html +2 -2
  24. package/.next/server/pages/en-US/s.html +2 -2
  25. package/.next/server/pages/en-US.html +2 -2
  26. package/.next/server/pages-manifest.json +1 -1
  27. package/.next/static/chunks/247.6f1391104a867395.js +1 -0
  28. package/.next/static/chunks/{webpack-1c08d77cfe1b8585.js → webpack-b4a2fdf4ef127bb7.js} +1 -1
  29. package/.next/trace +91 -91
  30. package/.turbo/turbo-build.log +3 -3
  31. package/.turbo/turbo-test.log +10 -10
  32. package/README.md +51 -261
  33. package/cypress/integration/seo.test.js +2 -2
  34. package/package.json +9 -9
  35. package/src/sdk/cart/useCheckoutButton.ts +9 -2
  36. package/.next/static/chunks/247.52b3924429a474c6.js +0 -1
  37. /package/.next/static/{CL5sqlZ2cFl4nWEkYnXnd → crd_9b3CySb6GRRyCuS1a}/_buildManifest.js +0 -0
  38. /package/.next/static/{CL5sqlZ2cFl4nWEkYnXnd → crd_9b3CySb6GRRyCuS1a}/_ssgManifest.js +0 -0
@@ -1,6 +1,6 @@
1
1
  $ yarn partytown & yarn generate && next build
2
- $ partytown copylib ./public/~partytown
3
2
  $ faststore generate-graphql -c
3
+ $ partytown copylib ./public/~partytown
4
4
  Partytown lib copied to: /home/runner/work/faststore/faststore/packages/core/public/~partytown
5
5
  success - GraphQL schema, types, and optimizations successfully generated 🎉
6
6
  ⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
@@ -50,11 +50,11 @@ Route (pages) Size First Load JS
50
50
  ├ ● /checkout 662 B 126 kB
51
51
  ├ ● /login 1.58 kB 127 kB
52
52
  └ ● /s 4.66 kB 141 kB
53
- + First Load JS shared by all 96.4 kB
53
+ + First Load JS shared by all 96.5 kB
54
54
  ├ chunks/framework-8e279965036b6169.js 45.4 kB
55
55
  ├ chunks/main-6f63f6746cc029db.js 33.1 kB
56
56
  ├ chunks/pages/_app-6516d0c2c7e0e686.js 12.5 kB
57
- ├ chunks/webpack-1c08d77cfe1b8585.js 2.45 kB
57
+ ├ chunks/webpack-b4a2fdf4ef127bb7.js 2.45 kB
58
58
  └ css/5d1f64b61ea581f4.css 3.05 kB
59
59
 
60
60
  λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
@@ -1,23 +1,23 @@
1
1
  $ jest
2
- PASS test/server/index.test.ts (21.702 s)
2
+ PASS test/server/index.test.ts (21.317 s)
3
3
  FastStore GraphQL Layer
4
4
  @faststore/api
5
- ✓ should return a valid GraphQL schema (8 ms)
6
- ✓ should return a valid GraphQL schema contain all expected types (6 ms)
5
+ ✓ should return a valid GraphQL schema (9 ms)
6
+ ✓ should return a valid GraphQL schema contain all expected types (24 ms)
7
7
  ✓ should return a valid GraphQL schema contain all expected queries (1 ms)
8
- ✓ should return a valid GraphQL schema contain all expected mutations
8
+ ✓ should return a valid GraphQL schema contain all expected mutations (2 ms)
9
9
  VTEX API Extension
10
- ✓ getTypeDefsFromFolder function should return an Array (8 ms)
10
+ ✓ getTypeDefsFromFolder function should return an Array (10 ms)
11
11
  Third Party API Extension
12
- ✓ getTypeDefsFromFolder function should return an Array (18 ms)
12
+ ✓ getTypeDefsFromFolder function should return an Array (17 ms)
13
13
  Final Schema after merging
14
- ✓ should return a valid merged GraphQL schema (43 ms)
14
+ ✓ should return a valid merged GraphQL schema (55 ms)
15
15
  Envelop
16
- ✓ should exist with its plugins (48 ms)
17
- ✓ should handle options and execute (257 ms)
16
+ ✓ should exist with its plugins (54 ms)
17
+ ✓ should handle options and execute (528 ms)
18
18
 
19
19
  Test Suites: 1 passed, 1 total
20
20
  Tests: 9 passed, 9 total
21
21
  Snapshots: 0 total
22
- Time: 21.784 s
22
+ Time: 21.377 s
23
23
  Ran all test suites.
package/README.md CHANGED
@@ -7,58 +7,20 @@
7
7
  A starter powered by FastStore and NextJS
8
8
  </h1>
9
9
 
10
- Kickoff your store with this boilerplate. This starter ships with the main FastStore configuration files you might need to get up and running blazing fast with the blazing-fast store for React.
11
-
12
- ## ⚠️ Before you start
13
-
14
- As of Sep, 2022, this starter is still far from covering most basic cases found on VTEX. To summarize what we still do not support that is considered basic on the VTEX commerce platform, we prepared the list below. If the feature you want is listed, you can either wait for us to add support to the feature, or fork the repo and implement on your own. Note that, by forking the repo, you will miss new features and improvements we do in this repo and you will need a developer to backport the feature to your store. Finally, this list is a work in progress, so some features may be missing from both base.store starter and this list.
15
-
16
- 1. Multiple CMS Previews. Only one user is allowed to preview content from the CMS at a time. If two users preview any content from any page at the CMS, the previews are not consistent and one user may see data from the other.
17
- 2. Price Table
18
- 3. Internationalization
19
- 4. Shared Cart (Carrinho compartilhado)
20
- 5. Clear products that are our of stock from cart
21
- 6. GDPR (LGDP)
22
- 7. Shipping simulation
23
- 8. Sitemap
24
- 9. Promotions via utm
10
+ Kick off your store with this boilerplate.
11
+ This starter ships the main FastStore configuration files to get your store up and running blazing-fast. This source code is the base for FastStore projects starter.
25
12
 
26
13
  ## 🚀 Quick start
27
14
 
28
- 0. **Clone this repo**
29
-
30
- Get up and running by cloning this repo.
31
-
32
- ```shell
33
- # Clone this repo into your machine
34
- npx degit vtex-sites/nextjs.store awesome.store
35
- ```
36
-
37
15
  1. **Install dependencies**
38
16
 
39
17
  Install dependencies with yarn
40
18
 
41
19
  ```shell
42
- cd awesome.store/
43
20
  yarn
44
21
  ```
45
22
 
46
- 2. **Setup faststore.config.js**
47
-
48
- Choose the ecommerce platform provider of your choice in the `store.config` file and set the corresponding options. For instance, to connect to the VTEX platform on the store `fashioneurope`:
49
-
50
- ```js
51
- module.exports = {
52
- platform: 'vtex',
53
-
54
- api: {
55
- storeId: 'fashioneurope'
56
- environment: 'vtexcommercestable'
57
- }
58
- }
59
- ```
60
-
61
- 3. **Start developing**
23
+ 2. **Start developing**
62
24
 
63
25
  Navigate into your new site’s directory and start it up.
64
26
 
@@ -66,45 +28,49 @@ As of Sep, 2022, this starter is still far from covering most basic cases found
66
28
  yarn dev
67
29
  ```
68
30
 
69
- 4. **Open the source code and start editing!**
31
+ 3. **Open the source code and start editing!**
70
32
 
71
33
  Your site is now running at `http://localhost:3000`!
72
34
 
73
- Open the `awesome.store` directory in your code editor of choice and edit `src/pages/index.tsx`. Save your changes and the browser will update in real-time!
74
-
75
- ## :technologist: Contributing
76
-
77
- 1. **Keep the CHANGELOG updated**
78
- We use a CHANGELOG to keep the history of all notable changes made to this repository.
79
- Each PR must have at least one entry on the `[UNRELEASED]` section of the `CHANGELOG.md` file.
80
-
81
35
  ## 🧐 What's inside?
82
36
 
83
- A quick look at the top-level files and directories you'll see in a NextJS project.
37
+ A quick look at the top-level files and directories you'll see in a this NextJS project.
84
38
 
85
39
  ./
86
40
  ├── node_modules
41
+ ├── @generated
42
+ ├── cms
43
+ ├── public
87
44
  ├── src
88
- ├── .gitignore
89
- ├── .eslintignore
45
+ ├── test
46
+ ├── .babelrc.js
47
+ ├── .editorconfig
90
48
  ├── .prettierignore
91
49
  ├── .prettierrrc
92
- ├── .eslintrc
93
- ├── LICENSE
94
- └── yarn.lock
95
- ├── package.json
96
- ├── tsconfig.json
97
- ├── faststore.config.js
98
- ├── README.md
50
+ ├── .stylelintignore
51
+ ├── .gitignore
52
+ ├── .eslintignore
99
53
  ├── CHANGELOG.md
100
- ├── __generated__
101
- ├── babel.config.js
54
+ ├── codegen.ts
102
55
  ├── cypress
103
56
  ├── cypress.config.ts
57
+ ├── faststore.config.default.js
58
+ ├── faststore.config.js
59
+ ├── index.ts
60
+ ├── jest.config.js
61
+ ├── LICENSE
104
62
  ├── lighthouserc.js
105
- ├── public
63
+ ├── next-env.d.ts
64
+ ├── next.config.ts
65
+ ├── package.json
66
+ ├── tsconfig.json
67
+ ├── postcss.config.js
68
+ ├── postinstall.js
106
69
  ├── pull_request_template.md
107
- ├── renovate.json
70
+ ├── README.md
71
+ ├── stylelint.config.js
72
+ ├── tsconfig.json
73
+ ├── vtex.env
108
74
 
109
75
  1. **`/node_modules`**: This directory contains all of the modules of code that your project depends on (npm packages) are automatically installed.
110
76
 
@@ -114,39 +80,27 @@ A quick look at the top-level files and directories you'll see in a NextJS proje
114
80
 
115
81
  4. **`.prettierrc`**: This is a configuration file for [Prettier](https://prettier.io/). Prettier is a tool to help keep the formatting of your code consistent.
116
82
 
117
- 5. **`.eslintrc.js`**: This is a configuration file for [ESLint](https://eslint.org/). ESlint is a tool to find and fix problems in your JavaScript code.
118
-
119
- 6. **`LICENSE`**: NextJS is licensed under the MIT license.
120
-
121
- 7. **`yarn.lock`** (See `package.json` below, first). This is an automatically generated file based on the exact versions of your npm dependencies that were installed for your project. **(You won’t change this file directly).**
122
-
123
- 8. **`package.json`**: A manifest file for Node.js projects, which includes things like metadata (the project’s name, author, etc). This manifest is how npm knows which packages to install for your project.
124
-
125
- 9. **`tsconfig.json`**: The configuration file for the typescript compiler. This will statically analyze your code for errors and bugs before releasing them into production
126
-
127
- 10. **`faststore.config.js`**: Configure your e-commerce platform, default sales channel etc.
128
-
129
- 11. **`README.md`**: A text file containing useful reference information about your project.
83
+ 5. **`LICENSE`**: NextJS is licensed under the MIT license.
130
84
 
131
- 12. **`CHANGELOG.md`**: A text file containing all notable changes to the project.
85
+ 6. **`package.json`**: A manifest file for Node.js projects, which includes things like metadata (the project’s name, author, etc). This manifest is how npm knows which packages to install for your project.
132
86
 
133
- 13. **`__generated__`**: Where TypeScript typings are generated for your GraphQL queries. You can use these files for strongly typing your App
87
+ 7. **`tsconfig.json`**: The configuration file for the typescript compiler. This will statically analyze your code for errors and bugs before releasing them into production
134
88
 
135
- 14. **`babel.config.js`**: [Babel configurations](https://babeljs.io/docs/en/configuration#babelrcjson) for you app. This is where you can change the targeted browsers.
89
+ 8. **`faststore.config.default.js`**: Configure your e-commerce platform, default sales channel etc.
136
90
 
137
- 15. **`cypress`**: End to End(e2e) tests using Cypress. Most of the scenarios are covered here. Add your custom flows to avoid regressions
91
+ 9. **`@generated`**: Where TypeScript typings are generated for your GraphQL queries. You can use these files for strongly typing your App
138
92
 
139
- 16. **`cypress.config.ts`**: [Cypress configuration file](https://docs.cypress.io/guides/references/configuration)
93
+ 10. **`cypress`**: End to End(e2e) tests using Cypress. Most of the scenarios are covered here. Add your custom flows to avoid regressions
140
94
 
141
- 17. **`lighthouserc.js`**: Configures [Google Lighthouse CI](https://github.com/GoogleChrome/lighthouse-ci). This is where you can turn on/off lighthouse assertions to be used by Lighthouse CI Bot/hook
95
+ 11. **`cypress.config.ts`**: [Cypress configuration file](https://docs.cypress.io/guides/references/configuration)
142
96
 
143
- 18. **`pull_request_template.md`**: Template used when creating your Pull Requests
97
+ 12. **`lighthouserc.js`**: Configures [Google Lighthouse CI](https://github.com/GoogleChrome/lighthouse-ci). This is where you can turn on/off lighthouse assertions to be used by Lighthouse CI Bot/hook
144
98
 
145
- 19. **`renovate.json`**: Renovate configuration file to keep your store always fresh with FastStore's latest versions
99
+ 13. **`pull_request_template.md`**: Template used when creating your Pull Requests
146
100
 
147
- 20. **`.prettierignore`**: Ignore listed files when applying prettier rules
101
+ 14. **`.prettierignore`**: Ignore listed files when applying prettier rules
148
102
 
149
- 21. **`.eslintignore`**: Ignore listed files when applying eslint rules
103
+ 15. **`.eslintignore`**: Ignore listed files when applying eslint rules
150
104
 
151
105
  ## 💻 Code Structure
152
106
 
@@ -154,8 +108,8 @@ All code is inside the `src` folder. The code is split into folders that impleme
154
108
 
155
109
  The `controller` is inside the `src/sdk` folder. This is where you will find most logic for the application. This folder contains hooks for adding items to cart, making graphql queries, resizing images, etc. If you need to write a custom business logic this is probably the place to put this logic.
156
110
 
157
- The `views` are written in the `src/components` folder and are subdivided into domain-specific components. Cart related items are inside the `src/components/cart` folder. Search and Product related components like facets, product summary, and search results are in their respective folders. Basic building blocks components are inside the UI folder. Components like button, checkbox, and modal are good candidates for the UI folder.
158
- Section components are those components that occupy a whole slice on the webpage and are desirable to be changed by a CMS. Section components are Product Gallery, Carousel, Shelf and Product description.
111
+ The `views` are written in the `src/components` folder and are subdivided into domain-specific components. Cart related items are inside the `src/components/cart` folder. Search and Product related components like facets, product summary, and search results are in their respective folders. Basic building blocks components used in the sections are inside the UI folder.
112
+ Section components are those components that occupy a whole slice on the webpage and are desirable to be changed by a CMS. Section components are Product Gallery, Product Shelf and Hero and BannerText.
159
113
 
160
114
  The `model`, in a website, is where the data fetching occurs. Since this project uses Jamstack, a crucial design decision was made to explicitly split where Static and Dynamic data are fetched. The files inside the `src/pages` folder use [NextJS's File System Route API](https://nextjs.org/docs/routing/introduction) to declare routes and fetch static data.
161
115
 
@@ -165,136 +119,12 @@ To summarize:
165
119
  2. `src/views`: Receives static data from `src/pages`, enriches this data with dynamic attributes, and render section components along with SEO tags.
166
120
  3. `src/components/sections`: Receives necessary data and use domain-specific components (cart/product/search/ui) for rendering a slice on the web page.
167
121
 
168
- ## ✏️ Adding Components
169
-
170
- What better than an example for learning the best practices while adding components? In this example, we will add a button component.
171
- Components live on the `src/components` folder. Each component may have, at most, 3 files: a component file, an export file, and a styling file.
172
- First, let's create a folder and the files.
173
-
174
- ```sh
175
- mkdir src/components/ui/Button
176
- touch src/components/ui/Button/Button.tsx
177
- touch src/components/ui/Button/index.tsx
178
- ```
179
-
180
- The `index.tsx` is just an export file, so its content is simple:
181
-
182
- ```tsx
183
- export { default } from './Button'
184
- ```
185
-
186
- The real thing happens on `Button.tsx`. On this file let's define the component like:
187
-
188
- ```tsx
189
- interface Props {}
190
-
191
- function Button(props: Props) {
192
- return <button {...props} />
193
- }
194
-
195
- export default Button
196
- ```
197
-
198
- And, that's it! Now you have a working button that you can use anywhere on your project. FastStore, however, brings a handy library called `@faststore/ui` with built-in components to help you speed up your development. To use it, just change `Button.tsx` to:
199
-
200
- ```tsx
201
- import { Button as UIButton } from '@faststore/ui'
202
- import type { ButtonProps } from '@faststore/ui'
203
-
204
- interface Props extends ButtonProps {}
205
-
206
- function Button(props: Props) {
207
- return <UIButton {...props} />
208
- }
209
-
210
- export default Button
211
- ```
212
-
213
- Now, your Button component is powered by Store UI. However, if you try to use this on your app you will see that the button is lacking styles. To add styles, we will use CSS modules because they allow us to target data attributes. On your terminal, type:
214
-
215
- ```sh
216
- touch src/components/ui/Button/button.scss
217
- ```
218
-
219
- Now, on `button.scss`:
220
-
221
- ```css
222
- [data-fs-button] {
223
- display: inline-flex;
224
- align-items: center;
225
- justify-content: center;
226
- }
227
- ```
228
-
229
- This `data-fs-button` is a CSS data attribute selector. To know which selectors are available, check [FastStore UI docs](https://faststoreui.netlify.app/).
230
-
231
- Now, include the component's CSS into the Store's CSS. Open `src/styles/global/components.scss` and import this CSS with:
232
-
233
- ```scss
234
- // ...
235
- @import 'src/components/ui/Button/button.scss';
236
- // ...
237
- ```
238
-
239
- For most components, you would stop here. However, buttons can have different variants. For instance, suppose you want to have a button component with primary and secondary variants. To add variants to the component, update `Button.tsx`:
240
-
241
- ```tsx
242
- import { Button as UIButton } from '@faststore/ui'
243
- import type { ButtonProps } from '@faststore/ui'
244
-
245
- interface Props extends ButtonProps {
246
- variant: 'secondary' | 'primary'
247
- }
248
-
249
- function Button({ variant, ...props }: Props) {
250
- return <UIButton data-button-variant={variant} {...props} />
251
- }
252
-
253
- export default Button
254
- ```
255
-
256
- and then, on `button.scss`:
257
-
258
- ```css
259
- [data-fs-button][data-button-variant='primary'] {
260
- background: blue;
261
- }
262
-
263
- [data-fs-button][data-button-variant='secondary'] {
264
- background: pink;
265
- }
266
- ```
267
-
268
- You can also use classes, if you wanted to:
269
-
270
- ```tsx
271
- function Button({ variant, ...props }: Props) {
272
- return <UIButton className={variant} {...props} />
273
- }
274
- ```
275
-
276
- ```css
277
- .primary[data-fs-button] {
278
- background: blue;
279
- }
280
-
281
- .secondary[data-fs-button] {
282
- background: pink;
283
- }
284
- ```
285
-
286
- Now we have a styled Button component that accepts different variants!! 🎉
287
-
288
122
  ### Managing SVG Icons
289
123
 
290
124
  Icons help build web pages by illustrating concepts and improving website navigation. However, using icons can decrease the page's performance. One option to avoid the decrease of the page's performance is to use SVGs from a single SVG file, located in `/static/icons.svg`, and load them with the `ui/Icon` component.
291
125
 
292
126
  In the following steps, learn how to add and use a new SVG icon and avoid decreasing page performance while using an icon.
293
127
 
294
- > ⚠️ Warning
295
- >
296
- > This is a recommendation while using icons on a web page. Evaluate if this fits in your project.
297
-
298
128
  #### Adding an SVG icon
299
129
 
300
130
  1. In the SVG file, change the `svg` tag to `symbol`.
@@ -316,7 +146,7 @@ An example adding Bell icon:
316
146
 
317
147
  ```tsx
318
148
  // src/components/ui/MyIconButton/MyIconButton.tsx
319
- import Icon from 'src/components/ui/Icon' // this path can be outdated.
149
+ import Icon from '@faststore/ui'
320
150
 
321
151
  function ButtonIcon() {
322
152
  return (
@@ -330,55 +160,16 @@ export default ButtonIcon
330
160
  ```
331
161
 
332
162
  This project uses SVGs from [Phosphor icons](https://phosphoricons.com/).
163
+ More details, please refer to this [doc](https://www.faststore.dev/docs/icons).
333
164
 
334
165
  ## 🖊️ Styling Components
335
166
 
336
- Our customized themes are based on [Design Tokens](https://css-tricks.com/what-are-design-tokens/) using [CSS Variables](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) or a CSS class for each token. Today, we have the following files in the `src/styles` folder:
337
-
338
- ### `tokens.scss`
339
-
340
- Here you'll find the basic structure to build your theme (font base, color palette, spacing, color-text, body background color...), feel free to update it with your brand guidelines.
341
-
342
- #### <b>Colors</b>
343
-
344
- We suggest using a color palette of 3 colors and its gradation: `primary`, `secondary` and `neutral`.
345
-
346
- We also listed a couple of customizable tokens so you can easily change your body background, for example.
347
-
348
- If you feel the need to edit some of the color decisions, you can enter `tokens.scss` and update the semantical tokens. E.g.:
349
-
350
- ```scss
351
- --fs-border-color: var(--fs-color-neutral-4); // Current
352
- --fs-border-color: var(--fs-color-neutral-5); // Updated
353
- ```
354
-
355
- #### <b>Typography</b>
356
-
357
- We use the [Modular Scale](https://www.modularscale.com/) setting to create our text-sizes. If you want to change it, just set the `--fs-text-size-base` and the `scale` ratio.
358
-
359
- #### <b>Spacing</b>
360
-
361
- The spacing scale is based on `rem` sizes, so it will remain consistent if you change the `--fs-text-size-base`.
362
-
363
- ### `layout.scss`
364
-
365
- List of classes used to create default page grid.
366
-
367
- ```scss
368
- .layout__content // Should be used for sections that fit centered on the grid.
369
- .layout__section // This class only adds default vertical margins for page sections.
370
- ```
371
-
372
- ![grid-example-image](https://user-images.githubusercontent.com/3356699/150801221-4027dc6a-1cc4-40a7-a323-8be7a148458d.png)
373
-
374
- ### `typography.scss`
375
-
376
- For the typography-related styles, we decided to use classes to add extra stylings like `font-weight` and `line-height`. In this file, you'll see all the classes for titles, paragraphs, and default settings on the body. You can create new ones here if needed.
167
+ Our customized themes are based on [Design Tokens](https://css-tricks.com/what-are-design-tokens/) using [CSS Variables](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) or a CSS class for each token. We utilize the styles from the `@faststore/ui` package, which are imported into the `src/styles` directory. Additionally, each component's styles are imported directly into the section where they are being used. Refer to [Theming overview](https://www.faststore.dev/docs/theming-overview) for more details.
377
168
 
378
169
  ## 🍒 Adding queries
379
170
 
380
171
  We use [graphql-codegen](https://www.graphql-code-generator.com/) to pre-process GraphQL queries. This compilation generates TypeScript typings and configurations for our graphql server under the folder `@generated/graphql`.
381
- This means we can statically analyse your code in search of bugs and secure your graphql server before each deploy. If, however you need to change any GraphQL Fragment, Query or Mutation, you will need to regenerate the whole thing. To do this, open your terminal and type
172
+ This means we can statically analyze your code in search of bugs and secure your graphql server before each deploy. If, however you need to change any GraphQL Fragment, Query or Mutation, you will need to regenerate the whole thing. To do this, open your terminal and type
382
173
 
383
174
  ```sh
384
175
  $ yarn dev
@@ -396,15 +187,14 @@ That's it! you have just regenerated all graphql queries/fragments for your appl
396
187
 
397
188
  ## CMS Integration
398
189
 
399
- This store is integrated with [VTEX headless CMS](https://www.faststore.dev/tutorials/cms/0).
400
-
401
- The page rendered with CMS is:
190
+ This store is integrated with [VTEX headless CMS](https://v1.faststore.dev/tutorials/cms/0).
402
191
 
403
- - index page: `pages/index.tsx`
192
+ The page rendered with CMS is the index page: `pages/index.tsx`
193
+ The `cms/faststore` contains the `content-types.json` and `sections.json` files.
404
194
 
405
195
  ### CMS configs
406
196
 
407
- It's possible to change the CMS tenant and workspace at `faststore.config.js`.
197
+ It's possible to change the CMS tenant and workspace at `faststore.config.default.js`.
408
198
 
409
199
  ## 🎓 Learning the Frameworks
410
200
 
@@ -177,7 +177,7 @@ describe('Collection Page Seo', () => {
177
177
  .should('exist')
178
178
  .should(($link) => {
179
179
  expect($link.attr('href')).to.eq(
180
- `${storeUrl}${pages.collection}?sort=score_desc`
180
+ `${storeUrl}${pages.collection}`
181
181
  )
182
182
  })
183
183
  })
@@ -234,7 +234,7 @@ describe('Filtered Collection Page Seo', () => {
234
234
  .should('exist')
235
235
  .should(($link) => {
236
236
  expect($link.attr('href')).to.eq(
237
- `${storeUrl}${pages.collection}?sort=score_desc`
237
+ `${storeUrl}${pages.collection}`
238
238
  )
239
239
  })
240
240
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "3.0.5",
3
+ "version": "3.0.7",
4
4
  "license": "MIT",
5
5
  "repository": "vtex/faststore",
6
6
  "browserslist": "supports es6-module and not dead",
@@ -39,11 +39,11 @@
39
39
  "@envelop/graphql-jit": "^1.1.1",
40
40
  "@envelop/parser-cache": "^2.2.0",
41
41
  "@envelop/validation-cache": "^2.2.0",
42
- "@faststore/api": "^3.0.4",
43
- "@faststore/components": "^3.0.3",
44
- "@faststore/graphql-utils": "^3.0.3",
45
- "@faststore/sdk": "^3.0.3",
46
- "@faststore/ui": "^3.0.3",
42
+ "@faststore/api": "^3.0.7",
43
+ "@faststore/components": "^3.0.7",
44
+ "@faststore/graphql-utils": "^3.0.7",
45
+ "@faststore/sdk": "^3.0.7",
46
+ "@faststore/ui": "^3.0.7",
47
47
  "@graphql-codegen/cli": "^3.3.1",
48
48
  "@graphql-codegen/client-preset": "^4.1.0",
49
49
  "@graphql-codegen/typescript": "^3.0.4",
@@ -83,8 +83,8 @@
83
83
  "devDependencies": {
84
84
  "@cypress/code-coverage": "^3.12.1",
85
85
  "@envelop/testing": "^6.0.0",
86
- "@faststore/cli": "^3.0.3",
87
- "@faststore/eslint-config": "^3.0.3",
86
+ "@faststore/cli": "^3.0.7",
87
+ "@faststore/eslint-config": "^3.0.7",
88
88
  "@faststore/lighthouse": "^1.12.32",
89
89
  "@lhci/cli": "^0.9.0",
90
90
  "@testing-library/cypress": "^10.0.1",
@@ -128,5 +128,5 @@
128
128
  "node": "18.19.0",
129
129
  "yarn": "1.19.1"
130
130
  },
131
- "gitHead": "59c6ea9340a7f793d79be21b87e30712b2280450"
131
+ "gitHead": "1672bc9ba921b70b5f9acfa2845c8f566d29be16"
132
132
  }
@@ -2,13 +2,20 @@ import storeConfig from '../../../faststore.config'
2
2
  import { useCart } from './index'
3
3
 
4
4
  export const useCheckoutButton = () => {
5
- const { isValidating } = useCart()
5
+ const { isValidating, id } = useCart()
6
6
 
7
7
  const onClick = (e: React.MouseEvent<HTMLButtonElement>) => {
8
8
  e.preventDefault()
9
+ const isDevEnv =
10
+ window.location.host.includes('.vtex.app') ||
11
+ window.location.host.includes('localhost')
9
12
 
10
13
  if (!isValidating) {
11
- window.location.href = `${storeConfig.checkoutUrl}`
14
+ if (!isDevEnv) {
15
+ window.location.href = `${storeConfig.checkoutUrl}`
16
+ } else if (id) {
17
+ window.location.href = `${storeConfig.checkoutUrl}?orderFormId=${id}`
18
+ }
12
19
  }
13
20
  }
14
21
 
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[247],{9767:function(e,t,a){"use strict";var r=a(2784),i=a(5450);let n=(0,r.forwardRef)(function({value:e,as:t="span",variant:a="selling",testId:n="fs-price",formatter:c=e=>e,SRText:s,...l},o){let u=c(e,a);return r.createElement(t,{ref:o,"data-fs-price":!0,"data-fs-price-variant":a,"data-testid":n,...l},s&&r.createElement(i.Z,{text:s}),u)});t.Z=n},9088:function(e,t,a){"use strict";var r=a(2784),i=a(9767);let n=(0,r.forwardRef)(function({testId:e="fs-product-price",value:t,listPrice:a,formatter:n,...c},s){let l=a??0,o=t??0;return r.createElement("div",{ref:s,"data-fs-product-price":!0,"data-testid":e,...c},o!==l&&0!==l?r.createElement(r.Fragment,null,r.createElement(i.Z,{value:l,formatter:n,testId:"list-price","data-value":l,variant:"listing",SRText:"Original price:"}),r.createElement(i.Z,{value:o,formatter:n,testId:"price","data-value":o,variant:"spot",SRText:"Price:"})):r.createElement(i.Z,{value:o,formatter:n,testId:"price","data-value":o,variant:"spot",SRText:"Price:"}))});t.Z=n},6693:function(e,t,a){"use strict";var r=a(2784),i=a(7041),n=a(2614),c=a(2256);t.Z=({max:e,min:t=1,initial:a,disabled:s=!1,onChange:l,testId:o="fs-quantity-selector",...u})=>{let[d,m]=(0,r.useState)(a??t),f=d===t,p=d===e,changeQuantity=e=>{let t=validateQuantityBounds(d+e);l?.(t),m(t)};function validateQuantityBounds(a){let r=t?Math.max(a,t):a;return e?Math.min(r,e):r}return(0,r.useEffect)(()=>{a&&m(a)},[a]),r.createElement("div",{"data-fs-quantity-selector":s?"disabled":"true","data-testid":o,...u},r.createElement(i.Z,{"data-quantity-selector-button":"left",icon:r.createElement(n.Z,{name:"Minus",width:16,height:16,weight:"bold"}),"aria-label":"Decrement Quantity","aria-controls":"quantity-selector-input",disabled:f||s,onClick:()=>changeQuantity(-1),testId:`${o}-left-button`,size:"small"}),r.createElement(c.Z,{"data-quantity-selector-input":!0,id:"quantity-selector-input","aria-label":"Quantity",value:d,onChange:function(e){let t=e.currentTarget.value;Number.isNaN(Number(t))||m(()=>{let e=validateQuantityBounds(Number(t));return l?.(e),e})},disabled:s}),r.createElement(i.Z,{"data-quantity-selector-button":"right","aria-controls":"quantity-selector-input","aria-label":"Increment Quantity",disabled:p||s,icon:r.createElement(n.Z,{name:"Plus",width:16,height:16,weight:"bold"}),onClick:()=>changeQuantity(1),testId:`${o}-right-button`,size:"small"}))}},6133:function(e,t,a){"use strict";var r=a(2784);t.Z=function({testId:e="fs-empty-state",title:t,titleIcon:a,variant:i="default",bkgColor:n="default",children:c,...s}){return r.createElement("section",{"data-fs-empty-state":!0,"data-fs-empty-state-variant":i,"data-fs-empty-state-bkg-color":n,"data-fs-content":"empty-state","data-testid":e,...s},t&&r.createElement("header",{"data-fs-empty-state-title":!0},a&&r.createElement(r.Fragment,null,a),r.createElement("p",null,t)),c)}},6247:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return cart_CartSidebar_CartSidebar}});var r=a(9499),i=a(1072),n=a(2784),c=a(3666),s=a(6652),l=a(7215),o=a(5049),u=a(276),d=a(8138),CartSidebar_CartSidebar=function({testId:e="fs-cart-sidebar",title:t="Your Cart",size:a="partial",direction:r="rightSide",totalItems:i,children:m,alertIcon:f,alertText:p,overlayProps:b,onClose:v,...y}){let{fade:h,fadeOut:O}=(0,c.b)(),{closeCart:g}=(0,s.l)();return n.createElement(l.Z,{"data-fs-cart-sidebar":!0,isOpen:!0,fade:h,onDismiss:O,size:a,direction:r,onTransitionEnd:()=>"out"===h&&g(),testId:e,overlayProps:b,...y},n.createElement(o.Z,{closeBtnProps:{testId:"fs-cart-sidebar-button-close"},onClose:()=>{v(),O()}},n.createElement("h2",{"data-fs-cart-sidebar-title":!0},t,n.createElement(u.Z,{variant:"info"},i))),p&&n.createElement(d.Z,{icon:f},p),m)},m=a(4564),CartSidebar_CartSidebarList=function({children:e}){return n.createElement(m.Z,{"data-fs-cart-sidebar-list":!0},e)},CartSidebar_CartSidebarFooter=function({children:e}){return n.createElement("footer",{"data-fs-cart-sidebar-footer":!0},e)},f=a(3339),p=a(2614),b=a(3218),v=a(7997),y=a.n(v),useCheckoutButton=()=>{var{isValidating:e}=(0,b.jD)();return{onClick:t=>{t.preventDefault(),e||(window.location.href="".concat(y().checkoutUrl))},disabled:e,"data-testid":"checkout-button"}},h=a(1868),O=a(4730);let g=(0,n.forwardRef)(function({icon:e,testId:t="fs-gift",children:a,...r},i){return n.createElement("div",{ref:i,"data-fs-gift":!0,"data-testid":t,...r},!!e&&n.createElement("span",{"data-fs-gift-icon":!0},e),n.createElement("div",{"data-fs-gift-wrapper":!0},a))}),_=(0,n.forwardRef)(function({testId:e="fs-gift-image",children:t,...a},r){return n.createElement("div",{ref:r,"data-fs-gift-image":!0,"data-testid":e,...a},t)});var E=a(9767);let j=(0,n.forwardRef)(function({price:e,productName:t,titleMessage:a="Get a",badgeLabel:r="Free",testId:i="fs-gift-content",...c},s){return n.createElement("section",{ref:s,"data-fs-gift-content":!0,"data-testid":i,...c},n.createElement("h3",{"data-fs-gift-product-title":!0},a," ",t),n.createElement("span",{"data-fs-gift-product-summary":!0},n.createElement(E.Z,{value:e?.listPrice?e.listPrice:0,formatter:e?.formatter,testId:"list-price","data-value":e?.listPrice,variant:"listing",SRText:"Original price:"}),n.createElement(u.Z,null,r)))});var C=a(8918),P=a(113),S=a(2322),w=["item"];function ownKeys(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(a),!0).forEach(function(t){(0,r.Z)(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var ui_Gift_Gift=function(e){var{item:t}=e,a=(0,O.Z)(e,w);return(0,S.jsxs)(g,_objectSpread(_objectSpread({icon:(0,S.jsx)(p.Z,{name:"Tag",width:18,height:18})},a),{},{children:[(0,S.jsx)(_,{children:(0,S.jsx)(C.Z,{src:t.itemOffered.image[0].url,alt:t.itemOffered.image[0].alternateName,width:89,height:89})}),(0,S.jsx)(j,{productName:t.itemOffered.isVariantOf.name,price:{value:t.price,listPrice:t.listPrice,formatter:P.P}})]}))},k=a(7041),x=a(6693),Z=a(9088);let I=(0,n.forwardRef)(function({testId:e="fs-cart-item",price:t,quantity:a,unavailable:r,onQuantityChange:i,children:c,removeBtnProps:s,...l},o){return n.createElement("article",{ref:o,"data-fs-cart-item":r?"unavailable":"true","data-testid":e,...l},n.createElement("div",{"data-fs-cart-item-content":!0},c),n.createElement(k.Z,{"data-fs-cart-item-remove-button":!0,icon:n.createElement(p.Z,{name:"XCircle"}),"aria-label":"Remove",...s}),n.createElement("div",{"data-fs-cart-item-actions":!0},n.createElement(x.Z,{min:1,initial:a,onChange:i}),n.createElement(Z.Z,{"data-fs-cart-item-prices":!0,listPrice:t?.listPrice?t.listPrice:0,value:t?.value?t.value:0,formatter:t?.formatter})))}),D=(0,n.forwardRef)(function({testId:e="fs-cart-item-image",children:t,...a},r){return n.createElement("div",{ref:r,"data-fs-cart-item-image":!0,"data-testid":e,...a},t)}),q=(0,n.forwardRef)(function({testId:e="fs-cart-item-summary",title:t,activeVariations:a=[],children:r,...i},c){return n.createElement("div",{ref:c,"data-fs-cart-item-summary":!0,"data-testid":e,...i},n.createElement("div",{"data-fs-cart-item-title":!0},t),a.length>0&&n.createElement("div",{"data-fs-cart-item-skus":!0},a.map(({label:e,option:t})=>n.createElement("p",{key:e},e,": ",n.createElement("span",null,t)))),r)});var useRemoveButton=e=>{var{currency:{code:t}}=(0,h.kP)();return{onClick:(0,n.useCallback)(a=>{a.preventDefault(),e&&((0,i._)({name:"remove_from_cart",params:{currency:t,value:e.price*e.quantity,items:[{item_id:e.itemOffered.isVariantOf.productGroupID,item_name:e.itemOffered.isVariantOf.name,item_brand:e.itemOffered.brand.name,item_variant:e.itemOffered.sku,quantity:e.quantity,price:e.price,discount:e.listPrice-e.price,currency:t,item_variant_name:e.itemOffered.name,product_reference_id:e.itemOffered.gtin}]}}),b.i8.removeItem(e.id))},[t,e]),"data-testid":"remove-from-cart-button","data-sku":null==e?void 0:e.itemOffered.sku}},cart_CartItem_CartItem=function(e){var{item:t}=e,a=useRemoveButton(t),{sendCartItemEvent:r}=function(){var{currency:{code:e}}=(0,h.kP)(),t=(0,n.useCallback)((t,a)=>{var r=a-t.quantity;return(0,i._)({name:r>0?"add_to_cart":"remove_from_cart",params:{currency:e,value:t.price*Math.abs(r),items:[{item_id:t.itemOffered.isVariantOf.productGroupID,item_name:t.itemOffered.isVariantOf.name,item_brand:t.itemOffered.brand.name,item_variant:t.itemOffered.sku,quantity:Math.abs(r),price:t.price,discount:t.listPrice-t.price,currency:e,item_variant_name:t.itemOffered.name,product_reference_id:t.itemOffered.gtin}]}})},[e]);return(0,n.useMemo)(()=>({sendCartItemEvent:t}),[t])}(),c=(0,n.useCallback)(e=>{r(t,e),b.i8.updateItemQuantity(t.id,e)},[t,r]),s=t.itemOffered.isVariantOf.skuVariants.activeVariations,l=Object.keys(s).map(e=>({label:e,option:s[e]}));return(0,S.jsxs)(I,{price:{value:t.price,listPrice:t.listPrice,formatter:P.P},quantity:t.quantity,onQuantityChange:c,removeBtnProps:a,"data-sku":t.itemOffered.sku,"data-seller":t.seller.identifier,children:[(0,S.jsx)(D,{children:(0,S.jsx)(C.Z,{src:t.itemOffered.image[0].url,alt:t.itemOffered.image[0].alternateName,width:56,height:56})}),(0,S.jsx)(q,{title:t.itemOffered.isVariantOf.name,activeVariations:l})]})},F=a(6133),EmptyCart_EmptyCart=function(e){var{onDismiss:t}=e;return(0,S.jsx)(F.Z,{title:"Your Cart is empty",titleIcon:(0,S.jsx)(p.Z,{name:"ShoppingCart",width:56,height:56,weight:"thin"}),children:(0,S.jsx)(f.Z,{onClick:t,variant:"secondary",children:"Start Shopping"})})};let R=(0,n.forwardRef)(function({testId:e="fs-order-summary",subtotalLabel:t,subtotalValue:a,discountLabel:r="Discount",discountValue:i,totalLabel:c="Total",totalValue:s,...l},o){return n.createElement(m.Z,{ref:o,"data-fs-order-summary":!0,"data-testid":e,...l},a?n.createElement("li",{"data-fs-order-summary-subtotal":!0},n.createElement("span",{"data-fs-order-summary-subtotal-label":!0,"data-testid":`${e}-subtotal-label`},t),n.createElement("span",{"data-fs-order-summary-subtotal-value":!0,"data-testid":`${e}-subtotal-value`},a)):null,i?n.createElement("li",{"data-fs-order-summary-discount":!0},n.createElement("span",{"data-fs-order-summary-discount-label":!0,"data-testid":`${e}-discount-label`},r),n.createElement("span",{"data-fs-order-summary-discount-value":!0,"data-testid":`${e}-discount-value`},i)):null,n.createElement("li",{"data-fs-order-summary-total":!0},n.createElement("span",{"data-fs-order-summary-total-label":!0,"data-testid":`${e}-total-label`},c),n.createElement("span",{"data-fs-order-summary-total-value":!0,"data-testid":`${e}-total-value`},s)))});var cart_OrderSummary_OrderSummary=function(e){var{subTotal:t,total:a,numberOfItems:r,checkoutButton:i}=e,n=t-a,c=(0,P.P)(n);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(R,{subtotalLabel:"Subtotal (".concat(r," products)"),subtotalValue:(0,P.P)(t),discountValue:n>0?"-".concat(c):void 0,totalValue:(0,P.P)(a)}),i]})},V=a(6222),N=a.n(V);function CartSidebar_ownKeys(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function CartSidebar_objectSpread(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?CartSidebar_ownKeys(Object(a),!0).forEach(function(t){(0,r.Z)(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):CartSidebar_ownKeys(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var cart_CartSidebar_CartSidebar=function(e){var{title:t,alert:{icon:{icon:a,alt:r},text:l},checkoutButton:{label:o,loadingLabel:u,icon:{icon:d,alt:m}}}=e,v=useCheckoutButton(),{items:y,gifts:O,totalItems:g,isValidating:_,subTotal:E,total:j}=(0,b.jD)(),{cart:C,closeCart:P}=(0,s.l)(),{fadeOut:w}=(0,c.b)(),{sendViewCartEvent:k}=function(){var{currency:{code:e}}=(0,h.kP)(),{items:t,gifts:a,total:r}=(0,b.jD)(),c=(0,n.useCallback)(()=>(0,i._)({name:"view_cart",params:{currency:e,value:r,items:t.concat(a).map(t=>({item_id:t.itemOffered.isVariantOf.productGroupID,item_name:t.itemOffered.isVariantOf.name,item_brand:t.itemOffered.brand.name,item_variant:t.itemOffered.sku,quantity:t.quantity,price:t.price,discount:t.listPrice-t.price,currency:e,item_variant_name:t.itemOffered.name,product_reference_id:t.itemOffered.gtin}))}}),[e,a,t,r]);return(0,n.useMemo)(()=>({sendViewCartEvent:c}),[c])}(),x=(0,n.useMemo)(()=>0===y.length,[y]);return(0,n.useEffect)(()=>{C&&k()},[C,k]),(0,S.jsx)(S.Fragment,{children:C&&(0,S.jsx)(n.Suspense,{fallback:null,children:(0,S.jsx)(CartSidebar_CartSidebar,{overlayProps:{className:"section ".concat(N().section," section-cart-sidebar")},title:t,totalItems:g,alertIcon:(0,S.jsx)(p.Z,{name:a,"aria-label":r}),alertText:l,onClose:w,children:x?(0,S.jsx)(EmptyCart_EmptyCart,{onDismiss:P}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(CartSidebar_CartSidebarList,{children:[y.map(e=>(0,S.jsx)("li",{children:(0,S.jsx)(cart_CartItem_CartItem,{item:e})},e.id)),O.length>0&&(0,S.jsx)(S.Fragment,{children:O.map(e=>(0,S.jsx)("li",{children:(0,S.jsx)(ui_Gift_Gift,{item:e})},e.id))})]}),(0,S.jsx)(CartSidebar_CartSidebarFooter,{children:(0,S.jsx)(cart_OrderSummary_OrderSummary,{subTotal:E,total:j,numberOfItems:g,checkoutButton:(0,S.jsx)(f.Z,CartSidebar_objectSpread(CartSidebar_objectSpread({variant:"primary",icon:!_&&(0,S.jsx)(p.Z,{name:d,"aria-label":m,width:18,height:18}),iconPosition:"right"},v),{},{children:_?u:o}))})})]})})})})}},113:function(e,t,a){"use strict";a.d(t,{P:function(){return useFormattedPrice}});var r=a(2784),i=a(1868),usePriceFormatter=function(){var{decimals:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{currency:t,locale:a}=(0,i.kP)();return(0,r.useCallback)(r=>Intl.NumberFormat(a,{style:"currency",currency:t.code,minimumFractionDigits:e?2:0}).format(r),[t.code,a,e])},useFormattedPrice=e=>{var t=usePriceFormatter();return(0,r.useMemo)(()=>t(e),[t,e])}},6222:function(e){e.exports={section:"section_section__yzDFp"}}}]);