|
1 | 1 | import type { Meta, StoryObj } from "@storybook/web-components"; |
2 | 2 | import { html } from "lit"; |
| 3 | +import { unsafeHTML } from "lit/directives/unsafe-html.js"; |
3 | 4 |
|
4 | | -const meta = { |
5 | | - title: "Control Flow/Sequence", |
6 | | - tags: ["autodocs"], |
7 | | - render: () => html` |
8 | | - <aa-sequence name="demo-sequence" debug> |
| 5 | +const defaultSource = `<aa-session> |
| 6 | + <aa-sequence id="demo-seq" name="demo-sequence" debug> |
| 7 | + <aa-screen submit-button-hidden> |
9 | 8 | <aa-label>Step 1: Welcome</aa-label> |
| 9 | + </aa-screen> |
| 10 | + <aa-screen submit-button-hidden> |
10 | 11 | <aa-label>Step 2: Instructions</aa-label> |
| 12 | + </aa-screen> |
| 13 | + <aa-screen submit-button-hidden> |
11 | 14 | <aa-label>Step 3: Complete</aa-label> |
12 | | - </aa-sequence> |
13 | | - `, |
| 15 | + </aa-screen> |
| 16 | + </aa-sequence> |
| 17 | +</aa-session> |
| 18 | +<button onclick="document.getElementById('demo-seq').next()">Next Step</button>`; |
| 19 | + |
| 20 | +const meta = { |
| 21 | + title: "Control Flow/Sequence", |
| 22 | + tags: ["autodocs"], |
| 23 | + render: () => html`${unsafeHTML(defaultSource)}`, |
| 24 | + parameters: { |
| 25 | + docs: { |
| 26 | + source: { code: defaultSource, language: "html" }, |
| 27 | + }, |
| 28 | + }, |
14 | 29 | } satisfies Meta; |
15 | 30 |
|
16 | 31 | export default meta; |
17 | 32 | type Story = StoryObj; |
18 | 33 |
|
19 | 34 | export const Default: Story = {}; |
20 | 35 |
|
| 36 | +const withScreensSource = `<aa-session> |
| 37 | + <aa-sequence name="survey-sequence" debug> |
| 38 | + <aa-screen submit-button-text="Next"> |
| 39 | + <aa-label>Question 1</aa-label> |
| 40 | + <aa-text-answer |
| 41 | + name="q1" |
| 42 | + label="What is your name?" |
| 43 | + type="text" |
| 44 | + ></aa-text-answer> |
| 45 | + </aa-screen> |
| 46 | + <aa-screen submit-button-text="Next"> |
| 47 | + <aa-label>Question 2</aa-label> |
| 48 | + <aa-slider |
| 49 | + name="q2" |
| 50 | + min="1" |
| 51 | + max="10" |
| 52 | + min-label="Low" |
| 53 | + max-label="High" |
| 54 | + ></aa-slider> |
| 55 | + </aa-screen> |
| 56 | + <aa-screen submit-button-text="Finish"> |
| 57 | + <aa-label>Thank you!</aa-label> |
| 58 | + </aa-screen> |
| 59 | + </aa-sequence> |
| 60 | +</aa-session>`; |
| 61 | + |
21 | 62 | export const WithScreens: Story = { |
22 | | - render: () => html` |
23 | | - <aa-sequence name="survey-sequence" debug> |
24 | | - <aa-screen submit-button-text="Next"> |
25 | | - <aa-label>Question 1</aa-label> |
26 | | - <aa-text-answer name="q1" label="What is your name?" type="text"></aa-text-answer> |
27 | | - </aa-screen> |
28 | | - <aa-screen submit-button-text="Next"> |
29 | | - <aa-label>Question 2</aa-label> |
30 | | - <aa-slider name="q2" min="1" max="10" min-label="Low" max-label="High"></aa-slider> |
31 | | - </aa-screen> |
32 | | - <aa-screen submit-button-text="Finish"> |
33 | | - <aa-label>Thank you!</aa-label> |
34 | | - </aa-screen> |
35 | | - </aa-sequence> |
36 | | - `, |
| 63 | + render: () => html`${unsafeHTML(withScreensSource)}`, |
| 64 | + parameters: { |
| 65 | + docs: { |
| 66 | + source: { code: withScreensSource, language: "html" }, |
| 67 | + }, |
| 68 | + }, |
37 | 69 | }; |
0 commit comments