Giter Site home page Giter Site logo

prototypa / storybook-amp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from onwidget/storybook-amp

0.0 0.0 0.0 2.5 MB

⚡ Addon to render AMP html in Storybook

Home Page: https://storybook.js.org/addons/storybook-amp

License: MIT License

JavaScript 98.33% HTML 1.67%

storybook-amp's Introduction

Storybook AMP · npm package

Storybook addon for AMP (Accelerated Mobile Pages). Allows to display in your stories AMP Html components generated with React.

Screenshot

Features

  • Deliver in each story the output code (AMP ready) resulting from the SSR.
  • Works with AMP websites, AMP email and AMP ads
  • Realtime AMP validation.
  • Adds addon panel to also validate the story (using online AMP Validator) and view the output code.
  • Support Styled Components using a custom render function

Demo

demo.onwidget.com/storybook-amp/


Installation

npm install -D storybook-amp

Configuration

Next, update .storybook/main.js to the following:

// .storybook/main.js

module.exports = {
  stories: [
    // ...
  ],
  addons: [
    // Other Storybook addons

    'storybook-amp', // 👈 The addon registered here
  ],
};

Usage

To set custom settings, use the amp parameter.

// .storybook/preview.js

const scripts = '';
const styles = '';

export const parameters = {
  // Other defined parameters

  amp: {              // 👈 The addon parameters here
    isEnabled: true,  // Enable the addon, false by default (boolean)
    scripts,          // Global scripts to add, empty by default (string)
    styles,           // Custom css styles, empty by default (string)
  },
};

You can use the amp parameter to override settings on each story individually:

// Story example

export default {
  title: "Components/amp-youtube",
  parameters: {
    amp: {
      scripts: // 👈 Script needed by the story
        `<script async custom-element="amp-youtube" src="https://cdn.ampproject.org/v0/amp-youtube-0.1.js"></script>`,
    },
  },
};

export const Story = (args) => (
  <amp-youtube
    width="480"
    height="270"
    layout="responsive"
    data-videoid='lBTCB7yLs8Y'
  ></amp-youtube>
)

For more examples and configurations go to the Demo


Tested Addons Compatibility

  • Addon Viewport
  • Addon Controls
  • Addon Backgrounds
  • Addon Storysource
  • Addon Docs (Coming soon)
  • Addon Toolbars (Coming soon)
  • Addon Accessibility (Coming soon)
  • Addon Chromatic (Coming soon)

AMP Documentation

storybook-amp's People

Contributors

prototypa avatar tyom avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.