grafana/packages/grafana-ui/.storybook/preview.ts

89 lines
2.7 KiB
TypeScript
Raw Normal View History

Chore: Upgrade Storybook to v7 (#65943) * chore(grafana-ui): begin migration to storybook7 * refactor(storybook): begin cleanup of storybook and addon configs * chore(storybook): add storybook/blocks to keep yarn berry happy * chore(storybook): rename intro story for storybook 7 * chore(stories): rename internal stories to support SB7 story name mapper * chore(betterer): update glob to support internal story renaming * chore(stories): silence TS errors for subcomponents in SB7 * fix(clickoutsidewrapper): window | document can be undefined not null * chore(storybook): remove patch for 6.5.16 * revert(storybook): put back story globs * docs(storybook): replace removed <Props /> with <ArgsTypes /> in mdx files * docs(storybook): use ArgTypes instead of ArgsTable * chore(storybook): use correct ArgTypes import name in mdx files * chore(storybook): patch blocks to expose Preview component for docs * chore(storybook): rename deprecated ComponentStory and ComponentMeta for v7 * feat(storybook): add STORY env var to customise which stories storybook should load * chore(storybook): bump to 7.0.4 * fix(storybook): set esbuild minify target to fix erroring docs in production builds * fix(toolbarbuttonrow): fix import path to prevent error in storybook doc * docs(storybook): fix up some more stories * chore(storybook): more config updates to match storybook documentation * chore(storybook): bump to 7.0.5 * Apply suggestions from code review Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com> * chore(storybook): fix broken merge causing types issues * chore(storybook): mimic broken alphabetical storySort and docs overview ordering * docs(storybook): fix button docs adding p tags due to mdx2 * chore(storybook): bump to 7.0.10 * chore(storybook): apply patch on yarn install * chore(text): update stories for storybook 7 * fix(storybook): make sure globs don't include internal stories in production --------- Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com>
2023-05-11 07:26:12 -05:00
import { Preview } from '@storybook/react';
import 'jquery';
import { getTimeZone, getTimeZones } from '@grafana/data';
Chore: Upgrade Storybook to v7 (#65943) * chore(grafana-ui): begin migration to storybook7 * refactor(storybook): begin cleanup of storybook and addon configs * chore(storybook): add storybook/blocks to keep yarn berry happy * chore(storybook): rename intro story for storybook 7 * chore(stories): rename internal stories to support SB7 story name mapper * chore(betterer): update glob to support internal story renaming * chore(stories): silence TS errors for subcomponents in SB7 * fix(clickoutsidewrapper): window | document can be undefined not null * chore(storybook): remove patch for 6.5.16 * revert(storybook): put back story globs * docs(storybook): replace removed <Props /> with <ArgsTypes /> in mdx files * docs(storybook): use ArgTypes instead of ArgsTable * chore(storybook): use correct ArgTypes import name in mdx files * chore(storybook): patch blocks to expose Preview component for docs * chore(storybook): rename deprecated ComponentStory and ComponentMeta for v7 * feat(storybook): add STORY env var to customise which stories storybook should load * chore(storybook): bump to 7.0.4 * fix(storybook): set esbuild minify target to fix erroring docs in production builds * fix(toolbarbuttonrow): fix import path to prevent error in storybook doc * docs(storybook): fix up some more stories * chore(storybook): more config updates to match storybook documentation * chore(storybook): bump to 7.0.5 * Apply suggestions from code review Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com> * chore(storybook): fix broken merge causing types issues * chore(storybook): mimic broken alphabetical storySort and docs overview ordering * docs(storybook): fix button docs adding p tags due to mdx2 * chore(storybook): bump to 7.0.10 * chore(storybook): apply patch on yarn install * chore(text): update stories for storybook 7 * fix(storybook): make sure globs don't include internal stories in production --------- Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com>
2023-05-11 07:26:12 -05:00
import '../../../public/vendor/flot/jquery.flot.js';
import '../../../public/vendor/flot/jquery.flot.selection';
import '../../../public/vendor/flot/jquery.flot.time';
import '../../../public/vendor/flot/jquery.flot.stack';
import '../../../public/vendor/flot/jquery.flot.stackpercent';
import '../../../public/vendor/flot/jquery.flot.fillbelow';
import '../../../public/vendor/flot/jquery.flot.crosshair';
import '../../../public/vendor/flot/jquery.flot.dashes';
import '../../../public/vendor/flot/jquery.flot.gauge';
Chore: Upgrade Storybook to v7 (#65943) * chore(grafana-ui): begin migration to storybook7 * refactor(storybook): begin cleanup of storybook and addon configs * chore(storybook): add storybook/blocks to keep yarn berry happy * chore(storybook): rename intro story for storybook 7 * chore(stories): rename internal stories to support SB7 story name mapper * chore(betterer): update glob to support internal story renaming * chore(stories): silence TS errors for subcomponents in SB7 * fix(clickoutsidewrapper): window | document can be undefined not null * chore(storybook): remove patch for 6.5.16 * revert(storybook): put back story globs * docs(storybook): replace removed <Props /> with <ArgsTypes /> in mdx files * docs(storybook): use ArgTypes instead of ArgsTable * chore(storybook): use correct ArgTypes import name in mdx files * chore(storybook): patch blocks to expose Preview component for docs * chore(storybook): rename deprecated ComponentStory and ComponentMeta for v7 * feat(storybook): add STORY env var to customise which stories storybook should load * chore(storybook): bump to 7.0.4 * fix(storybook): set esbuild minify target to fix erroring docs in production builds * fix(toolbarbuttonrow): fix import path to prevent error in storybook doc * docs(storybook): fix up some more stories * chore(storybook): more config updates to match storybook documentation * chore(storybook): bump to 7.0.5 * Apply suggestions from code review Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com> * chore(storybook): fix broken merge causing types issues * chore(storybook): mimic broken alphabetical storySort and docs overview ordering * docs(storybook): fix button docs adding p tags due to mdx2 * chore(storybook): bump to 7.0.10 * chore(storybook): apply patch on yarn install * chore(text): update stories for storybook 7 * fix(storybook): make sure globs don't include internal stories in production --------- Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com>
2023-05-11 07:26:12 -05:00
import { withTheme } from '../src/utils/storybook/withTheme';
import { withTimeZone } from '../src/utils/storybook/withTimeZone';
import { ThemedDocsContainer } from '../src/utils/storybook/ThemedDocsContainer';
Chore: Upgrade Storybook to v7 (#65943) * chore(grafana-ui): begin migration to storybook7 * refactor(storybook): begin cleanup of storybook and addon configs * chore(storybook): add storybook/blocks to keep yarn berry happy * chore(storybook): rename intro story for storybook 7 * chore(stories): rename internal stories to support SB7 story name mapper * chore(betterer): update glob to support internal story renaming * chore(stories): silence TS errors for subcomponents in SB7 * fix(clickoutsidewrapper): window | document can be undefined not null * chore(storybook): remove patch for 6.5.16 * revert(storybook): put back story globs * docs(storybook): replace removed <Props /> with <ArgsTypes /> in mdx files * docs(storybook): use ArgTypes instead of ArgsTable * chore(storybook): use correct ArgTypes import name in mdx files * chore(storybook): patch blocks to expose Preview component for docs * chore(storybook): rename deprecated ComponentStory and ComponentMeta for v7 * feat(storybook): add STORY env var to customise which stories storybook should load * chore(storybook): bump to 7.0.4 * fix(storybook): set esbuild minify target to fix erroring docs in production builds * fix(toolbarbuttonrow): fix import path to prevent error in storybook doc * docs(storybook): fix up some more stories * chore(storybook): more config updates to match storybook documentation * chore(storybook): bump to 7.0.5 * Apply suggestions from code review Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com> * chore(storybook): fix broken merge causing types issues * chore(storybook): mimic broken alphabetical storySort and docs overview ordering * docs(storybook): fix button docs adding p tags due to mdx2 * chore(storybook): bump to 7.0.10 * chore(storybook): apply patch on yarn install * chore(text): update stories for storybook 7 * fix(storybook): make sure globs don't include internal stories in production --------- Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com>
2023-05-11 07:26:12 -05:00
2019-03-21 10:06:55 -05:00
// @ts-ignore
import lightTheme from './grafana.light.scss';
2019-03-21 10:06:55 -05:00
// @ts-ignore
import darkTheme from './grafana.dark.scss';
import { GrafanaDark, GrafanaLight } from './storybookTheme';
2019-01-09 02:40:57 -06:00
const handleThemeChange = (theme: any) => {
2019-03-21 10:06:55 -05:00
if (theme !== 'light') {
lightTheme.unuse();
darkTheme.use();
} else {
darkTheme.unuse();
lightTheme.use();
}
};
2019-02-06 10:03:42 -06:00
Chore: Upgrade Storybook to v7 (#65943) * chore(grafana-ui): begin migration to storybook7 * refactor(storybook): begin cleanup of storybook and addon configs * chore(storybook): add storybook/blocks to keep yarn berry happy * chore(storybook): rename intro story for storybook 7 * chore(stories): rename internal stories to support SB7 story name mapper * chore(betterer): update glob to support internal story renaming * chore(stories): silence TS errors for subcomponents in SB7 * fix(clickoutsidewrapper): window | document can be undefined not null * chore(storybook): remove patch for 6.5.16 * revert(storybook): put back story globs * docs(storybook): replace removed <Props /> with <ArgsTypes /> in mdx files * docs(storybook): use ArgTypes instead of ArgsTable * chore(storybook): use correct ArgTypes import name in mdx files * chore(storybook): patch blocks to expose Preview component for docs * chore(storybook): rename deprecated ComponentStory and ComponentMeta for v7 * feat(storybook): add STORY env var to customise which stories storybook should load * chore(storybook): bump to 7.0.4 * fix(storybook): set esbuild minify target to fix erroring docs in production builds * fix(toolbarbuttonrow): fix import path to prevent error in storybook doc * docs(storybook): fix up some more stories * chore(storybook): more config updates to match storybook documentation * chore(storybook): bump to 7.0.5 * Apply suggestions from code review Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com> * chore(storybook): fix broken merge causing types issues * chore(storybook): mimic broken alphabetical storySort and docs overview ordering * docs(storybook): fix button docs adding p tags due to mdx2 * chore(storybook): bump to 7.0.10 * chore(storybook): apply patch on yarn install * chore(text): update stories for storybook 7 * fix(storybook): make sure globs don't include internal stories in production --------- Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com>
2023-05-11 07:26:12 -05:00
const preview: Preview = {
decorators: [withTheme(handleThemeChange), withTimeZone()],
Chore: Upgrade Storybook to v7 (#65943) * chore(grafana-ui): begin migration to storybook7 * refactor(storybook): begin cleanup of storybook and addon configs * chore(storybook): add storybook/blocks to keep yarn berry happy * chore(storybook): rename intro story for storybook 7 * chore(stories): rename internal stories to support SB7 story name mapper * chore(betterer): update glob to support internal story renaming * chore(stories): silence TS errors for subcomponents in SB7 * fix(clickoutsidewrapper): window | document can be undefined not null * chore(storybook): remove patch for 6.5.16 * revert(storybook): put back story globs * docs(storybook): replace removed <Props /> with <ArgsTypes /> in mdx files * docs(storybook): use ArgTypes instead of ArgsTable * chore(storybook): use correct ArgTypes import name in mdx files * chore(storybook): patch blocks to expose Preview component for docs * chore(storybook): rename deprecated ComponentStory and ComponentMeta for v7 * feat(storybook): add STORY env var to customise which stories storybook should load * chore(storybook): bump to 7.0.4 * fix(storybook): set esbuild minify target to fix erroring docs in production builds * fix(toolbarbuttonrow): fix import path to prevent error in storybook doc * docs(storybook): fix up some more stories * chore(storybook): more config updates to match storybook documentation * chore(storybook): bump to 7.0.5 * Apply suggestions from code review Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com> * chore(storybook): fix broken merge causing types issues * chore(storybook): mimic broken alphabetical storySort and docs overview ordering * docs(storybook): fix button docs adding p tags due to mdx2 * chore(storybook): bump to 7.0.10 * chore(storybook): apply patch on yarn install * chore(text): update stories for storybook 7 * fix(storybook): make sure globs don't include internal stories in production --------- Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com>
2023-05-11 07:26:12 -05:00
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
darkMode: {
dark: GrafanaDark,
light: GrafanaLight,
},
docs: {
container: ThemedDocsContainer,
},
knobs: {
disable: true,
},
layout: 'fullscreen',
options: {
// Sort stories first by Docs Overview, then alphabetically
// We should be able to use the builtin alphabetical sort, but is broken in SB 7.0
// https://github.com/storybookjs/storybook/issues/22470
storySort: (a, b) => {
// Skip sorting for stories with nosort tag
if (a.tags.includes('nosort') || b.tags.includes('nosort')) {
return 0;
}
Chore: Upgrade Storybook to v7 (#65943) * chore(grafana-ui): begin migration to storybook7 * refactor(storybook): begin cleanup of storybook and addon configs * chore(storybook): add storybook/blocks to keep yarn berry happy * chore(storybook): rename intro story for storybook 7 * chore(stories): rename internal stories to support SB7 story name mapper * chore(betterer): update glob to support internal story renaming * chore(stories): silence TS errors for subcomponents in SB7 * fix(clickoutsidewrapper): window | document can be undefined not null * chore(storybook): remove patch for 6.5.16 * revert(storybook): put back story globs * docs(storybook): replace removed <Props /> with <ArgsTypes /> in mdx files * docs(storybook): use ArgTypes instead of ArgsTable * chore(storybook): use correct ArgTypes import name in mdx files * chore(storybook): patch blocks to expose Preview component for docs * chore(storybook): rename deprecated ComponentStory and ComponentMeta for v7 * feat(storybook): add STORY env var to customise which stories storybook should load * chore(storybook): bump to 7.0.4 * fix(storybook): set esbuild minify target to fix erroring docs in production builds * fix(toolbarbuttonrow): fix import path to prevent error in storybook doc * docs(storybook): fix up some more stories * chore(storybook): more config updates to match storybook documentation * chore(storybook): bump to 7.0.5 * Apply suggestions from code review Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com> * chore(storybook): fix broken merge causing types issues * chore(storybook): mimic broken alphabetical storySort and docs overview ordering * docs(storybook): fix button docs adding p tags due to mdx2 * chore(storybook): bump to 7.0.10 * chore(storybook): apply patch on yarn install * chore(text): update stories for storybook 7 * fix(storybook): make sure globs don't include internal stories in production --------- Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com>
2023-05-11 07:26:12 -05:00
if (a.title.startsWith('Docs Overview')) {
if (b.title.startsWith('Docs Overview')) {
return 0;
}
return -1;
} else if (b.title.startsWith('Docs Overview')) {
return 1;
}
return a.id === b.id ? 0 : a.id.localeCompare(b.id, undefined, { numeric: true });
},
},
},
globalTypes: {
timeZone: {
description: 'Set the timezone for the storybook preview',
defaultValue: getTimeZone(),
toolbar: {
icon: 'globe',
items: getTimeZones(true)
.filter((timezone) => !!timezone)
.map((timezone) => ({
title: timezone,
value: timezone,
})),
},
},
},
Chore: Bump storybook to v6 (#28926) * Wip * feat: get storybook and app building locally * docs: comment webpack react alias * build(grafana-ui): put back ts-loader * build: prefer storybook essentials over actions and docs. bump dark-mode * chore(storybook): migrate to latest config * build: prevent test env throwing Invalid hook call errors * chore: lodash resolves to package dependency rather than project * use decorators as variable instead of function * perf(storybook): reduce bundling time by splitting type check and compilation * refactor(storybook): use sortOrder.order param to sort intro story first * build: use yarn workspace command * refactor(storybook): use previous knobs addon registration * migrate button story to controls * build(storybook): silence warnings in console * build: bump storybook related ts packages * style: remove trailing whitespace * refactor(graphng): export interface for storybook * controls migration guide * fix typo * docs(storybook): default docs to use dark theme as per current implementation * revert(grafana-ui): put back react-is namedExport this was changed for react 17 bump but causes rollup to fail during bundling * chore: bump storybook to 6.1, enable fastRefresh, silence eslint prop-types * docs(grafana-ui): move knobs -> controls migration guide to storybook style-guide * chore(storybook): silence terminal warning about order of docs addon * Update contribute/style-guides/storybook.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Apply documentation suggestions Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * chore(storybook): bump to 6.1.2 Co-authored-by: Peter Holmberg <peter.hlmbrg@gmail.com> Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2020-11-24 03:38:41 -06:00
};
Chore: Upgrade Storybook to v7 (#65943) * chore(grafana-ui): begin migration to storybook7 * refactor(storybook): begin cleanup of storybook and addon configs * chore(storybook): add storybook/blocks to keep yarn berry happy * chore(storybook): rename intro story for storybook 7 * chore(stories): rename internal stories to support SB7 story name mapper * chore(betterer): update glob to support internal story renaming * chore(stories): silence TS errors for subcomponents in SB7 * fix(clickoutsidewrapper): window | document can be undefined not null * chore(storybook): remove patch for 6.5.16 * revert(storybook): put back story globs * docs(storybook): replace removed <Props /> with <ArgsTypes /> in mdx files * docs(storybook): use ArgTypes instead of ArgsTable * chore(storybook): use correct ArgTypes import name in mdx files * chore(storybook): patch blocks to expose Preview component for docs * chore(storybook): rename deprecated ComponentStory and ComponentMeta for v7 * feat(storybook): add STORY env var to customise which stories storybook should load * chore(storybook): bump to 7.0.4 * fix(storybook): set esbuild minify target to fix erroring docs in production builds * fix(toolbarbuttonrow): fix import path to prevent error in storybook doc * docs(storybook): fix up some more stories * chore(storybook): more config updates to match storybook documentation * chore(storybook): bump to 7.0.5 * Apply suggestions from code review Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com> * chore(storybook): fix broken merge causing types issues * chore(storybook): mimic broken alphabetical storySort and docs overview ordering * docs(storybook): fix button docs adding p tags due to mdx2 * chore(storybook): bump to 7.0.10 * chore(storybook): apply patch on yarn install * chore(text): update stories for storybook 7 * fix(storybook): make sure globs don't include internal stories in production --------- Co-authored-by: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com>
2023-05-11 07:26:12 -05:00
export default preview;