From 46926d54ca3fcfd61497da77f2470e6dd2a735d8 Mon Sep 17 00:00:00 2001 From: Ken Sternberg Date: Thu, 3 Aug 2023 15:11:55 -0700 Subject: [PATCH] web: adding a storybook for the ak-toggle-group component --- .../stories/ak-toggle-group.stories.ts | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 web/src/components/stories/ak-toggle-group.stories.ts diff --git a/web/src/components/stories/ak-toggle-group.stories.ts b/web/src/components/stories/ak-toggle-group.stories.ts new file mode 100644 index 000000000..59fd1049b --- /dev/null +++ b/web/src/components/stories/ak-toggle-group.stories.ts @@ -0,0 +1,67 @@ +import "@goauthentik/elements/messages/MessageContainer"; +import { Meta } from "@storybook/web-components"; + +import { TemplateResult, html } from "lit"; + +import "../ak-toggle-group"; +import AkToggleGroup from "../ak-toggle-group"; + +const metadata: Meta = { + title: "Components / Toggle Group", + component: "ak-toggle-group", + parameters: { + docs: { + description: { + component: "A stylized toggle control", + }, + }, + }, +}; + +export default metadata; + +const LIGHT = "pf-t-light"; +function injectTheme() { + setTimeout(() => { + if (!document.body.classList.contains(LIGHT)) { + document.body.classList.add(LIGHT); + } + }); +} + +const container = (testItem: TemplateResult) => { + injectTheme(); + return html`
+ + ${testItem} +
    +
    `; +} + +const testOptions = [ + ["funky", "Option One: The Funky One"], + ["invalid", "Option Two: The Invalid One"], + ["weird", "Option Three: The Weird One"], +]; + +export const ToggleGroup = () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const displayChange = (ev: any) => { + document.getElementById( + "toggle-message-pad" + )!.innerText = `Value selected: ${ev.detail.value}`; + }; + + return container( + html` + ${testOptions.map(([key, label]) => html``)} + ` + ); +};