From f4807a3081503cc638f563ce5b47261b38509ea4 Mon Sep 17 00:00:00 2001 From: Ken Sternberg Date: Wed, 2 Aug 2023 11:37:12 -0700 Subject: [PATCH] web: a HACK for Storybook to inject the "use light theme" flag into the body. This isn't really a very good hack; what it does is say that every story is responsible for hacking its theme into the parent. This is very annoying, but it does mean that we can at least show our components in the best light. --- .../stories/ak-application-wizard.stories.ts | 23 +++++++++++++++---- web/src/elements/forms/Radio.ts | 3 ++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/web/src/admin/applications/wizard/stories/ak-application-wizard.stories.ts b/web/src/admin/applications/wizard/stories/ak-application-wizard.stories.ts index 187e4aeb3..e121bdc21 100644 --- a/web/src/admin/applications/wizard/stories/ak-application-wizard.stories.ts +++ b/web/src/admin/applications/wizard/stories/ak-application-wizard.stories.ts @@ -54,10 +54,21 @@ const metadata: Meta = { }, }; +const LIGHT = "pf-t-light"; +function injectTheme() { + setTimeout(() => { + if (!document.body.classList.contains(LIGHT)) { + document.body.classList.add(LIGHT); + } + }) +} + + export default metadata; -const container = (testItem: TemplateResult) => - html`
+const container = (testItem: TemplateResult) => { + injectTheme(); + return html`
${testItem} -
`; +
`; +} export const PageOne = () => { return container( html` - + +
`, ); @@ -82,6 +95,7 @@ export const PageTwo = () => { return container( html` +
`, ); @@ -91,6 +105,7 @@ export const PageThreeLdap = () => { return container( html` +
`, ); diff --git a/web/src/elements/forms/Radio.ts b/web/src/elements/forms/Radio.ts index 432b4ee98..ef2255d94 100644 --- a/web/src/elements/forms/Radio.ts +++ b/web/src/elements/forms/Radio.ts @@ -69,7 +69,8 @@ export class Radio extends CustomEmitterElement(AKElement) { // already set. buildChangeHandler(option: RadioOption) { return (ev: Event) => { - // This is a controlled input. Stop the native event from escaping. + // This is a controlled input. Stop the native event from escaping or affecting the + // value. We'll do that ourselves. ev.stopPropagation(); ev.preventDefault(); if (this.value === option.value) {