All Projects β†’ tuchk4 β†’ Storybook Readme

tuchk4 / Storybook Readme

Licence: mit
React Storybook addon to render README files in github style

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Storybook Readme

Github Markdown Toc.go
Easy TOC creation for GitHub README.md (in go)
Stars: ✭ 387 (-24.27%)
Mutual labels:  readme
Make A Readme
πŸ“„ Because nobody can read your mind (yet)
Stars: ✭ 426 (-16.63%)
Mutual labels:  readme
Storybook Addon Specifications
πŸ“– Write tests next to your stories and display their results inside storybook interface
Stars: ✭ 453 (-11.35%)
Mutual labels:  storybook
Story2sketch
Convert Storybook into Sketch symbols πŸ’Ž
Stars: ✭ 391 (-23.48%)
Mutual labels:  storybook
Github Profile Readme Generator
πŸš€ Generate GitHub profile README easily with the latest add-ons like visitors count, GitHub stats, etc using minimal UI.
Stars: ✭ 7,812 (+1428.77%)
Mutual labels:  readme
The Documentation Compendium
πŸ“’ Various README templates & tips on writing high-quality documentation that people want to read.
Stars: ✭ 4,306 (+742.66%)
Mutual labels:  readme
Github Profile Readme Generator
GitHub profile readme generator allows you to create nice and simple GitHub profile readme files that will be included in your profile previews.
Stars: ✭ 374 (-26.81%)
Mutual labels:  readme
React Event Timeline
A responsive event timeline in React.js
Stars: ✭ 504 (-1.37%)
Mutual labels:  storybook
Awesome Readme Templates
A collection of awesome readme templates to display on your github profile.
Stars: ✭ 423 (-17.22%)
Mutual labels:  readme
Storycap
A Storybook Addon, Save the screenshot image of your stories πŸ“· via puppeteer.
Stars: ✭ 451 (-11.74%)
Mutual labels:  storybook
Stackoverflow Clone
This project is a simplified a full stack clone of Stackoverflow.
Stars: ✭ 395 (-22.7%)
Mutual labels:  storybook
Cuke Ui
πŸ₯’ ι»„η“œuiοΌšδΈ€δΈͺε³ζ’ε³η”¨ηš„React UI εΊ“
Stars: ✭ 402 (-21.33%)
Mutual labels:  storybook
Storybook Addon Designs
A Storybook addon that embed Figma, websites, PDF or images in the addon panel.
Stars: ✭ 441 (-13.7%)
Mutual labels:  storybook
Waka Readme
Wakatime Weekly Metrics on your Profile Readme.
Stars: ✭ 386 (-24.46%)
Mutual labels:  readme
Badgen
Fast handcraft svg badge generator.
Stars: ✭ 464 (-9.2%)
Mutual labels:  readme
Figma Html
Convert Figma designs to HTML, React, Vue, Angular, and more!
Stars: ✭ 382 (-25.24%)
Mutual labels:  storybook
Markdownview Android
MarkdownView is an Android webview with the capability of loading Markdown text or file and display it as HTML, it extends Android webview.
Stars: ✭ 432 (-15.46%)
Mutual labels:  readme
React Typescript Web Extension Starter
πŸ–₯ A Web Extension starter kit built with React, TypeScript, SCSS, Storybook, Jest, EsLint, Prettier, Webpack and Bootstrap. Supports Google Chrome + Mozilla Firefox + Brave Browser πŸ”₯
Stars: ✭ 510 (-0.2%)
Mutual labels:  storybook
Ignite Andross
The original React Native boilerplate from Infinite Red - Redux, React Navigation, & more
Stars: ✭ 476 (-6.85%)
Mutual labels:  storybook
Creative Profile Readme
A Collection of GitHub Profiles with awesome readme
Stars: ✭ 449 (-12.13%)
Mutual labels:  readme

Storybook README addon

NOTE: This README is only for version ^5.0.0. For older versions README_V4.md

All previous api should work correctly at ^5.0.0 and above. But vue users will need to change their import path, as vue commands have been moved to their own folder.


Storybook README addon

This addon is compatible with:

Live demo

Features:

  • Automatically generate props table (only for React)
  • 100% markdown support
  • Code highlighting
  • Possible to add docs to addons panel or around the story
  • Accept multiple README (useful for hoc component - add component's and original component's README)
  • Looks like Github's README
  • Supports <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.

Install

npm install --save-dev storybook-readme

or

yarn add --dev storybook-readme

Webpack Configuration for React Storybook

Nothing to do :)

But if you are using Typescript with React you need to add markdown-loader in your webpack config

{
  test: /\.md$/,
  use: [
    {
      loader: 'markdown-loader',
    }
  ]
}

Webpack Configuration for Vue Storybook

