web: updated storybook stories for the wizard, illustration how "a simple wizard" is configured in source code and tested with storybook.
This commit is contained in:
parent
965353f45d
commit
eb9247b78f
|
@ -1,48 +1,47 @@
|
||||||
import { AKElement } from "@goauthentik/elements/Base";
|
|
||||||
|
|
||||||
import { customElement } from "@lit/reactive-element/decorators/custom-element.js";
|
import { customElement } from "@lit/reactive-element/decorators/custom-element.js";
|
||||||
import { html } from "lit";
|
import { html } from "lit";
|
||||||
import { property } from "lit/decorators.js";
|
import { BackStep, CancelWizard, CloseWizard, NextStep } from "../commonWizardButtons";
|
||||||
import { ifDefined } from "lit/directives/if-defined.js";
|
import { msg } from "@lit/localize";
|
||||||
|
|
||||||
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
||||||
import PFRadio from "@patternfly/patternfly/components/Radio/radio.css";
|
import PFRadio from "@patternfly/patternfly/components/Radio/radio.css";
|
||||||
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
||||||
|
|
||||||
import "../ak-wizard-context";
|
import type { WizardStep } from "@goauthentik/components/ak-wizard-main/types";
|
||||||
import "../ak-wizard-frame";
|
import { AkWizard } from "../AkWizard";
|
||||||
import type { WizardStep } from "../types";
|
|
||||||
|
type WizardStateUpdate = {
|
||||||
|
message: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const dummySteps: WizardStep[] = [
|
||||||
|
{
|
||||||
|
label: "Test Step1",
|
||||||
|
render: () => html`<h2>This space intentionally left blank today</h2>`,
|
||||||
|
disabled: false,
|
||||||
|
buttons: [NextStep, CancelWizard],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Test Step 2",
|
||||||
|
render: () => html`<h2>This space also intentionally left blank</h2>`,
|
||||||
|
disabled: false,
|
||||||
|
buttons: [BackStep, CloseWizard],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
@customElement("ak-demo-wizard")
|
@customElement("ak-demo-wizard")
|
||||||
export class AkDemoWizard extends AKElement {
|
export class ApplicationWizard extends AkWizard<WizardStateUpdate, WizardStep> {
|
||||||
static get styles() {
|
static get styles() {
|
||||||
return [PFBase, PFButton, PFRadio];
|
return [PFBase, PFButton, PFRadio];
|
||||||
}
|
}
|
||||||
|
|
||||||
@property({ attribute: false })
|
constructor() {
|
||||||
steps: WizardStep[] = [];
|
super(msg("Open Wizard"), msg("Demo Wizard"), msg("Run the demo wizard"));
|
||||||
|
this.steps = [...dummySteps];
|
||||||
@property({ type: Boolean })
|
|
||||||
open = false;
|
|
||||||
|
|
||||||
@property()
|
|
||||||
header!: string;
|
|
||||||
|
|
||||||
@property()
|
|
||||||
description?: string;
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return html`
|
|
||||||
<ak-wizard-context .steps=${this.steps}>
|
|
||||||
<ak-wizard-frame
|
|
||||||
?open=${this.open}
|
|
||||||
header=${this.header}
|
|
||||||
canCancel
|
|
||||||
description=${ifDefined(this.description)}
|
|
||||||
>
|
|
||||||
<button slot="trigger" class="pf-c-button pf-m-primary">Show Wizard</button>
|
|
||||||
</ak-wizard-frame>
|
|
||||||
</ak-wizard-context>
|
|
||||||
`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close() {
|
||||||
|
this.frame.value!.open = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,7 @@ import "@goauthentik/elements/messages/MessageContainer";
|
||||||
import { Meta } from "@storybook/web-components";
|
import { Meta } from "@storybook/web-components";
|
||||||
|
|
||||||
import { TemplateResult, html } from "lit";
|
import { TemplateResult, html } from "lit";
|
||||||
|
import "./ak-demo-wizard";
|
||||||
import AkWizard from "../ak-wizard-frame";
|
|
||||||
import "../ak-wizard-main";
|
|
||||||
import { BackStep, CancelWizard, CloseWizard, NextStep } from "../commonWizardButtons";
|
|
||||||
import type { WizardStep } from "../types";
|
|
||||||
|
|
||||||
const metadata: Meta<AkWizard> = {
|
const metadata: Meta<AkWizard> = {
|
||||||
title: "Components / Wizard / Basic",
|
title: "Components / Wizard / Basic",
|
||||||
|
@ -36,28 +32,9 @@ const container = (testItem: TemplateResult) =>
|
||||||
${testItem}
|
${testItem}
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
const dummySteps: WizardStep[] = [
|
|
||||||
{
|
|
||||||
label: "Test Step1",
|
|
||||||
render: () => html`<h2>This space intentionally left blank today</h2>`,
|
|
||||||
disabled: false,
|
|
||||||
buttons: [NextStep, CancelWizard],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Test Step 2",
|
|
||||||
render: () => html`<h2>This space also intentionally left blank</h2>`,
|
|
||||||
disabled: false,
|
|
||||||
buttons: [BackStep, CloseWizard],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const OnePageWizard = () => {
|
export const OnePageWizard = () => {
|
||||||
return container(
|
return container(
|
||||||
html` <ak-wizard-main
|
html` <ak-demo-wizard></ak-demo-wizard>`
|
||||||
.steps=${dummySteps}
|
|
||||||
canCancel
|
|
||||||
header="The Grand Illusion"
|
|
||||||
prompt="Start the show!"
|
|
||||||
></ak-wizard-main>`,
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Reference in New Issue