Skip to content

Commit

Permalink
Merge pull request #3165 from vuestorefront/v2
Browse files Browse the repository at this point in the history
chore: automatic sync v2->v2-develop
  • Loading branch information
github-actions[bot] authored May 20, 2024
2 parents c6eafc2 + 2a77bee commit 452d79d
Show file tree
Hide file tree
Showing 20 changed files with 252 additions and 96 deletions.
39 changes: 39 additions & 0 deletions .yarn/patches/@nuxt-module-builder-npm-0.6.0-755acb37c3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
diff --git a/dist/chunks/build.mjs b/dist/chunks/build.mjs
index 103067eb77b600e58143d0f1ab9eeb570a882af5..b88a7d7d435df0c1348a1ec821fbdcb16340f9c6 100644
--- a/dist/chunks/build.mjs
+++ b/dist/chunks/build.mjs
@@ -1,6 +1,7 @@
import { promises, existsSync } from 'node:fs';
import { pathToFileURL } from 'node:url';
-import { resolve, dirname } from 'pathe';
+import { createRequire } from 'node:module';
+import { resolve, isAbsolute } from 'pathe';
import { readPackageJSON, readTSConfig } from 'pkg-types';
import { defu } from 'defu';
import { consola } from 'consola';
@@ -210,7 +211,24 @@ async function loadTSCompilerOptions(path) {
});
}
const files = Array.isArray(config.extends) ? config.extends : config.extends ? [config.extends] : [];
- return defu(config.compilerOptions, ...await Promise.all(files.map((file) => loadTSCompilerOptions(dirname(resolve(path, file))))));
+ return defu(config.compilerOptions, ...await Promise.all(files.map((file) => loadTSCompilerOptions(resolveExtends(file, path)))));
}

+function resolveExtends(extended, from) {
+ // see https://github.com/dominikg/tsconfck/issues/149
+ if (extended === '..') extended = '../tsconfig.json';
+ const req = createRequire(from);
+ let error;
+ try {
+ return req.resolve(extended);
+ } catch (e) {
+ error = e;
+ }
+ if (extended[0] !== '.' && !isAbsolute(extended)) {
+ return req.resolve(`${extended}/tsconfig.json`);
+ }
+
+ throw error;
+ }
+
export { build as default };
56 changes: 17 additions & 39 deletions apps/docs/components/content/2.getting-started/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ You can try out Storefront UI in your browser with our online playground.
<a href="http://play-vue.vuestorefront.io/" target="_blank" rel="noopener noreferrer" class="custom-block dark:text-white font-medium px-4 py-2 border-green border-2 rounded-lg hover:bg-green transition-colors hover:text-white">Stackblitz playground</a>
</div>


::tabs{:titles='["Vite", "Nuxt", "Astro"]' class="mt-8"}

