Skip to content

Commit e45fd09

Browse files
committedApr 14, 2024
feat!: update documentation and the way to use the composable
2 parents 1ac55cc + 3685841 commit e45fd09

29 files changed

+11777
-3383
lines changed
 

‎.eslintignore

-2
This file was deleted.

‎.eslintrc

-4
This file was deleted.

‎.gitignore

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ node_modules
99
.tmp
1010
.cache
1111

12-
# Yarn
13-
**/.yarn/cache
14-
**/.yarn/*state*
15-
1612
# Generated dirs
1713
dist
1814

‎.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"eslint.experimental.useFlatConfig": true
3+
}

‎README.md

+22-23
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,7 @@
2020
1. Add `@nuxtjs/snipcart` dependency to your project
2121

2222
```bash
23-
# Using pnpm
24-
pnpm add -D @nuxtjs/snipcart
25-
26-
# Using yarn
27-
yarn add --dev @nuxtjs/snipcart
28-
29-
# Using npm
30-
npm install --save-dev @nuxtjs/snipcart
23+
npx nuxi@latest module add snipcart
3124
```
3225

3326
2. Add `@nuxtjs/snipcart` to the `modules` section of `nuxt.config.ts`
@@ -52,25 +45,34 @@ At any time please have a look at our beautiful playground example.
5245

5346
We tried to not create too much wrapper around the Snipcart api so we don't have to maintain so much if Snipcart change. But you may found some of them useful as:
5447
- exposing snipcart instance
55-
- use of isReady boolean to watch and make sure you can use snipcart instance safely
56-
- realtime store subscription (working but performance hit)
57-
- some function in case you are not using the JS SDK form `window.Snipcart` that will help you add html attributes that Snipcart will read on load. As bindProductItem or bindProductItemCustom
58-
- ability to change language or currency using respectively `setLanguage` or `setCurrency`
48+
- isReady will define the basic settings are ready to be used but snipcart not loaded yet
49+
- use watch on snipcart to make sure its ready
50+
- realtime store subscription
51+
- utils functions As bindProductItem or bindProductItemCustom
52+
- wrapper utils function to change language or currency using respectively `setLanguage` or `setCurrency`
5953

6054
As we have a full typescript support play with it and read the description of what is exposed.
6155

6256
## Loading
6357

6458
We are following Snipcart [different loadings](https://docs.snipcart.com/v3/setup/installation). You can control the load of the js using `loadStrategy` configuration property. You can tell snipcart to not load css using `loadCSS` config property.
6559

66-
If you load async take in consideration on server or client you will not have access to `window.Snipcart` or `snipcart` exposed by `useSnipcart` until its loaded. So adapt your logic
60+
If you load async take in consideration you will not have access to `window.Snipcart` or `snipcart` exposed by `useSnipcart` until its loaded. So adapt your logic. Check on playground we have added few comments
6761

6862
## [Customization](https://docs.snipcart.com/v3/setup/customization)
6963

7064
With nuxt it is super easy to customize snipart components. Use your own class css in addition of custom html to override [snipcart component](https://docs.snipcart.com/v3/themes/default/reference).
7165

7266
To do that create for example `public/snipcart-custom.html` as inside the playground. And make sure you add the path in the nuxt config using `templatesUrl` property
7367

68+
```
69+
snipcart: {
70+
templatesUrl: '/snipcart-custom.html',
71+
```
72+
73+
this will after be passed to snipcart to understand what file to retrieve to have access to all templates it will use to build snipcart components
74+
75+
7476
## [Snipcart SDK](https://docs.snipcart.com/v3/sdk/basics)
7577

7678
As we told before we expose the snipcart SDK as by default with window.Snipcart or form the composable `useSnipcart`. So you will have the exact same full access to snipcart SDK
@@ -79,26 +81,23 @@ As we told before we expose the snipcart SDK as by default with window.Snipcart
7981

8082
```bash
8183
# Install dependencies
82-
npm install
83-
84-
# Generate type stubs
85-
npm run dev:prepare
84+
pnpm install
8685

8786
# Develop with the playground
88-
npm run dev
87+
pnpm dev
8988

9089
# Build the playground
91-
npm run dev:build
90+
pnpm dev:build
9291

9392
# Run ESLint
94-
npm run lint
93+
pnpm lint
9594

9695
# Run Vitest
97-
npm run test
98-
npm run test:watch
96+
pnpm test
97+
pnpm test:watch
9998

10099
# Release new version
101-
npm run release
100+
pnpm release
102101
```
103102
<!-- Badges -->
104103
[npm-version-src]: https://img.shields.io/npm/v/@nuxtjs/snipcart/next.svg?style=flat&colorA=18181B&colorB=28CF8D

‎eslint.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// @ts-check
2+
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
3+
4+
export default createConfigForNuxt({
5+
features: {
6+
tooling: true,
7+
stylistic: true,
8+
},
9+
dirs: {
10+
src: [
11+
'./playground',
12+
],
13+
},
14+
})

0 commit comments

Comments
 (0)
Please sign in to comment.