@reliability-design/web 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/rel-accordion/rel-accordion.stories.ts +313 -0
- package/dist/components/rel-accordion/rel-accordion.ts +114 -0
- package/dist/components/rel-alert/rel-alert.stories.ts +412 -0
- package/dist/components/rel-alert/rel-alert.ts +194 -0
- package/dist/components/rel-avatar/rel-avatar.stories.ts +327 -0
- package/dist/components/rel-avatar/rel-avatar.ts +100 -0
- package/dist/components/rel-badge/rel-badge.stories.ts +350 -0
- package/dist/components/rel-badge/rel-badge.ts +70 -0
- package/dist/components/rel-breadcrumb/rel-breadcrumb.stories.ts +306 -0
- package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +97 -0
- package/dist/components/rel-button/rel-button.stories.ts +356 -0
- package/dist/components/rel-button/rel-button.ts +204 -0
- package/dist/components/rel-card/rel-card.stories.ts +299 -0
- package/dist/components/rel-card/rel-card.ts +33 -0
- package/dist/components/rel-cardmedia/rel-cardmedia.stories.ts +368 -0
- package/dist/components/rel-cardmedia/rel-cardmedia.ts +80 -0
- package/dist/components/rel-checkbox/rel-checkbox.stories.ts +414 -0
- package/dist/components/rel-checkbox/rel-checkbox.ts +164 -0
- package/dist/components/rel-chip/rel-chip.stories.ts +552 -0
- package/dist/components/rel-chip/rel-chip.ts +261 -0
- package/dist/components/rel-container/rel-container.stories.ts +239 -0
- package/dist/components/rel-container/rel-container.ts +74 -0
- package/dist/components/rel-divider/rel-divider.stories.ts +229 -0
- package/dist/components/rel-divider/rel-divider.ts +44 -0
- package/dist/components/rel-layout/rel-layout.stories.ts +713 -0
- package/dist/components/rel-layout/rel-layout.ts +60 -0
- package/dist/components/rel-menu/rel-menu.stories.ts +910 -0
- package/dist/components/rel-menu/rel-menu.ts +319 -0
- package/dist/components/rel-progress/rel-progress.stories.ts +817 -0
- package/dist/components/rel-progress/rel-progress.ts +182 -0
- package/dist/components/rel-radio/rel-radio.stories.ts +1048 -0
- package/dist/components/rel-radio/rel-radio.ts +187 -0
- package/dist/components/rel-segmented-button/rel-segmented-button.stories.ts +1079 -0
- package/dist/components/rel-segmented-button/rel-segmented-button.ts +150 -0
- package/dist/components/rel-select/rel-select.stories.ts +1201 -0
- package/dist/components/rel-select/rel-select.ts +261 -0
- package/dist/components/rel-slider/rel-slider.stories.ts +730 -0
- package/dist/components/rel-slider/rel-slider.ts +440 -0
- package/dist/components/rel-snackbar/rel-snackbar.stories.ts +808 -0
- package/dist/components/rel-snackbar/rel-snackbar.ts +212 -0
- package/dist/components/rel-stepper/rel-stepper.stories.ts +752 -0
- package/dist/components/rel-stepper/rel-stepper.ts +425 -0
- package/dist/components/rel-switch/rel-switch.stories.ts +441 -0
- package/dist/components/rel-switch/rel-switch.ts +161 -0
- package/dist/components/rel-tab/rel-tab.stories.ts +492 -0
- package/dist/components/rel-tab/rel-tab.ts +145 -0
- package/dist/components/rel-textfield/rel-textfield.stories.ts +710 -0
- package/dist/components/rel-textfield/rel-textfield.ts +224 -0
- package/dist/components/rel-toast/rel-toast.stories.ts +394 -0
- package/dist/components/rel-toast/rel-toast.ts +154 -0
- package/dist/components/rel-tooltip/rel-tooltip.stories.ts +364 -0
- package/dist/components/rel-tooltip/rel-tooltip.ts +80 -0
- package/dist/index.d.mts +372 -0
- package/dist/index.d.ts +372 -0
- package/dist/index.js +4593 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4544 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles/vars.css +184 -0
- package/package.json +32 -0
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components-vite';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import './rel-checkbox';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The Checkbox component allows users to select one or more options from a set.
|
|
7
|
+
* Built with Lit web components for framework-agnostic usage.
|
|
8
|
+
*
|
|
9
|
+
* ## Features
|
|
10
|
+
* - **3 States**: default, error, disabled
|
|
11
|
+
* - **3 Status Options**: unchecked, checked, indeterminate
|
|
12
|
+
* - **Label Support**: Required label text
|
|
13
|
+
* - **Supporting Text**: Optional helper text below label
|
|
14
|
+
* - **Custom Icons**: Check and indeterminate visual indicators
|
|
15
|
+
* - **Interactive Toggle**: Cycles through unchecked → checked → indeterminate
|
|
16
|
+
* - **Accessible**: Focus ring and keyboard support
|
|
17
|
+
*/
|
|
18
|
+
const meta: Meta = {
|
|
19
|
+
title: 'Components/Checkbox',
|
|
20
|
+
tags: ['autodocs'],
|
|
21
|
+
component: 'rel-checkbox',
|
|
22
|
+
argTypes: {
|
|
23
|
+
label: {
|
|
24
|
+
control: 'text',
|
|
25
|
+
description: 'Checkbox label text',
|
|
26
|
+
table: {
|
|
27
|
+
defaultValue: { summary: 'Label' },
|
|
28
|
+
type: { summary: 'string' },
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
supportingtext: {
|
|
32
|
+
control: 'text',
|
|
33
|
+
description: 'Optional supporting text below label',
|
|
34
|
+
table: {
|
|
35
|
+
type: { summary: 'string' },
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
state: {
|
|
39
|
+
control: { type: 'select' },
|
|
40
|
+
options: ['default', 'error', 'disabled'],
|
|
41
|
+
description: 'Checkbox state',
|
|
42
|
+
table: {
|
|
43
|
+
defaultValue: { summary: 'default' },
|
|
44
|
+
type: { summary: 'string' },
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
status: {
|
|
48
|
+
control: { type: 'select' },
|
|
49
|
+
options: ['unchecked', 'checked', 'indeterminate'],
|
|
50
|
+
description: 'Checkbox status',
|
|
51
|
+
table: {
|
|
52
|
+
defaultValue: { summary: 'unchecked' },
|
|
53
|
+
type: { summary: 'string' },
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
render: (args) => html`
|
|
58
|
+
<rel-checkbox
|
|
59
|
+
label="${args.label || 'Label'}"
|
|
60
|
+
supportingtext="${args.supportingtext || ''}"
|
|
61
|
+
state="${args.state || 'default'}"
|
|
62
|
+
status="${args.status || 'unchecked'}"
|
|
63
|
+
></rel-checkbox>
|
|
64
|
+
`,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default meta;
|
|
68
|
+
type Story = StoryObj;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Unchecked - default unchecked state
|
|
72
|
+
*/
|
|
73
|
+
export const Unchecked: Story = {
|
|
74
|
+
args: {
|
|
75
|
+
label: 'Accept terms and conditions',
|
|
76
|
+
state: 'default',
|
|
77
|
+
status: 'unchecked',
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Checked - selected checkbox
|
|
83
|
+
*/
|
|
84
|
+
export const Checked: Story = {
|
|
85
|
+
args: {
|
|
86
|
+
label: 'Subscribe to newsletter',
|
|
87
|
+
state: 'default',
|
|
88
|
+
status: 'checked',
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Indeterminate - partial selection state
|
|
94
|
+
*/
|
|
95
|
+
export const Indeterminate: Story = {
|
|
96
|
+
args: {
|
|
97
|
+
label: 'Select all items',
|
|
98
|
+
supportingtext: 'Some items are selected',
|
|
99
|
+
state: 'default',
|
|
100
|
+
status: 'indeterminate',
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* With supporting text
|
|
106
|
+
*/
|
|
107
|
+
export const WithSupportingText: Story = {
|
|
108
|
+
args: {
|
|
109
|
+
label: 'Enable notifications',
|
|
110
|
+
supportingtext: 'Receive updates about your account activity',
|
|
111
|
+
state: 'default',
|
|
112
|
+
status: 'unchecked',
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Error state - unchecked
|
|
118
|
+
*/
|
|
119
|
+
export const ErrorUnchecked: Story = {
|
|
120
|
+
args: {
|
|
121
|
+
label: 'I agree to the terms',
|
|
122
|
+
supportingtext: 'You must accept the terms to continue',
|
|
123
|
+
state: 'error',
|
|
124
|
+
status: 'unchecked',
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Error state - checked
|
|
130
|
+
*/
|
|
131
|
+
export const ErrorChecked: Story = {
|
|
132
|
+
args: {
|
|
133
|
+
label: 'Send promotional emails',
|
|
134
|
+
supportingtext: 'This option conflicts with your privacy settings',
|
|
135
|
+
state: 'error',
|
|
136
|
+
status: 'checked',
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Disabled - unchecked
|
|
142
|
+
*/
|
|
143
|
+
export const DisabledUnchecked: Story = {
|
|
144
|
+
args: {
|
|
145
|
+
label: 'Premium features',
|
|
146
|
+
supportingtext: 'Upgrade to enable this option',
|
|
147
|
+
state: 'disabled',
|
|
148
|
+
status: 'unchecked',
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Disabled - checked
|
|
154
|
+
*/
|
|
155
|
+
export const DisabledChecked: Story = {
|
|
156
|
+
args: {
|
|
157
|
+
label: 'Two-factor authentication',
|
|
158
|
+
supportingtext: 'Required by your organization',
|
|
159
|
+
state: 'disabled',
|
|
160
|
+
status: 'checked',
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* All states - showcase of all checkbox states
|
|
166
|
+
*/
|
|
167
|
+
export const AllStates: Story = {
|
|
168
|
+
render: () => html`
|
|
169
|
+
<div style="display: flex; flex-direction: column; gap: 24px; padding: 24px; background: #f5f5f5;">
|
|
170
|
+
<div>
|
|
171
|
+
<h3 style="margin: 0 0 12px 0; color: #000;">Default State</h3>
|
|
172
|
+
<div style="display: flex; flex-direction: column; gap: 12px;">
|
|
173
|
+
<rel-checkbox label="Unchecked" state="default" status="unchecked"></rel-checkbox>
|
|
174
|
+
<rel-checkbox label="Checked" state="default" status="checked"></rel-checkbox>
|
|
175
|
+
<rel-checkbox label="Indeterminate" state="default" status="indeterminate"></rel-checkbox>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<div>
|
|
180
|
+
<h3 style="margin: 0 0 12px 0; color: #000;">Error State</h3>
|
|
181
|
+
<div style="display: flex; flex-direction: column; gap: 12px;">
|
|
182
|
+
<rel-checkbox label="Unchecked" state="error" status="unchecked" supportingtext="Error message"></rel-checkbox>
|
|
183
|
+
<rel-checkbox label="Checked" state="error" status="checked" supportingtext="Error message"></rel-checkbox>
|
|
184
|
+
<rel-checkbox label="Indeterminate" state="error" status="indeterminate" supportingtext="Error message"></rel-checkbox>
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
|
|
188
|
+
<div>
|
|
189
|
+
<h3 style="margin: 0 0 12px 0; color: #000;">Disabled State</h3>
|
|
190
|
+
<div style="display: flex; flex-direction: column; gap: 12px;">
|
|
191
|
+
<rel-checkbox label="Unchecked" state="disabled" status="unchecked"></rel-checkbox>
|
|
192
|
+
<rel-checkbox label="Checked" state="disabled" status="checked"></rel-checkbox>
|
|
193
|
+
<rel-checkbox label="Indeterminate" state="disabled" status="indeterminate"></rel-checkbox>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
`,
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Settings form - checkboxes in settings context
|
|
202
|
+
*/
|
|
203
|
+
export const SettingsForm: Story = {
|
|
204
|
+
render: () => html`
|
|
205
|
+
<div style="max-width: 600px; padding: 24px; background: #fff; border-radius: 8px;">
|
|
206
|
+
<h2 style="margin: 0 0 16px 0; color: #000;">Notification Settings</h2>
|
|
207
|
+
<div style="display: flex; flex-direction: column; gap: 16px;">
|
|
208
|
+
<rel-checkbox
|
|
209
|
+
label="Email notifications"
|
|
210
|
+
supportingtext="Receive updates and alerts via email"
|
|
211
|
+
status="checked"
|
|
212
|
+
></rel-checkbox>
|
|
213
|
+
|
|
214
|
+
<rel-checkbox
|
|
215
|
+
label="Push notifications"
|
|
216
|
+
supportingtext="Get instant notifications on your device"
|
|
217
|
+
status="checked"
|
|
218
|
+
></rel-checkbox>
|
|
219
|
+
|
|
220
|
+
<rel-checkbox
|
|
221
|
+
label="SMS notifications"
|
|
222
|
+
supportingtext="Receive text messages for important updates"
|
|
223
|
+
status="unchecked"
|
|
224
|
+
></rel-checkbox>
|
|
225
|
+
|
|
226
|
+
<rel-checkbox
|
|
227
|
+
label="Marketing emails"
|
|
228
|
+
supportingtext="Get tips, offers, and product updates"
|
|
229
|
+
status="unchecked"
|
|
230
|
+
></rel-checkbox>
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
`,
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Agreement form - terms acceptance
|
|
238
|
+
*/
|
|
239
|
+
export const AgreementForm: Story = {
|
|
240
|
+
render: () => html`
|
|
241
|
+
<div style="max-width: 600px; padding: 24px; background: #fff; border-radius: 8px;">
|
|
242
|
+
<h2 style="margin: 0 0 16px 0; color: #000;">Create Account</h2>
|
|
243
|
+
<div style="display: flex; flex-direction: column; gap: 16px;">
|
|
244
|
+
<rel-checkbox
|
|
245
|
+
label="I accept the Terms of Service"
|
|
246
|
+
supportingtext="Required to create an account"
|
|
247
|
+
state="error"
|
|
248
|
+
status="unchecked"
|
|
249
|
+
></rel-checkbox>
|
|
250
|
+
|
|
251
|
+
<rel-checkbox
|
|
252
|
+
label="I accept the Privacy Policy"
|
|
253
|
+
supportingtext="Required to create an account"
|
|
254
|
+
state="error"
|
|
255
|
+
status="unchecked"
|
|
256
|
+
></rel-checkbox>
|
|
257
|
+
|
|
258
|
+
<rel-checkbox
|
|
259
|
+
label="Subscribe to our newsletter"
|
|
260
|
+
supportingtext="Optional - Get updates about new features"
|
|
261
|
+
status="unchecked"
|
|
262
|
+
></rel-checkbox>
|
|
263
|
+
</div>
|
|
264
|
+
<button style="margin-top: 24px; width: 100%; background: #ddd; border: none; color: #999; padding: 12px; border-radius: 8px; cursor: not-allowed; font-weight: 600;">
|
|
265
|
+
Create Account
|
|
266
|
+
</button>
|
|
267
|
+
</div>
|
|
268
|
+
`,
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Select all - indeterminate state usage
|
|
273
|
+
*/
|
|
274
|
+
export const SelectAllExample: Story = {
|
|
275
|
+
render: () => html`
|
|
276
|
+
<div style="max-width: 600px; padding: 24px; background: #fff; border-radius: 8px;">
|
|
277
|
+
<h2 style="margin: 0 0 16px 0; color: #000;">Manage Files</h2>
|
|
278
|
+
<div style="display: flex; flex-direction: column; gap: 12px;">
|
|
279
|
+
<rel-checkbox
|
|
280
|
+
label="Select all"
|
|
281
|
+
status="indeterminate"
|
|
282
|
+
style="border-bottom: 1px solid #ddd; padding-bottom: 12px;"
|
|
283
|
+
></rel-checkbox>
|
|
284
|
+
|
|
285
|
+
<div style="padding-left: 24px; display: flex; flex-direction: column; gap: 12px;">
|
|
286
|
+
<rel-checkbox label="document.pdf" status="checked"></rel-checkbox>
|
|
287
|
+
<rel-checkbox label="presentation.pptx" status="checked"></rel-checkbox>
|
|
288
|
+
<rel-checkbox label="spreadsheet.xlsx" status="unchecked"></rel-checkbox>
|
|
289
|
+
<rel-checkbox label="image.jpg" status="unchecked"></rel-checkbox>
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
`,
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Preferences panel
|
|
298
|
+
*/
|
|
299
|
+
export const PreferencesPanel: Story = {
|
|
300
|
+
render: () => html`
|
|
301
|
+
<div style="max-width: 600px; padding: 24px; background: #fff; border-radius: 8px;">
|
|
302
|
+
<h2 style="margin: 0 0 8px 0; color: #000;">Display Preferences</h2>
|
|
303
|
+
<p style="margin: 0 0 24px 0; color: #666; font-size: 14px;">
|
|
304
|
+
Customize how you view content
|
|
305
|
+
</p>
|
|
306
|
+
|
|
307
|
+
<div style="display: flex; flex-direction: column; gap: 20px;">
|
|
308
|
+
<div>
|
|
309
|
+
<h3 style="margin: 0 0 12px 0; font-size: 16px; color: #000;">Layout</h3>
|
|
310
|
+
<div style="display: flex; flex-direction: column; gap: 12px;">
|
|
311
|
+
<rel-checkbox label="Show sidebar" status="checked"></rel-checkbox>
|
|
312
|
+
<rel-checkbox label="Compact mode" status="unchecked"></rel-checkbox>
|
|
313
|
+
<rel-checkbox label="Show thumbnails" status="checked"></rel-checkbox>
|
|
314
|
+
</div>
|
|
315
|
+
</div>
|
|
316
|
+
|
|
317
|
+
<div>
|
|
318
|
+
<h3 style="margin: 0 0 12px 0; font-size: 16px; color: #000;">Content</h3>
|
|
319
|
+
<div style="display: flex; flex-direction: column; gap: 12px;">
|
|
320
|
+
<rel-checkbox label="Auto-play videos" status="unchecked"></rel-checkbox>
|
|
321
|
+
<rel-checkbox label="Show captions" status="checked"></rel-checkbox>
|
|
322
|
+
<rel-checkbox label="High quality images" status="checked"></rel-checkbox>
|
|
323
|
+
</div>
|
|
324
|
+
</div>
|
|
325
|
+
</div>
|
|
326
|
+
</div>
|
|
327
|
+
`,
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Features list - disabled options
|
|
332
|
+
*/
|
|
333
|
+
export const FeaturesList: Story = {
|
|
334
|
+
render: () => html`
|
|
335
|
+
<div style="max-width: 600px; padding: 24px; background: #fff; border-radius: 8px;">
|
|
336
|
+
<h2 style="margin: 0 0 8px 0; color: #000;">Your Plan Features</h2>
|
|
337
|
+
<p style="margin: 0 0 24px 0; color: #666; font-size: 14px;">
|
|
338
|
+
Free Plan - Upgrade to unlock more features
|
|
339
|
+
</p>
|
|
340
|
+
|
|
341
|
+
<div style="display: flex; flex-direction: column; gap: 12px;">
|
|
342
|
+
<rel-checkbox
|
|
343
|
+
label="Basic dashboard"
|
|
344
|
+
supportingtext="View your stats and analytics"
|
|
345
|
+
state="disabled"
|
|
346
|
+
status="checked"
|
|
347
|
+
></rel-checkbox>
|
|
348
|
+
|
|
349
|
+
<rel-checkbox
|
|
350
|
+
label="5 projects"
|
|
351
|
+
supportingtext="Manage up to 5 projects"
|
|
352
|
+
state="disabled"
|
|
353
|
+
status="checked"
|
|
354
|
+
></rel-checkbox>
|
|
355
|
+
|
|
356
|
+
<rel-checkbox
|
|
357
|
+
label="Unlimited projects"
|
|
358
|
+
supportingtext="Upgrade to Pro for unlimited projects"
|
|
359
|
+
state="disabled"
|
|
360
|
+
status="unchecked"
|
|
361
|
+
></rel-checkbox>
|
|
362
|
+
|
|
363
|
+
<rel-checkbox
|
|
364
|
+
label="Advanced analytics"
|
|
365
|
+
supportingtext="Upgrade to Pro for detailed insights"
|
|
366
|
+
state="disabled"
|
|
367
|
+
status="unchecked"
|
|
368
|
+
></rel-checkbox>
|
|
369
|
+
|
|
370
|
+
<rel-checkbox
|
|
371
|
+
label="Priority support"
|
|
372
|
+
supportingtext="Upgrade to Pro for 24/7 support"
|
|
373
|
+
state="disabled"
|
|
374
|
+
status="unchecked"
|
|
375
|
+
></rel-checkbox>
|
|
376
|
+
</div>
|
|
377
|
+
|
|
378
|
+
<button style="margin-top: 24px; width: 100%; background: #00F49C; border: none; color: #000; padding: 12px; border-radius: 8px; cursor: pointer; font-weight: 600;">
|
|
379
|
+
Upgrade to Pro
|
|
380
|
+
</button>
|
|
381
|
+
</div>
|
|
382
|
+
`,
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Permission settings
|
|
387
|
+
*/
|
|
388
|
+
export const PermissionSettings: Story = {
|
|
389
|
+
render: () => html`
|
|
390
|
+
<div style="max-width: 600px; padding: 24px; background: #fff; border-radius: 8px;">
|
|
391
|
+
<h2 style="margin: 0 0 16px 0; color: #000;">User Permissions</h2>
|
|
392
|
+
<div style="display: flex; flex-direction: column; gap: 16px;">
|
|
393
|
+
<div>
|
|
394
|
+
<h3 style="margin: 0 0 12px 0; font-size: 16px; color: #000;">Content</h3>
|
|
395
|
+
<div style="display: flex; flex-direction: column; gap: 12px;">
|
|
396
|
+
<rel-checkbox label="Can view content" state="disabled" status="checked"></rel-checkbox>
|
|
397
|
+
<rel-checkbox label="Can create content" status="checked"></rel-checkbox>
|
|
398
|
+
<rel-checkbox label="Can edit content" status="checked"></rel-checkbox>
|
|
399
|
+
<rel-checkbox label="Can delete content" status="unchecked"></rel-checkbox>
|
|
400
|
+
</div>
|
|
401
|
+
</div>
|
|
402
|
+
|
|
403
|
+
<div>
|
|
404
|
+
<h3 style="margin: 0 0 12px 0; font-size: 16px; color: #000;">Users</h3>
|
|
405
|
+
<div style="display: flex; flex-direction: column; gap: 12px;">
|
|
406
|
+
<rel-checkbox label="Can view users" status="checked"></rel-checkbox>
|
|
407
|
+
<rel-checkbox label="Can invite users" status="unchecked"></rel-checkbox>
|
|
408
|
+
<rel-checkbox label="Can manage users" status="unchecked"></rel-checkbox>
|
|
409
|
+
</div>
|
|
410
|
+
</div>
|
|
411
|
+
</div>
|
|
412
|
+
</div>
|
|
413
|
+
`,
|
|
414
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { LitElement, html, css } from "lit";
|
|
2
|
+
import { customElement, property } from "lit/decorators.js";
|
|
3
|
+
|
|
4
|
+
type CheckboxState = "default" | "error" | "disabled";
|
|
5
|
+
type CheckboxStatus = "unchecked" | "checked" | "indeterminate";
|
|
6
|
+
|
|
7
|
+
@customElement("rel-checkbox")
|
|
8
|
+
export class RelCheckbox extends LitElement {
|
|
9
|
+
@property({ type: String }) label = "Label";
|
|
10
|
+
@property({ type: String }) supportingtext = "";
|
|
11
|
+
@property({ type: String }) state: CheckboxState = "default";
|
|
12
|
+
@property({ type: String }) status: CheckboxStatus = "unchecked";
|
|
13
|
+
|
|
14
|
+
static styles = css`
|
|
15
|
+
:host {
|
|
16
|
+
display: block;
|
|
17
|
+
font-family: var(--rel-fontFamilies-primary);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.wrapper {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
gap: 4px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.row {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
gap: 10px;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
input {
|
|
34
|
+
position: absolute;
|
|
35
|
+
opacity: 0;
|
|
36
|
+
pointer-events: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.box {
|
|
40
|
+
width: 18px;
|
|
41
|
+
height: 18px;
|
|
42
|
+
border-radius: 4px;
|
|
43
|
+
border: 2px solid var(--rel-colors-gray-heading);
|
|
44
|
+
background: var(--rel-colors-white);
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
transition: all 0.2s;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* ICONS FIXED SIZE */
|
|
52
|
+
svg {
|
|
53
|
+
width: 12px;
|
|
54
|
+
height: 12px;
|
|
55
|
+
display: none;
|
|
56
|
+
pointer-events: none;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* CHECKED */
|
|
60
|
+
.checked .box {
|
|
61
|
+
background: var(--rel-colors-gray-heading);
|
|
62
|
+
border-color: var(--rel-colors-gray-heading);
|
|
63
|
+
}
|
|
64
|
+
.checked .check-icon {
|
|
65
|
+
display: block;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* INDETERMINATE */
|
|
69
|
+
.indeterminate .box {
|
|
70
|
+
background: var(--rel-colors-gray-heading);
|
|
71
|
+
border-color: var(--rel-colors-gray-heading);
|
|
72
|
+
}
|
|
73
|
+
.indeterminate .indeterminate-icon {
|
|
74
|
+
display: block;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* ERROR */
|
|
78
|
+
.error .box {
|
|
79
|
+
border-color: var(--rel-colors-red-primary);
|
|
80
|
+
}
|
|
81
|
+
.error.checked .box,
|
|
82
|
+
.error.indeterminate .box {
|
|
83
|
+
background: var(--rel-colors-red-primary);
|
|
84
|
+
border-color: var(--rel-colors-red-primary);
|
|
85
|
+
}
|
|
86
|
+
.error .label,
|
|
87
|
+
.error .text {
|
|
88
|
+
color: var(--rel-colors-red-primary);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* DISABLED */
|
|
92
|
+
.disabled {
|
|
93
|
+
opacity: 0.55;
|
|
94
|
+
cursor: not-allowed !important;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.label {
|
|
98
|
+
font-size: var(--rel-fontSizes-md);
|
|
99
|
+
color: var(--rel-colors-gray-heading);
|
|
100
|
+
font-weight: var(--rel-fontWeights-medium);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.text {
|
|
104
|
+
font-size: var(--rel-fontSizes-sm);
|
|
105
|
+
color: var(--rel-colors-gray-text);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* Focus ring */
|
|
109
|
+
input:focus-visible + .box {
|
|
110
|
+
outline: 2px solid var(--rel-colors-blue-primary);
|
|
111
|
+
outline-offset: 2px;
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
|
|
115
|
+
private toggle() {
|
|
116
|
+
if (this.state === "disabled") return;
|
|
117
|
+
|
|
118
|
+
if (this.status === "unchecked") this.status = "checked";
|
|
119
|
+
else if (this.status === "checked") this.status = "indeterminate";
|
|
120
|
+
else this.status = "unchecked";
|
|
121
|
+
|
|
122
|
+
this.dispatchEvent(new CustomEvent("changed", { detail: this.status }));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
render() {
|
|
126
|
+
const className = `
|
|
127
|
+
wrapper
|
|
128
|
+
${this.state}
|
|
129
|
+
${this.status}
|
|
130
|
+
`;
|
|
131
|
+
|
|
132
|
+
return html`
|
|
133
|
+
<div class="${className}">
|
|
134
|
+
<label class="row">
|
|
135
|
+
<input
|
|
136
|
+
type="checkbox"
|
|
137
|
+
@change=${this.toggle}
|
|
138
|
+
?disabled=${this.state === "disabled"}
|
|
139
|
+
/>
|
|
140
|
+
|
|
141
|
+
<span class="box">
|
|
142
|
+
<!-- CHECK ICON -->
|
|
143
|
+
<svg class="check-icon" viewBox="0 0 18 14" fill="white">
|
|
144
|
+
<path
|
|
145
|
+
d="M6.44479 14L0.5 7.36383L1.9862 5.70478L6.44479 10.6819L16.0138 0L17.5 1.65904L6.44479 14Z"
|
|
146
|
+
/>
|
|
147
|
+
</svg>
|
|
148
|
+
|
|
149
|
+
<!-- INDETERMINATE ICON -->
|
|
150
|
+
<svg class="indeterminate-icon" viewBox="0 0 16 2" fill="white">
|
|
151
|
+
<rect width="16" height="2" />
|
|
152
|
+
</svg>
|
|
153
|
+
</span>
|
|
154
|
+
|
|
155
|
+
<span class="label">${this.label}</span>
|
|
156
|
+
</label>
|
|
157
|
+
|
|
158
|
+
${this.supportingtext
|
|
159
|
+
? html`<span class="text">${this.supportingtext}</span>`
|
|
160
|
+
: null}
|
|
161
|
+
</div>
|
|
162
|
+
`;
|
|
163
|
+
}
|
|
164
|
+
}
|