@amedia/brick-mcp 0.0.2 → 0.1.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/data/components-metadata.json +35 -29
- package/data/tokens-documentation.json +1 -1
- package/data/tokens.json +4848 -128
- package/dist/data/components/brick-actions.md +59 -0
- package/dist/data/components/brick-alt-teaser.md +264 -0
- package/dist/data/components/brick-avatar.md +299 -0
- package/dist/data/components/brick-button.md +373 -0
- package/dist/data/components/brick-card.md +359 -0
- package/dist/data/components/brick-carousel.md +355 -0
- package/dist/data/components/brick-classnames.md +147 -0
- package/dist/data/components/brick-countdown.md +180 -0
- package/dist/data/components/brick-dialog.md +458 -0
- package/dist/data/components/brick-fonts.md +389 -0
- package/dist/data/components/brick-helloworld.md +228 -0
- package/dist/data/components/brick-icon.md +274 -0
- package/dist/data/components/brick-icons.md +570 -0
- package/dist/data/components/brick-illustrations.md +604 -0
- package/dist/data/components/brick-image.md +361 -0
- package/dist/data/components/brick-input.md +557 -0
- package/dist/data/components/brick-mcp.json +6 -0
- package/dist/data/components/brick-nifs.md +164 -0
- package/dist/data/components/brick-pill.json +6 -0
- package/dist/data/components/brick-player.json +7 -0
- package/dist/data/components/brick-published.json +7 -0
- package/dist/data/components/brick-share.json +7 -0
- package/dist/data/components/brick-stepper.json +7 -0
- package/dist/data/components/brick-tab.json +7 -0
- package/dist/data/components/brick-tabs.json +9 -0
- package/dist/data/components/brick-tag.json +7 -0
- package/dist/data/components/brick-teaser-player.json +9 -0
- package/dist/data/components/brick-teaser-reels.json +9 -0
- package/dist/data/components/brick-teaser.json +9 -0
- package/dist/data/components/brick-template.json +9 -0
- package/dist/data/components/brick-textarea.json +7 -0
- package/dist/data/components/brick-themes.json +6 -0
- package/dist/data/components/brick-toast.json +9 -0
- package/dist/data/components/brick-toggle.json +7 -0
- package/dist/data/components/brick-tokens.json +8 -0
- package/dist/data/components/brick-tooltip.json +7 -0
- package/dist/data/components-metadata.json +234 -0
- package/dist/data/tokens-documentation.json +7 -0
- package/dist/data/tokens.json +4976 -0
- package/dist/http.js +314 -0
- package/dist/http.js.map +7 -0
- package/dist/index.js +26 -37
- package/dist/index.js.map +2 -2
- package/package.json +2 -2
- package/scripts/generate-data.js +15 -47
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brick-actions
|
|
3
|
+
version: 0.1.5
|
|
4
|
+
category: Tooling
|
|
5
|
+
tags: [github-actions, automation, eik, publishing, ci-cd]
|
|
6
|
+
use_cases: [ci-cd, automated-publishing, eik-deployment]
|
|
7
|
+
related: []
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Brick Actions
|
|
11
|
+
|
|
12
|
+
Custom JavaScript GitHub Actions used to automate packaging and publishing to Eik when packages are published to NPM.
|
|
13
|
+
|
|
14
|
+
## Key Capabilities
|
|
15
|
+
|
|
16
|
+
- Automatically publishes packages to Eik CDN after NPM publication
|
|
17
|
+
- Filters packages based on Eik configuration in package.json
|
|
18
|
+
- Integrates with Changesets workflow for version management
|
|
19
|
+
- Validates required secrets/tokens before execution
|
|
20
|
+
|
|
21
|
+
## Technical Details
|
|
22
|
+
|
|
23
|
+
- **Type**: GitHub Action (JavaScript)
|
|
24
|
+
- **Main**: dist/index.js
|
|
25
|
+
- **Build Tool**: @vercel/ncc
|
|
26
|
+
- **Dependencies**: @actions/core, @actions/exec, @actions/github, @eik/cli, @manypkg/get-packages
|
|
27
|
+
|
|
28
|
+
## How It Works
|
|
29
|
+
|
|
30
|
+
1. Triggered when Changesets publishes packages to NPM
|
|
31
|
+
2. Receives `publishedPackages` as input
|
|
32
|
+
3. Filters packages that have `eik` configuration in package.json
|
|
33
|
+
4. Runs `eik package` command with proper credentials
|
|
34
|
+
5. Publishes to Eik CDN at https://assets.acdn.no
|
|
35
|
+
|
|
36
|
+
## Development
|
|
37
|
+
|
|
38
|
+
### Building
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm run build-index
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This uses @vercel/ncc to compile code and modules into a single distribution file.
|
|
45
|
+
|
|
46
|
+
### Testing
|
|
47
|
+
|
|
48
|
+
Can be tested locally using [Act](https://github.com/nektos/act) with environment variables via dotenv.
|
|
49
|
+
|
|
50
|
+
## Important Notes
|
|
51
|
+
|
|
52
|
+
- Not a Brick web component - this is tooling for CI/CD
|
|
53
|
+
- Changesets handles versioning and CHANGELOG updates
|
|
54
|
+
- Does not commit `.eik/integrity.json` files
|
|
55
|
+
- Requires proper Eik credentials in GitHub secrets
|
|
56
|
+
|
|
57
|
+
## Version
|
|
58
|
+
|
|
59
|
+
Current version: 0.1.5
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brick-alt-teaser
|
|
3
|
+
version: 8.0.65
|
|
4
|
+
selector: brick-alt-teaser-v8
|
|
5
|
+
category: Media
|
|
6
|
+
tags: [teaser, article, news, card, content-preview, media, alt-theme]
|
|
7
|
+
use_cases:
|
|
8
|
+
[
|
|
9
|
+
news-listing,
|
|
10
|
+
content-cards,
|
|
11
|
+
article-preview,
|
|
12
|
+
editorial-content,
|
|
13
|
+
opinion-pieces,
|
|
14
|
+
video-teasers,
|
|
15
|
+
photo-galleries,
|
|
16
|
+
reviews,
|
|
17
|
+
featured-content,
|
|
18
|
+
]
|
|
19
|
+
related: [brick-image, brick-player, brick-pill, brick-icon]
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# Brick Alt Teaser
|
|
23
|
+
|
|
24
|
+
A flexible article teaser component designed for the Alt theme, supporting multiple content types including standard articles, features, opinions, videos, galleries, and reviews.
|
|
25
|
+
|
|
26
|
+
## Key Capabilities
|
|
27
|
+
|
|
28
|
+
- Multiple layout variants: standard article, feature, opinion, video, gallery, and review
|
|
29
|
+
- Responsive image handling with srcset and custom aspect ratios
|
|
30
|
+
- Video playback integration via brick-player
|
|
31
|
+
- Photo gallery support with image count indicator
|
|
32
|
+
- Review ratings displayed as dice icons
|
|
33
|
+
- Opinion pieces with author bylines and profile images
|
|
34
|
+
- Countdown timer support for time-sensitive content
|
|
35
|
+
- Analytics integration with ADP (Amedia Data Platform)
|
|
36
|
+
- Customizable background colors for visual categorization
|
|
37
|
+
- Accessibility features including ARIA labels and screen reader support
|
|
38
|
+
|
|
39
|
+
## Props/Attributes
|
|
40
|
+
|
|
41
|
+
| Attribute | Type | Default | Required | Description |
|
|
42
|
+
| ----------------------------- | ------- | --------- | -------- | ------------------------------------------------------------------ |
|
|
43
|
+
| `title` | string | '' | yes | Main headline of the article |
|
|
44
|
+
| `link` | string | '' | yes | URL to the full article |
|
|
45
|
+
| `publication` | string | '' | no | Publication domain (e.g., "www.tb.no") |
|
|
46
|
+
| `name` | string | '' | no | Publication name (e.g., "Tønsbergs Blad") |
|
|
47
|
+
| `articleId` | string | '' | no | Unique article identifier for tracking |
|
|
48
|
+
| `published` | string | '' | no | Publication date/time (supports ISO 8601 or human-readable format) |
|
|
49
|
+
| `readEstimate` | string | '' | no | Estimated reading time (e.g., "Lesetid 4 min") |
|
|
50
|
+
| `image` | string | '' | no | Primary image URL |
|
|
51
|
+
| `srcset` | string | '' | no | Responsive image srcset for different screen sizes |
|
|
52
|
+
| `imagesizes` | string | '' | no | Image sizes attribute for responsive images |
|
|
53
|
+
| `imageRatio` | string | '' | no | Custom aspect ratio (e.g., "16/9", "4/3", "1.33") |
|
|
54
|
+
| `aoi` | number | - | no | Area of interest width for image cropping |
|
|
55
|
+
| `altText` | string | '' | no | Alternative text for images |
|
|
56
|
+
| `tags` | string | '' | no | Comma-separated content tags |
|
|
57
|
+
| `pretitle` | string | '' | no | Text displayed above the main title (for features) |
|
|
58
|
+
| `feature` | boolean | false | no | Enables feature layout variant |
|
|
59
|
+
| `opinion` | boolean | false | no | Enables opinion layout variant |
|
|
60
|
+
| `review` | number | - | no | Review rating (1-6, displayed as dice icons) |
|
|
61
|
+
| `gallery` | string | '' | no | Comma-separated list of gallery image URLs |
|
|
62
|
+
| `isVideo` | boolean | false | no | Enables video teaser mode |
|
|
63
|
+
| `videoId` | string | '' | no | Video identifier for brick-player |
|
|
64
|
+
| `playerId` | string | '' | no | Flowplayer player ID |
|
|
65
|
+
| `authorName` | string | '' | no | Author name(s) for opinion pieces (comma-separated for multiple) |
|
|
66
|
+
| `authorRole` | string | '' | no | Author role/title for opinion pieces |
|
|
67
|
+
| `authorImage` | string | '' | no | Author profile image URL |
|
|
68
|
+
| `backgroundColor` | string | '#d3d9de' | no | Background color for the teaser card |
|
|
69
|
+
| `countdown` | string | '' | no | ISO 8601 date for countdown timer |
|
|
70
|
+
| `menuOnClickEventName` | string | '' | no | Custom event name dispatched when menu is clicked |
|
|
71
|
+
| `publicationOnHoverEventName` | string | '' | no | Custom event name dispatched on publication logo hover |
|
|
72
|
+
| `siteId` | string | '' | no | Site identifier for analytics |
|
|
73
|
+
| `small` | boolean | false | no | Enables compact layout variant |
|
|
74
|
+
|
|
75
|
+
## Examples
|
|
76
|
+
|
|
77
|
+
### Basic Article Teaser
|
|
78
|
+
|
|
79
|
+
```html
|
|
80
|
+
<brick-alt-teaser-v8
|
|
81
|
+
title="Harvard: Fem av de beste treningsøvelsene du noensinne kan gjøre"
|
|
82
|
+
link="https://example.com/article/123"
|
|
83
|
+
publication="www.tb.no"
|
|
84
|
+
name="Tønsbergs Blad"
|
|
85
|
+
published="i dag 13:37"
|
|
86
|
+
readEstimate="Lesetid 4 min"
|
|
87
|
+
image="https://g.acdn.no/api/reflex/v1/image/resize/480/example.jpg"
|
|
88
|
+
srcset="https://g.acdn.no/api/reflex/v1/image/resize/480/example.jpg 880w, https://g.acdn.no/api/reflex/v1/image/resize/1280/example.jpg 1280w"
|
|
89
|
+
articleId="5-95-91371"
|
|
90
|
+
tags="Utvikling"
|
|
91
|
+
backgroundColor="#D3D9DE"
|
|
92
|
+
>
|
|
93
|
+
</brick-alt-teaser-v8>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Feature Teaser
|
|
97
|
+
|
|
98
|
+
```html
|
|
99
|
+
<brick-alt-teaser-v8
|
|
100
|
+
feature="true"
|
|
101
|
+
pretitle="Stikktittel for feature"
|
|
102
|
+
title="Tittel for feature teaser"
|
|
103
|
+
publication="www.akersposten.no"
|
|
104
|
+
name="Akersposten"
|
|
105
|
+
image="https://g.acdn.no/api/reflex/v1/image/resize/480/example.jpg"
|
|
106
|
+
altText="Beskrivende alt-tekst"
|
|
107
|
+
link="https://example.com/feature/456"
|
|
108
|
+
backgroundColor="#DEDCD3"
|
|
109
|
+
>
|
|
110
|
+
</brick-alt-teaser-v8>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Video Teaser
|
|
114
|
+
|
|
115
|
+
```html
|
|
116
|
+
<brick-alt-teaser-v8
|
|
117
|
+
title="Tittel for video teaser"
|
|
118
|
+
isVideo="true"
|
|
119
|
+
videoId="ea507f6b-ca59-4ae6-a5fa-942fd02b458a"
|
|
120
|
+
playerId="3689c16b-4cb9-4a36-baf4-2c3aa7fcc811"
|
|
121
|
+
publication="www.tb.no"
|
|
122
|
+
name="Tønsbergs Blad"
|
|
123
|
+
published="i dag 13:37"
|
|
124
|
+
readEstimate="Spilletid 13:37 min"
|
|
125
|
+
link="https://example.com/video/789"
|
|
126
|
+
backgroundColor="#D3DED6"
|
|
127
|
+
>
|
|
128
|
+
</brick-alt-teaser-v8>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Opinion Teaser
|
|
132
|
+
|
|
133
|
+
```html
|
|
134
|
+
<brick-alt-teaser-v8
|
|
135
|
+
opinion="true"
|
|
136
|
+
title="Mening om viktig samfunnsspørsmål"
|
|
137
|
+
authorName="Hege Breen Bakken"
|
|
138
|
+
authorRole="Politisk redaktør i Drammens Tidende"
|
|
139
|
+
authorImage="https://image.journalisten.no/357695.jpg"
|
|
140
|
+
publication="www.dt.no"
|
|
141
|
+
name="Drammens Tidende"
|
|
142
|
+
published="i dag 13:37"
|
|
143
|
+
image="https://g.acdn.no/api/reflex/v1/image/resize/480/example.jpg"
|
|
144
|
+
link="https://example.com/opinion/101"
|
|
145
|
+
>
|
|
146
|
+
</brick-alt-teaser-v8>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Gallery Teaser
|
|
150
|
+
|
|
151
|
+
```html
|
|
152
|
+
<brick-alt-teaser-v8
|
|
153
|
+
title="Bildegalleri fra årets arrangement"
|
|
154
|
+
gallery="https://example.com/img1.jpg, https://example.com/img2.jpg, https://example.com/img3.jpg"
|
|
155
|
+
image="https://example.com/img1.jpg"
|
|
156
|
+
readEstimate="3 bilder"
|
|
157
|
+
publication="www.tb.no"
|
|
158
|
+
name="Tønsbergs Blad"
|
|
159
|
+
published="i dag 13:37"
|
|
160
|
+
link="https://example.com/gallery/202"
|
|
161
|
+
altText="Bilder fra arrangementet"
|
|
162
|
+
>
|
|
163
|
+
</brick-alt-teaser-v8>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Review Teaser
|
|
167
|
+
|
|
168
|
+
```html
|
|
169
|
+
<brick-alt-teaser-v8
|
|
170
|
+
title="Anmeldelse: Årets beste film"
|
|
171
|
+
review="5"
|
|
172
|
+
image="https://g.acdn.no/api/reflex/v1/image/resize/480/example.jpg"
|
|
173
|
+
publication="www.tb.no"
|
|
174
|
+
name="Tønsbergs Blad"
|
|
175
|
+
published="i dag 13:37"
|
|
176
|
+
readEstimate="Lesetid 6 min"
|
|
177
|
+
link="https://example.com/review/303"
|
|
178
|
+
altText="Filmplakat"
|
|
179
|
+
>
|
|
180
|
+
</brick-alt-teaser-v8>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Programmatic Usage
|
|
184
|
+
|
|
185
|
+
```javascript
|
|
186
|
+
import { BrickAltTeaser } from '@amedia/brick-alt-teaser';
|
|
187
|
+
|
|
188
|
+
// The component auto-registers as brick-alt-teaser-v8
|
|
189
|
+
// You can also manually define it:
|
|
190
|
+
if (!customElements.get('brick-alt-teaser-v8')) {
|
|
191
|
+
customElements.define('brick-alt-teaser-v8', BrickAltTeaser);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Create and append programmatically
|
|
195
|
+
const teaser = document.createElement('brick-alt-teaser-v8');
|
|
196
|
+
teaser.setAttribute('title', 'My Article Title');
|
|
197
|
+
teaser.setAttribute('link', 'https://example.com/article');
|
|
198
|
+
teaser.setAttribute('image', 'https://example.com/image.jpg');
|
|
199
|
+
document.querySelector('#container').appendChild(teaser);
|
|
200
|
+
|
|
201
|
+
// Listen to custom events
|
|
202
|
+
teaser.addEventListener('my-menu-event', (event) => {
|
|
203
|
+
console.log('Menu clicked');
|
|
204
|
+
});
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Accessibility
|
|
208
|
+
|
|
209
|
+
- **ARIA Labels**: Each teaser includes a comprehensive screen reader label combining title, publication, and date
|
|
210
|
+
- **Keyboard Navigation**: Single tab stop per teaser (title link only) to avoid redundant navigation
|
|
211
|
+
- **Focus Indicators**: Clear 2px outline on all focusable elements
|
|
212
|
+
- **Semantic HTML**: Uses `<article>` with Schema.org NewsArticle markup
|
|
213
|
+
- **Alt Text Support**: Images can include descriptive alternative text via `altText` attribute
|
|
214
|
+
- **Skip Decorative Images**: Image links are `aria-hidden` to prevent duplicate announcements
|
|
215
|
+
- **Menu Button**: Options menu includes proper `aria-expanded` state management
|
|
216
|
+
|
|
217
|
+
## Analytics Integration
|
|
218
|
+
|
|
219
|
+
The component includes built-in ADP (Amedia Data Platform) tracking:
|
|
220
|
+
|
|
221
|
+
- **Teaser Clicks**: Automatically tagged with `data-adp-clickLabel="teaser"` and `data-adp-clickValue="read-article"`
|
|
222
|
+
- **Menu Interactions**: Menu button tagged with `data-adp-clickvalue="open-menu"`
|
|
223
|
+
- **Publication Tracking**: Publication logo includes hover tracking
|
|
224
|
+
- **Custom Events**: Dispatches custom events via `menuOnClickEventName` and `publicationOnHoverEventName`
|
|
225
|
+
- **Article Metadata**: Includes Schema.org itemprops for structured data tracking
|
|
226
|
+
|
|
227
|
+
## Layout Variants
|
|
228
|
+
|
|
229
|
+
The component automatically selects layout based on attributes:
|
|
230
|
+
|
|
231
|
+
- **Opinion Layout**: Triggered by `opinion="true"` - Image above title with author byline
|
|
232
|
+
- **Video/Gallery Layout**: Triggered by `isVideo="true"` or `gallery` attribute - Media at top
|
|
233
|
+
- **Feature Layout**: Triggered by `feature="true"` - Enhanced styling with optional pretitle
|
|
234
|
+
- **Standard Layout**: Default layout with image below title
|
|
235
|
+
- **Small Layout**: Triggered by `small="true"` - Compact horizontal layout
|
|
236
|
+
|
|
237
|
+
## Technical Details
|
|
238
|
+
|
|
239
|
+
- **Custom Element**: `brick-alt-teaser-v8`
|
|
240
|
+
- **Base Class**: HTMLElement (vanilla web component)
|
|
241
|
+
- **Dependencies**:
|
|
242
|
+
- `@amedia/brick-tokens` - Design tokens and styling
|
|
243
|
+
- `@amedia/brick-image` - Image rendering
|
|
244
|
+
- `@amedia/brick-player` - Video playback
|
|
245
|
+
- `@amedia/brick-pill` - Tag/pill components
|
|
246
|
+
- `@amedia/brick-icon` - Icon rendering
|
|
247
|
+
- **Renders as**: `<article>` with nested semantic HTML
|
|
248
|
+
- **Styling**: CSS-in-JS via Stitches with design tokens
|
|
249
|
+
- **Schema.org**: Implements NewsArticle microdata
|
|
250
|
+
|
|
251
|
+
## Important Notes
|
|
252
|
+
|
|
253
|
+
- **Alt Team Component**: Built and maintained by the Alt theme team. Consult with them before using in other contexts.
|
|
254
|
+
- **Image Srcset**: As of v8.0.0, image srcset must be provided externally with correct sizes and encoding - it is no longer auto-generated
|
|
255
|
+
- **Date Formats**: The `published` attribute accepts both human-readable strings ("i dag 13:37") and ISO 8601 timestamps
|
|
256
|
+
- **Multiple Authors**: Opinion pieces support multiple comma-separated authors, which will display with ellipsis overflow
|
|
257
|
+
- **Background Colors**: Common background colors follow design token patterns for subject categorization (default, nature, sport, health, culture, economy)
|
|
258
|
+
- **Review Ratings**: Review attribute accepts values 1-6, displayed as dice icons
|
|
259
|
+
- **Video Player**: Requires valid Flowplayer player ID and video ID for video teasers
|
|
260
|
+
- **Countdown**: Countdown attribute expects ISO 8601 date format for time-sensitive content
|
|
261
|
+
|
|
262
|
+
## Version
|
|
263
|
+
|
|
264
|
+
Current version: 8.0.65
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brick-avatar
|
|
3
|
+
version: 0.2.36
|
|
4
|
+
selector: brick-avatar-v0
|
|
5
|
+
category: Media
|
|
6
|
+
tags: [avatar, profile, user, image, initials, icon, identity, media]
|
|
7
|
+
use_cases:
|
|
8
|
+
[
|
|
9
|
+
user-profiles,
|
|
10
|
+
author-bylines,
|
|
11
|
+
comment-sections,
|
|
12
|
+
team-rosters,
|
|
13
|
+
sports-teams,
|
|
14
|
+
contact-lists,
|
|
15
|
+
chat-interfaces,
|
|
16
|
+
social-features,
|
|
17
|
+
]
|
|
18
|
+
related: [brick-image, brick-tokens]
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# Brick Avatar
|
|
22
|
+
|
|
23
|
+
A visual component representing a person, object, or entity through an image, icon, or initials.
|
|
24
|
+
|
|
25
|
+
## Key Capabilities
|
|
26
|
+
|
|
27
|
+
- Display user profile images with automatic fallback to initials
|
|
28
|
+
- Support for multiple sizes (small, medium, large) and shapes (default theme, circle)
|
|
29
|
+
- Decorative letter shapes for sports teams and organizations (shield, t-shirt)
|
|
30
|
+
- Custom CSS property support for SVG backgrounds
|
|
31
|
+
- Accessible implementation with proper alt text handling
|
|
32
|
+
- Server-side rendering support for optimal performance
|
|
33
|
+
|
|
34
|
+
## Props/Attributes
|
|
35
|
+
|
|
36
|
+
| Attribute | Type | Default | Required | Description |
|
|
37
|
+
| -------------------- | ------------------------------ | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
38
|
+
| `data-img` | string | "" | no | URL for the avatar image. Preferably a square image (cropped from top if not square) |
|
|
39
|
+
| `data-letters` | string | "" | no | One or two letter string used as initials when image is not provided or fails to load |
|
|
40
|
+
| `data-alt` | string | "" | no | Alternative text for images or screen reader text for letter avatars. Empty string hides decorative avatars from assistive technology |
|
|
41
|
+
| `data-size` | "small" \| "medium" \| "large" | "medium" | no | Controls the size of the avatar using design tokens |
|
|
42
|
+
| `data-shape` | "circle" \| "" | "" | no | Sets the avatar shape. Empty string uses theme default avatar shape |
|
|
43
|
+
| `data-letters-shape` | "shield" \| "tshirt" \| "" | "" | no | Adds a background shape behind letters. Only applies when using `data-letters`, not with `data-img` |
|
|
44
|
+
|
|
45
|
+
## Examples
|
|
46
|
+
|
|
47
|
+
### Basic Avatar with Initials
|
|
48
|
+
|
|
49
|
+
Display user initials as a fallback or primary identifier.
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<brick-avatar-v0
|
|
53
|
+
data-letters="AM"
|
|
54
|
+
data-alt="Initials for Amedia"
|
|
55
|
+
data-size="medium"
|
|
56
|
+
>
|
|
57
|
+
</brick-avatar-v0>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Avatar with Image
|
|
61
|
+
|
|
62
|
+
Show a profile photo with automatic fallback to initials if image fails.
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<brick-avatar-v0
|
|
66
|
+
data-img="https://example.com/profile-photo.jpg"
|
|
67
|
+
data-alt="Profile picture of John Doe"
|
|
68
|
+
data-letters="JD"
|
|
69
|
+
data-size="large"
|
|
70
|
+
>
|
|
71
|
+
</brick-avatar-v0>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Circle Avatar for User Profiles
|
|
75
|
+
|
|
76
|
+
Use circle shape for a softer, more personal feel in user interfaces.
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<brick-avatar-v0
|
|
80
|
+
data-img="https://example.com/user-avatar.jpg"
|
|
81
|
+
data-alt="User profile picture"
|
|
82
|
+
data-shape="circle"
|
|
83
|
+
data-size="medium"
|
|
84
|
+
>
|
|
85
|
+
</brick-avatar-v0>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Sports Team Avatar with Shield
|
|
89
|
+
|
|
90
|
+
Display team initials with a shield background, commonly used in sports applications.
|
|
91
|
+
|
|
92
|
+
```html
|
|
93
|
+
<brick-avatar-v0
|
|
94
|
+
data-letters="BSK"
|
|
95
|
+
data-alt="Bærum Sportsklubb team logo"
|
|
96
|
+
data-letters-shape="shield"
|
|
97
|
+
data-size="medium"
|
|
98
|
+
style="--b-avatar-color-fg:var(--brick-colors-supportiveSportFg);
|
|
99
|
+
--b-avatar-color-border:var(--brick-colors-supportiveSportBg);
|
|
100
|
+
--b-avatar-color-shape:var(--brick-colors-supportiveSportBg);"
|
|
101
|
+
>
|
|
102
|
+
</brick-avatar-v0>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Team Avatar with T-Shirt Shape
|
|
106
|
+
|
|
107
|
+
Use t-shirt shape for team jerseys or sports team identification.
|
|
108
|
+
|
|
109
|
+
```html
|
|
110
|
+
<brick-avatar-v0
|
|
111
|
+
data-letters="T"
|
|
112
|
+
data-alt="Team T jersey"
|
|
113
|
+
data-letters-shape="tshirt"
|
|
114
|
+
data-size="large"
|
|
115
|
+
style="--b-avatar-color-fg:var(--brick-colors-supportiveSportFg);
|
|
116
|
+
--b-avatar-color-shape:red;"
|
|
117
|
+
>
|
|
118
|
+
</brick-avatar-v0>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Avatar with SVG Background
|
|
122
|
+
|
|
123
|
+
Set a custom SVG as the avatar background using CSS custom property.
|
|
124
|
+
|
|
125
|
+
```html
|
|
126
|
+
<brick-avatar-v0
|
|
127
|
+
data-alt="Organization logo"
|
|
128
|
+
data-size="small"
|
|
129
|
+
style="--b-avatar-borderWidth:0;
|
|
130
|
+
--b-avatar-svg:url('https://example.com/logo.svg')"
|
|
131
|
+
>
|
|
132
|
+
</brick-avatar-v0>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Decorative Avatar (No Alt Text)
|
|
136
|
+
|
|
137
|
+
For purely decorative avatars where information is conveyed elsewhere, omit `data-alt` for accessibility.
|
|
138
|
+
|
|
139
|
+
```html
|
|
140
|
+
<brick-avatar-v0
|
|
141
|
+
data-img="https://example.com/decorative-icon.jpg"
|
|
142
|
+
data-size="small"
|
|
143
|
+
>
|
|
144
|
+
</brick-avatar-v0>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Server-Side Rendering
|
|
148
|
+
|
|
149
|
+
### Render Function
|
|
150
|
+
|
|
151
|
+
Use the template function for optimal server-side rendering performance.
|
|
152
|
+
|
|
153
|
+
```javascript
|
|
154
|
+
import { renderBrickAvatar } from '@amedia/brick-avatar/template';
|
|
155
|
+
|
|
156
|
+
const markup = renderBrickAvatar({
|
|
157
|
+
dataLetters: 'KN',
|
|
158
|
+
dataAlttext: 'Initials for Kari Nordmann',
|
|
159
|
+
dataSize: 'medium',
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Client-Side Import
|
|
164
|
+
|
|
165
|
+
Import the web component definition for client-side hydration and interactivity.
|
|
166
|
+
|
|
167
|
+
```javascript
|
|
168
|
+
import '@amedia/brick-avatar';
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## CSS Custom Properties
|
|
172
|
+
|
|
173
|
+
Customize the avatar appearance using CSS custom properties. Always scope your overrides and ensure WCAG 2.1 AA compliance.
|
|
174
|
+
|
|
175
|
+
| Property | Description | Default |
|
|
176
|
+
| ------------------------- | ------------------------------------------------------ | ----------------------------------- |
|
|
177
|
+
| `--b-avatar-svg` | Set the background SVG image using `url()` notation | None |
|
|
178
|
+
| `--b-avatar-size` | Controls the size (prefer using `data-size` attribute) | `var(--brick-sizes-avatarM)` |
|
|
179
|
+
| `--b-avatar-color-bg` | Background color for letter avatars | `var(--brick-colors-baseNeutral00)` |
|
|
180
|
+
| `--b-avatar-color-fg` | Text color for letter avatars | `var(--brick-colors-baseFg)` |
|
|
181
|
+
| `--b-avatar-color-border` | Border color | `var(--brick-colors-baseNeutral00)` |
|
|
182
|
+
| `--b-avatar-color-shape` | Background color for letter shapes (shield, t-shirt) | `transparent` |
|
|
183
|
+
| `--b-avatar-borderWidth` | Border width | `var(--brick-borderWidths-baseS)` |
|
|
184
|
+
| `--b-avatar-padding` | Internal padding | `0` |
|
|
185
|
+
|
|
186
|
+
### Custom Styling Example
|
|
187
|
+
|
|
188
|
+
```html
|
|
189
|
+
<brick-avatar-v0
|
|
190
|
+
data-img="https://api.nifs.no/images/teams/logo/8/"
|
|
191
|
+
data-size="large"
|
|
192
|
+
style="--b-avatar-padding:10px;
|
|
193
|
+
--b-avatar-size:120px;
|
|
194
|
+
--b-avatar-color-bg:var(--brick-colors-supportiveSportBg);
|
|
195
|
+
--b-avatar-color-fg:var(--brick-colors-supportiveSportFg);
|
|
196
|
+
--b-avatar-color-border:transparent;"
|
|
197
|
+
>
|
|
198
|
+
</brick-avatar-v0>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Accessibility
|
|
202
|
+
|
|
203
|
+
### Image Avatars
|
|
204
|
+
|
|
205
|
+
- Always provide `data-alt` for informative images describing the person or entity
|
|
206
|
+
- Omit `data-alt` for purely decorative avatars (automatically gets empty alt attribute)
|
|
207
|
+
- Screen readers will ignore decorative images with empty alt text
|
|
208
|
+
|
|
209
|
+
### Letter Avatars
|
|
210
|
+
|
|
211
|
+
- The `data-alt` property creates a visually hidden element for screen readers
|
|
212
|
+
- Provides context for abbreviated initials (e.g., "KN" becomes "Initials for Kari Nordmann")
|
|
213
|
+
- Ensures users with assistive technology understand the meaning of the letters
|
|
214
|
+
|
|
215
|
+
### Keyboard Navigation
|
|
216
|
+
|
|
217
|
+
- Avatar component is non-interactive by default
|
|
218
|
+
- If wrapped in an interactive element (button, link), ensure proper focus states
|
|
219
|
+
|
|
220
|
+
## Common Patterns
|
|
221
|
+
|
|
222
|
+
### Author Byline
|
|
223
|
+
|
|
224
|
+
Display author information in article headers or comments.
|
|
225
|
+
|
|
226
|
+
```html
|
|
227
|
+
<div class="author-byline">
|
|
228
|
+
<brick-avatar-v0
|
|
229
|
+
data-img="https://example.com/author.jpg"
|
|
230
|
+
data-alt="Photo of Jane Smith"
|
|
231
|
+
data-letters="JS"
|
|
232
|
+
data-size="small"
|
|
233
|
+
data-shape="circle"
|
|
234
|
+
>
|
|
235
|
+
</brick-avatar-v0>
|
|
236
|
+
<span class="author-name">Jane Smith</span>
|
|
237
|
+
</div>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### User List
|
|
241
|
+
|
|
242
|
+
Show multiple users in a team or contact list.
|
|
243
|
+
|
|
244
|
+
```html
|
|
245
|
+
<ul class="user-list">
|
|
246
|
+
<li>
|
|
247
|
+
<brick-avatar-v0 data-letters="AM" data-alt="Amedia" data-size="medium">
|
|
248
|
+
</brick-avatar-v0>
|
|
249
|
+
<span>Amedia</span>
|
|
250
|
+
</li>
|
|
251
|
+
<li>
|
|
252
|
+
<brick-avatar-v0
|
|
253
|
+
data-letters="KN"
|
|
254
|
+
data-alt="Kari Nordmann"
|
|
255
|
+
data-size="medium"
|
|
256
|
+
>
|
|
257
|
+
</brick-avatar-v0>
|
|
258
|
+
<span>Kari Nordmann</span>
|
|
259
|
+
</li>
|
|
260
|
+
</ul>
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Sports Team Roster
|
|
264
|
+
|
|
265
|
+
Display team members with jersey-style avatars.
|
|
266
|
+
|
|
267
|
+
```html
|
|
268
|
+
<div class="team-roster">
|
|
269
|
+
<brick-avatar-v0
|
|
270
|
+
data-letters="10"
|
|
271
|
+
data-alt="Player number 10"
|
|
272
|
+
data-letters-shape="tshirt"
|
|
273
|
+
data-size="large"
|
|
274
|
+
style="--b-avatar-color-shape:#003366;
|
|
275
|
+
--b-avatar-color-fg:#ffffff;"
|
|
276
|
+
>
|
|
277
|
+
</brick-avatar-v0>
|
|
278
|
+
</div>
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Technical Details
|
|
282
|
+
|
|
283
|
+
- **Custom Element**: `brick-avatar-v0`
|
|
284
|
+
- **Base Class**: BrickElement (from @amedia/brick-template)
|
|
285
|
+
- **Dependencies**: @amedia/brick-tokens, @amedia/brick-image
|
|
286
|
+
- **Renders as**: Custom element with internal image or text content
|
|
287
|
+
- **Browser Support**: All modern browsers supporting Custom Elements v1
|
|
288
|
+
|
|
289
|
+
## Important Notes
|
|
290
|
+
|
|
291
|
+
- Images should preferably be square for best results; non-square images are cropped from the top
|
|
292
|
+
- The `data-letters-shape` attribute only works with letter avatars, not image avatars
|
|
293
|
+
- Custom CSS properties override default theme values; ensure color contrast meets WCAG 2.1 AA standards
|
|
294
|
+
- When using `--b-avatar-svg`, the image is set as a background and will not have alt text for accessibility
|
|
295
|
+
- Server-side rendering is recommended for optimal performance and SEO
|
|
296
|
+
|
|
297
|
+
## Version
|
|
298
|
+
|
|
299
|
+
Current version: 0.2.36
|