You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-11-23 11:02:35 +03:00
Adjust types in storybook
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
|
import { ArgTypes, Decorator, Parameters } from "@storybook/react";
|
||||||
import { useLayoutEffect } from "react";
|
import { useLayoutEffect } from "react";
|
||||||
import { createMemoryRouter, RouterProvider } from "react-router-dom";
|
import { createMemoryRouter, RouterProvider } from "react-router-dom";
|
||||||
import "../src/index.css";
|
import "../src/index.css";
|
||||||
|
|
||||||
export const parameters = {
|
export const parameters: Parameters = {
|
||||||
actions: { argTypesRegex: "^on[A-Z].*" },
|
actions: { argTypesRegex: "^on[A-Z].*" },
|
||||||
controls: {
|
controls: {
|
||||||
matchers: {
|
matchers: {
|
||||||
@@ -12,7 +13,7 @@ export const parameters = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const globalTypes = {
|
export const globalTypes: ArgTypes = {
|
||||||
theme: {
|
theme: {
|
||||||
name: "Theme",
|
name: "Theme",
|
||||||
description: "Global theme for components",
|
description: "Global theme for components",
|
||||||
@@ -35,7 +36,7 @@ export const globalTypes = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const ThemeSwitcher = ({ theme }) => {
|
const ThemeSwitcher: React.FC<{ theme?: "light" | "dark" }> = ({ theme }) => {
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (theme === "dark") {
|
if (theme === "dark") {
|
||||||
document.documentElement.classList.add("dark");
|
document.documentElement.classList.add("dark");
|
||||||
@@ -49,7 +50,7 @@ const ThemeSwitcher = ({ theme }) => {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const withThemeProvider = (Story, context) => {
|
const withThemeProvider: Decorator = (Story, context) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ThemeSwitcher theme={context.globals.theme} />
|
<ThemeSwitcher theme={context.globals.theme} />
|
||||||
@@ -58,7 +59,7 @@ const withThemeProvider = (Story, context) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const withRouter = (Story, context) => {
|
const withRouter: Decorator = (Story, _context) => {
|
||||||
const router = createMemoryRouter([
|
const router = createMemoryRouter([
|
||||||
{
|
{
|
||||||
path: "/*",
|
path: "/*",
|
||||||
@@ -69,4 +70,4 @@ const withRouter = (Story, context) => {
|
|||||||
return <RouterProvider router={router} />;
|
return <RouterProvider router={router} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const decorators = [withThemeProvider, withRouter];
|
export const decorators: Decorator[] = [withThemeProvider, withRouter];
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import type { Meta, StoryObj } from "@storybook/react";
|
|||||||
import Block from "./Block";
|
import Block from "./Block";
|
||||||
import { Title, Subtitle, Body } from "./Typography";
|
import { Title, Subtitle, Body } from "./Typography";
|
||||||
|
|
||||||
const meta: Meta<typeof Block> = {
|
const meta = {
|
||||||
title: "UI/Block",
|
title: "UI/Block",
|
||||||
component: Block,
|
component: Block,
|
||||||
subcomponents: {
|
subcomponents: {
|
||||||
@@ -26,7 +26,7 @@ const meta: Meta<typeof Block> = {
|
|||||||
Body,
|
Body,
|
||||||
} as Record<string, React.ComponentType<any>>,
|
} as Record<string, React.ComponentType<any>>,
|
||||||
tags: ["docsPage"],
|
tags: ["docsPage"],
|
||||||
};
|
} satisfies Meta<typeof Block>;
|
||||||
|
|
||||||
export default meta;
|
export default meta;
|
||||||
type Story = StoryObj<typeof Block>;
|
type Story = StoryObj<typeof Block>;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import type { Meta, StoryObj } from "@storybook/react";
|
|||||||
|
|
||||||
import Button from "./Button";
|
import Button from "./Button";
|
||||||
|
|
||||||
const meta: Meta<typeof Button> = {
|
const meta = {
|
||||||
title: "UI/Button",
|
title: "UI/Button",
|
||||||
component: Button,
|
component: Button,
|
||||||
tags: ["docsPage"],
|
tags: ["docsPage"],
|
||||||
@@ -32,7 +32,7 @@ const meta: Meta<typeof Button> = {
|
|||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
} satisfies Meta<typeof Button>;
|
||||||
|
|
||||||
export default meta;
|
export default meta;
|
||||||
type Story = StoryObj<typeof Button>;
|
type Story = StoryObj<typeof Button>;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import DateTime from "./DateTime";
|
|||||||
|
|
||||||
const now = new Date(2022, 11, 16, 15, 32, 10);
|
const now = new Date(2022, 11, 16, 15, 32, 10);
|
||||||
|
|
||||||
const meta: Meta<typeof DateTime> = {
|
const meta = {
|
||||||
title: "UI/DateTime",
|
title: "UI/DateTime",
|
||||||
component: DateTime,
|
component: DateTime,
|
||||||
tags: ["docsPage"],
|
tags: ["docsPage"],
|
||||||
@@ -35,7 +35,7 @@ const meta: Meta<typeof DateTime> = {
|
|||||||
control: "date",
|
control: "date",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
} satisfies Meta<typeof DateTime>;
|
||||||
|
|
||||||
export default meta;
|
export default meta;
|
||||||
type Story = StoryObj<typeof DateTime>;
|
type Story = StoryObj<typeof DateTime>;
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ import type { Meta, StoryObj } from "@storybook/react";
|
|||||||
|
|
||||||
import LoadingScreen from "./LoadingScreen";
|
import LoadingScreen from "./LoadingScreen";
|
||||||
|
|
||||||
const meta: Meta<typeof LoadingScreen> = {
|
const meta = {
|
||||||
title: "UI/Loading Screen",
|
title: "UI/Loading Screen",
|
||||||
component: LoadingScreen,
|
component: LoadingScreen,
|
||||||
tags: ["docsPage"],
|
tags: ["docsPage"],
|
||||||
};
|
} satisfies Meta<typeof LoadingScreen>;
|
||||||
|
|
||||||
export default meta;
|
export default meta;
|
||||||
type Story = StoryObj<typeof LoadingScreen>;
|
type Story = StoryObj<typeof LoadingScreen>;
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ import type { Meta, StoryObj } from "@storybook/react";
|
|||||||
|
|
||||||
import LoadingSpinner from "./LoadingSpinner";
|
import LoadingSpinner from "./LoadingSpinner";
|
||||||
|
|
||||||
const meta: Meta<typeof LoadingSpinner> = {
|
const meta = {
|
||||||
title: "UI/Loading Spinner",
|
title: "UI/Loading Spinner",
|
||||||
component: LoadingSpinner,
|
component: LoadingSpinner,
|
||||||
tags: ["docsPage"],
|
tags: ["docsPage"],
|
||||||
};
|
} satisfies Meta<typeof LoadingSpinner>;
|
||||||
|
|
||||||
export default meta;
|
export default meta;
|
||||||
type Story = StoryObj<typeof LoadingSpinner>;
|
type Story = StoryObj<typeof LoadingSpinner>;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ const Template: React.FC<TemplateProps> = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const meta: Meta<typeof Template> = {
|
const meta = {
|
||||||
title: "Components/OAuth 2.0 Session",
|
title: "Components/OAuth 2.0 Session",
|
||||||
component: Template,
|
component: Template,
|
||||||
tags: ["docsPage"],
|
tags: ["docsPage"],
|
||||||
@@ -87,7 +87,7 @@ const meta: Meta<typeof Template> = {
|
|||||||
clientName: "My client",
|
clientName: "My client",
|
||||||
clientUri: "https://example.com/",
|
clientUri: "https://example.com/",
|
||||||
},
|
},
|
||||||
};
|
} satisfies Meta<typeof Template>;
|
||||||
|
|
||||||
export default meta;
|
export default meta;
|
||||||
type Story = StoryObj<typeof Template>;
|
type Story = StoryObj<typeof Template>;
|
||||||
|
|||||||
@@ -16,14 +16,14 @@ import type { Meta, StoryObj } from "@storybook/react";
|
|||||||
|
|
||||||
import Typography from "./Typography";
|
import Typography from "./Typography";
|
||||||
|
|
||||||
const meta: Meta<typeof Typography> = {
|
const meta = {
|
||||||
title: "UI/Typography",
|
title: "UI/Typography",
|
||||||
component: Typography,
|
component: Typography,
|
||||||
tags: ["docsPage"],
|
tags: ["docsPage"],
|
||||||
args: {
|
args: {
|
||||||
children: "Typography",
|
children: "Typography",
|
||||||
},
|
},
|
||||||
};
|
} satisfies Meta<typeof Typography>;
|
||||||
|
|
||||||
export default meta;
|
export default meta;
|
||||||
type Story = StoryObj<typeof Typography>;
|
type Story = StoryObj<typeof Typography>;
|
||||||
|
|||||||
Reference in New Issue
Block a user