@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,389 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brick-fonts
|
|
3
|
+
version: 2.0.2
|
|
4
|
+
category: Resources
|
|
5
|
+
tags: [fonts, typography, web-fonts, font-face, css, theming, woff2]
|
|
6
|
+
use_cases:
|
|
7
|
+
[typography, branding, theme-implementation, font-loading, multi-brand]
|
|
8
|
+
related: [brick-tokens]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Brick Fonts
|
|
12
|
+
|
|
13
|
+
Distribution package for Amedia's web fonts, providing theme-specific font files and font-face CSS declarations optimized for CDN delivery via Eik.
|
|
14
|
+
|
|
15
|
+
## Key Capabilities
|
|
16
|
+
|
|
17
|
+
- Serves font files (.woff2) and font-face CSS for 5 different Amedia themes
|
|
18
|
+
- Optimized font delivery via Eik CDN (assets.acdn.no)
|
|
19
|
+
- Supports version pinning for performance optimization
|
|
20
|
+
- Uses font-display: swap for improved loading performance
|
|
21
|
+
- Includes both proprietary and open-source fonts
|
|
22
|
+
- Automatic integration with Maelstrom-served applications
|
|
23
|
+
|
|
24
|
+
## Supported Themes and Font Families
|
|
25
|
+
|
|
26
|
+
### Alfa
|
|
27
|
+
|
|
28
|
+
- National2 (light, regular, italic, medium, bold)
|
|
29
|
+
- National2 Narrow (regular, bold)
|
|
30
|
+
- Open Sans (300, 400, 700 with italic variants)
|
|
31
|
+
- Playfair Display (variable font 400-900)
|
|
32
|
+
- Tiempos Text
|
|
33
|
+
|
|
34
|
+
### Bravo
|
|
35
|
+
|
|
36
|
+
- National2 (light, regular, italic, medium, bold)
|
|
37
|
+
- National2 Narrow (regular, bold, extrabold)
|
|
38
|
+
- Open Sans (300, 400, 700 with italic variants)
|
|
39
|
+
- Playfair Display (variable font 400-900)
|
|
40
|
+
- Merriweather (bold)
|
|
41
|
+
- Tiempos Headline
|
|
42
|
+
|
|
43
|
+
### Charlie
|
|
44
|
+
|
|
45
|
+
- National2 (multiple weights)
|
|
46
|
+
- National2 Narrow
|
|
47
|
+
- Open Sans
|
|
48
|
+
- Playfair Display
|
|
49
|
+
- Tiempos Headline (regular, bold)
|
|
50
|
+
- Tiempos Text
|
|
51
|
+
|
|
52
|
+
### Nettavisen
|
|
53
|
+
|
|
54
|
+
- FaktorTittel (regular, medium, black)
|
|
55
|
+
- FaktorSans (regular, bold, italic)
|
|
56
|
+
- FaktorSerif (regular, bold with italic variants)
|
|
57
|
+
- Open Sans (300, 400, 700 with italic variants)
|
|
58
|
+
|
|
59
|
+
### Alt
|
|
60
|
+
|
|
61
|
+
- ALT Rund Display
|
|
62
|
+
- ALT Rund Text
|
|
63
|
+
- Crimson Pro
|
|
64
|
+
|
|
65
|
+
## Installation Methods
|
|
66
|
+
|
|
67
|
+
### Via Maelstrom (Automatic)
|
|
68
|
+
|
|
69
|
+
If your application is served through Maelstrom, fonts are automatically available. Simply use font-family declarations in your CSS:
|
|
70
|
+
|
|
71
|
+
```css
|
|
72
|
+
body {
|
|
73
|
+
font-family: 'National2', sans-serif;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
h1 {
|
|
77
|
+
font-family: 'Playfair Display', serif;
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Via CDN Link (Manual)
|
|
82
|
+
|
|
83
|
+
For applications not using Maelstrom, include the font-face CSS via link element:
|
|
84
|
+
|
|
85
|
+
```html
|
|
86
|
+
<!-- Using version alias (easier to update) -->
|
|
87
|
+
<link
|
|
88
|
+
rel="stylesheet"
|
|
89
|
+
href="https://assets.acdn.no/pkg/@amedia/brick-fonts/v2/css/bravo/font-face.css"
|
|
90
|
+
/>
|
|
91
|
+
|
|
92
|
+
<!-- Using pinned version (better performance) -->
|
|
93
|
+
<link
|
|
94
|
+
rel="stylesheet"
|
|
95
|
+
href="https://assets.acdn.no/pkg/@amedia/brick-fonts/2.0.2/css/nettavisen/font-face.css"
|
|
96
|
+
/>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Via NPM
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npm install @amedia/brick-fonts
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
import { bravo, nettavisen } from '@amedia/brick-fonts';
|
|
107
|
+
// Exports paths to sample font files for testing
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## CDN URLs by Theme
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
https://assets.acdn.no/pkg/@amedia/brick-fonts/v2/css/alfa/font-face.css
|
|
114
|
+
https://assets.acdn.no/pkg/@amedia/brick-fonts/v2/css/bravo/font-face.css
|
|
115
|
+
https://assets.acdn.no/pkg/@amedia/brick-fonts/v2/css/charlie/font-face.css
|
|
116
|
+
https://assets.acdn.no/pkg/@amedia/brick-fonts/v2/css/nettavisen/font-face.css
|
|
117
|
+
https://assets.acdn.no/pkg/@amedia/brick-fonts/v2/css/alt/font-face.css
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Examples
|
|
121
|
+
|
|
122
|
+
### Basic Theme Font Loading
|
|
123
|
+
|
|
124
|
+
```html
|
|
125
|
+
<!doctype html>
|
|
126
|
+
<html>
|
|
127
|
+
<head>
|
|
128
|
+
<link
|
|
129
|
+
rel="stylesheet"
|
|
130
|
+
href="https://assets.acdn.no/pkg/@amedia/brick-fonts/2.0.2/css/bravo/font-face.css"
|
|
131
|
+
/>
|
|
132
|
+
<style>
|
|
133
|
+
body {
|
|
134
|
+
font-family: 'National2', sans-serif;
|
|
135
|
+
font-weight: 400;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
h1 {
|
|
139
|
+
font-family: 'National2 Narrow', sans-serif;
|
|
140
|
+
font-weight: 700;
|
|
141
|
+
}
|
|
142
|
+
</style>
|
|
143
|
+
</head>
|
|
144
|
+
<body>
|
|
145
|
+
<h1>Headline with National2 Narrow</h1>
|
|
146
|
+
<p>Body text with National2</p>
|
|
147
|
+
</body>
|
|
148
|
+
</html>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Multiple Theme Support (Multi-brand Application)
|
|
152
|
+
|
|
153
|
+
```html
|
|
154
|
+
<head>
|
|
155
|
+
<!-- Load fonts for multiple brands -->
|
|
156
|
+
<link
|
|
157
|
+
rel="stylesheet"
|
|
158
|
+
href="https://assets.acdn.no/pkg/@amedia/brick-fonts/2.0.2/css/bravo/font-face.css"
|
|
159
|
+
/>
|
|
160
|
+
<link
|
|
161
|
+
rel="stylesheet"
|
|
162
|
+
href="https://assets.acdn.no/pkg/@amedia/brick-fonts/2.0.2/css/nettavisen/font-face.css"
|
|
163
|
+
/>
|
|
164
|
+
|
|
165
|
+
<style>
|
|
166
|
+
.bravo-theme {
|
|
167
|
+
font-family: 'National2', sans-serif;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.nettavisen-theme {
|
|
171
|
+
font-family: 'FaktorSans', sans-serif;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.nettavisen-theme h1 {
|
|
175
|
+
font-family: 'FaktorTittel', sans-serif;
|
|
176
|
+
font-weight: 900;
|
|
177
|
+
}
|
|
178
|
+
</style>
|
|
179
|
+
</head>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Using Variable Fonts
|
|
183
|
+
|
|
184
|
+
```css
|
|
185
|
+
.headline {
|
|
186
|
+
font-family: 'Playfair Display', serif;
|
|
187
|
+
font-weight: 600; /* Any value between 400-900 */
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.subheadline {
|
|
191
|
+
font-family: 'Playfair Display', serif;
|
|
192
|
+
font-weight: 800; /* Smoothly interpolated */
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Storybook Configuration
|
|
197
|
+
|
|
198
|
+
```html
|
|
199
|
+
<!-- .storybook/preview-head.html -->
|
|
200
|
+
<link
|
|
201
|
+
rel="stylesheet"
|
|
202
|
+
href="https://assets.acdn.no/pkg/@amedia/brick-fonts/v2/css/alfa/font-face.css"
|
|
203
|
+
/>
|
|
204
|
+
<link
|
|
205
|
+
rel="stylesheet"
|
|
206
|
+
href="https://assets.acdn.no/pkg/@amedia/brick-fonts/v2/css/bravo/font-face.css"
|
|
207
|
+
/>
|
|
208
|
+
<link
|
|
209
|
+
rel="stylesheet"
|
|
210
|
+
href="https://assets.acdn.no/pkg/@amedia/brick-fonts/v2/css/charlie/font-face.css"
|
|
211
|
+
/>
|
|
212
|
+
<link
|
|
213
|
+
rel="stylesheet"
|
|
214
|
+
href="https://assets.acdn.no/pkg/@amedia/brick-fonts/v2/css/nettavisen/font-face.css"
|
|
215
|
+
/>
|
|
216
|
+
<link
|
|
217
|
+
rel="stylesheet"
|
|
218
|
+
href="https://assets.acdn.no/pkg/@amedia/brick-fonts/v2/css/alt/font-face.css"
|
|
219
|
+
/>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Performance Optimization
|
|
223
|
+
|
|
224
|
+
### Version Pinning vs Aliasing
|
|
225
|
+
|
|
226
|
+
**Using version alias (v2)**
|
|
227
|
+
|
|
228
|
+
```html
|
|
229
|
+
<link
|
|
230
|
+
rel="stylesheet"
|
|
231
|
+
href="https://assets.acdn.no/pkg/@amedia/brick-fonts/v2/css/bravo/font-face.css"
|
|
232
|
+
/>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
- Easier to maintain (automatic updates to latest v2.x.x)
|
|
236
|
+
- Performance cost: creates critical request chain (alias → CSS → font files)
|
|
237
|
+
- Lighthouse may warn about chained requests
|
|
238
|
+
|
|
239
|
+
**Using pinned version (2.0.2)**
|
|
240
|
+
|
|
241
|
+
```html
|
|
242
|
+
<link
|
|
243
|
+
rel="stylesheet"
|
|
244
|
+
href="https://assets.acdn.no/pkg/@amedia/brick-fonts/2.0.2/css/bravo/font-face.css"
|
|
245
|
+
/>
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
- Better performance (direct CSS → font files)
|
|
249
|
+
- Requires manual version updates
|
|
250
|
+
- Recommended for production
|
|
251
|
+
|
|
252
|
+
### Font Loading Strategy
|
|
253
|
+
|
|
254
|
+
All fonts use `font-display: swap` which:
|
|
255
|
+
|
|
256
|
+
- Shows fallback font immediately
|
|
257
|
+
- Swaps to web font when loaded
|
|
258
|
+
- Prevents invisible text (FOIT)
|
|
259
|
+
- Improves perceived performance
|
|
260
|
+
|
|
261
|
+
## Font File Structure
|
|
262
|
+
|
|
263
|
+
### CSS Files
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
css/
|
|
267
|
+
├── alfa/
|
|
268
|
+
│ └── font-face.css
|
|
269
|
+
├── bravo/
|
|
270
|
+
│ └── font-face.css
|
|
271
|
+
├── charlie/
|
|
272
|
+
│ └── font-face.css
|
|
273
|
+
├── nettavisen/
|
|
274
|
+
│ └── font-face.css
|
|
275
|
+
└── alt/
|
|
276
|
+
└── font-face.css
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Font Files
|
|
280
|
+
|
|
281
|
+
```
|
|
282
|
+
fonts/
|
|
283
|
+
├── alfa/
|
|
284
|
+
│ ├── national-2-light.woff2
|
|
285
|
+
│ ├── national-2-regular.woff2
|
|
286
|
+
│ └── ... (24 total files)
|
|
287
|
+
├── bravo/
|
|
288
|
+
│ ├── national-2-bold.woff2
|
|
289
|
+
│ ├── national-2-narrow-regular.woff2
|
|
290
|
+
│ └── ... (19 total files)
|
|
291
|
+
├── charlie/
|
|
292
|
+
│ └── ... (23 total files)
|
|
293
|
+
├── nettavisen/
|
|
294
|
+
│ ├── FaktorSans-Bold.woff2
|
|
295
|
+
│ ├── FaktorSerif-RegularItalic.woff2
|
|
296
|
+
│ └── ... (16 total files)
|
|
297
|
+
└── alt/
|
|
298
|
+
└── ... (6 total files)
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## Font-Face Example (Bravo Theme)
|
|
302
|
+
|
|
303
|
+
```css
|
|
304
|
+
@font-face {
|
|
305
|
+
font-family: 'National2';
|
|
306
|
+
src: url('https://assets.acdn.no/pkg/@amedia/brick-fonts/2.0.1/fonts/bravo/national-2-regular.woff2');
|
|
307
|
+
font-weight: 400;
|
|
308
|
+
font-style: normal;
|
|
309
|
+
font-display: swap;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
@font-face {
|
|
313
|
+
font-family: 'National2';
|
|
314
|
+
src: url('https://assets.acdn.no/pkg/@amedia/brick-fonts/2.0.1/fonts/bravo/national-2-bold.woff2');
|
|
315
|
+
font-weight: 700;
|
|
316
|
+
font-style: normal;
|
|
317
|
+
font-display: swap;
|
|
318
|
+
}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
## Technical Details
|
|
322
|
+
|
|
323
|
+
- **Package Type**: Asset distribution (fonts + CSS)
|
|
324
|
+
- **Format**: WOFF2 (Web Open Font Format 2)
|
|
325
|
+
- **Distribution**: Eik CDN (https://assets.acdn.no)
|
|
326
|
+
- **Build System**: Custom Node.js build script
|
|
327
|
+
- **Dependencies**: None (standalone asset package)
|
|
328
|
+
|
|
329
|
+
## Adding New Fonts
|
|
330
|
+
|
|
331
|
+
1. Add .woff2 file(s) to appropriate theme directory in `fonts/`
|
|
332
|
+
2. Add @font-face rule to matching theme in `css/`
|
|
333
|
+
3. Ensure font-weight and font-style match the font file characteristics
|
|
334
|
+
4. Use [wakamaifondue.com](https://wakamaifondue.com/) to analyze font capabilities
|
|
335
|
+
5. Create changeset and publish new version
|
|
336
|
+
6. Eik automatically publishes both CSS and font files
|
|
337
|
+
|
|
338
|
+
## License Information
|
|
339
|
+
|
|
340
|
+
### Proprietary Fonts
|
|
341
|
+
|
|
342
|
+
- National2, National2 Narrow
|
|
343
|
+
- Faktor (FaktorTittel, FaktorSans, FaktorSerif)
|
|
344
|
+
- ALT Rund (Display, Text)
|
|
345
|
+
- Tiempos (Headline, Text)
|
|
346
|
+
- Merriweather
|
|
347
|
+
- Bespoke fonts
|
|
348
|
+
|
|
349
|
+
Contact licensing team for details.
|
|
350
|
+
|
|
351
|
+
### Open Source Fonts
|
|
352
|
+
|
|
353
|
+
**Open Sans**
|
|
354
|
+
|
|
355
|
+
- License: SIL Open Font License (OFL)
|
|
356
|
+
- Source: [Google Fonts](https://github.com/googlefonts/opensans)
|
|
357
|
+
|
|
358
|
+
**Playfair Display**
|
|
359
|
+
|
|
360
|
+
- License: SIL Open Font License (OFL)
|
|
361
|
+
- Source: [GitHub](https://github.com/clauseggers/Playfair)
|
|
362
|
+
|
|
363
|
+
**Crimson Pro**
|
|
364
|
+
|
|
365
|
+
- License: SIL Open Font License (OFL)
|
|
366
|
+
|
|
367
|
+
## Important Notes
|
|
368
|
+
|
|
369
|
+
- Font files are served from Eik CDN, not from npm package
|
|
370
|
+
- The npm package only contains path references, not actual font files
|
|
371
|
+
- All fonts use .woff2 format for optimal compression
|
|
372
|
+
- Font-display: swap is used for all fonts to improve loading performance
|
|
373
|
+
- Version 2.0.0 removed CommonJS builds (ESM only)
|
|
374
|
+
- Automatic integration with Maelstrom removes need for manual link tags
|
|
375
|
+
|
|
376
|
+
## Tools for Font Development
|
|
377
|
+
|
|
378
|
+
- [wakamaifondue.com](https://wakamaifondue.com/) - Analyze font file capabilities
|
|
379
|
+
- [WhatFont Chrome Extension](https://chrome.google.com/webstore/detail/whatfont/jabopobgcpjmedljpbcaablpmlmfcogm) - Identify fonts on web pages
|
|
380
|
+
|
|
381
|
+
## Version
|
|
382
|
+
|
|
383
|
+
Current version: 2.0.2
|
|
384
|
+
|
|
385
|
+
### Recent Changes
|
|
386
|
+
|
|
387
|
+
- 2.0.2: Better fallback font for National2 Narrow
|
|
388
|
+
- 2.0.1: Changed font-display from auto to swap for better loading performance
|
|
389
|
+
- 2.0.0: Removed CommonJS build (ESM only)
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brick-helloworld
|
|
3
|
+
version: 2.0.2
|
|
4
|
+
selector: brick-helloworld-v2
|
|
5
|
+
category: Development
|
|
6
|
+
tags:
|
|
7
|
+
[
|
|
8
|
+
example,
|
|
9
|
+
demo,
|
|
10
|
+
development,
|
|
11
|
+
tutorial,
|
|
12
|
+
web-components,
|
|
13
|
+
template,
|
|
14
|
+
getting-started,
|
|
15
|
+
]
|
|
16
|
+
use_cases:
|
|
17
|
+
[
|
|
18
|
+
learning-brick-components,
|
|
19
|
+
testing-build-process,
|
|
20
|
+
understanding-component-anatomy,
|
|
21
|
+
server-side-rendering-examples,
|
|
22
|
+
client-side-rendering-examples,
|
|
23
|
+
]
|
|
24
|
+
related: [brick-input, brick-toggle, brick-template]
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Brick Helloworld
|
|
28
|
+
|
|
29
|
+
A demonstration component showcasing the anatomy and usage patterns of Brick components, used for testing and educational purposes.
|
|
30
|
+
|
|
31
|
+
## Key Capabilities
|
|
32
|
+
|
|
33
|
+
- Demonstrates both server-side and client-side rendering patterns
|
|
34
|
+
- Shows template processing with named template slots
|
|
35
|
+
- Integrates with other Brick components (brick-input, brick-toggle)
|
|
36
|
+
- Illustrates mirrored props and observed attributes
|
|
37
|
+
- Provides examples of Stitches styling integration
|
|
38
|
+
- Serves as a reference implementation for new Brick components
|
|
39
|
+
|
|
40
|
+
## Props/Attributes
|
|
41
|
+
|
|
42
|
+
| Attribute | Type | Default | Required | Description |
|
|
43
|
+
| ------------------- | ------- | --------- | -------- | ------------------------------------------------------------- |
|
|
44
|
+
| `data-text` | string | undefined | no | Text content to display in the component |
|
|
45
|
+
| `data-version` | string | undefined | no | Version string used for styling variants |
|
|
46
|
+
| `is-rendered` | boolean | false | no | Indicates if markup was rendered server-side |
|
|
47
|
+
| `children-rendered` | string | undefined | no | Internal attribute set when child components finish rendering |
|
|
48
|
+
|
|
49
|
+
## Examples
|
|
50
|
+
|
|
51
|
+
### Basic Usage - Template Literals
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<brick-helloworld-v2 data-text="Hello, World!" data-version="v2">
|
|
55
|
+
<template name="content">
|
|
56
|
+
<p>I am a paragraph inside a template named content</p>
|
|
57
|
+
</template>
|
|
58
|
+
</brick-helloworld-v2>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### JavaScript createElement
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
const el = document.createElement('brick-helloworld-v2');
|
|
65
|
+
el.dataset.text = 'The quick brown fox jumps over the lazy dog';
|
|
66
|
+
el.dataset.version = 'v2';
|
|
67
|
+
document.body.appendChild(el);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Server-Side Rendering
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
import {
|
|
74
|
+
renderBrickHelloworld,
|
|
75
|
+
getCssText,
|
|
76
|
+
} from '@amedia/brick-helloworld/template';
|
|
77
|
+
|
|
78
|
+
const markup = renderBrickHelloworld({
|
|
79
|
+
dataText: 'The quick brown fox jumps over the lazy dog',
|
|
80
|
+
dataVersion: 'v2',
|
|
81
|
+
isRendered: true,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Include the styles
|
|
85
|
+
const css = `<style>${getCssText()}</style>`;
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Client-Side Import
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
// Via npm
|
|
92
|
+
import '@amedia/brick-helloworld';
|
|
93
|
+
|
|
94
|
+
// Via Eik CDN
|
|
95
|
+
import 'https://assets.acdn.no/pkg/@amedia/brick-helloworld/v2/brick-helloworld.js';
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Using Template Slots
|
|
99
|
+
|
|
100
|
+
```html
|
|
101
|
+
<brick-helloworld-v2 data-text="Main content" data-version="v2">
|
|
102
|
+
<template name="content">
|
|
103
|
+
<div class="custom-content">
|
|
104
|
+
<h2>Custom Template Content</h2>
|
|
105
|
+
<p>This content is processed by the component</p>
|
|
106
|
+
</div>
|
|
107
|
+
</template>
|
|
108
|
+
</brick-helloworld-v2>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Framework Integration
|
|
112
|
+
|
|
113
|
+
### Node.js (>=18) - HTTPS Imports
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
// Using HTTPS imports (Node.js >= 18)
|
|
117
|
+
import {
|
|
118
|
+
renderBrickHelloworld,
|
|
119
|
+
getCssText,
|
|
120
|
+
} from 'https://assets.acdn.no/pkg/@amedia/brick-helloworld/v2/template.js';
|
|
121
|
+
|
|
122
|
+
const html = renderBrickHelloworld({
|
|
123
|
+
dataText: 'Server rendered content',
|
|
124
|
+
dataVersion: 'v2',
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Programmatic Usage
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
import { BrickHelloworld } from '@amedia/brick-helloworld';
|
|
132
|
+
|
|
133
|
+
const component = new BrickHelloworld();
|
|
134
|
+
component.dataText = 'Programmatically set text';
|
|
135
|
+
component.dataVersion = 'v2';
|
|
136
|
+
document.body.appendChild(component);
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Common Patterns
|
|
140
|
+
|
|
141
|
+
### Hybrid Server/Client Rendering
|
|
142
|
+
|
|
143
|
+
When markup is rendered server-side with `isRendered: true`, the component will not recreate the DOM client-side but will still attach event listeners and process templates:
|
|
144
|
+
|
|
145
|
+
```html
|
|
146
|
+
<!-- Server-rendered HTML -->
|
|
147
|
+
<brick-helloworld-v2 data-version="v2" data-text="Content" is-rendered>
|
|
148
|
+
<div class="hello-v2">
|
|
149
|
+
Content
|
|
150
|
+
<div class="hello-v2">v2</div>
|
|
151
|
+
</div>
|
|
152
|
+
<!-- Child components rendered server-side -->
|
|
153
|
+
</brick-helloworld-v2>
|
|
154
|
+
|
|
155
|
+
<!-- Client-side script -->
|
|
156
|
+
<script
|
|
157
|
+
type="module"
|
|
158
|
+
src="https://assets.acdn.no/pkg/@amedia/brick-helloworld/v2/brick-helloworld.js"
|
|
159
|
+
></script>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Template Processing
|
|
163
|
+
|
|
164
|
+
The component demonstrates how to process named template slots and move content:
|
|
165
|
+
|
|
166
|
+
```javascript
|
|
167
|
+
// Component processes template[name="content"]
|
|
168
|
+
// and moves it into a div wrapper
|
|
169
|
+
processTemplates() {
|
|
170
|
+
const templateContent = this.querySelector('template[name="content"]');
|
|
171
|
+
if (templateContent) {
|
|
172
|
+
const range = document.createRange();
|
|
173
|
+
range.selectNodeContents(templateContent.content);
|
|
174
|
+
const contentWrapper = document.createElement('div');
|
|
175
|
+
range.surroundContents(contentWrapper);
|
|
176
|
+
this.appendChild(contentWrapper);
|
|
177
|
+
templateContent.remove();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Component Composition
|
|
183
|
+
|
|
184
|
+
Shows integration with other Brick components:
|
|
185
|
+
|
|
186
|
+
```html
|
|
187
|
+
<brick-helloworld-v2 data-text="Form Example" data-version="v2">
|
|
188
|
+
<!-- brick-input and brick-toggle are automatically included -->
|
|
189
|
+
</brick-helloworld-v2>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Technical Details
|
|
193
|
+
|
|
194
|
+
- **Custom Element**: `brick-helloworld-v2`
|
|
195
|
+
- **Base Class**: BrickElement (from @amedia/brick-template)
|
|
196
|
+
- **Dependencies**: @amedia/brick-tokens, @amedia/brick-template, @amedia/brick-input, @amedia/brick-toggle
|
|
197
|
+
- **Renders as**: Custom element with internal div structure
|
|
198
|
+
- **Styling**: Stitches-based styling with variant support
|
|
199
|
+
- **Mirrored Props**: `data-text`, `data-version` (automatically synced between attributes and properties)
|
|
200
|
+
- **Observed Attributes**: `children-rendered`
|
|
201
|
+
|
|
202
|
+
## Important Notes
|
|
203
|
+
|
|
204
|
+
- This is a demonstration/example component primarily for development and testing purposes
|
|
205
|
+
- Not intended for production use cases - serves as a reference implementation
|
|
206
|
+
- Demonstrates the complete anatomy of a Brick component including build configuration
|
|
207
|
+
- Used for testing release workflows, publishing, and build processes
|
|
208
|
+
- Template processing occurs after children are rendered (via `children-rendered` attribute)
|
|
209
|
+
- The component automatically includes brick-input and brick-toggle as child dependencies
|
|
210
|
+
- Server-side rendering requires the `/template` export path
|
|
211
|
+
- CSS is automatically injected when used client-side, but must be manually included for SSR via `getCssText()`
|
|
212
|
+
|
|
213
|
+
## Installation
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
npm install @amedia/brick-helloworld
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Version
|
|
220
|
+
|
|
221
|
+
Current version: 2.0.2
|
|
222
|
+
|
|
223
|
+
## Package Exports
|
|
224
|
+
|
|
225
|
+
- **ESM (Node)**: `dist/index.mjs`
|
|
226
|
+
- **CommonJS (Node)**: `dist/index.js`
|
|
227
|
+
- **Browser Bundle (Eik)**: `dist/eik/brick-helloworld.js`
|
|
228
|
+
- **Template (SSR)**: `template/index.mjs`
|