1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

docs: add data-theme attribute to storybook html

This commit is contained in:
Thomas Heartman 2022-02-17 13:41:57 +01:00
parent 1b8a15aa12
commit 9bcb489d8c
6 changed files with 62 additions and 12 deletions

View File

@ -1,12 +1,13 @@
module.exports = {
"stories": [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions"
],
"framework": "@storybook/react"
}
stories: [
'../src/**/*.stories.mdx',
'../src/**/*.stories.@(js|jsx|ts|tsx)',
],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'storybook-addon-root-attribute/register',
],
framework: '@storybook/react',
};

View File

@ -1,4 +1,5 @@
import '../src/css/custom.css';
import { withRootAttribute } from 'storybook-addon-root-attribute';
export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
@ -8,4 +9,24 @@ export const parameters = {
date: /Date$/,
},
},
layout: 'fullscreen',
// add docusaurus theming to storybook iframes
rootAttribute: {
root: 'html',
attribute: 'data-theme',
defaultState: {
name: 'Light',
value: 'light',
},
states: [
{
name: 'Dark',
value: 'dark',
},
],
tooltip: true,
},
};
export const decorators = [withRootAttribute];

View File

@ -58,6 +58,7 @@
"@storybook/addon-links": "^6.4.19",
"@storybook/react": "^6.4.19",
"@storybook/testing-library": "^0.0.9",
"babel-loader": "^8.2.3"
"babel-loader": "^8.2.3",
"storybook-addon-root-attribute": "^1.0.2"
}
}

View File

@ -0,0 +1,8 @@
import React from 'react';
import './styles.module.css';
const Component = ({ text }) => (
<article className="user-feedback">{text}</article>
);
export default Component;

View File

@ -0,0 +1,16 @@
import React from 'react';
import Component from './UserFeedback';
export default {
title: 'User feedback component',
component: Component,
};
const Template = (args) => <Component {...args} />;
export const A = Template.bind({});
A.args = {
x: true,
y: 45,
text: 'blah blah blah',
};

View File

@ -0,0 +1,3 @@
.user-feedback {
background: goldenrod;
}