Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move nuxt image test to showcase example #615

Merged
merged 18 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"eslint.experimental.useFlatConfig": true
"eslint.experimental.useFlatConfig": true,
"cSpell.words": ["nuxt", "ofetch"]
}
4 changes: 4 additions & 0 deletions examples/showcase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ This example shows how to use various Nuxt features and modules in combination w

- Add Nuxt pages to Storybook

## Modules

- [Nuxt Image](https://image.nuxt.com)

---

Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { Meta, StoryObj } from '@storybook/vue3'

import MyComponent from '~/components/MyNuxtImage.vue'
import NuxtImageComponent from './NuxtImage.vue'

// More on how to set up stories at: https://storybook.js.org/docs/vue/writing-stories/introduction

const meta = {
title: 'Plugins/NuxtImage',
component: MyComponent,
title: 'Modules/Nuxt Image',
component: NuxtImageComponent,
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/vue/writing-docs/autodocs
tags: ['autodocs'],
} satisfies Meta<typeof MyComponent>
} satisfies Meta<typeof NuxtImageComponent>

export default meta
type Story = StoryObj<typeof meta>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
height="200"
class="rounded"
/>
<br />

Check warning on line 10 in examples/showcase/components/NuxtImage.vue

View workflow job for this annotation

GitHub Actions / ci (20, macos-latest)

Disallow self-closing on HTML void elements (<br/>)

Check warning on line 10 in examples/showcase/components/NuxtImage.vue

View workflow job for this annotation

GitHub Actions / ci (18, macos-latest)

Disallow self-closing on HTML void elements (<br/>)

Check warning on line 10 in examples/showcase/components/NuxtImage.vue

View workflow job for this annotation

GitHub Actions / ci (18, ubuntu-latest)

Disallow self-closing on HTML void elements (<br/>)

Check warning on line 10 in examples/showcase/components/NuxtImage.vue

View workflow job for this annotation

GitHub Actions / ci (20, ubuntu-latest)

Disallow self-closing on HTML void elements (<br/>)

Check warning on line 10 in examples/showcase/components/NuxtImage.vue

View workflow job for this annotation

GitHub Actions / ci (20, windows-latest)

Disallow self-closing on HTML void elements (<br/>)

Check warning on line 10 in examples/showcase/components/NuxtImage.vue

View workflow job for this annotation

GitHub Actions / ci (18, windows-latest)

Disallow self-closing on HTML void elements (<br/>)
<h4>responsive image with nuxt-image component:</h4>
<h4>Responsive image with nuxt-image component:</h4>
<NuxtPicture
src="/images/sb-nuxt-logo.jpg"
width="1204"
Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
modules: ['@nuxtjs/storybook'],
modules: ['@nuxtjs/storybook', '@nuxt/image'],
runtimeConfig: {
// For testing runtimeConfig in useMyComposable
app: {
Expand Down
1 change: 1 addition & 0 deletions examples/showcase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"build-storybook": "storybook build"
},
"dependencies": {
"@nuxt/image": "^1.7.0",
"nuxt": "^3.11.2",
"vue": "^3.4.21",
"vue-router": "^4.3.0"
Expand Down
Binary file added examples/showcase/public/images/sb-nuxt-logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions packages/storybook-addon/src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { setup } from '@storybook/vue3'
import type { ObjectPlugin, Plugin } from 'nuxt/app'
import { applyPlugins, createNuxtApp } from 'nuxt/app'
import { getContext } from 'unctx'
import { $fetch } from 'ofetch'
// @ts-expect-error virtual file
import { runtimeConfig } from 'virtual:nuxt-runtime-config'

Expand Down Expand Up @@ -51,6 +52,13 @@ setup(async (vueApp, storyContext) => {
data: {},
state: {},
}
// Set $fetch
// based on https://github.com/nuxt/nuxt/blob/356173134280b66c5902e5129d2f5ee73b799352/packages/nuxt/src/core/templates.ts#L390-L403
if (!globalThis.$fetch) {
globalThis.$fetch = $fetch.create({
baseURL: '/',
})
}

const nuxt = createNuxtApp({
vueApp,
Expand Down
47 changes: 46 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading