1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-disable import/no-unassigned-import */
import { html, ifDefined } from "../vendor/lit.all.mjs";
import "./moz-toggle.mjs";
import "../moz-support-link/moz-support-link.mjs";
export default {
title: "UI Widgets/Toggle",
component: "moz-toggle",
parameters: {
status: "in-development",
actions: {
handles: ["toggle"],
},
fluent: `
moz-toggle-aria-label =
.aria-label = This is the aria-label
moz-toggle-label =
.label = This is the label
moz-toggle-description =
.label = This is the label
.description = This is the description.
`,
},
};
const Template = ({
pressed,
disabled,
label,
description,
ariaLabel,
l10nId,
hasSupportLink,
accessKey,
}) => html`
<div style="max-width: 400px">
<moz-toggle
?pressed=${pressed}
?disabled=${disabled}
label=${ifDefined(label)}
description=${ifDefined(description)}
aria-label=${ifDefined(ariaLabel)}
data-l10n-id=${ifDefined(l10nId)}
data-l10n-attrs="aria-label, description, label"
accesskey=${ifDefined(accessKey)}
>
${hasSupportLink
? html`
<a
is="moz-support-link"
support-page="addons"
slot="support-link"
></a>
`
: ""}
</moz-toggle>
</div>
`;
export const Toggle = Template.bind({});
Toggle.args = {
pressed: true,
disabled: false,
l10nId: "moz-toggle-aria-label",
};
export const ToggleDisabled = Template.bind({});
ToggleDisabled.args = {
...Toggle.args,
disabled: true,
};
export const WithLabel = Template.bind({});
WithLabel.args = {
pressed: true,
disabled: false,
l10nId: "moz-toggle-label",
hasSupportLink: false,
accessKey: "h",
};
export const WithDescription = Template.bind({});
WithDescription.args = {
...WithLabel.args,
l10nId: "moz-toggle-description",
};
export const WithSupportLink = Template.bind({});
WithSupportLink.args = {
...WithDescription.args,
hasSupportLink: true,
};
|