@amedia/brick-mcp 0.1.3 → 0.1.4
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/README.md +50 -1
- package/data/components/brick-mcp.md +259 -0
- package/data/components/brick-pill.md +362 -0
- package/data/components/brick-player.md +331 -0
- package/data/components/brick-published.md +219 -0
- package/data/components/brick-share.md +335 -0
- package/data/components/brick-stepper.md +319 -0
- package/data/components/brick-tab.md +241 -0
- package/data/components/brick-tabs.md +420 -0
- package/data/components/brick-tag.md +335 -0
- package/data/components/brick-teaser-player.md +248 -0
- package/data/components/brick-teaser-reels.md +190 -0
- package/data/components/brick-teaser.md +262 -0
- package/data/components/brick-template.md +226 -0
- package/data/components/brick-textarea.md +191 -0
- package/data/components/brick-themes.md +104 -0
- package/data/components/brick-toast.md +271 -0
- package/data/components/brick-toggle.md +268 -0
- package/data/components/brick-tokens.md +287 -0
- package/data/components/brick-tooltip.md +249 -0
- package/data/components-metadata.json +34 -34
- package/data/tokens.json +0 -7
- package/dist/data/components/brick-mcp.md +259 -0
- package/dist/data/components/brick-pill.md +362 -0
- package/dist/data/components/brick-player.md +331 -0
- package/dist/data/components/brick-published.md +219 -0
- package/dist/data/components/brick-share.md +335 -0
- package/dist/data/components/brick-stepper.md +319 -0
- package/dist/data/components/brick-tab.md +241 -0
- package/dist/data/components/brick-tabs.md +420 -0
- package/dist/data/components/brick-tag.md +335 -0
- package/dist/data/components/brick-teaser-player.md +248 -0
- package/dist/data/components/brick-teaser-reels.md +190 -0
- package/dist/data/components/brick-teaser.md +262 -0
- package/dist/data/components/brick-template.md +226 -0
- package/dist/data/components/brick-textarea.md +191 -0
- package/dist/data/components/brick-themes.md +104 -0
- package/dist/data/components/brick-toast.md +271 -0
- package/dist/data/components/brick-toggle.md +268 -0
- package/dist/data/components/brick-tokens.md +287 -0
- package/dist/data/components/brick-tooltip.md +249 -0
- package/dist/data/components-metadata.json +34 -34
- package/dist/data/tokens.json +0 -7
- package/package.json +37 -37
- package/data/components/brick-mcp.json +0 -6
- package/data/components/brick-pill.json +0 -6
- package/data/components/brick-player.json +0 -7
- package/data/components/brick-published.json +0 -7
- package/data/components/brick-share.json +0 -7
- package/data/components/brick-stepper.json +0 -7
- package/data/components/brick-tab.json +0 -7
- package/data/components/brick-tabs.json +0 -9
- package/data/components/brick-tag.json +0 -7
- package/data/components/brick-teaser-player.json +0 -9
- package/data/components/brick-teaser-reels.json +0 -9
- package/data/components/brick-teaser.json +0 -9
- package/data/components/brick-template.json +0 -9
- package/data/components/brick-textarea.json +0 -7
- package/data/components/brick-themes.json +0 -6
- package/data/components/brick-toast.json +0 -9
- package/data/components/brick-toggle.json +0 -7
- package/data/components/brick-tokens.json +0 -8
- package/data/components/brick-tooltip.json +0 -7
- package/dist/data/components/brick-mcp.json +0 -6
- package/dist/data/components/brick-pill.json +0 -6
- package/dist/data/components/brick-player.json +0 -7
- package/dist/data/components/brick-published.json +0 -7
- package/dist/data/components/brick-share.json +0 -7
- package/dist/data/components/brick-stepper.json +0 -7
- package/dist/data/components/brick-tab.json +0 -7
- package/dist/data/components/brick-tabs.json +0 -9
- package/dist/data/components/brick-tag.json +0 -7
- package/dist/data/components/brick-teaser-player.json +0 -9
- package/dist/data/components/brick-teaser-reels.json +0 -9
- package/dist/data/components/brick-teaser.json +0 -9
- package/dist/data/components/brick-template.json +0 -9
- package/dist/data/components/brick-textarea.json +0 -7
- package/dist/data/components/brick-themes.json +0 -6
- package/dist/data/components/brick-toast.json +0 -9
- package/dist/data/components/brick-toggle.json +0 -7
- package/dist/data/components/brick-tokens.json +0 -8
- package/dist/data/components/brick-tooltip.json +0 -7
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brick-textarea
|
|
3
|
+
version: 2.0.10
|
|
4
|
+
selector: brick-textarea-v2
|
|
5
|
+
category: Forms
|
|
6
|
+
tags: [textarea, input, form, multiline, validation, accessibility]
|
|
7
|
+
use_cases: [forms, comments, messages, descriptions, feedback, multiline-input]
|
|
8
|
+
related: [brick-input, brick-tokens, brick-template]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Brick Textarea
|
|
12
|
+
|
|
13
|
+
An accessible, validated multiline text input component with label, help text, error handling, and character count support.
|
|
14
|
+
|
|
15
|
+
## Key Capabilities
|
|
16
|
+
|
|
17
|
+
- Multiline text input with semantic label
|
|
18
|
+
- Optional or required field support
|
|
19
|
+
- Built-in validation with error messages
|
|
20
|
+
- Help text for guidance
|
|
21
|
+
- Character length constraints (min/max)
|
|
22
|
+
- Hidden label option for compact layouts
|
|
23
|
+
- Autofocus support
|
|
24
|
+
- Pattern validation
|
|
25
|
+
- Accessibility-first design with proper ARIA labels
|
|
26
|
+
- Server-side rendering support
|
|
27
|
+
|
|
28
|
+
## Props/Attributes
|
|
29
|
+
|
|
30
|
+
| Attribute | Type | Default | Required | Description |
|
|
31
|
+
| -------------------- | ------ | ------- | -------- | ----------------------------------------------------- |
|
|
32
|
+
| `data-label-text` | string | - | yes | Label text for the textarea |
|
|
33
|
+
| `data-id` | string | - | yes | Unique ID for the textarea element |
|
|
34
|
+
| `data-name` | string | - | yes | Name attribute for form submission |
|
|
35
|
+
| `data-value` | string | - | no | Initial textarea value |
|
|
36
|
+
| `data-placeholder` | string | - | no | Placeholder text |
|
|
37
|
+
| `data-help-text` | string | - | no | Help text displayed below textarea |
|
|
38
|
+
| `data-error-text` | string | - | no | Error message to display |
|
|
39
|
+
| `data-required` | string | - | no | Set to "true" to mark as required field |
|
|
40
|
+
| `data-optional-text` | string | - | no | Text to show for optional fields (e.g., "Optional") |
|
|
41
|
+
| `data-label-hidden` | string | - | no | Set to "true" to visually hide label (keeps for a11y) |
|
|
42
|
+
| `data-maxlength` | string | - | no | Maximum character length |
|
|
43
|
+
| `data-minlength` | string | - | no | Minimum character length |
|
|
44
|
+
| `data-pattern` | string | - | no | Validation pattern (regex) |
|
|
45
|
+
| `data-autofocus` | string | - | no | Set to "true" to autofocus on load |
|
|
46
|
+
| `data-alt` | string | - | no | Alternative text for accessibility |
|
|
47
|
+
|
|
48
|
+
## Examples
|
|
49
|
+
|
|
50
|
+
### Basic Textarea
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<brick-textarea-v2
|
|
54
|
+
data-id="comment"
|
|
55
|
+
data-name="comment"
|
|
56
|
+
data-label-text="Your Comment"
|
|
57
|
+
data-placeholder="Enter your comment here..."
|
|
58
|
+
>
|
|
59
|
+
</brick-textarea-v2>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Required Field with Help Text
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<brick-textarea-v2
|
|
66
|
+
data-id="message"
|
|
67
|
+
data-name="message"
|
|
68
|
+
data-label-text="Message"
|
|
69
|
+
data-help-text="Please provide a detailed message"
|
|
70
|
+
data-required="true"
|
|
71
|
+
>
|
|
72
|
+
</brick-textarea-v2>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### With Character Limits
|
|
76
|
+
|
|
77
|
+
```html
|
|
78
|
+
<brick-textarea-v2
|
|
79
|
+
data-id="bio"
|
|
80
|
+
data-name="bio"
|
|
81
|
+
data-label-text="Biography"
|
|
82
|
+
data-maxlength="500"
|
|
83
|
+
data-minlength="10"
|
|
84
|
+
data-help-text="Between 10 and 500 characters"
|
|
85
|
+
>
|
|
86
|
+
</brick-textarea-v2>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### With Error State
|
|
90
|
+
|
|
91
|
+
```html
|
|
92
|
+
<brick-textarea-v2
|
|
93
|
+
data-id="feedback"
|
|
94
|
+
data-name="feedback"
|
|
95
|
+
data-label-text="Feedback"
|
|
96
|
+
data-required="true"
|
|
97
|
+
data-error-text="This field is required"
|
|
98
|
+
>
|
|
99
|
+
</brick-textarea-v2>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Optional Field
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<brick-textarea-v2
|
|
106
|
+
data-id="notes"
|
|
107
|
+
data-name="notes"
|
|
108
|
+
data-label-text="Additional Notes"
|
|
109
|
+
data-optional-text="Optional"
|
|
110
|
+
>
|
|
111
|
+
</brick-textarea-v2>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### With Initial Value
|
|
115
|
+
|
|
116
|
+
```html
|
|
117
|
+
<brick-textarea-v2
|
|
118
|
+
data-id="description"
|
|
119
|
+
data-name="description"
|
|
120
|
+
data-label-text="Description"
|
|
121
|
+
data-value="This is the initial description text."
|
|
122
|
+
>
|
|
123
|
+
</brick-textarea-v2>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Programmatic Usage
|
|
127
|
+
|
|
128
|
+
```javascript
|
|
129
|
+
const textarea = document.querySelector('brick-textarea-v2');
|
|
130
|
+
|
|
131
|
+
// Get value
|
|
132
|
+
const value = textarea.dataValue;
|
|
133
|
+
|
|
134
|
+
// Set value
|
|
135
|
+
textarea.dataValue = 'New text content';
|
|
136
|
+
|
|
137
|
+
// Show error
|
|
138
|
+
textarea.dataErrorText = 'Invalid input';
|
|
139
|
+
|
|
140
|
+
// Clear error
|
|
141
|
+
textarea.dataErrorText = '';
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Server-Side Rendering
|
|
145
|
+
|
|
146
|
+
```javascript
|
|
147
|
+
import { renderBrickTextarea } from '@amedia/brick-textarea/template';
|
|
148
|
+
|
|
149
|
+
const html = renderBrickTextarea({
|
|
150
|
+
dataId: 'message',
|
|
151
|
+
dataName: 'message',
|
|
152
|
+
dataLabelText: 'Your Message',
|
|
153
|
+
dataPlaceholder: 'Type your message...',
|
|
154
|
+
dataRequired: 'true',
|
|
155
|
+
dataHelpText: 'Maximum 1000 characters',
|
|
156
|
+
dataMaxlength: '1000',
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Accessibility
|
|
161
|
+
|
|
162
|
+
- Proper label association with textarea via `for` and `id`
|
|
163
|
+
- Required fields marked with `aria-required`
|
|
164
|
+
- Error states with `aria-invalid` and `aria-describedby`
|
|
165
|
+
- Help text linked via `aria-describedby`
|
|
166
|
+
- Hidden labels remain accessible to screen readers
|
|
167
|
+
- Keyboard navigation support
|
|
168
|
+
- Validation error announcements
|
|
169
|
+
|
|
170
|
+
## Technical Details
|
|
171
|
+
|
|
172
|
+
- **Custom Element**: `brick-textarea-v2`
|
|
173
|
+
- **Base Class**: BrickElement
|
|
174
|
+
- **Dependencies**:
|
|
175
|
+
- @amedia/brick-template (base class)
|
|
176
|
+
- @amedia/brick-tokens (design tokens)
|
|
177
|
+
- **Renders as**: `<textarea>` with label and help elements
|
|
178
|
+
- **SSR Compatible**: Yes, with template function
|
|
179
|
+
|
|
180
|
+
## Important Notes
|
|
181
|
+
|
|
182
|
+
- The `data-id` and `data-name` attributes are required for proper form functionality
|
|
183
|
+
- Error text automatically shows validation state
|
|
184
|
+
- Character limits are enforced by the browser
|
|
185
|
+
- Pattern validation uses HTML5 pattern attribute
|
|
186
|
+
- Hidden labels (`data-label-hidden="true"`) remain accessible to assistive technology
|
|
187
|
+
- The component does not handle form submission - use within a `<form>` element
|
|
188
|
+
|
|
189
|
+
## Version
|
|
190
|
+
|
|
191
|
+
Current version: 2.0.10
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brick-themes
|
|
3
|
+
version: 1.0.1
|
|
4
|
+
selector: N/A
|
|
5
|
+
category: Utilities
|
|
6
|
+
tags: [themes, theming, publications, branding, design-tokens]
|
|
7
|
+
use_cases: [publication-branding, multi-tenant-theming, brand-customization]
|
|
8
|
+
related: [brick-tokens]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Brick Themes
|
|
12
|
+
|
|
13
|
+
A utility package that provides theme name constants for Amedia publications, used in conjunction with brick-tokens for publication-specific styling and branding.
|
|
14
|
+
|
|
15
|
+
## Key Capabilities
|
|
16
|
+
|
|
17
|
+
- Centralized theme name constants
|
|
18
|
+
- Publication theme definitions
|
|
19
|
+
- Used by brick-tokens for theme generation
|
|
20
|
+
- TypeScript type definitions
|
|
21
|
+
- Ensures consistent theme naming across the design system
|
|
22
|
+
|
|
23
|
+
## Overview
|
|
24
|
+
|
|
25
|
+
Brick Themes is an internal utility package that defines theme names for various Amedia publications. It works in conjunction with `@amedia/brick-tokens` to provide publication-specific design tokens and styling.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Import Theme Names
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
import { themes } from '@amedia/brick-themes';
|
|
33
|
+
|
|
34
|
+
// Use theme names
|
|
35
|
+
console.log(themes.alfa); // 'alfa'
|
|
36
|
+
console.log(themes.bergen); // 'bergen'
|
|
37
|
+
console.log(themes.bt); // 'bt'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### With Brick Tokens
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
import '@amedia/brick-tokens';
|
|
44
|
+
import '@amedia/brick-tokens/dist/themes/alfa/index.js';
|
|
45
|
+
import '@amedia/brick-tokens/dist/themes/bergen/index.js';
|
|
46
|
+
import '@amedia/brick-tokens/dist/themes/bt/index.js';
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Available Themes
|
|
50
|
+
|
|
51
|
+
The package provides theme names for Amedia publications including:
|
|
52
|
+
|
|
53
|
+
- **Alfa** (alfa)
|
|
54
|
+
- **Bergen** (bergen)
|
|
55
|
+
- **BT** (bt)
|
|
56
|
+
- And many more publication-specific themes
|
|
57
|
+
|
|
58
|
+
Each theme name corresponds to a theme definition in brick-tokens that includes:
|
|
59
|
+
- Publication-specific color palettes
|
|
60
|
+
- Brand colors
|
|
61
|
+
- Typography settings
|
|
62
|
+
- Spacing and layout tokens
|
|
63
|
+
|
|
64
|
+
## Integration with Brick Tokens
|
|
65
|
+
|
|
66
|
+
Brick Themes works as a companion package to brick-tokens:
|
|
67
|
+
|
|
68
|
+
1. **brick-themes**: Defines theme name constants
|
|
69
|
+
2. **brick-tokens**: Uses these names to generate theme-specific token sets
|
|
70
|
+
3. **Components**: Apply themes via brick-tokens
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
// Theme names from brick-themes
|
|
74
|
+
import { themes } from '@amedia/brick-themes';
|
|
75
|
+
|
|
76
|
+
// Theme tokens from brick-tokens
|
|
77
|
+
import `@amedia/brick-tokens/dist/themes/${themes.alfa}/index.js`;
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Technical Details
|
|
81
|
+
|
|
82
|
+
- **Package Type**: Theme name constants and utilities
|
|
83
|
+
- **Output**: ES modules with theme definitions
|
|
84
|
+
- **TypeScript**: Full type definitions included
|
|
85
|
+
- **CDN**: Available via Eik CDN
|
|
86
|
+
- **Dependencies**: None (standalone utility)
|
|
87
|
+
|
|
88
|
+
## CDN Usage
|
|
89
|
+
|
|
90
|
+
```html
|
|
91
|
+
<script src="https://assets.acdn.no/pkg/@amedia/brick-themes/1.0.1/brick-themes.js" type="module"></script>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Important Notes
|
|
95
|
+
|
|
96
|
+
- This is primarily an internal package used by brick-tokens
|
|
97
|
+
- Theme names must match between brick-themes and brick-tokens
|
|
98
|
+
- The package ensures type safety for theme names
|
|
99
|
+
- Publication themes are managed centrally for consistency
|
|
100
|
+
- Version 1.0.1 is the current stable version
|
|
101
|
+
|
|
102
|
+
## Version
|
|
103
|
+
|
|
104
|
+
Current version: 1.0.1
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brick-toast
|
|
3
|
+
version: 0.1.28
|
|
4
|
+
selector: brick-toast
|
|
5
|
+
category: Feedback
|
|
6
|
+
tags: [toast, notification, alert, message, feedback, snackbar, temporary]
|
|
7
|
+
use_cases: [success-messages, error-notifications, info-alerts, temporary-feedback, user-notifications]
|
|
8
|
+
related: [brick-button, brick-icon, brick-tokens]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Brick Toast
|
|
12
|
+
|
|
13
|
+
A notification component that displays temporary messages with configurable position, duration, status styling, and optional close button.
|
|
14
|
+
|
|
15
|
+
## Key Capabilities
|
|
16
|
+
|
|
17
|
+
- Temporary notification messages
|
|
18
|
+
- Multiple position options (9 positions)
|
|
19
|
+
- Auto-dismiss with configurable duration
|
|
20
|
+
- Optional close button
|
|
21
|
+
- Error status styling
|
|
22
|
+
- Custom icons support
|
|
23
|
+
- Programmatic open/close control
|
|
24
|
+
- Accessibility support
|
|
25
|
+
- Automatic stacking of multiple toasts
|
|
26
|
+
- Server-side rendering support
|
|
27
|
+
|
|
28
|
+
## Props/Attributes
|
|
29
|
+
|
|
30
|
+
| Attribute | Type | Default | Required | Description |
|
|
31
|
+
| ---------------- | ----------------------------------------------------------------------------------- | ----------------- | -------- | ---------------------------------------------- |
|
|
32
|
+
| `data-message` | string | - | yes | Message text to display |
|
|
33
|
+
| `data-open` | string | `"false"` | no | Set to "true" to show toast |
|
|
34
|
+
| `data-duration` | string (number) | `"3000"` | no | Auto-dismiss duration in milliseconds |
|
|
35
|
+
| `data-position` | `"top-center" \| "top-left" \| "top-right" \| "center-center" \| "bottom-left" \| "bottom-center" \| "bottom-right"` | `"bottom-center"` | no | Toast position on screen |
|
|
36
|
+
| `data-status` | `"error"` | - | no | Status styling (currently only error supported)|
|
|
37
|
+
| `data-iconid` | string | - | no | Icon ID from brick-icon |
|
|
38
|
+
| `data-close-btn` | string | `"true"` | no | Set to "false" to hide close button |
|
|
39
|
+
|
|
40
|
+
## Examples
|
|
41
|
+
|
|
42
|
+
### Basic Toast
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<brick-toast
|
|
46
|
+
data-message="Changes saved successfully"
|
|
47
|
+
data-open="true"
|
|
48
|
+
>
|
|
49
|
+
</brick-toast>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Error Toast
|
|
53
|
+
|
|
54
|
+
```html
|
|
55
|
+
<brick-toast
|
|
56
|
+
data-message="An error occurred"
|
|
57
|
+
data-status="error"
|
|
58
|
+
data-open="true"
|
|
59
|
+
>
|
|
60
|
+
</brick-toast>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Top Right Position
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<brick-toast
|
|
67
|
+
data-message="New message received"
|
|
68
|
+
data-position="top-right"
|
|
69
|
+
data-open="true"
|
|
70
|
+
>
|
|
71
|
+
</brick-toast>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### With Custom Icon
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<brick-toast
|
|
78
|
+
data-message="Upload complete"
|
|
79
|
+
data-iconid="check-circle"
|
|
80
|
+
data-open="true"
|
|
81
|
+
>
|
|
82
|
+
</brick-toast>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Without Close Button
|
|
86
|
+
|
|
87
|
+
```html
|
|
88
|
+
<brick-toast
|
|
89
|
+
data-message="Loading..."
|
|
90
|
+
data-close-btn="false"
|
|
91
|
+
data-duration="5000"
|
|
92
|
+
data-open="true"
|
|
93
|
+
>
|
|
94
|
+
</brick-toast>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Long Duration
|
|
98
|
+
|
|
99
|
+
```html
|
|
100
|
+
<brick-toast
|
|
101
|
+
data-message="Important notification"
|
|
102
|
+
data-duration="10000"
|
|
103
|
+
data-open="true"
|
|
104
|
+
>
|
|
105
|
+
</brick-toast>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Programmatic Usage
|
|
109
|
+
|
|
110
|
+
```javascript
|
|
111
|
+
// Create and show toast
|
|
112
|
+
const toast = document.createElement('brick-toast');
|
|
113
|
+
toast.dataMessage = 'Action completed';
|
|
114
|
+
toast.dataPosition = 'top-center';
|
|
115
|
+
toast.dataDuration = '3000';
|
|
116
|
+
toast.dataOpen = 'true';
|
|
117
|
+
document.body.appendChild(toast);
|
|
118
|
+
|
|
119
|
+
// Show existing toast
|
|
120
|
+
const existingToast = document.querySelector('brick-toast');
|
|
121
|
+
existingToast.dataOpen = 'true';
|
|
122
|
+
|
|
123
|
+
// Close toast
|
|
124
|
+
existingToast.dataOpen = 'false';
|
|
125
|
+
|
|
126
|
+
// Listen for close event
|
|
127
|
+
toast.addEventListener('brick-toast:close', (event) => {
|
|
128
|
+
console.log('Toast closed');
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Position Options
|
|
133
|
+
|
|
134
|
+
```html
|
|
135
|
+
<!-- Top positions -->
|
|
136
|
+
<brick-toast data-position="top-left" data-message="Top left" data-open="true"></brick-toast>
|
|
137
|
+
<brick-toast data-position="top-center" data-message="Top center" data-open="true"></brick-toast>
|
|
138
|
+
<brick-toast data-position="top-right" data-message="Top right" data-open="true"></brick-toast>
|
|
139
|
+
|
|
140
|
+
<!-- Center positions -->
|
|
141
|
+
<brick-toast data-position="center-center" data-message="Center" data-open="true"></brick-toast>
|
|
142
|
+
|
|
143
|
+
<!-- Bottom positions -->
|
|
144
|
+
<brick-toast data-position="bottom-left" data-message="Bottom left" data-open="true"></brick-toast>
|
|
145
|
+
<brick-toast data-position="bottom-center" data-message="Bottom center" data-open="true"></brick-toast>
|
|
146
|
+
<brick-toast data-position="bottom-right" data-message="Bottom right" data-open="true"></brick-toast>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Server-Side Rendering
|
|
150
|
+
|
|
151
|
+
```javascript
|
|
152
|
+
import { renderBrickToast } from '@amedia/brick-toast/template';
|
|
153
|
+
|
|
154
|
+
const html = renderBrickToast({
|
|
155
|
+
dataMessage: 'Success message',
|
|
156
|
+
dataStatus: 'error',
|
|
157
|
+
dataPosition: 'top-right',
|
|
158
|
+
dataDuration: '5000',
|
|
159
|
+
dataOpen: 'true',
|
|
160
|
+
dataIconid: 'check',
|
|
161
|
+
dataCloseBtn: 'true',
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Accessibility
|
|
166
|
+
|
|
167
|
+
- Role="alert" for screen reader announcements
|
|
168
|
+
- Live region announcements for dynamic messages
|
|
169
|
+
- Keyboard accessible close button (Enter/Space)
|
|
170
|
+
- Focus management for close button
|
|
171
|
+
- ARIA labels for all interactive elements
|
|
172
|
+
|
|
173
|
+
## Common Patterns
|
|
174
|
+
|
|
175
|
+
### Success Notification
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
function showSuccess(message) {
|
|
179
|
+
const toast = document.createElement('brick-toast');
|
|
180
|
+
toast.dataMessage = message;
|
|
181
|
+
toast.dataIconid = 'check-circle';
|
|
182
|
+
toast.dataPosition = 'bottom-center';
|
|
183
|
+
toast.dataOpen = 'true';
|
|
184
|
+
document.body.appendChild(toast);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
showSuccess('Settings saved successfully');
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Error Notification
|
|
191
|
+
|
|
192
|
+
```javascript
|
|
193
|
+
function showError(message) {
|
|
194
|
+
const toast = document.createElement('brick-toast');
|
|
195
|
+
toast.dataMessage = message;
|
|
196
|
+
toast.dataStatus = 'error';
|
|
197
|
+
toast.dataIconid = 'alert-circle';
|
|
198
|
+
toast.dataPosition = 'top-center';
|
|
199
|
+
toast.dataDuration = '5000';
|
|
200
|
+
toast.dataOpen = 'true';
|
|
201
|
+
document.body.appendChild(toast);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
showError('Failed to save changes');
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Multiple Toasts
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
// Toasts automatically stack when multiple are shown
|
|
211
|
+
function showMultipleToasts() {
|
|
212
|
+
['First message', 'Second message', 'Third message'].forEach((msg, i) => {
|
|
213
|
+
setTimeout(() => {
|
|
214
|
+
const toast = document.createElement('brick-toast');
|
|
215
|
+
toast.dataMessage = msg;
|
|
216
|
+
toast.dataOpen = 'true';
|
|
217
|
+
document.body.appendChild(toast);
|
|
218
|
+
}, i * 500);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Framework Integration
|
|
224
|
+
|
|
225
|
+
### Svelte
|
|
226
|
+
|
|
227
|
+
```svelte
|
|
228
|
+
<script>
|
|
229
|
+
let showToast = false;
|
|
230
|
+
let message = '';
|
|
231
|
+
|
|
232
|
+
function notify(msg) {
|
|
233
|
+
message = msg;
|
|
234
|
+
showToast = true;
|
|
235
|
+
}
|
|
236
|
+
</script>
|
|
237
|
+
|
|
238
|
+
<brick-toast
|
|
239
|
+
data-message={message}
|
|
240
|
+
data-open={showToast ? 'true' : 'false'}
|
|
241
|
+
on:brick-toast:close={() => showToast = false}
|
|
242
|
+
/>
|
|
243
|
+
|
|
244
|
+
<button on:click={() => notify('Hello!')}>Show Toast</button>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Technical Details
|
|
248
|
+
|
|
249
|
+
- **Custom Element**: `brick-toast`
|
|
250
|
+
- **Base Class**: BrickElement
|
|
251
|
+
- **Dependencies**:
|
|
252
|
+
- @amedia/brick-button (close button)
|
|
253
|
+
- @amedia/brick-icon (icons)
|
|
254
|
+
- @amedia/brick-template (base class)
|
|
255
|
+
- @amedia/brick-tokens (design tokens)
|
|
256
|
+
- **Renders as**: Fixed position overlay element
|
|
257
|
+
- **SSR Compatible**: Yes, with template function
|
|
258
|
+
|
|
259
|
+
## Important Notes
|
|
260
|
+
|
|
261
|
+
- Toasts auto-dismiss after the specified duration (default 3000ms)
|
|
262
|
+
- Multiple toasts automatically stack in the specified position
|
|
263
|
+
- The close button can be disabled for loading states
|
|
264
|
+
- Currently only "error" status is styled differently (more statuses may be added)
|
|
265
|
+
- Toast remains in DOM after closing unless manually removed
|
|
266
|
+
- Position is fixed and unaffected by scroll
|
|
267
|
+
- Toasts should be added to document.body for proper positioning
|
|
268
|
+
|
|
269
|
+
## Version
|
|
270
|
+
|
|
271
|
+
Current version: 0.1.28
|