Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@ampproject/storybook-addon
Advanced tools
Readme
The storybook AMP addon allows rendering of AMP content inside the Storybook environment.
@ampproject/storybook-addon
allows switching between three AMP modes:
Module (v0.js
), No-module (v0.mjs
) and Bento. It also allows switching
between development mode (locally hosted v0.js
) and production mode (CDN
hosted v0.js
).
First, add the @ampproject/storybook-addon
to your project:
npm install --save-dev @ampproject/storybook-addon
Second, register the @ampproject/storybook-addon
to your
config (.storybook/main.js
):
module.exports = {
addons: ['@ampproject/storybook-addon'],
};
An AMP story uses withAmp
decorator:
import {h} from 'preact';
import {storiesOf} from '@storybook/preact';
import {withAmp} from '@ampproject/storybook-addon';
export default {
title: 'amp-carousel',
decorators: [withAmp],
parameters: {
extensions: [{name: 'amp-carousel', version: '0.2'}]},
},
};
export const Default = () => {
return (
<amp-base-carousel width="440" height="225">
{['lightcoral', 'peachpuff', 'lavender'].map((color) => (
<div key={color}>{color}</div>
))}
</amp-base-carousel>
);
};
The following parameters can be specified:
extensions: [{name, version}]
- a list of extensions to be installed.experiments: [string]
- a list of experiments to enabled.amp-script
hashesInline scripts used by amp-script
require a <meta name="amp-script-src">
tag that includes their content hash.
This addon generates the script hash for stories that need it. The following works without writing the respective <meta>
tag:
export const UsingInlineScript = () => (
<>
<amp-script script="hello" nodom></amp-script>
<script id="hello" type="text/plain" target="amp-script">
{`console.log('Hello');`}
</script>
</>
);
FAQs
Storybook addon for building and testing AMP components
The npm package @ampproject/storybook-addon receives a total of 92 weekly downloads. As such, @ampproject/storybook-addon popularity was classified as not popular.
We found that @ampproject/storybook-addon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 16 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.