@amedia/brick-mcp 1.0.3 → 1.0.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.
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  name: brick-icon
3
- version: 2.3.1
3
+ version: 2.4.1
4
4
  selector: brick-icon-v2
5
5
  category: Media
6
- tags: [icon, svg, graphics, accessibility, sprite, visual]
6
+ tags: [icon, svg, graphics, accessibility, sprite, visual, aria, breaking-news, pulse-animation]
7
7
  use_cases:
8
8
  [
9
9
  all-ui,
@@ -18,60 +18,65 @@ related: [brick-button, brick-pill, brick-avatar]
18
18
 
19
19
  # Brick Icon
20
20
 
21
- A lightweight Web Component for rendering SVG icons from an embedded SVG sprite with built-in accessibility features.
21
+ A lightweight Web Component for rendering SVG icons from an embedded SVG sprite with built-in accessibility handling.
22
22
 
23
23
  ## Key Capabilities
24
24
 
25
- - Renders icons from an inline SVG sprite using icon IDs
26
- - Automatic accessibility handling with configurable screen reader text
27
- - Dynamic icon switching via attribute changes
28
- - Size control through data attributes or CSS variables
29
- - Color customization via CSS custom properties
30
- - Special animation support for breaking news icon
31
- - Framework-agnostic Web Component
25
+ - Renders icons from an inline SVG sprite sheet using symbol IDs
26
+ - Automatic accessibility: hides decorative icons from screen readers, exposes meaningful icons with configurable text
27
+ - Dynamic icon and text switching via observed attribute changes at runtime
28
+ - Predefined size control (`small`/`medium`) through data attributes, with full CSS custom property override support
29
+ - Customizable color via CSS custom properties (inherits `currentColor` by default)
30
+ - Built-in pulse animation for breaking news icon (`pill-breaking`), with `color-mix()` for modern browsers and legacy fallback
32
31
 
33
32
  ## Props/Attributes
34
33
 
35
- | Attribute | Type | Default | Required | Description |
36
- | ---------------- | ----------------------------- | -------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
37
- | `data-icon-id` | string | - | yes | The ID of the SVG symbol inside the embedded SVG sprite |
38
- | `data-icon-text` | string | - | no | Screen reader announcement text. When provided, icon gets `role="graphics-symbol"` and a `<title>` tag. When omitted, icon is hidden from screen readers with `aria-hidden="true"` |
39
- | `data-icon-size` | 'small' \| 'medium' \| string | 'medium' | no | Predefined size for the icon container. 'small' or 'medium' values use token-based sizing |
34
+ | Attribute | Type | Default | Required | Description |
35
+ | ---------------- | ----------------------------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
36
+ | `data-icon-id` | string | `""` | yes | The ID of the `<symbol>` element inside the embedded SVG sprite. Determines which icon is rendered via `<use href="#id">`. |
37
+ | `data-icon-text` | string | `""` | no | Screen reader announcement text. When provided, the SVG gets `role="graphics-symbol"` and a `<title>` element linked via `aria-labelledby`. When omitted, the SVG is hidden from assistive technology with `aria-hidden="true"`. |
38
+ | `data-icon-size` | `'small'` \| `'medium'` \| string | `""` | no | Predefined size for the icon. `'small'` maps to the `--brick-sizes-iconS` token (typically 12px). `'medium'` maps to `--brick-sizes-iconM` token (typically 24px). Custom string values are accepted but require corresponding CSS variable overrides to take effect. |
40
39
 
41
- ## Examples
40
+ ## Usage
42
41
 
43
- ### Basic Icon (Decorative)
42
+ ### Server-side rendering (preferred)
44
43
 
45
- Icon without screen reader text, suitable for decorative purposes or when paired with visible text:
44
+ Import the render function from the `/template` submodule and call it to produce an HTML string:
46
45
 
47
- ```html
48
- <brick-icon-v2 data-icon-id="chevron-right"></brick-icon-v2>
46
+ ```ts
47
+ import { renderBrickIcon } from '@amedia/brick-icon/template';
48
+
49
+ const html = renderBrickIcon({
50
+ dataIconId: 'play',
51
+ dataIconText: 'Play video',
52
+ dataIconSize: 'medium',
53
+ });
49
54
  ```
50
55
 
51
- ### Accessible Icon
56
+ The returned HTML is a fully formed `<brick-icon-v2>` custom element with `is-rendered` and `brick-component="brick-icon"` attributes, ready for hydration on the client.
52
57
 
53
- Icon with screen reader text for meaningful standalone icons:
58
+ Decorative icon (hidden from screen readers):
54
59
 
55
- ```html
56
- <brick-icon-v2 data-icon-id="play" data-icon-text="Play video"> </brick-icon-v2>
60
+ ```ts
61
+ import { renderBrickIcon } from '@amedia/brick-icon/template';
62
+
63
+ const html = renderBrickIcon({
64
+ dataIconId: 'chevron-right',
65
+ dataIconSize: 'small',
66
+ });
57
67
  ```
58
68
 
59
- ### Sized Icon
69
+ ### Client-side (declarative HTML)
60
70
 
61
- Icon with predefined size:
71
+ Use the custom element directly in HTML after registering the component:
62
72
 
63
73
  ```html
64
- <brick-icon-v2
65
- data-icon-id="search"
66
- data-icon-text="Search"
67
- data-icon-size="small"
68
- >
69
- </brick-icon-v2>
70
- ```
74
+ <script type="module" src="https://assets.acdn.no/pkg/@amedia/brick-icon/v2/brick-icon.js"></script>
71
75
 
72
- ### Icon in Button Context
76
+ <brick-icon-v2 data-icon-id="play" data-icon-text="Play video"></brick-icon-v2>
77
+ ```
73
78
 
74
- Decorative icon alongside text (hidden from screen readers):
79
+ Decorative icon alongside visible text (no `data-icon-text` needed):
75
80
 
76
81
  ```html
77
82
  <button>
@@ -80,52 +85,23 @@ Decorative icon alongside text (hidden from screen readers):
80
85
  </button>
81
86
  ```
82
87
 
83
- ### Breaking News Icon
84
-
85
- Special icon with pulse animation:
88
+ Sized icon:
86
89
 
87
90
  ```html
88
- <brick-icon-v2 data-icon-id="pill-breaking" data-icon-text="Breaking news">
89
- </brick-icon-v2>
90
- ```
91
-
92
- ## Programmatic Usage
93
-
94
- ### Client-Side Rendering
95
-
96
- ```javascript
97
- import '@amedia/brick-icon';
98
-
99
- // The custom element defines itself automatically
100
- const icon = document.createElement('brick-icon-v2');
101
- icon.setAttribute('data-icon-id', 'chevron-right');
102
- icon.setAttribute('data-icon-text', 'Navigate right');
103
- document.body.appendChild(icon);
104
- ```
105
-
106
- ### Server-Side Rendering
107
-
108
- ```javascript
109
- import { renderBrickIcon } from '@amedia/brick-icon/template';
110
-
111
- const html = renderBrickIcon({
112
- dataIconId: 'play',
113
- dataIconText: 'Play video',
114
- dataIconSize: 'medium',
115
- });
91
+ <brick-icon-v2
92
+ data-icon-id="search"
93
+ data-icon-text="Search"
94
+ data-icon-size="small"
95
+ ></brick-icon-v2>
116
96
  ```
117
97
 
118
- ### Dynamic Icon Changes
98
+ ### Dynamic attribute changes
119
99
 
120
- Icons can be updated dynamically via attribute changes:
100
+ Both `data-icon-id` and `data-icon-text` are observed attributes. Changing them at runtime updates the rendered SVG immediately without re-creating the element:
121
101
 
122
- ```javascript
102
+ ```js
123
103
  const icon = document.querySelector('brick-icon-v2');
124
-
125
- // Update icon ID
126
104
  icon.setAttribute('data-icon-id', 'chevron-up');
127
-
128
- // Update screen reader text
129
105
  icon.setAttribute('data-icon-text', 'Collapse section');
130
106
  ```
131
107
 
@@ -133,7 +109,7 @@ icon.setAttribute('data-icon-text', 'Collapse section');
133
109
 
134
110
  ### SVG Sprite Requirement
135
111
 
136
- brick-icon requires an SVG sprite to be embedded in the HTML page. The sprite must contain `<symbol>` elements with IDs matching the `data-icon-id` values.
112
+ `brick-icon` requires an SVG sprite to be embedded in the HTML page. The sprite must contain `<symbol>` elements whose `id` attributes match the `data-icon-id` values used on the component.
137
113
 
138
114
  ```html
139
115
  <svg style="display: none;">
@@ -146,32 +122,24 @@ brick-icon requires an SVG sprite to be embedded in the HTML page. The sprite mu
146
122
  </svg>
147
123
  ```
148
124
 
149
- Check out `@amedia/brick-icons` package which provides theme-specific SVG sprites maintained in Figma.
150
-
151
- ### Why Inline SVG Sprite
152
-
153
- - Eliminates additional network requests
154
- - Simpler implementation without asynchronous loading
155
- - Icons available immediately when HTML is parsed
156
- - Better perceived performance
157
- - Optimal for small to medium icon sets
125
+ The `@amedia/brick-icons` package provides theme-specific SVG sprites maintained in Figma.
158
126
 
159
127
  ## Accessibility
160
128
 
161
- ### Automatic ARIA Handling
129
+ ### Automatic ARIA handling
162
130
 
163
- - **With `data-icon-text`**: Icon receives `role="graphics-symbol"` and a `<title>` element with the provided text, making it accessible to screen readers
164
- - **Without `data-icon-text`**: Icon receives `aria-hidden="true"`, hiding it from screen readers (appropriate for decorative icons)
131
+ - **With `data-icon-text`**: The inner `<svg>` receives `role="graphics-symbol"` and `aria-labelledby` pointing to a `<title>` element that contains the provided text. Screen readers announce the icon text.
132
+ - **Without `data-icon-text`**: The inner `<svg>` receives `aria-hidden="true"`, completely hiding the icon from the accessibility tree. Use this for decorative icons or when adjacent visible text already conveys the meaning.
165
133
 
166
- ### VoiceOver Compatibility
134
+ ### Reduced motion
167
135
 
168
- Icons include `aria-labelledby` attributes for proper announcement in Safari with VoiceOver.
136
+ The breaking news pulse animation respects `prefers-reduced-motion` and disables itself when the user preference is set.
169
137
 
170
- ### Best Practices
138
+ ### Best practices
171
139
 
172
- - Omit `data-icon-text` for decorative icons or when adjacent text provides context
173
- - Always provide `data-icon-text` for standalone interactive icons
174
- - Ensure color contrast meets WCAG 2.1 AA requirements when customizing colors
140
+ - Omit `data-icon-text` for purely decorative icons or when surrounding text provides the same information.
141
+ - Always provide `data-icon-text` for standalone meaningful icons (e.g., an icon-only button must have icon text or an `aria-label` on the button).
142
+ - Ensure color contrast meets WCAG 2.1 AA when customizing icon colors.
175
143
 
176
144
  ## Styling
177
145
 
@@ -180,22 +148,22 @@ Icons include `aria-labelledby` attributes for proper announcement in Safari wit
180
148
  | Property | Description | Default |
181
149
  | ------------------------------------ | ----------------------------------------- | ------------------------------------------ |
182
150
  | `--b-icon-color` | Icon fill color | `currentColor` |
183
- | `--b-icon-size` | Container size (height) | `var(--brick-sizes-iconM)` (24px) |
184
- | `--b-icon-svg-width` | SVG element width | `var(--brick-sizes-iconM)` (24px) |
185
- | `--b-icon-svg-height` | SVG element height | `var(--brick-sizes-iconM)` (24px) |
151
+ | `--b-icon-size` | Container and default SVG size (height) | `var(--brick-sizes-iconM)` (24px) |
152
+ | `--b-icon-svg-width` | SVG element width | Inherits from `--b-icon-size` |
153
+ | `--b-icon-svg-height` | SVG element height | Inherits from `--b-icon-size` |
186
154
  | `--b-icon-color-breaking-pulseStart` | Breaking icon pulse animation start color | `var(--brick-colors-pillNonePulseStartBg)` |
187
155
  | `--b-icon-color-breaking-pulseEnd` | Breaking icon pulse animation end color | `var(--brick-colors-pillNonePulseEndBg)` |
188
156
 
189
- ### Custom Sizing Example
157
+ ### Custom sizing example
190
158
 
191
159
  ```css
192
- brick-icon-v2[data-icon-id='custom-large'] {
160
+ brick-icon-v2[data-icon-id="custom-large"] {
193
161
  --b-icon-svg-width: 48px;
194
162
  --b-icon-svg-height: 48px;
195
163
  }
196
164
  ```
197
165
 
198
- ### Color Customization
166
+ ### Color customization
199
167
 
200
168
  ```css
201
169
  brick-icon-v2 {
@@ -203,26 +171,7 @@ brick-icon-v2 {
203
171
  }
204
172
  ```
205
173
 
206
- ## Common Patterns
207
-
208
- ### Icon with Adjacent Text
209
-
210
- ```html
211
- <a href="/search">
212
- <brick-icon-v2 data-icon-id="search"></brick-icon-v2>
213
- Search
214
- </a>
215
- ```
216
-
217
- ### Icon-Only Button
218
-
219
- ```html
220
- <button aria-label="Close dialog">
221
- <brick-icon-v2 data-icon-id="close" data-icon-text="Close"> </brick-icon-v2>
222
- </button>
223
- ```
224
-
225
- ### Responsive Icon Sizing
174
+ ### Responsive sizing
226
175
 
227
176
  ```css
228
177
  brick-icon-v2 {
@@ -238,37 +187,41 @@ brick-icon-v2 {
238
187
 
239
188
  ## Technical Details
240
189
 
241
- - **Custom Element**: `brick-icon-v2`
242
- - **Base Class**: BrickElement
243
- - **Dependencies**: @amedia/brick-tokens, @amedia/brick-template
244
- - **Renders as**: `<brick-icon-v2>` container with internal `<svg>` element
245
- - **Observed Attributes**: `data-icon-id`, `data-icon-text`
246
- - **Mirrored Props**: `data-icon-id`, `data-icon-text`, `data-icon-size`
190
+ - **Package version**: `2.4.1`
191
+ - **Custom Element tag**: `brick-icon-v2` -- must match the `selector` in frontmatter; the tag uses only the **major** version, not the full semver
192
+ - **Base class**: `BrickElement` (from `@amedia/brick-template`)
193
+ - **Dependencies**: `@amedia/brick-tokens@6.2.2`, `@amedia/brick-template@2.1.0`
194
+ - **Observed attributes** (trigger `attributeChangedCallback`): `data-icon-id`, `data-icon-text`
195
+ - **Mirrored props**: `data-icon-id`, `data-icon-text`, `data-icon-size`
196
+ - **SSR submodule**: `@amedia/brick-icon/template` exports `renderBrickIcon`, `iconStyle`, `iconContainerStyle`
197
+ - **Build target**: ES2020 + Safari 15
247
198
 
248
199
  ## Important Notes
249
200
 
250
- ### Version 2 Breaking Changes
201
+ ### SVG sprite must be present in the DOM
202
+
203
+ The component references icons via `<use href="#iconId">`. If the SVG sprite containing the corresponding `<symbol>` is not embedded in the page, no icon will be visible. There is no external sprite loading or error indication.
251
204
 
252
- Version 2.0.0 introduced breaking changes:
205
+ ### Version 2 breaking changes (from v1)
253
206
 
254
- - New tag name: `brick-icon-v2` (previously `brick-icon`)
255
- - Requires embedded SVG sprite in HTML (no external sprite loading)
256
- - Removed `theme` property (no longer needed)
257
- - Removed CommonJS build
207
+ - Tag name changed to `brick-icon-v2` (previously `brick-icon`)
208
+ - Requires embedded SVG sprite in HTML (external sprite loading was removed)
209
+ - The `theme` property was removed
210
+ - CommonJS build was removed; ESM only
258
211
 
259
- ### Size Control
212
+ ### Size control
260
213
 
261
- The `data-icon-size` attribute sets predefined sizes:
214
+ The `data-icon-size` attribute triggers predefined CSS overrides:
262
215
 
263
- - `small`: Uses `--brick-sizes-iconS` token (typically 16px)
264
- - `medium`: Uses `--brick-sizes-iconM` token (typically 24px)
216
+ - `small`: Uses `--brick-sizes-iconS` token (fallback 12px)
217
+ - `medium`: Uses `--brick-sizes-iconM` token (fallback 24px)
265
218
 
266
- For custom sizes, use CSS custom properties instead.
219
+ For sizes outside these presets, use CSS custom properties directly.
267
220
 
268
- ### Breaking News Animation
221
+ ### Breaking news animation
269
222
 
270
- The icon with `data-icon-id="pill-breaking"` includes a special pulsing animation controlled by the `--b-icon-color-breaking-pulseStart` and `--b-icon-color-breaking-pulseEnd` CSS variables.
223
+ The icon with `data-icon-id="pill-breaking"` has a pulse animation. Since version 2.4.0, the animation uses CSS `color-mix()` on browsers that support it, with an automatic fallback to dedicated pulse color variables (`--b-icon-color-breaking-pulseStart`, `--b-icon-color-breaking-pulseEnd`) for older browsers. The animation is disabled when the user has `prefers-reduced-motion` enabled.
271
224
 
272
- ## Version
225
+ ### `data-icon-size` is not an observed attribute
273
226
 
274
- Current version: 2.3.1
227
+ Only `data-icon-id` and `data-icon-text` are in the `observedAttributes` list. Changing `data-icon-size` after the element has connected does not trigger an automatic re-render of size styles. Set it before the element connects, or update the CSS custom properties directly.