@amedia/brick-mcp 0.0.2 → 0.1.0

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.
Files changed (48) hide show
  1. package/data/components-metadata.json +28 -28
  2. package/data/tokens-documentation.json +1 -1
  3. package/data/tokens.json +4848 -128
  4. package/dist/data/components/brick-actions.md +59 -0
  5. package/dist/data/components/brick-alt-teaser.md +264 -0
  6. package/dist/data/components/brick-avatar.md +299 -0
  7. package/dist/data/components/brick-button.md +373 -0
  8. package/dist/data/components/brick-card.md +359 -0
  9. package/dist/data/components/brick-carousel.md +355 -0
  10. package/dist/data/components/brick-classnames.md +147 -0
  11. package/dist/data/components/brick-countdown.md +180 -0
  12. package/dist/data/components/brick-dialog.md +458 -0
  13. package/dist/data/components/brick-fonts.md +389 -0
  14. package/dist/data/components/brick-helloworld.md +228 -0
  15. package/dist/data/components/brick-icon.md +274 -0
  16. package/dist/data/components/brick-icons.md +570 -0
  17. package/dist/data/components/brick-illustrations.md +604 -0
  18. package/dist/data/components/brick-image.md +361 -0
  19. package/dist/data/components/brick-input.md +557 -0
  20. package/dist/data/components/brick-mcp.json +6 -0
  21. package/dist/data/components/brick-nifs.md +164 -0
  22. package/dist/data/components/brick-pill.json +6 -0
  23. package/dist/data/components/brick-player.json +7 -0
  24. package/dist/data/components/brick-published.json +7 -0
  25. package/dist/data/components/brick-share.json +7 -0
  26. package/dist/data/components/brick-stepper.json +7 -0
  27. package/dist/data/components/brick-tab.json +7 -0
  28. package/dist/data/components/brick-tabs.json +9 -0
  29. package/dist/data/components/brick-tag.json +7 -0
  30. package/dist/data/components/brick-teaser-player.json +9 -0
  31. package/dist/data/components/brick-teaser-reels.json +9 -0
  32. package/dist/data/components/brick-teaser.json +9 -0
  33. package/dist/data/components/brick-template.json +9 -0
  34. package/dist/data/components/brick-textarea.json +7 -0
  35. package/dist/data/components/brick-themes.json +6 -0
  36. package/dist/data/components/brick-toast.json +9 -0
  37. package/dist/data/components/brick-toggle.json +7 -0
  38. package/dist/data/components/brick-tokens.json +8 -0
  39. package/dist/data/components/brick-tooltip.json +7 -0
  40. package/dist/data/components-metadata.json +228 -0
  41. package/dist/data/tokens-documentation.json +7 -0
  42. package/dist/data/tokens.json +4976 -0
  43. package/dist/http.js +314 -0
  44. package/dist/http.js.map +7 -0
  45. package/dist/index.js +26 -37
  46. package/dist/index.js.map +2 -2
  47. package/package.json +1 -1
  48. package/scripts/generate-data.js +15 -47
