Skip to content

Commit

Permalink
Merge pull request #56 from tfoxy/fix-docs-stories
Browse files Browse the repository at this point in the history
Fix docs stories
  • Loading branch information
NickMcBurney committed Nov 18, 2023
2 parents e6362d4 + 3be6e45 commit cc22781
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 24 deletions.
3 changes: 0 additions & 3 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
module.exports = {
stories: ["../examples/**/*.stories.mdx", "../examples/**/*.stories.@(js|jsx|ts|tsx)"],
addons: ["../preset.js", "@storybook/addon-essentials"],
docs: {
autodocs: false
},
framework: {
name: "@storybook/vue3-vite",
options: {}
Expand Down
1 change: 1 addition & 0 deletions examples/basicExamples.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import routerViewWrapper from './components/routerViewWrapper.vue'
export default {
title: 'Basic Router View Wrapper',
component: routerViewWrapper,
tags: ['autodocs'],
}

/**
Expand Down
16 changes: 4 additions & 12 deletions src/withMockRouter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

import { setup, Decorator } from '@storybook/vue3'
import { App } from 'vue';
import { Decorator } from '@storybook/vue3'
import { getCurrentInstance } from 'vue';
import { action } from '@storybook/addon-actions'
import type { StoryContext, StoryFn } from '@storybook/types'

import type {
Router,
Expand All @@ -29,16 +28,9 @@ export function withMockRouter (
/* optional: router options - used to pass `initialRoute` value, `beforeEach()` navigation guard methods and vue-router `createRouter` options */
options: { meta?: Array<string>, params?: Array<string>, query?: Array<string> }
): Decorator {
let app: App
let ctx: StoryContext

setup((setupApp: App, context: StoryContext) => {
app = setupApp
ctx = context
})

return () => ({
return (_, ctx) => ({
setup () {
const { app } = getCurrentInstance()!.appContext
const existingRouter = app.config.globalProperties.$router as MockRouter
const existingRoute = app.config.globalProperties.$route as MockRoute

Expand Down
13 changes: 4 additions & 9 deletions src/withVueRouter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { setup, Decorator } from '@storybook/vue3'
import { App } from 'vue';
import type { StoryContext, StoryFn } from '@storybook/types'
import { Decorator } from '@storybook/vue3'
import { getCurrentInstance } from 'vue';

import {
createRouter,
Expand Down Expand Up @@ -38,14 +37,10 @@ export function withVueRouter (
vueRouterOptions?: RouterOptions;
}
): Decorator {
let app: App

setup((setupApp: App) => {
app = setupApp
})

return () => ({
setup () {
const { app } = getCurrentInstance()!.appContext

/* setup router var */
let router

Expand Down

0 comments on commit cc22781

Please sign in to comment.