Setup a very basic storybook
This commit is contained in:
parent
8c8eef22ce
commit
045c20844f
15 changed files with 5915 additions and 391 deletions
24
src/keycloak-theme/account/createPageStory.tsx
Normal file
24
src/keycloak-theme/account/createPageStory.tsx
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { getKcContext, type KcContext } from "./kcContext";
|
||||
import KcApp from "./KcApp";
|
||||
import type { DeepPartial } from "keycloakify/tools/DeepPartial";
|
||||
|
||||
export function createPageStory<PageId extends KcContext["pageId"]>(params: {
|
||||
pageId: PageId;
|
||||
}) {
|
||||
|
||||
const { pageId } = params;
|
||||
|
||||
function PageStory(params: { kcContext?: DeepPartial<Extract<KcContext, { pageId: PageId }>>; }) {
|
||||
|
||||
const { kcContext } = getKcContext({
|
||||
mockPageId: pageId,
|
||||
storyParams: params.kcContext
|
||||
});
|
||||
|
||||
return <KcApp kcContext={kcContext} />;
|
||||
|
||||
}
|
||||
|
||||
return { PageStory };
|
||||
|
||||
}
|
||||
|
|
@ -1,17 +1,20 @@
|
|||
import { getKcContext } from "keycloakify/account";
|
||||
import { createGetKcContext } from "keycloakify/account";
|
||||
|
||||
export type KcContextExtension =
|
||||
| { pageId: "my-extra-page-1.ftl"; }
|
||||
| { pageId: "my-extra-page-2.ftl"; someCustomValue: string; };
|
||||
|
||||
export const { kcContext } = getKcContext<KcContextExtension>({
|
||||
//mockPageId: "password.ftl",
|
||||
export const { getKcContext } = createGetKcContext<KcContextExtension>({
|
||||
mockData: [
|
||||
{
|
||||
pageId: "my-extra-page-2.ftl",
|
||||
pageId: "my-extra-page-2.ftl",
|
||||
someCustomValue: "foo bar"
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
export type KcContext = NonNullable<typeof kcContext>;
|
||||
export const { kcContext } = getKcContext({
|
||||
//mockPageId: "password.ftl",
|
||||
});
|
||||
|
||||
export type KcContext = NonNullable<typeof kcContext>;
|
||||
|
|
|
|||
14
src/keycloak-theme/account/pages/Password.stories.tsx
Normal file
14
src/keycloak-theme/account/pages/Password.stories.tsx
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
import { ComponentStory, ComponentMeta } from "@storybook/react";
|
||||
import { createPageStory } from "../createPageStory";
|
||||
|
||||
const { PageStory } = createPageStory({
|
||||
pageId: "password.ftl"
|
||||
});
|
||||
|
||||
export default {
|
||||
title: "account/Password",
|
||||
component: PageStory,
|
||||
} as ComponentMeta<typeof PageStory>;
|
||||
|
||||
export const Default: ComponentStory<typeof PageStory> = () => <PageStory />;
|
||||
Loading…
Add table
Add a link
Reference in a new issue