@@ -0,0 +1,458 @@
1
+ ---
2
+ name: brick-dialog
3
+ version: 2.0.13
4
+ selector: brick-dialog-v2
5
+ category: Feedback
6
+ tags:
7
+ [
8
+ dialog,
9
+ modal,
10
+ overlay,
11
+ popup,
12
+ user-interaction,
13
+ focus-management,
14
+ accessibility,
15
+ ]
16
+ use_cases:
17
+ [
18
+ confirmation-dialogs,
19
+ alert-messages,
20
+ forms,
21
+ subscription-offers,
22
+ user-prompts,
23
+ information-display,
24
+ video-players,
25
+ content-overlays,
26
+ ]
27
+ related: [brick-button]
28
+ ---
29
+
30
+ # Brick Dialog
31
+
32
+ A Web Component for displaying dialog and modal windows that overlay page content and require user interaction.
33
+
34
+ ## Key Capabilities
35
+
36
+ - **Dual modes**: Supports both non-modal dialogs and modal windows with different interaction patterns
37
+ - **Position control**: Configure dialog position (top, center, bottom) for non-modal dialogs
38
+ - **Template-based content**: Use HTML template tags to define header and content areas
39
+ - **Full accessibility**: Built-in ARIA support, focus management, and keyboard navigation
40
+ - **Focus trapping**: Automatic focus trapping for modal dialogs to ensure accessibility
41
+ - **Automatic styling**: Includes close buttons and responsive layout out of the box
42
+
43
+ ## Props/Attributes
44
+
45
+ | Attribute | Type | Default | Required | Description |
46
+ | --------------- | ------------------------------- | ---------- | -------- | ------------------------------------------------------------------------------------------------------- |
47
+ | `data-type` | `"dialog" \| "modal"` | `"dialog"` | no | The type of dialog to render. Use "dialog" for non-blocking overlays, "modal" for blocking interactions |
48
+ | `data-position` | `"top" \| "center" \| "bottom"` | `"center"` | no | Position of the dialog in the viewport. Only applicable when `data-type="dialog"` |
49
+ | `data-id` | string | - | no | Custom ID for the internal dialog element |
50
+
51
+ ## Examples
52
+
53
+ ### Basic Dialog
54
+
55
+ A non-modal dialog allows users to interact with both the dialog and the underlying page content.
56
+
57
+ ```html
58
+ <brick-dialog-v2 data-type="dialog" data-position="center">
59
+ <template data-name="header">
60
+ <h2>Dialog Title</h2>
61
+ </template>
62
+ <template data-name="content">
63
+ <p>This is a non-modal dialog. You can interact with the page behind it.</p>
64
+ </template>
65
+ </brick-dialog-v2>
66
+
67
+ <script>
68
+ const dialog = document.querySelector('brick-dialog-v2');
69
+ document.querySelector('.open-btn').addEventListener('click', () => {
70
+ dialog.openDialog();
71
+ });
72
+ </script>
73
+ ```
74
+
75
+ ### Modal Dialog
76
+
77
+ A modal dialog blocks interaction with the underlying page until dismissed.
78
+
79
+ ```html
80
+ <brick-dialog-v2 data-type="modal">
81
+ <template data-name="header">
82
+ <h2>Confirm Action</h2>
83
+ </template>
84
+ <template data-name="content">
85
+ <p>Are you sure you want to proceed?</p>
86
+ <brick-button-v9
87
+ data-label="Confirm"
88
+ data-version="primary"
89
+ ></brick-button-v9>
90
+ <brick-button-v9
91
+ data-label="Cancel"
92
+ data-version="secondary"
93
+ ></brick-button-v9>
94
+ </template>
95
+ </brick-dialog-v2>
96
+ ```
97
+
98
+ ### Dialog with Custom ID
99
+
100
+ Provide a unique ID for the dialog element for better integration and tracking.
101
+
102
+ ```html
103
+ <brick-dialog-v2 data-id="subscription-dialog" data-type="modal">
104
+ <template data-name="header">
105
+ <h2>Subscribe Today</h2>
106
+ </template>
107
+ <template data-name="content">
108
+ <p>Get access to premium content for just 1 kr!</p>
109
+ <brick-button-v9
110
+ data-label="Subscribe Now"
111
+ data-version="primary"
112
+ style="--brick-colors-buttonPrimaryBg:var(--brick-colors-buttonSignalBg);"
113
+ >
114
+ </brick-button-v9>
115
+ </template>
116
+ </brick-dialog-v2>
117
+ ```
118
+
119
+ ### Dialog Positioned at Top
120
+
121
+ Position a non-modal dialog at the top of the viewport.
122
+
123
+ ```html
124
+ <brick-dialog-v2 data-type="dialog" data-position="top">
125
+ <template data-name="header">
126
+ <h2>Notification</h2>
127
+ </template>
128
+ <template data-name="content">
129
+ <p>New updates are available.</p>
130
+ </template>
131
+ </brick-dialog-v2>
132
+ ```
133
+
134
+ ### Dialog with Rich Content
135
+
136
+ Include complex content like forms, buttons, and links inside the dialog.
137
+
138
+ ```html
139
+ <brick-dialog-v2 data-type="modal">
140
+ <template data-name="header">
141
+ <h2>Special Offer</h2>
142
+ </template>
143
+ <template data-name="content">
144
+ <p>Subscribe for 1 kr today!</p>
145
+ <brick-button-v9
146
+ onclick="alert('Button clicked!')"
147
+ data-label="Subscribe"
148
+ data-version="primary"
149
+ data-size="small"
150
+ >
151
+ </brick-button-v9>
152
+ <brick-button-v9
153
+ onclick="alert('Learn more')"
154
+ data-label="Learn More"
155
+ data-version="secondary"
156
+ data-size="small"
157
+ >
158
+ </brick-button-v9>
159
+ <p>Read more about <a href="#">what you get access to here.</a></p>
160
+ </template>
161
+ </brick-dialog-v2>
162
+ ```
163
+
164
+ ## Framework Integration
165
+
166
+ ### Svelte
167
+
168
+ Svelte 5 has a known issue where the first `<template>` tag may be stripped during compilation. Use a dummy template as a workaround.
169
+
170
+ ```svelte
171
+ <script>
172
+ let dialogRef;
173
+
174
+ function openDialog() {
175
+ dialogRef.openDialog();
176
+ }
177
+ </script>
178
+
179
+ <brick-dialog-v2 bind:this={dialogRef} data-type="modal">
180
+ <!-- Workaround for Svelte 5 template stripping -->
181
+ <template data-name="template-for-svelte-compile-will-be-stripped"></template>
182
+
183
+ <template data-name="header">
184
+ <h2>Dialog Title</h2>
185
+ </template>
186
+
187
+ <template data-name="content">
188
+ <p>Dialog content goes here.</p>
189
+ </template>
190
+ </brick-dialog-v2>
191
+
192
+ <button on:click={openDialog}>Open Dialog</button>
193
+ ```
194
+
195
+ ### Svelte with Custom Styles
196
+
197
+ You can include scoped styles within the template tags.
198
+
199
+ ```svelte
200
+ <script>
201
+ let dialogRef;
202
+
203
+ function openDialog() {
204
+ dialogRef.openDialog();
205
+ }
206
+ </script>
207
+
208
+ <brick-dialog-v2 bind:this={dialogRef}>
209
+ <template data-name="header">
210
+ <style>
211
+ .custom-title {
212
+ color: red;
213
+ }
214
+ </style>
215
+ <h2><div class="custom-title">Dialog Title</div></h2>
216
+ </template>
217
+
218
+ <template data-name="content">
219
+ <p>Dialog content goes here.</p>
220
+ </template>
221
+ </brick-dialog-v2>
222
+
223
+ <button on:click={openDialog}>Open Dialog</button>
224
+ ```
225
+
226
+ ## Programmatic Usage
227
+
228
+ ```javascript
229
+ import '@amedia/brick-dialog';
230
+
231
+ // Create dialog element
232
+ const dialog = document.createElement('brick-dialog-v2');
233
+ dialog.dataset.type = 'modal';
234
+ dialog.dataset.id = `dialog-${Math.random().toString(36).substring(2)}`;
235
+
236
+ // Add content via templates
237
+ dialog.innerHTML = `
238
+ <template data-name="header">
239
+ <h2>My Dialog</h2>
240
+ </template>
241
+ <template data-name="content">
242
+ <p>Dialog content here</p>
243
+ </template>
244
+ `;
245
+
246
+ // Append to DOM
247
+ document.body.appendChild(dialog);
248
+
249
+ // Open the dialog
250
+ dialog.openDialog();
251
+
252
+ // Close the dialog
253
+ dialog.close();
254
+ ```
255
+
256
+ ### Using Methods
257
+
258
+ ```javascript
259
+ const dialog = document.querySelector('brick-dialog-v2');
260
+
261
+ // Open dialog (automatically calls show() or showModal() based on data-type)
262
+ dialog.openDialog();
263
+
264
+ // Alternative: use native dialog methods
265
+ dialog.show(); // For non-modal dialogs
266
+ dialog.showModal(); // For modal dialogs
267
+
268
+ // Close dialog
269
+ dialog.close();
270
+ ```
271
+
272
+ ## Accessibility
273
+
274
+ The brick-dialog component is built with comprehensive accessibility features:
275
+
276
+ ### ARIA Support
277
+
278
+ - Uses `role="dialog"` to inform assistive technologies
279
+ - Adds `aria-modal="true"` for modal dialogs to indicate content underneath is inert
280
+ - Automatically sets `aria-labelledby` if a heading with an ID is present in the header
281
+ - Falls back to `aria-label="Dialog"` if no heading is found
282
+
283
+ ### Focus Management
284
+
285
+ - Saves the previously focused element before opening
286
+ - Automatically moves focus to the dialog when opened
287
+ - Restores focus to the original element when closed
288
+ - Maintains logical focus order for keyboard users
289
+
290
+ ### Keyboard Interactions
291
+
292
+ - **Escape key**: Closes non-modal dialogs
293
+ - **Tab key**: For modal dialogs, focus is trapped within the dialog
294
+ - Tab cycles forward through focusable elements
295
+ - Shift+Tab cycles backward
296
+ - Focus loops from last to first element and vice versa
297
+
298
+ ### Background Interaction Prevention
299
+
300
+ - Modal dialogs add `aria-hidden="true"` to the `<body>` element
301
+ - Disables scrolling on the body when modal is open
302
+ - Ensures users cannot accidentally interact with background content
303
+
304
+ ### Close Buttons
305
+
306
+ - Accessible close button in the header
307
+ - Additional close button in the footer for modal dialogs
308
+ - Both buttons use the accessible `brick-button-v9` component
309
+
310
+ ## CSS Customization
311
+
312
+ The dialog supports CSS custom properties for styling customization. Scope your overrides appropriately.
313
+
314
+ | Property | Description | Default |
315
+ | ---------------------------- | ---------------------------------------- | ------- |
316
+ | `--b-dialog-max-inline-size` | Controls the maximum width of the dialog | `80vw` |
317
+
318
+ ### Example
319
+
320
+ ```html
321
+ <style>
322
+ brick-dialog-v2 {
323
+ --b-dialog-max-inline-size: 600px;
324
+ }
325
+
326
+ brick-dialog-v2 header {
327
+ border-bottom: 1px solid grey;
328
+ padding-bottom: var(--brick-space-x1);
329
+ }
330
+
331
+ brick-dialog-v2 p {
332
+ font-family: var(--brick-fonts-baseBodyM);
333
+ }
334
+ </style>
335
+ ```
336
+
337
+ ## Template Tags
338
+
339
+ Content is added to the dialog using HTML `<template>` tags with `data-name` attributes.
340
+
341
+ | data-name | Description |
342
+ | --------- | --------------------------------------------------------------- |
343
+ | `header` | Content for the dialog header (appears before the close button) |
344
+ | `content` | Main content area of the dialog |
345
+
346
+ ## Common Patterns
347
+
348
+ ### Subscription Offer Modal
349
+
350
+ Display a subscription offer that requires user attention.
351
+
352
+ ```html
353
+ <brick-dialog-v2 data-type="modal" data-id="subscription-modal">
354
+ <template data-name="header">
355
+ <h2>Special Offer</h2>
356
+ </template>
357
+ <template data-name="content">
358
+ <p>Subscribe for only 1 kr today!</p>
359
+ <brick-button-v9
360
+ data-label="Subscribe Now"
361
+ data-version="primary"
362
+ style="--brick-colors-buttonPrimaryBg:var(--brick-colors-buttonSignalBg);"
363
+ >
364
+ </brick-button-v9>
365
+ <p>Learn more about <a href="/subscription">all the benefits here</a>.</p>
366
+ </template>
367
+ </brick-dialog-v2>
368
+ ```
369
+
370
+ ### Confirmation Dialog
371
+
372
+ Use a modal for critical actions requiring confirmation.
373
+
374
+ ```html
375
+ <brick-dialog-v2 data-type="modal">
376
+ <template data-name="header">
377
+ <h2>Delete Confirmation</h2>
378
+ </template>
379
+ <template data-name="content">
380
+ <p>
381
+ Are you sure you want to delete this item? This action cannot be undone.
382
+ </p>
383
+ <brick-button-v9
384
+ class="confirm-delete"
385
+ data-label="Delete"
386
+ data-version="primary"
387
+ data-size="small"
388
+ >
389
+ </brick-button-v9>
390
+ <brick-button-v9
391
+ class="cancel"
392
+ data-label="Cancel"
393
+ data-version="secondary"
394
+ data-size="small"
395
+ >
396
+ </brick-button-v9>
397
+ </template>
398
+ </brick-dialog-v2>
399
+ ```
400
+
401
+ ### Non-Modal Information Dialog
402
+
403
+ Use a non-modal dialog for supplementary information.
404
+
405
+ ```html
406
+ <brick-dialog-v2 data-type="dialog" data-position="bottom">
407
+ <template data-name="header">
408
+ <h2>Tip</h2>
409
+ </template>
410
+ <template data-name="content">
411
+ <p>You can use keyboard shortcuts to navigate faster!</p>
412
+ </template>
413
+ </brick-dialog-v2>
414
+ ```
415
+
416
+ ## Technical Details
417
+
418
+ - **Custom Element**: `brick-dialog-v2`
419
+ - **Base Class**: BrickElement
420
+ - **Dependencies**: @amedia/brick-template, @amedia/brick-tokens, @amedia/brick-button
421
+ - **Renders as**: `<dialog>` element with wrapper divs and header/footer structure
422
+
423
+ ## Important Notes
424
+
425
+ ### Dialog vs Modal Choice
426
+
427
+ **Use a dialog when:**
428
+
429
+ - Information or interaction is supplementary and non-critical
430
+ - Users might need to interact with both the dialog and main content
431
+ - Minimizing workflow disruption is important
432
+
433
+ **Use a modal when:**
434
+
435
+ - Immediate user action is required before proceeding
436
+ - User focus must be solely on the modal content
437
+ - Preventing interaction with main content is necessary to avoid errors
438
+
439
+ ### Unique IDs
440
+
441
+ Always provide a unique ID for the dialog when possible:
442
+
443
+ ```javascript
444
+ const dialogId = `dialog-${Math.random().toString(36).substring(2)}`;
445
+ // Or use a UUID library for more robustness
446
+ ```
447
+
448
+ ### Server-Side Rendering
449
+
450
+ The current version (2.0.13) does not support server-side rendering. Future versions may add this capability if needed.
451
+
452
+ ### Template Tag Attributes
453
+
454
+ Use `data-name` (not `name`) for template tag identification. This was changed in version 1.0.0.
455
+
456
+ ## Version
457
+
458
+ Current version: 2.0.13