@pure-ds/storybook 0.3.19 → 0.4.1
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/.storybook/addons/pds-configurator/SearchTool.js +44 -44
- package/.storybook/preview.js +6 -2
- package/dist/pds-reference.json +65 -13
- package/package.json +50 -50
- package/stories/components/PdsCalendar.stories.js +266 -263
- package/stories/components/PdsDrawer.stories.js +2 -2
- package/stories/components/PdsIcon.stories.js +2 -2
- package/stories/components/PdsJsonform.stories.js +2 -2
- package/stories/components/PdsRichtext.stories.js +367 -367
- package/stories/components/PdsScrollrow.stories.js +140 -140
- package/stories/components/PdsSplitpanel.stories.js +502 -502
- package/stories/components/PdsTabstrip.stories.js +2 -2
- package/stories/components/PdsToaster.stories.js +186 -186
- package/stories/components/PdsUpload.stories.js +66 -66
- package/stories/enhancements/Dropdowns.stories.js +185 -185
- package/stories/enhancements/InteractiveStates.stories.js +625 -625
- package/stories/enhancements/MeshGradients.stories.js +321 -320
- package/stories/enhancements/OpenGroups.stories.js +227 -227
- package/stories/enhancements/RangeSliders.stories.js +232 -232
- package/stories/enhancements/RequiredFields.stories.js +189 -189
- package/stories/enhancements/Toggles.stories.js +167 -167
- package/stories/foundations/Colors.stories.js +2 -1
- package/stories/foundations/Icons.stories.js +4 -0
- package/stories/foundations/SmartSurfaces.stories.js +485 -367
- package/stories/foundations/Spacing.stories.js +5 -1
- package/stories/foundations/Typography.stories.js +4 -0
- package/stories/foundations/ZIndex.stories.js +329 -325
- package/stories/layout/LayoutOverview.stories.js +247 -0
- package/stories/layout/LayoutSystem.stories.js +852 -0
- package/stories/patterns/BorderEffects.stories.js +74 -72
- package/stories/primitives/Accordion.stories.js +5 -3
- package/stories/primitives/Alerts.stories.js +261 -46
- package/stories/primitives/Badges.stories.js +4 -0
- package/stories/primitives/Buttons.stories.js +2 -2
- package/stories/primitives/Cards.stories.js +98 -170
- package/stories/primitives/Media.stories.js +442 -203
- package/stories/primitives/Tables.stories.js +358 -232
- package/stories/utilities/Backdrop.stories.js +197 -0
- package/stories/patterns/Layout.stories.js +0 -99
- package/stories/utilities/GridSystem.stories.js +0 -208
|
@@ -1,367 +1,367 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
2
|
-
|
|
3
|
-
const docsParameters = {
|
|
4
|
-
description: {
|
|
5
|
-
component: 'Rich text editor with markdown support and formatting toolbar. Provide a #showdown import-map entry for best performance; set format="markdown" to keep submitted values as Markdown.'
|
|
6
|
-
}
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
if (typeof window !== 'undefined') {
|
|
10
|
-
import('../reference/reference-docs.js')
|
|
11
|
-
.then(({ createComponentDocsPage }) => {
|
|
12
|
-
docsParameters.page = createComponentDocsPage('pds-richtext');
|
|
13
|
-
})
|
|
14
|
-
.catch((error) => {
|
|
15
|
-
console.warn('storybook: docs page failed to load for pds-richtext', error);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const richtextStoryStyles = html`
|
|
20
|
-
<style>
|
|
21
|
-
.richtext-form {
|
|
22
|
-
max-width: 37.5rem;
|
|
23
|
-
display: grid;
|
|
24
|
-
gap: var(--spacing-4);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.richtext-form-actions {
|
|
28
|
-
display: flex;
|
|
29
|
-
gap: var(--spacing-3);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.richtext-article-shell {
|
|
33
|
-
max-width: 50rem;
|
|
34
|
-
display: grid;
|
|
35
|
-
gap: var(--spacing-3);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.richtext-article-editor {
|
|
39
|
-
min-height: 25rem;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.richtext-email-card {
|
|
43
|
-
max-width: 43.75rem;
|
|
44
|
-
display: grid;
|
|
45
|
-
gap: var(--spacing-4);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.richtext-email-form {
|
|
49
|
-
display: grid;
|
|
50
|
-
gap: var(--spacing-3);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.richtext-email-actions {
|
|
54
|
-
display: flex;
|
|
55
|
-
flex-wrap: wrap;
|
|
56
|
-
gap: var(--spacing-2);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.richtext-comment-shell {
|
|
60
|
-
max-width: 37.5rem;
|
|
61
|
-
display: grid;
|
|
62
|
-
gap: var(--spacing-4);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.richtext-comment-card {
|
|
66
|
-
margin-bottom: var(--spacing-4);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.richtext-comment-header {
|
|
70
|
-
display: flex;
|
|
71
|
-
gap: var(--spacing-3);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.richtext-comment-avatar {
|
|
75
|
-
width: 3rem;
|
|
76
|
-
height: 3rem;
|
|
77
|
-
background: var(--color-primary);
|
|
78
|
-
border-radius: 50%;
|
|
79
|
-
display: flex;
|
|
80
|
-
align-items: center;
|
|
81
|
-
justify-content: center;
|
|
82
|
-
color: var(--color-primary-contrast, #fff);
|
|
83
|
-
flex-shrink: 0;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.richtext-comment-body {
|
|
87
|
-
flex: 1;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.richtext-comment-text {
|
|
91
|
-
margin: var(--spacing-2) 0;
|
|
92
|
-
opacity: 0.9;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.richtext-comment-meta {
|
|
96
|
-
display: flex;
|
|
97
|
-
gap: var(--spacing-2);
|
|
98
|
-
font-size: 0.85rem;
|
|
99
|
-
opacity: 0.7;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.richtext-comment-meta button {
|
|
103
|
-
padding: 0;
|
|
104
|
-
font-size: 0.85rem;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.richtext-comment-editor {
|
|
108
|
-
min-height: 9.375rem;
|
|
109
|
-
margin: var(--spacing-3) 0;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.richtext-comment-actions {
|
|
113
|
-
display: flex;
|
|
114
|
-
gap: var(--spacing-2);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.richtext-comment-form {
|
|
118
|
-
display: grid;
|
|
119
|
-
gap: var(--spacing-3);
|
|
120
|
-
}
|
|
121
|
-
</style>
|
|
122
|
-
`;
|
|
123
|
-
|
|
124
|
-
const bindToastForms = (selector) => {
|
|
125
|
-
setTimeout(() => {
|
|
126
|
-
if (typeof document === 'undefined') {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
document.querySelectorAll(selector).forEach((form) => {
|
|
131
|
-
if (!(form instanceof HTMLFormElement)) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (form.dataset.toastBound === 'true') {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
form.addEventListener('submit', (event) => {
|
|
140
|
-
event.preventDefault();
|
|
141
|
-
|
|
142
|
-
if (typeof window === 'undefined' || !window.toastFormData) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const target = event.currentTarget instanceof HTMLFormElement
|
|
147
|
-
? event.currentTarget
|
|
148
|
-
: form;
|
|
149
|
-
|
|
150
|
-
window.toastFormData(new FormData(target));
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
form.dataset.toastBound = 'true';
|
|
154
|
-
});
|
|
155
|
-
}, 0);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
export default {
|
|
159
|
-
title: 'Components/Pds Richtext',
|
|
160
|
-
tags: ['autodocs'],
|
|
161
|
-
parameters: {
|
|
162
|
-
pds: {
|
|
163
|
-
tags: ['editor', 'richtext', 'forms']
|
|
164
|
-
},
|
|
165
|
-
docs: docsParameters
|
|
166
|
-
},
|
|
167
|
-
argTypes: {
|
|
168
|
-
value: {
|
|
169
|
-
control: 'text',
|
|
170
|
-
description: 'Initial HTML content'
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
export const Default = {
|
|
176
|
-
render: (args) => html`
|
|
177
|
-
${richtextStoryStyles}
|
|
178
|
-
<pds-richtext placeholder="Start typing your rich text here..."
|
|
179
|
-
value="${args.value}"
|
|
180
|
-
@input="${(e) => console.log('Content:', e.target.value)}">
|
|
181
|
-
</pds-richtext>
|
|
182
|
-
`,
|
|
183
|
-
args: {
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
// Sample rich text content
|
|
189
|
-
const htmlString = `
|
|
190
|
-
<h2>Welcome to the Rich Text Editor</h2>
|
|
191
|
-
<p>This is a <strong>rich text editor</strong> component that allows you to create and edit formatted text easily.</p>
|
|
192
|
-
<p>Use the toolbar to format your content with headings, lists, links, and more.</p>
|
|
193
|
-
`;
|
|
194
|
-
|
|
195
|
-
const markdownSample = `**Getting Started**
|
|
196
|
-
|
|
197
|
-
- Write markdown directly in the editor
|
|
198
|
-
- Try bold, italics, lists, and links
|
|
199
|
-
- Submit the form to inspect the markdown payload
|
|
200
|
-
|
|
201
|
-
> Markdown mode keeps your formatting exact`;
|
|
202
|
-
|
|
203
|
-
export const WithContent = () => html`
|
|
204
|
-
${richtextStoryStyles}
|
|
205
|
-
<pds-richtext value="${htmlString}"></pds-richtext>
|
|
206
|
-
`;
|
|
207
|
-
|
|
208
|
-
export const InForm = () => {
|
|
209
|
-
bindToastForms('.richtext-form');
|
|
210
|
-
|
|
211
|
-
return html`
|
|
212
|
-
${richtextStoryStyles}
|
|
213
|
-
<form class="richtext-form">
|
|
214
|
-
<label>
|
|
215
|
-
<span>Blog Post Content</span>
|
|
216
|
-
<pds-richtext
|
|
217
|
-
name="blog-content"
|
|
218
|
-
value="<h3>My Blog Post</h3><p>Write your content here...</p>"
|
|
219
|
-
>
|
|
220
|
-
</pds-richtext>
|
|
221
|
-
</label>
|
|
222
|
-
<div class="richtext-form-actions">
|
|
223
|
-
<button type="submit" class="btn-primary">Publish</button>
|
|
224
|
-
<button type="button" class="btn-ghost">Save Draft</button>
|
|
225
|
-
</div>
|
|
226
|
-
</form>
|
|
227
|
-
`;
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
export const ArticleContent = () => html`
|
|
231
|
-
${richtextStoryStyles}
|
|
232
|
-
<div class="richtext-article-shell">
|
|
233
|
-
<h3>Article Editor</h3>
|
|
234
|
-
<pds-richtext
|
|
235
|
-
class="richtext-article-editor"
|
|
236
|
-
value="<h2>The Future of Web Development</h2><p>Web development has evolved dramatically over the past decade. Modern frameworks and tools have made it easier than ever to build sophisticated applications.</p><h3>Key Trends</h3><ul><li><strong>Component-Based Architecture</strong> - Reusable, modular components</li><li><strong>Progressive Web Apps</strong> - Native-like experiences on the web</li><li><strong>AI Integration</strong> - Smart features powered by machine learning</li></ul><h3>Best Practices</h3><p>When building modern web applications, consider:</p><ol><li>Performance optimization</li><li>Accessibility standards</li><li>Mobile-first design</li><li>Security considerations</li></ol><blockquote><p>The web is the platform of the future, and it's more powerful than ever before.</p></blockquote><p>For more information, visit <a href='https://example.com'>our documentation</a>.</p>"
|
|
237
|
-
>
|
|
238
|
-
</pds-richtext>
|
|
239
|
-
</div>
|
|
240
|
-
`;
|
|
241
|
-
|
|
242
|
-
ArticleContent.storyName = 'Article Content';
|
|
243
|
-
|
|
244
|
-
export const EmailComposer = () => {
|
|
245
|
-
bindToastForms('.richtext-email-form');
|
|
246
|
-
|
|
247
|
-
return html`
|
|
248
|
-
${richtextStoryStyles}
|
|
249
|
-
<article class="card richtext-email-card">
|
|
250
|
-
<h3>Compose Email</h3>
|
|
251
|
-
|
|
252
|
-
<form class="richtext-email-form">
|
|
253
|
-
<label>
|
|
254
|
-
<strong>To:</strong>
|
|
255
|
-
<div class="input-icon">
|
|
256
|
-
<pds-icon icon="envelope"></pds-icon>
|
|
257
|
-
<input
|
|
258
|
-
type="email"
|
|
259
|
-
name="to"
|
|
260
|
-
placeholder="recipient@example.com"
|
|
261
|
-
required>
|
|
262
|
-
</div>
|
|
263
|
-
</label>
|
|
264
|
-
|
|
265
|
-
<label>
|
|
266
|
-
<strong>Subject:</strong>
|
|
267
|
-
<input type="text" name="subject" placeholder="Email subject" required>
|
|
268
|
-
</label>
|
|
269
|
-
|
|
270
|
-
<label>
|
|
271
|
-
<strong>Message:</strong>
|
|
272
|
-
<pds-richtext
|
|
273
|
-
name="email-body"
|
|
274
|
-
value="<p>Hello,</p><p>I hope this message finds you well.</p><p>Best regards,<br><strong>Your Name</strong></p>"
|
|
275
|
-
>
|
|
276
|
-
</pds-richtext>
|
|
277
|
-
</label>
|
|
278
|
-
|
|
279
|
-
<div class="richtext-email-actions">
|
|
280
|
-
<button type="submit" class="btn-primary">
|
|
281
|
-
<pds-icon icon="arrow-up"></pds-icon>
|
|
282
|
-
Send Email
|
|
283
|
-
</button>
|
|
284
|
-
<button type="button" class="btn-outline">
|
|
285
|
-
<pds-icon icon="upload"></pds-icon>
|
|
286
|
-
Attach File
|
|
287
|
-
</button>
|
|
288
|
-
<button type="button" class="btn-ghost">Save Draft</button>
|
|
289
|
-
</div>
|
|
290
|
-
</form>
|
|
291
|
-
</article>
|
|
292
|
-
`;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
EmailComposer.storyName = 'Email Composer';
|
|
296
|
-
|
|
297
|
-
export const CommentEditor = () => {
|
|
298
|
-
bindToastForms('.richtext-comment-form');
|
|
299
|
-
|
|
300
|
-
return html`
|
|
301
|
-
${richtextStoryStyles}
|
|
302
|
-
<div class="richtext-comment-shell">
|
|
303
|
-
<article class="card surface-elevated richtext-comment-card">
|
|
304
|
-
<div class="richtext-comment-header">
|
|
305
|
-
<div class="richtext-comment-avatar">
|
|
306
|
-
<pds-icon icon="user"></pds-icon>
|
|
307
|
-
</div>
|
|
308
|
-
<div class="richtext-comment-body">
|
|
309
|
-
<strong>John Doe</strong>
|
|
310
|
-
<p class="richtext-comment-text">This is a great article! I really enjoyed reading about the latest trends in web development. The section on component architecture was particularly insightful.</p>
|
|
311
|
-
<div class="richtext-comment-meta">
|
|
312
|
-
<span>2 hours ago</span>
|
|
313
|
-
<button class="btn-ghost">Reply</button>
|
|
314
|
-
<button class="btn-ghost">Like</button>
|
|
315
|
-
</div>
|
|
316
|
-
</div>
|
|
317
|
-
</div>
|
|
318
|
-
</article>
|
|
319
|
-
|
|
320
|
-
<article class="card">
|
|
321
|
-
<form class="richtext-comment-form">
|
|
322
|
-
<h4>Add a Comment</h4>
|
|
323
|
-
<pds-richtext
|
|
324
|
-
class="richtext-comment-editor"
|
|
325
|
-
name="comment-body"
|
|
326
|
-
value="<p>Share your thoughts...</p>"
|
|
327
|
-
>
|
|
328
|
-
</pds-richtext>
|
|
329
|
-
<div class="richtext-comment-actions">
|
|
330
|
-
<button type="submit" class="btn-primary">
|
|
331
|
-
<pds-icon icon="chat-circle"></pds-icon>
|
|
332
|
-
Post Comment
|
|
333
|
-
</button>
|
|
334
|
-
<button type="button" class="btn-outline">Cancel</button>
|
|
335
|
-
</div>
|
|
336
|
-
</form>
|
|
337
|
-
</article>
|
|
338
|
-
</div>
|
|
339
|
-
`;
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
CommentEditor.storyName = 'Comment Editor';
|
|
343
|
-
|
|
344
|
-
export const MarkdownForm = () => {
|
|
345
|
-
bindToastForms('.richtext-markdown-form');
|
|
346
|
-
|
|
347
|
-
return html`
|
|
348
|
-
${richtextStoryStyles}
|
|
349
|
-
<form class="richtext-form richtext-markdown-form">
|
|
350
|
-
<label>
|
|
351
|
-
<span>Release Notes (Markdown)</span>
|
|
352
|
-
<pds-richtext
|
|
353
|
-
name="release-notes"
|
|
354
|
-
format="markdown"
|
|
355
|
-
placeholder="Document your release highlights..."
|
|
356
|
-
value="${markdownSample}"
|
|
357
|
-
></pds-richtext>
|
|
358
|
-
</label>
|
|
359
|
-
<div class="richtext-form-actions">
|
|
360
|
-
<button type="submit" class="btn-primary">Submit Markdown</button>
|
|
361
|
-
<button type="reset" class="btn-ghost">Reset</button>
|
|
362
|
-
</div>
|
|
363
|
-
</form>
|
|
364
|
-
`;
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
MarkdownForm.storyName = 'Markdown Format';
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
|
|
3
|
+
const docsParameters = {
|
|
4
|
+
description: {
|
|
5
|
+
component: 'Rich text editor with markdown support and formatting toolbar. Provide a #showdown import-map entry for best performance; set format="markdown" to keep submitted values as Markdown.'
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
if (typeof window !== 'undefined') {
|
|
10
|
+
import('../reference/reference-docs.js')
|
|
11
|
+
.then(({ createComponentDocsPage }) => {
|
|
12
|
+
docsParameters.page = createComponentDocsPage('pds-richtext');
|
|
13
|
+
})
|
|
14
|
+
.catch((error) => {
|
|
15
|
+
console.warn('storybook: docs page failed to load for pds-richtext', error);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const richtextStoryStyles = html`
|
|
20
|
+
<style>
|
|
21
|
+
.richtext-form {
|
|
22
|
+
max-width: 37.5rem;
|
|
23
|
+
display: grid;
|
|
24
|
+
gap: var(--spacing-4);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.richtext-form-actions {
|
|
28
|
+
display: flex;
|
|
29
|
+
gap: var(--spacing-3);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.richtext-article-shell {
|
|
33
|
+
max-width: 50rem;
|
|
34
|
+
display: grid;
|
|
35
|
+
gap: var(--spacing-3);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.richtext-article-editor {
|
|
39
|
+
min-height: 25rem;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.richtext-email-card {
|
|
43
|
+
max-width: 43.75rem;
|
|
44
|
+
display: grid;
|
|
45
|
+
gap: var(--spacing-4);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.richtext-email-form {
|
|
49
|
+
display: grid;
|
|
50
|
+
gap: var(--spacing-3);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.richtext-email-actions {
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-wrap: wrap;
|
|
56
|
+
gap: var(--spacing-2);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.richtext-comment-shell {
|
|
60
|
+
max-width: 37.5rem;
|
|
61
|
+
display: grid;
|
|
62
|
+
gap: var(--spacing-4);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.richtext-comment-card {
|
|
66
|
+
margin-bottom: var(--spacing-4);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.richtext-comment-header {
|
|
70
|
+
display: flex;
|
|
71
|
+
gap: var(--spacing-3);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.richtext-comment-avatar {
|
|
75
|
+
width: 3rem;
|
|
76
|
+
height: 3rem;
|
|
77
|
+
background: var(--color-primary);
|
|
78
|
+
border-radius: 50%;
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
justify-content: center;
|
|
82
|
+
color: var(--color-primary-contrast, #fff);
|
|
83
|
+
flex-shrink: 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.richtext-comment-body {
|
|
87
|
+
flex: 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.richtext-comment-text {
|
|
91
|
+
margin: var(--spacing-2) 0;
|
|
92
|
+
opacity: 0.9;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.richtext-comment-meta {
|
|
96
|
+
display: flex;
|
|
97
|
+
gap: var(--spacing-2);
|
|
98
|
+
font-size: 0.85rem;
|
|
99
|
+
opacity: 0.7;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.richtext-comment-meta button {
|
|
103
|
+
padding: 0;
|
|
104
|
+
font-size: 0.85rem;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.richtext-comment-editor {
|
|
108
|
+
min-height: 9.375rem;
|
|
109
|
+
margin: var(--spacing-3) 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.richtext-comment-actions {
|
|
113
|
+
display: flex;
|
|
114
|
+
gap: var(--spacing-2);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.richtext-comment-form {
|
|
118
|
+
display: grid;
|
|
119
|
+
gap: var(--spacing-3);
|
|
120
|
+
}
|
|
121
|
+
</style>
|
|
122
|
+
`;
|
|
123
|
+
|
|
124
|
+
const bindToastForms = (selector) => {
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
if (typeof document === 'undefined') {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
document.querySelectorAll(selector).forEach((form) => {
|
|
131
|
+
if (!(form instanceof HTMLFormElement)) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (form.dataset.toastBound === 'true') {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
form.addEventListener('submit', (event) => {
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
|
|
142
|
+
if (typeof window === 'undefined' || !window.toastFormData) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const target = event.currentTarget instanceof HTMLFormElement
|
|
147
|
+
? event.currentTarget
|
|
148
|
+
: form;
|
|
149
|
+
|
|
150
|
+
window.toastFormData(new FormData(target));
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
form.dataset.toastBound = 'true';
|
|
154
|
+
});
|
|
155
|
+
}, 0);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export default {
|
|
159
|
+
title: 'Components/Pds Richtext',
|
|
160
|
+
tags: ['autodocs', 'richtext', 'editor', 'wysiwyg', 'text', 'content'],
|
|
161
|
+
parameters: {
|
|
162
|
+
pds: {
|
|
163
|
+
tags: ['richtext', 'editor', 'wysiwyg', 'text', 'content', 'pds-richtext', 'forms']
|
|
164
|
+
},
|
|
165
|
+
docs: docsParameters
|
|
166
|
+
},
|
|
167
|
+
argTypes: {
|
|
168
|
+
value: {
|
|
169
|
+
control: 'text',
|
|
170
|
+
description: 'Initial HTML content'
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export const Default = {
|
|
176
|
+
render: (args) => html`
|
|
177
|
+
${richtextStoryStyles}
|
|
178
|
+
<pds-richtext placeholder="Start typing your rich text here..."
|
|
179
|
+
value="${args.value}"
|
|
180
|
+
@input="${(e) => console.log('Content:', e.target.value)}">
|
|
181
|
+
</pds-richtext>
|
|
182
|
+
`,
|
|
183
|
+
args: {
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// Sample rich text content
|
|
189
|
+
const htmlString = `
|
|
190
|
+
<h2>Welcome to the Rich Text Editor</h2>
|
|
191
|
+
<p>This is a <strong>rich text editor</strong> component that allows you to create and edit formatted text easily.</p>
|
|
192
|
+
<p>Use the toolbar to format your content with headings, lists, links, and more.</p>
|
|
193
|
+
`;
|
|
194
|
+
|
|
195
|
+
const markdownSample = `**Getting Started**
|
|
196
|
+
|
|
197
|
+
- Write markdown directly in the editor
|
|
198
|
+
- Try bold, italics, lists, and links
|
|
199
|
+
- Submit the form to inspect the markdown payload
|
|
200
|
+
|
|
201
|
+
> Markdown mode keeps your formatting exact`;
|
|
202
|
+
|
|
203
|
+
export const WithContent = () => html`
|
|
204
|
+
${richtextStoryStyles}
|
|
205
|
+
<pds-richtext value="${htmlString}"></pds-richtext>
|
|
206
|
+
`;
|
|
207
|
+
|
|
208
|
+
export const InForm = () => {
|
|
209
|
+
bindToastForms('.richtext-form');
|
|
210
|
+
|
|
211
|
+
return html`
|
|
212
|
+
${richtextStoryStyles}
|
|
213
|
+
<form class="richtext-form">
|
|
214
|
+
<label>
|
|
215
|
+
<span>Blog Post Content</span>
|
|
216
|
+
<pds-richtext
|
|
217
|
+
name="blog-content"
|
|
218
|
+
value="<h3>My Blog Post</h3><p>Write your content here...</p>"
|
|
219
|
+
>
|
|
220
|
+
</pds-richtext>
|
|
221
|
+
</label>
|
|
222
|
+
<div class="richtext-form-actions">
|
|
223
|
+
<button type="submit" class="btn-primary">Publish</button>
|
|
224
|
+
<button type="button" class="btn-ghost">Save Draft</button>
|
|
225
|
+
</div>
|
|
226
|
+
</form>
|
|
227
|
+
`;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export const ArticleContent = () => html`
|
|
231
|
+
${richtextStoryStyles}
|
|
232
|
+
<div class="richtext-article-shell">
|
|
233
|
+
<h3>Article Editor</h3>
|
|
234
|
+
<pds-richtext
|
|
235
|
+
class="richtext-article-editor"
|
|
236
|
+
value="<h2>The Future of Web Development</h2><p>Web development has evolved dramatically over the past decade. Modern frameworks and tools have made it easier than ever to build sophisticated applications.</p><h3>Key Trends</h3><ul><li><strong>Component-Based Architecture</strong> - Reusable, modular components</li><li><strong>Progressive Web Apps</strong> - Native-like experiences on the web</li><li><strong>AI Integration</strong> - Smart features powered by machine learning</li></ul><h3>Best Practices</h3><p>When building modern web applications, consider:</p><ol><li>Performance optimization</li><li>Accessibility standards</li><li>Mobile-first design</li><li>Security considerations</li></ol><blockquote><p>The web is the platform of the future, and it's more powerful than ever before.</p></blockquote><p>For more information, visit <a href='https://example.com'>our documentation</a>.</p>"
|
|
237
|
+
>
|
|
238
|
+
</pds-richtext>
|
|
239
|
+
</div>
|
|
240
|
+
`;
|
|
241
|
+
|
|
242
|
+
ArticleContent.storyName = 'Article Content';
|
|
243
|
+
|
|
244
|
+
export const EmailComposer = () => {
|
|
245
|
+
bindToastForms('.richtext-email-form');
|
|
246
|
+
|
|
247
|
+
return html`
|
|
248
|
+
${richtextStoryStyles}
|
|
249
|
+
<article class="card richtext-email-card">
|
|
250
|
+
<h3>Compose Email</h3>
|
|
251
|
+
|
|
252
|
+
<form class="richtext-email-form">
|
|
253
|
+
<label>
|
|
254
|
+
<strong>To:</strong>
|
|
255
|
+
<div class="input-icon">
|
|
256
|
+
<pds-icon icon="envelope"></pds-icon>
|
|
257
|
+
<input
|
|
258
|
+
type="email"
|
|
259
|
+
name="to"
|
|
260
|
+
placeholder="recipient@example.com"
|
|
261
|
+
required>
|
|
262
|
+
</div>
|
|
263
|
+
</label>
|
|
264
|
+
|
|
265
|
+
<label>
|
|
266
|
+
<strong>Subject:</strong>
|
|
267
|
+
<input type="text" name="subject" placeholder="Email subject" required>
|
|
268
|
+
</label>
|
|
269
|
+
|
|
270
|
+
<label>
|
|
271
|
+
<strong>Message:</strong>
|
|
272
|
+
<pds-richtext
|
|
273
|
+
name="email-body"
|
|
274
|
+
value="<p>Hello,</p><p>I hope this message finds you well.</p><p>Best regards,<br><strong>Your Name</strong></p>"
|
|
275
|
+
>
|
|
276
|
+
</pds-richtext>
|
|
277
|
+
</label>
|
|
278
|
+
|
|
279
|
+
<div class="richtext-email-actions">
|
|
280
|
+
<button type="submit" class="btn-primary">
|
|
281
|
+
<pds-icon icon="arrow-up"></pds-icon>
|
|
282
|
+
Send Email
|
|
283
|
+
</button>
|
|
284
|
+
<button type="button" class="btn-outline">
|
|
285
|
+
<pds-icon icon="upload"></pds-icon>
|
|
286
|
+
Attach File
|
|
287
|
+
</button>
|
|
288
|
+
<button type="button" class="btn-ghost">Save Draft</button>
|
|
289
|
+
</div>
|
|
290
|
+
</form>
|
|
291
|
+
</article>
|
|
292
|
+
`;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
EmailComposer.storyName = 'Email Composer';
|
|
296
|
+
|
|
297
|
+
export const CommentEditor = () => {
|
|
298
|
+
bindToastForms('.richtext-comment-form');
|
|
299
|
+
|
|
300
|
+
return html`
|
|
301
|
+
${richtextStoryStyles}
|
|
302
|
+
<div class="richtext-comment-shell">
|
|
303
|
+
<article class="card surface-elevated richtext-comment-card">
|
|
304
|
+
<div class="richtext-comment-header">
|
|
305
|
+
<div class="richtext-comment-avatar">
|
|
306
|
+
<pds-icon icon="user"></pds-icon>
|
|
307
|
+
</div>
|
|
308
|
+
<div class="richtext-comment-body">
|
|
309
|
+
<strong>John Doe</strong>
|
|
310
|
+
<p class="richtext-comment-text">This is a great article! I really enjoyed reading about the latest trends in web development. The section on component architecture was particularly insightful.</p>
|
|
311
|
+
<div class="richtext-comment-meta">
|
|
312
|
+
<span>2 hours ago</span>
|
|
313
|
+
<button class="btn-ghost">Reply</button>
|
|
314
|
+
<button class="btn-ghost">Like</button>
|
|
315
|
+
</div>
|
|
316
|
+
</div>
|
|
317
|
+
</div>
|
|
318
|
+
</article>
|
|
319
|
+
|
|
320
|
+
<article class="card">
|
|
321
|
+
<form class="richtext-comment-form">
|
|
322
|
+
<h4>Add a Comment</h4>
|
|
323
|
+
<pds-richtext
|
|
324
|
+
class="richtext-comment-editor"
|
|
325
|
+
name="comment-body"
|
|
326
|
+
value="<p>Share your thoughts...</p>"
|
|
327
|
+
>
|
|
328
|
+
</pds-richtext>
|
|
329
|
+
<div class="richtext-comment-actions">
|
|
330
|
+
<button type="submit" class="btn-primary">
|
|
331
|
+
<pds-icon icon="chat-circle"></pds-icon>
|
|
332
|
+
Post Comment
|
|
333
|
+
</button>
|
|
334
|
+
<button type="button" class="btn-outline">Cancel</button>
|
|
335
|
+
</div>
|
|
336
|
+
</form>
|
|
337
|
+
</article>
|
|
338
|
+
</div>
|
|
339
|
+
`;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
CommentEditor.storyName = 'Comment Editor';
|
|
343
|
+
|
|
344
|
+
export const MarkdownForm = () => {
|
|
345
|
+
bindToastForms('.richtext-markdown-form');
|
|
346
|
+
|
|
347
|
+
return html`
|
|
348
|
+
${richtextStoryStyles}
|
|
349
|
+
<form class="richtext-form richtext-markdown-form">
|
|
350
|
+
<label>
|
|
351
|
+
<span>Release Notes (Markdown)</span>
|
|
352
|
+
<pds-richtext
|
|
353
|
+
name="release-notes"
|
|
354
|
+
format="markdown"
|
|
355
|
+
placeholder="Document your release highlights..."
|
|
356
|
+
value="${markdownSample}"
|
|
357
|
+
></pds-richtext>
|
|
358
|
+
</label>
|
|
359
|
+
<div class="richtext-form-actions">
|
|
360
|
+
<button type="submit" class="btn-primary">Submit Markdown</button>
|
|
361
|
+
<button type="reset" class="btn-ghost">Reset</button>
|
|
362
|
+
</div>
|
|
363
|
+
</form>
|
|
364
|
+
`;
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
MarkdownForm.storyName = 'Markdown Format';
|