Skip to content

Commit

Permalink
chore(storybook): improve preview.tsx (#2332)
Browse files Browse the repository at this point in the history
  • Loading branch information
sudongyuer authored Feb 11, 2024
1 parent 3971477 commit 2934a90
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions packages/storybook/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import React from "react";
import {themes} from "@storybook/theming";
import {NextUIProvider} from "@nextui-org/system/src/provider";
import type { Preview } from '@storybook/react';
import type {Preview} from "@storybook/react";

import './style.css'
import "./style.css";

const decorators: Preview['decorators'] = [
(Story, {globals: {locale}}) => {
const direction =
// @ts-ignore
locale && new Intl.Locale(locale)?.textInfo?.direction === "rtl" ? "rtl" : undefined;
const decorators: Preview["decorators"] = [
(Story, {globals: {locale}}) => {
const direction =
// @ts-ignore
locale && new Intl.Locale(locale)?.textInfo?.direction === "rtl" ? "rtl" : undefined;

return (
<NextUIProvider locale={locale}>
<div className="bg-dark" lang={locale} dir={direction}>
<Story />
</div>
</NextUIProvider>
);
},
]
return (
<NextUIProvider locale={locale}>
<div className="bg-dark" lang={locale} dir={direction}>
<Story />
</div>
</NextUIProvider>
);
},
];

const commonTheme = {
brandTitle: "NextUI",
brandUrl: "https://nextui.org",
brandTarget: "_self",
}
const commonTheme = {
brandTitle: "NextUI",
brandUrl: "https://nextui.org",
brandTarget: "_self",
};

const parameters: Preview['parameters'] = {
const parameters: Preview["parameters"] = {
actions: {argTypesRegex: "^on[A-Z].*"},
options: {
storySort: {
Expand Down Expand Up @@ -103,7 +103,7 @@ const locales = [
"zh-TW",
];

const globalTypes: Preview['globalTypes'] = {
const globalTypes: Preview["globalTypes"] = {
locale: {
toolbar: {
icon: "globe",
Expand All @@ -117,8 +117,10 @@ const globalTypes: Preview['globalTypes'] = {
},
};

export default {
const preview: Preview = {
decorators,
parameters,
globalTypes
} satisfies Preview;
globalTypes,
};

export default preview;

0 comments on commit 2934a90

Please sign in to comment.