#tab-1
Expand Down Expand Up @@ -90,7 +89,6 @@ export default {

Finally, you'll need to add CSS directives to add each Tailwind layer to `src/style.css`. Since Storefront UI fits into your Tailwind workflow, you'll need to add Tailwind's base, components, and utilities layers to your CSS.


```css
/* src/style.css */
@tailwind base;
Expand All @@ -102,89 +100,78 @@ Finally, you'll need to add CSS directives to add each Tailwind layer to `src/st

Now, you can import Storefront UI components in your app and all the Tailwind utilities from the `@storefront-ui/vue` library will be available in your project.



<<<../../../../preview/nuxt/pages/showcases/Button/ButtonBlock.vue



<Showcase showcase-name="Button/ButtonBlock" :show-source="false"/>

#tab-2

## Nuxt 3

If you prefer video guides, we have a quick video that can help you set up Storefront UI in your Nuxt 3 project.

<iframe src="https://www.youtube-nocookie.com/embed/YamdPmZexto" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="allowfullscreen" class="w-full max-w-lg mx-auto rounded aspect-video relative mt-8 custom-block"></iframe>

### Install all dependencies

With Nuxt 3, the fastest way to get started is to use the `@nuxtjs/tailwindcss` module. The [Nuxt Tailwind module](https://tailwindcss.nuxtjs.org/) will automatically install Tailwind CSS and PostCSS for you.

Additionally, you'll need to install the Storefront UI's Vue library and Tailwind preset.
With Nuxt 3, the fastest way to get started is to use the `@storefront-ui/nuxt` module. The [Storefront-io Nuxt module](https://www.npmjs.com/package/@storefront-ui/nuxt) will automatically install `@nuxtjs/tailwindcss` inside `nuxt` and storefront-ui tailwindcss presets.

```bash
# npm
npm i -D @nuxtjs/tailwindcss @storefront-ui/vue
npm i -D @storefront-ui/nuxt

# yarn
yarn add -D @nuxtjs/tailwindcss @storefront-ui/vue
yarn add -D @storefront-ui/nuxt

# pnpm
pnpm add -D @nuxtjs/tailwindcss @storefront-ui/vue
pnpm add -D @storefront-ui/nuxt
```

### Add the Nuxt Tailwind module to your `nuxt.config.ts`

```ts
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@nuxtjs/tailwindcss']
modules: ['@storefront-ui/nuxt']
})
```

### Modify your `tailwind.config.ts`
### Tailwind configuration

Storefront UI plugs into your Tailwind configuration to add any base styles and CSS variables. To do this, you need to import the Storefront UI Tailwind preset and add it to your `tailwind.config.ts` file.
Since we use `@nuxtjs/tailwindcss` under the hood, there is possibility to use `tailwindcss` property in `nuxt.config.ts` file. Other than that there is default `tailwind` way to create config via `tailwind.config.ts` file.

::tip Add a path to your installed package
Internally, `@nuxtjs/tailwindcss` will merge the three places that you can add configurations. In order of priority, the options are:

1. `tailwind.config.ts` file
2. `nuxt.config.ts` file with `tailwindcss` property
3. Storefront UI [default configuration](https://github.com/vuestorefront/storefront-ui/blob/v2-develop/packages/config/tailwind/index.ts)

::tip Add a path to your installed package
In order for Tailwind to properly detect the utility classes used in Storefront UI components, you need to add a path to wherever your `node_modules` folder is located to the `content` property. In the example below, we're using the default location for `node_modules`, but this may change if you're working in a monorepo.
::

```ts
// tailwind.config.ts
import type { Config } from 'tailwindcss';
import { tailwindConfig } from '@storefront-ui/vue/tailwind-config';

export default <Config>{
presets: [tailwindConfig],
content: ['./**/*.vue', './node_modules/@storefront-ui/vue/**/*.{js,mjs}'],
};
```
### Add Tailwind to Your CSS

Finally, you'll need to add CSS directives to add each Tailwind layer to `src/style.css`. Since Storefront UI fits into your Tailwind workflow, you'll need to add Tailwind's base, components, and utilities layers to your CSS.
### Custom `tailwind.css` file

If you're going to create your own Tailwind CSS file, make sure to add the @tailwind directives for each of Tailwind’s layer types (base, components, and utilities).

```css
/* src/style.css */
/* ~/assets/css/tailwind.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
```

### You're ready to go

Now, you can import Storefront UI components in your app and all the Tailwind utilities from the `@storefront-ui/vue` library will be available in your project.


Now, you can import Storefront UI components in your app and all the Tailwind utilities from the `@storefront-ui/vue` library will be available in your project. Because `storefront-ui` is served as well from module, `@storefront-ui/vue` is available from [Nuxt autoimport](https://nuxt.com/docs/guide/concepts/auto-imports).

<<<../../../../preview/nuxt/pages/showcases/Button/ButtonBlock.vue



<Showcase showcase-name="Button/ButtonBlock" :show-source="false"/>

#tab-3
Expand Down Expand Up @@ -253,7 +240,6 @@ module.exports = {

Finally, you'll need to add CSS directives to add each Tailwind layer to `src/style.css`. Since Storefront UI fits into your Tailwind workflow, you'll need to add Tailwind's base, components, and utilities layers to your CSS.


```css
/* src/style.css */
@tailwind base;
Expand All @@ -265,14 +251,8 @@ Finally, you'll need to add CSS directives to add each Tailwind layer to `src/st

You can now import Storefront UI components inside your Astro project! You can either use them directly in your Astro components or import them into your Vue components.



<<<../../../../preview/nuxt/pages/showcases/Button/ButtonBlock.vue





```md
---
import { SfButton } from '@storefront-ui/vue';
Expand All @@ -281,8 +261,6 @@ import { SfButton } from '@storefront-ui/vue';
<SfButton> Hello </SfButton>
```



::tip Need interaction?
If you need interaction, you can create your own Vue components that use Storefront UI components under the hood. You can then import these components into your Astro components and use them as you would any other Vue component. Read more about Vue components in Astro in Astro's [Framework Components guide](https://docs.astro.build/en/core-concepts/framework-components/).
::
Expand Down
2 changes: 1 addition & 1 deletion apps/preview/nuxt/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default defineNuxtConfig({
},
],
},
modules: ['@nuxtjs/tailwindcss'],
modules: ['@storefront-ui/nuxt'],
css: ['@storefront-ui/example-style/index.scss', '@storefront-ui/example-style/controls.scss'],
imports: {
transform: {
Expand Down
1 change: 1 addition & 0 deletions apps/preview/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@nuxtjs/tailwindcss": "^6.12.0",
"@storefront-ui/eslint-config": "workspace:*",
"@storefront-ui/example-style": "workspace:*",
"@storefront-ui/nuxt": "workspace:*",
"@storefront-ui/shared": "workspace:*",
"@storefront-ui/tw-plugin-peer-next": "workspace:*",
"@storefront-ui/typography": "workspace:*",
Expand Down
3 changes: 1 addition & 2 deletions apps/preview/nuxt/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Config } from 'tailwindcss';
import sfTypography from '@storefront-ui/typography';
import { tailwindConfig } from '@storefront-ui/vue/tailwind-config';
import tailwindTypography from '@tailwindcss/typography';

export default <Config>{
presets: [tailwindConfig],
Expand All @@ -13,5 +12,5 @@ export default <Config>{
},
},
},
plugins: [sfTypography, tailwindTypography],
plugins: [sfTypography],
};
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
"dev": "yarn update-browserlist-db && yarn build:typography && yarn build:peer-next && yarn build:tailwind-config && yarn build:test-utils && yarn build:react && turbo run dev --parallel",
"dev:shared": "turbo run dev:shared",
"update-browserlist-db": "yarn dlx browserslist@latest",
"lint": "yarn build:typography && yarn build:peer-next && yarn build:tailwind-config && turbo run lint",
"lint": "yarn build:typography && yarn build:peer-next && yarn build:tailwind-config && yarn build:vue && turbo run lint",
"lint:fix": "turbo run lint:fix",
"lint:fix:sfui": "turbo run lint:fix:sfui",
"build:docs": "yarn build:peer-next && turbo run build:docs",
"build:next": "turbo run build:next",
"build:nuxt": "turbo run build:nuxt",
"build:nuxt": "turbo run build:nuxt-module && turbo run build:nuxt",
"build:replace-assets-url-with": "frs-replace \"http:\\/\\/localhost:3100\\/@assets\\/\" \"https://storage.googleapis.com/sfui_docs_artifacts_bucket_public/$ENV_NAME/\" -i \"apps/preview/*/pages/**/*\" -s \"preserve-structure\" -o .",
"build:nuxt-module": "turbo run build:nuxt-module",
"build:react": "turbo run build:react",
"build:vue": "turbo run build:vue",
"build:release": "turbo run build:release",
"build:release": "turbo run build:release && turbo run build:nuxt-module",
"build:tailwind-config": "turbo run build:tailwind-config",
"build:typography": "turbo run build:typography",
"build:peer-next": "turbo run build:peer-next",
Expand Down Expand Up @@ -88,6 +88,7 @@
}
},
"resolutions": {
"@changesets/assemble-release-plan@^6.0.0": "patch:@changesets/assemble-release-plan@npm%3A6.0.0#./.yarn/patches/@changesets-assemble-release-plan-npm-6.0.0-f7b3005037.patch"
"@changesets/assemble-release-plan@^6.0.0": "patch:@changesets/assemble-release-plan@npm%3A6.0.0#./.yarn/patches/@changesets-assemble-release-plan-npm-6.0.0-f7b3005037.patch",
"@nuxt/module-builder@^0.6.0": "patch:@nuxt/module-builder@npm%3A0.6.0#./.yarn/patches/@nuxt-module-builder-npm-0.6.0-755acb37c3.patch"
}
}
6 changes: 6 additions & 0 deletions packages/sfui/frameworks/nuxt/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
.output
playground
playground/**
dist
.eslintrc.cjs
8 changes: 8 additions & 0 deletions packages/sfui/frameworks/nuxt/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
extends: ['plugin:nuxt/recommended', '@storefront-ui/eslint-config/vue.js'],
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
};
12 changes: 12 additions & 0 deletions packages/sfui/frameworks/nuxt/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @storefront-ui/nuxt

## 2.5.0

### Minor Changes

- [#3155](https://github.com/vuestorefront/storefront-ui/pull/3155) [`a754c14`](https://github.com/vuestorefront/storefront-ui/commit/a754c147597bdc9a5af9fb635d59add8873f7178) Thanks [@Szymon-dziewonski](https://github.com/Szymon-dziewonski)! - [FIXED] `nuxt` module package is working, installation documentation of storefront-ui on nuxt is set to use module by default, add `eslint` lint, add `README.md` file. Previously nuxt module on npm contained only `CHANGELOG.md` and `package.json` files.

## 2.5.0-rc.0

### Minor Changes

- [#3155](https://github.com/vuestorefront/storefront-ui/pull/3155) [`a754c14`](https://github.com/vuestorefront/storefront-ui/commit/a754c147597bdc9a5af9fb635d59add8873f7178) Thanks [@Szymon-dziewonski](https://github.com/Szymon-dziewonski)! - [FIXED] `nuxt` module package is working, installation documentation of storefront-ui on nuxt is set to use module by default, add `eslint` lint, add `README.md` file. Previously nuxt module on npm contained only `CHANGELOG.md` and `package.json` files.

## 2.4.6

### Patch Changes
Expand Down
64 changes: 64 additions & 0 deletions packages/sfui/frameworks/nuxt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

### Install all dependencies

With Nuxt 3, the fastest way to get started is to use the `@storefront-ui/nuxt` module. The [Storefront-io Nuxt module](https://www.npmjs.com/package/@storefront-ui/nuxt) will automatically install `@nuxtjs/tailwindcss` and storefront-ui tailwindcss presets.

Additionally, you'll need to install the Storefront UI's Vue library and NuxtJs Tailwindcss Module.

```bash
# npm
npm i -D @storefront-ui/nuxt @storefront-ui/vue @nuxtjs/tailwindcss

# yarn
yarn add -D @storefront-ui/nuxt @storefront-ui/vue @nuxtjs/tailwindcss

# pnpm
pnpm add -D @storefront-ui/nuxt @storefront-ui/vue @nuxtjs/tailwindcss
```

### Add the Nuxt Tailwind module to your `nuxt.config.ts`

```ts
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@storefront-ui/nuxt']
})
```

### Tailwind configuration

Since we use `@nuxtjs/tailwindcss` under the hood, there is possibility to use `tailwindcss` property in `nuxt.config.ts` file. Other than that there is default `tailwind` way to create config via `tailwind.config.ts` file.

Priority of reading configuration, in most important from top to bottom:

1. `tailwind.config.ts` file
2. `nuxt.config.ts` file with `tailwindcss` property
3. default configuration inside module

::tip Add a path to your installed package
In order for Tailwind to properly detect the utility classes used in Storefront UI components, you need to add a path to wherever your `node_modules` folder is located to the `content` property. In the example below, we're using the default location for `node_modules`, but this may change if you're working in a monorepo.
::

```ts
// tailwind.config.ts
import type { Config } from 'tailwindcss';

export default <Config>{
content: ['./**/*.vue', './node_modules/@storefront-ui/vue/**/*.{js,mjs}'],
};
```

### Custom `tailwind.css` file

If you're going to create your own Tailwind CSS file, make sure to add the @tailwind directives for each of Tailwind’s layer types (base, components, and utilities).

```css
/* ~/assets/css/tailwind.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
```

### You're ready to go

Now, you can import Storefront UI components in your app and all the Tailwind utilities from the `@storefront-ui/vue` library will be available in your project. Because `storefront-ui` is served as well from module, `@storefront-ui/vue` is available from [nuxt autoimport](https://nuxt.com/docs/guide/concepts/auto-imports).
19 changes: 12 additions & 7 deletions packages/sfui/frameworks/nuxt/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storefront-ui/nuxt",
"version": "2.4.6",
"version": "2.5.0",
"homepage": "https://docs.storefrontui.io/v2/",
"installConfig": {
"hoistingLimits": "workspaces"
Expand Down Expand Up @@ -31,19 +31,24 @@
"dist"
],
"scripts": {
"build:nuxt-module": "nuxi prepare playground && nuxt-module-build",
"build:nuxt-module": "nuxt-module-build build",
"dev:playground": "nuxi dev playground",
"dev:build": "nuxi build playground",
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground"
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
"lint": "eslint --ext .vue,js,.ts .",
"lint:fix": "eslint --fix --ext .vue,.js,.ts ."
},
"dependencies": {
"@nuxt/kit": "^3.3.2",
"@nuxt/kit": "^3.11.2",
"@nuxtjs/tailwindcss": "^6.12.0",
"@storefront-ui/vue": "workspace:*"
"@storefront-ui/vue": "workspace:*",
"defu": "^6.1.4"
},
"devDependencies": {
"@nuxt/module-builder": "^0.6.0",
"@nuxt/schema": "^3.3.2",
"nuxt": "^3.3.2"
"@nuxt/schema": "^3.11.2",
"@storefront-ui/eslint-config": "workspace:*",
"eslint": "^8.34.0",
"nuxt": "^3.11.2"
}
}
Loading

0 comments on commit 452d79d

Please sign in to comment.