Skip to content

Commit

Permalink
chore(#693): reimplement storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher committed Aug 30, 2024
1 parent d8b8ca6 commit 7fa1ef9
Show file tree
Hide file tree
Showing 14 changed files with 2,226 additions and 2,298 deletions.
2 changes: 1 addition & 1 deletion examples/druxt-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"devDependencies": {
"@nuxt/postcss8": "latest",
"@nuxtjs/storybook": "latest",
"@nuxtjs/storybook": "4",
"postcss": "latest"
},
"resolutions": {
Expand Down
4,384 changes: 2,155 additions & 2,229 deletions examples/druxt-site/yarn.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/blocks/src/nuxt/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineNuxtModule, installModule } from '@nuxt/kit'
import { join } from 'path'
// import DruxtBlocksStorybook from './storybook'
import DruxtBlocksStorybook from './storybook'

/**
* The Nuxt.js module function.
Expand Down Expand Up @@ -63,9 +63,9 @@ const DruxtBlocksNuxtModule = defineNuxtModule({

// Nuxt Storybook.
// @TODO - @nuxt/kit and @nuxt/storybook aren't compatible.
// nuxt.hook('storybook:config', async ({ stories }) => {
// await DruxtBlocksStorybook.call(nuxt, { stories })
// })
nuxt.hook('storybook:config', async ({ stories }) => {
await DruxtBlocksStorybook.call(nuxt, { stories })
})
}
})

Expand Down
18 changes: 9 additions & 9 deletions packages/breadcrumb/src/nuxt/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineNuxtModule, installModule } from '@nuxt/kit'
import { join } from 'path'
import { addTemplate, defineNuxtModule, installModule } from '@nuxt/kit'
import { join, resolve } from 'path'

/**
* The Nuxt.js module function.
Expand Down Expand Up @@ -54,13 +54,13 @@ const DruxtBreadcrumbModule = defineNuxtModule({

// Nuxt Storybook.
// @TODO - @nuxt/kit and @nuxt/storybook aren't compatible.
// nuxt.hook('storybook:config', ({ stories }) => {
// addTemplate({
// src: resolve(__dirname, '../templates/druxt-breadcrumb.stories.js'),
// fileName: 'stories/druxt-breadcrumb.stories.js',
// })
// stories.push(resolve(nuxt.options.buildDir, './stories/druxt-breadcrumb.stories.js'))
// })
nuxt.hook('storybook:config', ({ stories }) => {
addTemplate({
src: resolve(__dirname, '../templates/druxt-breadcrumb.stories.js'),
fileName: 'stories/druxt-breadcrumb.stories.js',
})
stories.push(resolve(nuxt.options.buildDir, './stories/druxt-breadcrumb.stories.js'))
})
}
})

Expand Down
46 changes: 23 additions & 23 deletions packages/druxt/src/nuxt/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addPluginTemplate, defineNuxtModule, installModule } from '@nuxt/kit'
import { addPluginTemplate, addTemplate, defineNuxtModule, installModule } from '@nuxt/kit'
import chalk from 'chalk'
import { DrupalJsonApiParams } from 'drupal-jsonapi-params'
import { join, normalize, resolve } from 'path'
Expand Down Expand Up @@ -204,28 +204,28 @@ const DruxtNuxtModule = defineNuxtModule({

// Nuxt Storybook.
// @TODO - @nuxt/kit and @nuxt/storybook aren't compatible.
// nuxt.hook('storybook:config', async ({ stories }) => {
// // Druxt README story.
// addTemplate({
// src: resolve(__dirname, '../templates/stories/README.stories.mdx'),
// fileName: 'stories/druxt-README.stories.mdx',
// })
// stories.push(resolve(nuxt.options.buildDir, './stories/druxt-README.stories.mdx'))

// // Druxt custom module story.
// addTemplate({
// src: resolve(__dirname, '../templates/stories/druxt-module.stories.mdx'),
// fileName: 'stories/druxt-module.stories.mdx',
// })
// stories.push(resolve(nuxt.options.buildDir, './stories/druxt-module.stories.mdx'))

// // DruxtDebug component story.
// addTemplate({
// src: resolve(__dirname, '../templates/stories/druxt-debug.stories.js'),
// fileName: 'stories/druxt-debug.stories.js',
// })
// stories.push(resolve(nuxt.options.buildDir, './stories/druxt-debug.stories.js'))
// })
nuxt.hook('storybook:config', async ({ stories }) => {
// Druxt README story.
addTemplate({
src: resolve(__dirname, '../templates/stories/README.stories.mdx'),
fileName: 'stories/druxt-README.stories.mdx',
})
stories.push(resolve(nuxt.options.buildDir, './stories/druxt-README.stories.mdx'))

// Druxt custom module story.
addTemplate({
src: resolve(__dirname, '../templates/stories/druxt-module.stories.mdx'),
fileName: 'stories/druxt-module.stories.mdx',
})
stories.push(resolve(nuxt.options.buildDir, './stories/druxt-module.stories.mdx'))

// DruxtDebug component story.
addTemplate({
src: resolve(__dirname, '../templates/stories/druxt-debug.stories.js'),
fileName: 'stories/druxt-debug.stories.js',
})
stories.push(resolve(nuxt.options.buildDir, './stories/druxt-debug.stories.js'))
})
}
})

Expand Down
8 changes: 4 additions & 4 deletions packages/entity/src/nuxt/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineNuxtModule, installModule } from '@nuxt/kit'
import { join } from 'path'
// import DruxtEntityStorybook from '../nuxtStorybook'
import DruxtEntityStorybook from './storybook'

/**
* The Nuxt.js module function.
Expand Down Expand Up @@ -72,9 +72,9 @@ const DruxtEntityNuxtModule = defineNuxtModule({

// Nuxt Storybook.
// @TODO - @nuxt/kit and @nuxt/storybook aren't compatible.
// this.nuxt.hook('storybook:config', async ({ stories }) => {
// await DruxtEntityStorybook.call(this, { stories })
// })
nuxt.hook('storybook:config', async ({ stories }) => {
await DruxtEntityStorybook.call(nuxt, { stories })
})
}
})

Expand Down
3 changes: 2 additions & 1 deletion packages/entity/src/nuxt/storybook.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { addTemplate } from '@nuxt/kit'
import { resolve } from 'path'
import { DrupalJsonApiParams } from 'drupal-jsonapi-params'
import { DruxtClient } from 'druxt'
Expand All @@ -9,7 +10,7 @@ const titleFn = (parts) =>
).join('/')

export default async function ({ stories }) {
const { addTemplate, options } = this
const { options } = this

// Setup DruxtClient instance.
const druxt = new DruxtClient(options.druxt.baseUrl, { ...options.druxt, proxy: { api: false } })
Expand Down
8 changes: 4 additions & 4 deletions packages/menu/src/nuxt/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { addPluginTemplate, defineNuxtModule, installModule } from '@nuxt/kit'
import { join, resolve } from 'path'
// import DruxtMenuStorybook from './storybook'
import DruxtMenuStorybook from './storybook'

/**
* The Nuxt.js module function.
Expand Down Expand Up @@ -72,9 +72,9 @@ const DruxtMenuNuxtModule = defineNuxtModule({

// Nuxt Storybook.
// @TODO - @nuxt/kit and @nuxt/storybook aren't compatible.
// this.nuxt.hook('storybook:config', async ({ stories }) => {
// await DruxtMenuStorybook.call(this, { stories })
// })
nuxt.hook('storybook:config', async ({ stories }) => {
await DruxtMenuStorybook.call(nuxt, { stories })
})
}
})

Expand Down
3 changes: 2 additions & 1 deletion packages/menu/src/nuxt/storybook.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { addTemplate } from '@nuxt/kit'
import { resolve } from 'path'
import { DrupalJsonApiParams } from 'drupal-jsonapi-params'
import { DruxtClient } from 'druxt'
Expand All @@ -12,7 +13,7 @@ parts
.join('/')

export default async function ({ stories }) {
const { addTemplate, options } = this
const { options } = this

// Setup DruxtClient instance.
const druxt = new DruxtClient(options.druxt.baseUrl, { ...options.druxt, proxy: { api: false } })
Expand Down
16 changes: 8 additions & 8 deletions packages/router/src/nuxt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ const DruxtRouterNuxtModule = defineNuxtModule({

// Nuxt Storybook.
// @TODO - @nuxt/kit and @nuxt/storybook aren't compatible.
// nuxt.hook('storybook:config', async ({ stories }) => {
// addTemplate({
// src: resolve(__dirname, '../templates/druxt-router.stories.js'),
// fileName: 'stories/druxt-router.stories.js',
// options: {}
// })
// stories.push(resolve(options.buildDir, './stories/druxt-router.stories.js'))
// })
nuxt.hook('storybook:config', async ({ stories }) => {
addTemplate({
src: resolve(__dirname, '../templates/druxt-router.stories.js'),
fileName: 'stories/druxt-router.stories.js',
options: {}
})
stories.push(resolve(nuxt.options.buildDir, './stories/druxt-router.stories.js'))
})
}
})

Expand Down
8 changes: 4 additions & 4 deletions packages/site/src/nuxt/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { addLayout, defineNuxtModule, installModule } from '@nuxt/kit'
import { existsSync } from 'fs'
import { resolve } from 'path'
// import DruxtSiteStorybook from '../nuxtStorybook'
import DruxtSiteStorybook from './storybook'

/**
* Nuxt module function to install Druxt Site.
Expand Down Expand Up @@ -74,9 +74,9 @@ const DruxtSiteNuxtModule = defineNuxtModule({

// Nuxt Storybook.
// @TODO - @nuxt/kit and @nuxt/storybook aren't compatible.
// this.nuxt.hook('storybook:config', async ({ stories }) => {
// await DruxtSiteStorybook.call(this, { options, stories })
// })
nuxt.hook('storybook:config', async ({ stories }) => {
await DruxtSiteStorybook.call(nuxt, { options, stories })
})
}
})

Expand Down
3 changes: 1 addition & 2 deletions packages/site/src/nuxt/storybook.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { addTemplate } from '@nuxt/kit'
import { resolve } from 'path'
import { DrupalJsonApiParams } from 'drupal-jsonapi-params'
import { DruxtClient } from 'druxt'
Expand All @@ -8,8 +9,6 @@ const titleFn = (parts) =>
).join('/')

export default async function ({ options, stories }) {
const { addTemplate } = this

// Setup DruxtClient instance.
const druxt = new DruxtClient(options.baseUrl, { ...options, proxy: { api: false } })

Expand Down
14 changes: 7 additions & 7 deletions packages/views/src/nuxt/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { addPluginTemplate, defineNuxtModule, installModule } from '@nuxt/kit'
import { join, resolve } from 'path'
// import DruxtViewsStorybook from './storybook'
import DruxtViewsStorybook from './storybook'

/**
* The Nuxt.js module function.
Expand Down Expand Up @@ -67,13 +67,13 @@ const DruxtViewsNuxtModule = defineNuxtModule({

// Enable Vuex Store.
nuxt.options.store = true
}

// Nuxt Storybook.
// @TODO - @nuxt/kit and @nuxt/storybook aren't compatible.
// this.nuxt.hook('storybook:config', async ({ stories }) => {
// await DruxtViewsStorybook.call(this, { stories })
// })
// Nuxt Storybook.
// @TODO - @nuxt/kit and @nuxt/storybook aren't compatible.
nuxt.hook('storybook:config', async ({ stories }) => {
await DruxtViewsStorybook.call(nuxt, { stories })
})
}
})

export default DruxtViewsNuxtModule
3 changes: 2 additions & 1 deletion packages/views/src/nuxt/storybook.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { addTemplate } from '@nuxt/kit'
import merge from 'deepmerge'
import { DrupalJsonApiParams } from 'drupal-jsonapi-params'
import { DruxtClient } from 'druxt'
import { resolve } from 'path'

export default async function ({ stories }) {
const { addTemplate, options } = this
const { options } = this

// Setup DruxtClient instance.
const druxt = new DruxtClient(options.druxt.baseUrl, { ...options.druxt, proxy: { api: false } })
Expand Down

0 comments on commit 7fa1ef9

Please sign in to comment.