Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
storybook-readme
Advanced tools
NOTE: This README only for version ^5.0.0
. For older versions LEGACY_README.md
This addon is compatible with:
Features:
<docs/>
tags for vue components (example-vue/components/MyButton/MyButton.vue).Also it very useful because most projects and components already have README.md files. Now it is easy to add them into your Storybook.
Stories will be added with .addWithInfo method if Storybook Info Addon is installed.
npm install --save-dev storybook-readme
or
yarn add --dev storybook-readme
Nothing to do :)
Only if using Single File Components and want to use <docs>
tag at storybook documentation.
module.exports = storybookBaseConfig => {
storybookBaseConfig.module.rules.push({
resourceQuery: /blockType=docs/,
use: ['storybook-readme/vue/docs-loader', 'html-loader', 'markdown-loader'],
});
};
Define <docs>
tag inside vue module:
<docs>
Docs inside vue module
</docs>
<template>
<button class="button">
<slot></slot>
</button>
</template>
Use it to defone docs at story:
import MyButton from '../components/MyButton/MyButton.vue';
storiesOf('Vue <docs>', module).addParameters({
readme: {
content: MyButton.__docs,
},
});
Register addon at .storybook/addons.js
import 'storybook-readme/register';
Add decorator at .storybook/config.js
import { addReadme } from 'storybook-readme';
addDecorator(addReadme);
Hope it is very simple.
import React from 'react';
import { storiesOf } from '@storybook/react';
import Button from '../components/Button';
import ButtonReadme from '../components/Button/README.md';
storiesOf('Buttons', module)
.addDecorator(withKnobs)
.addParameters({
readme: {
// Show readme before story
content: ButtonReadme,
// Show readme at the addons panel
sidebar: ButtonReadme,
},
})
.add('Button', () => <Button />);
It is possible to override docs for story
import React from 'react';
import { storiesOf } from '@storybook/react';
import Button from '../components/Button';
import ButtonReadme from '../components/Button/README.md';
storiesOf('Buttons', module)
.addDecorator(withKnobs)
.addParameters({
readme: {
content: ButtonReadme,
sidebar: ButtonReadme,
},
})
.add('Button', () => <Button />)
.add('Button', () => <Button />)
.add('Button', () => <Button />, {
readme: {
// override docs
content: CustomButtonReadme,
sidebar: CustomButtonReadme,
},
});
Will be applied for series of stories.
.addParameters({
readme: {
/**
* Accepts string (markdown) or array of strings
* string | Array<string>
*/
content: Readme,
/**
* Accepts string (markdown) or array of strings
* string | Array<string>
*/
sidebar: Readme,
/**
* Override theme values
*
* All theme values https://github.com/tuchk4/storybook-readme/blob/master/packages/storybook-readme/src/styles/githubMarkdownCss.js#L436
*/
theme: {},
/**
* Highlightjs code theme
* Import theme at _.storybook/config.js_.
* Full list of theme https://highlightjs.org/static/demo/.
*/
codeTheme: 'github',
/**
* Wrapper for story. Usually used to set some styles
* NOTE: will be applied only for content docs (docs around the story)
*
* React: React.ReactNode
* Vue: Vue component
*/
StoryPreview: ({ children}) => <div>{children}</div>
/**
* Wrapper for hedaer docs. Usually used to set some styles
* NOTE: will be applied only for content docs (docs around the story)
*
* React: React.ReactNode
* Vue: Vue component
*/
HeaderPreview: ({ children}) => <div>{children}</div>
/**
* Wrapper for footer docs. Usually used to set some styles
* NOTE: will be applied only for content docs (docs around the story)
*
* React: React.ReactNode
* Vue: Vue component
*/
FooterPreview: ({ children}) => <div>{children}</div>
/**
* Wrapper for content and sidebar docs. Usually used to set some styles
* NOTE: will be applied only for content docs (docs around the story)
*
* React: React.ReactNode
* Vue: Vue component
*/
DocPreview: ({ children}) => <div>{children}</div>
},
})
Will be applied for all stories.
NOTE: that global configuration
is applied only for content docs (docs around the story).
import { configureReadme } from 'storybook-readme';
configureReadme({
/**
* Wrapper for story. Usually used to set some styles
* React: React.ReactNode
* Vue: Vue component
*/
StoryPreview: ({ children }) => <div>{children}</div>,
/**
* Wrapper for content and sidebar docs. Usually used to set some styles
* React: React.ReactNode
* Vue: Vue component
*/
DocPreview: ({ children }) => (
<div style={{ background: '#000' }}> {children}</div>
),
/**
* Wrapper for hedaer docs. Usually used to set some styles
* React: React.ReactNode
* Vue: Vue component
*/
HeaderPreview: ({ children }) => (
<div style={{ background: 'red' }}>{children}</div>
),
/**
* Wrapper for footer docs. Usually used to set some styles
* React: React.ReactNode
* Vue: Vue component
*/
FooterPreview: ({ children }) => <div>{children}</div>,
/**
* Header docs in markdown format
*/
header: '',
/**
* Footer docs in markdown format
*/
footer: '',
});
<!-- STORY -->
placeholder for story<!-- PROPS -->
placeholder for props tableButton variants could be imported separately.
\`\`\`js import { OutlinedButton, ContainedButton, TextButton } from 'Button'; \`\`\`
<!-- PROPS -->
Example:
<!-- STORY -->
Some docs after story
Use shortcodes between colon to insert emoji into the docs. For example
Here is rocket :rocket:
Here is rocket :rocket:
List of all shortcodes could be found at Emojipedia or at Gist/rxaviers
Fell free to suggest new features or report bugs :)
FAQs
Storybook addon to show components README (for React and Vue)
We found that storybook-readme demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.