Only for Single File Components with <docs> tag used for 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 define docs at story:

import MyButton from '../components/MyButton/MyButton.vue';

storiesOf('Vue <docs>', module).addParameters({
  readme: {
    content: MyButton.__docs,
  },
});

Setup

Register addon at .storybook/addons.js

import 'storybook-readme/register';

NOTE: It is possible to set addon's panel title

import registerWithPanelTitle from 'storybook-readme/registerWithPanelTitle';

registerWithPanelTitle('Docs');

Add decorator at .storybook/config.js

import { addDecorator, configure } from '@storybook/react';
import { addReadme } from 'storybook-readme';

// for Vue storybook
import { addReadme } from 'storybook-readme/vue'; // <---- vue subpackage

// for HTML storybook
import { addReadme } from 'storybook-readme/html'; // <---- html subpackage

addDecorator(addReadme);

function loadStories() {
  require('../stories/index.js');
}

configure(loadStories, module);

NOTE: for html storybook only sidebar docs are available.

Usage

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,
    },
  });

Full list of options

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,

      /**
       * Enable / disable code highlighting for sidebar. true by default
       */
      highlightSidebar: true,

      /**
       * Enable / disable code highlighting for content. true by default
       */
      highlightContent: true,

      /**
       * Override theme values
       *
       * All theme values https://github.com/tuchk4/storybook-readme/blob/master/packages/storybook-readme/src/styles/githubMarkdownCss.js#L436

       */
      theme: {},

      /**
       * Prism code theme
       * Full list of theme https://github.com/PrismJS/prism-themes
       * To be used with storybook-readme, naming of the code theme should be used in one of these styles. https://github.com/tuchk4/storybook-readme/tree/master/packages/storybook-readme/src/styles/prismCodeThemes
       */
      codeTheme: 'github',

      /**
       * You can include prop tables locally here. See `propTables` example
       * for more information
       */
      includePropTables: [YourImportedReactComponent],

      /**
       * 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 header 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>
    },
  })

Global configuration

Will be applied for all stories. NOTE: that global configuration is applied only for content docs (docs around the story).

import { addParameters } from '@storybook/react'; // or @storybook/vue for vuejs
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 header 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: '',
});

addParameters({
  readme: {
    // You can set a code theme globally.
    codeTheme: 'github',

    // You can exclude prop tables globally here. See `propTables` example
    // for more information
    excludePropTables: [YourImportedReactComponent],
  },
});

Readme placeholders

  • <!-- STORY --> placeholder for story
  • <!-- SOURCE --> placeholder for story source
  • <!-- STORY_SOURCE --> placeholder for story source
  • <!-- PROPS --> placeholder for props table. There are some issue with props parsing. Clarification issue#137
  • <!-- STORY HIDE START -->, <!-- STORY HIDE END --> content enclosed by the tags won't be shown in stories
Button variants could be imported separately.

\`\`\`js import { OutlinedButton, ContainedButton, TextButton } from 'Button'; \`\`\`

<!-- PROPS -->

Example:

<!-- STORY -->
<!-- SOURCE -->

<!-- STORY HIDE START -->

content here won't be shown in stories

<!-- STORY HIDE END -->

Some docs after story

Emoji

Use shortcodes between colon to insert emoji into the docs. For example

Here is rocket πŸš€

Here is rocket πŸš€

List of all shortcodes could be found at Emojipedia or at Gist/rxaviers

  • πŸš€
  • πŸ˜€
  • πŸ’

Feel free to suggest new features or report bugs :)

Api from v4.

Full docs for previous api are at README_V4.md

TL;DR:

Accepts README or array of README in markdown format. Multiple README is useful when you develop higher order components and want to add multiple READMEs along with the original component docs.

withReadme

Renders README at the addons panel.

import { withReadme } from 'storybook-readme';
import withReadme from 'storybook-readme/with-readme';

// as HigherOrder Component
storiesOf('Button', module).add(
  'Default',
  withReadme(ButtonReadme, () => <Button />),
);
// as Decorator
storiesOf('Button', module)
  .addDecorator(withReadme(ButtonReadme))
  .add('Default', () => <Button />);

withDocs

Renders README around the story.

import { withDocs } from 'storybook-readme';
import withDocs from 'storybook-readme/with-docs';

// as HigherOrder Component
storiesOf('Button', module).add(
  'Default',
  withDocs(ButtonReadme, () => <Button />),
);
// as Decorator
storiesOf('Button', module)
  .addDecorator(withDocs(ButtonReadme))
  .add('Default', () => <Button />);

doc

Renders README in main frame without story.

import { doc } from 'storybook-readme';

storiesOf('Button', module).add('Default', () => doc(ButtonReadme));
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].