Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
storybook-vue3-router
Advanced tools
A Storybook decorator that allows you to build stories for your routing-aware components.
A Storybook decorator that allows you to use your routing-aware components.
You will need to use this plugin if you wish to include stories for any component using Vue Router v4 <router-view>
and <router-link>
Vue Router v4 is used with Vue 3 projects.
npm install storybook-vue3-router
After installing you can import the Storybook decorator and start working with components using Vue Router v4
/* import Storybook addon (decorator for Vue Router) */
import vueRouter from 'storybook-vue3-router'
/* ...story setup... */
/* your story export */
export const Default = Template.bind({})
/* adding custom decorator to allow use of `<router-view>` and Vue Router 4+ */
Default.decorators = [
vueRouter()
]
/* import `action` to log router changes (this can be used by this addon to log router events) */
import { action } from '@storybook/addon-actions';
/* import Storybook addon (decorator for Vue Router) */
import vueRouter from 'storybook-vue3-router'
/* component you're writing story for */
import myRouterWrapperComponent from './myRouterWrapperComponent.vue'
/* your component defaults */
export default {
title: 'Components/Vue Router View Wrapper',
component: myRouterWrapperComponent,
}
/* your component story */
const Template = (args: Record<string, unknown>) => ({
components: { 'MyRouterWrapper': myRouterWrapperComponent },
setup () {
return { args }
},
template: `<MyRouterWrapper />`
})
/* your story export */
export const Default = Template.bind({})
/* adding custom decorator to allow use of `<router-view>` and Vue Router 4+ */
Default.decorators = [
vueRouter(null, (to, from) => action('ROUTE CHANGED')({ to: to, from: from }))
]
The example above uses:
Default.decorators = [
vueRouter(null, (to, from) => action('ROUTE CHANGED')({ to: to, from: from }))
]
/
and /about
routes, with <router-link>
for each route)You can pass custom router setup by including (or importing into your .stories.
file) and passing this as the first parametor within the vueRouter
decorator:
const customRoutes = [
{
path: '/',
name: 'home',
component: HomeComponent // this would need to be imported into the `.stories` file
},
{
path: '/about',
name: 'about',
component: AboutComponent // this would need to be imported into the `.stories` file
}
{
/* ... other routes ... */
}
]
/* ... other story setup ... */
Default.decorators = [
vueRouter(customRoutes, (to, from) => action('ROUTE CHANGED')({ to: to, from: from }))
]
The second parameter for vueRouter
is a function which is ran on Vue Routers beforeEach
route guard.
In our examples we're using this to log an action event to the Storybook UI.
This parametor is optional.
v1.0.4 (Fri Sep 10 2021)
main
FAQs
A Storybook decorator that allows you to build stories for your routing-aware components.
The npm package storybook-vue3-router receives a total of 38,733 weekly downloads. As such, storybook-vue3-router popularity was classified as popular.
We found that storybook-vue3-router demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.