@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.
- package/data/components/brick-helloworld.md +112 -143
- package/data/components/brick-icon.md +92 -139
- package/data/components/brick-icons.md +114 -318
- package/data/components/brick-mcp.md +104 -161
- package/data/components/brick-template.md +145 -146
- package/data/components-metadata.json +31 -31
- package/data/tokens.json +232 -227
- package/dist/data/components/brick-helloworld.md +112 -143
- package/dist/data/components/brick-icon.md +92 -139
- package/dist/data/components/brick-icons.md +114 -318
- package/dist/data/components/brick-mcp.md +104 -161
- package/dist/data/components/brick-template.md +145 -146
- package/dist/data/components-metadata.json +31 -31
- package/dist/data/tokens.json +232 -227
- package/dist/http.js +4 -2
- package/dist/http.js.map +3 -3
- package/dist/index.js +4 -2
- package/dist/index.js.map +3 -3
- package/package.json +34 -34
- package/scripts/check-docs-versions.js +10 -3
- package/scripts/generate-data.js +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: brick-helloworld
|
|
3
|
-
version: 2.0
|
|
3
|
+
version: 2.1.0
|
|
4
4
|
selector: brick-helloworld-v2
|
|
5
5
|
category: Development
|
|
6
6
|
tags:
|
|
@@ -12,6 +12,8 @@ tags:
|
|
|
12
12
|
web-components,
|
|
13
13
|
template,
|
|
14
14
|
getting-started,
|
|
15
|
+
i18n,
|
|
16
|
+
localisation,
|
|
15
17
|
]
|
|
16
18
|
use_cases:
|
|
17
19
|
[
|
|
@@ -20,209 +22,176 @@ use_cases:
|
|
|
20
22
|
understanding-component-anatomy,
|
|
21
23
|
server-side-rendering-examples,
|
|
22
24
|
client-side-rendering-examples,
|
|
25
|
+
localisation-examples,
|
|
23
26
|
]
|
|
24
27
|
related: [brick-input, brick-toggle, brick-template]
|
|
25
28
|
---
|
|
26
29
|
|
|
27
30
|
# Brick Helloworld
|
|
28
31
|
|
|
29
|
-
A demonstration component showcasing the anatomy and usage patterns of Brick components,
|
|
32
|
+
A demonstration component showcasing the anatomy and usage patterns of Brick components, including server-side rendering, client-side rendering, template slots, component composition, and localisation (i18n).
|
|
30
33
|
|
|
31
34
|
## Key Capabilities
|
|
32
35
|
|
|
33
36
|
- Demonstrates both server-side and client-side rendering patterns
|
|
34
|
-
-
|
|
37
|
+
- Supports localisation via `data-locale` attribute with `nb-NO`, `nn-NO`, and `da-DK` locales
|
|
35
38
|
- Integrates with other Brick components (brick-input, brick-toggle)
|
|
36
|
-
-
|
|
37
|
-
-
|
|
39
|
+
- Shows template processing with named template slots
|
|
40
|
+
- Illustrates Stitches styling with typography variants via `data-version`
|
|
38
41
|
- Serves as a reference implementation for new Brick components
|
|
39
42
|
|
|
40
43
|
## Props/Attributes
|
|
41
44
|
|
|
42
|
-
| Attribute | Type
|
|
43
|
-
| ------------------- |
|
|
44
|
-
| `data-text` | string
|
|
45
|
-
| `data-version` |
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
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
|
-
```
|
|
45
|
+
| Attribute | Type | Default | Required | Description |
|
|
46
|
+
| ------------------- | -------------------------------------- | ----------- | -------- | ----------------------------------------------------------------------------------- |
|
|
47
|
+
| `data-text` | `string` | `undefined` | no | Text content to display in the component |
|
|
48
|
+
| `data-version` | `"baseHeadlineXs" \| "baseMetaM" \| "baseMetaS" \| "baseHeadlineL" \| "baseHeadlineM" \| "baseBodyM"` | `"baseBodyM"` | no | Typography variant used for styling; maps to a Stitches variant in `styles.js` |
|
|
49
|
+
| `data-locale` | `"nb-NO" \| "nn-NO" \| "da-DK"` | `undefined` | no | Locale for translated text. Must be a supported locale or the component will throw |
|
|
50
|
+
| `is-rendered` | `boolean` | `false` | no | Indicates if markup was rendered server-side; prevents client-side DOM recreation |
|
|
51
|
+
| `children-rendered` | `string` | `undefined` | no | Internal attribute set when child components finish rendering; triggers template processing |
|
|
60
52
|
|
|
61
|
-
|
|
53
|
+
## Usage
|
|
62
54
|
|
|
63
|
-
|
|
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
|
-
```
|
|
55
|
+
### Server-side rendering (preferred)
|
|
69
56
|
|
|
70
|
-
|
|
57
|
+
Import the render function from the `/template` submodule and call it to produce an HTML string:
|
|
71
58
|
|
|
72
|
-
```
|
|
59
|
+
```ts
|
|
73
60
|
import {
|
|
74
61
|
renderBrickHelloworld,
|
|
75
62
|
getCssText,
|
|
76
63
|
} from '@amedia/brick-helloworld/template';
|
|
77
64
|
|
|
78
|
-
const
|
|
79
|
-
dataText: '
|
|
80
|
-
dataVersion: '
|
|
81
|
-
|
|
65
|
+
const html = renderBrickHelloworld({
|
|
66
|
+
dataText: 'Hello, World!',
|
|
67
|
+
dataVersion: 'baseBodyM',
|
|
68
|
+
dataLocale: 'nb-NO',
|
|
82
69
|
});
|
|
83
70
|
|
|
84
|
-
// Include the
|
|
71
|
+
// Include the critical CSS for the component
|
|
85
72
|
const css = `<style>${getCssText()}</style>`;
|
|
86
73
|
```
|
|
87
74
|
|
|
88
|
-
|
|
75
|
+
When `isRendered` is omitted it defaults to `true` in the render function, which wraps the output in a `<brick-helloworld ...>` custom element tag with the `is-rendered` attribute. This prevents the client-side Web Component from recreating the DOM.
|
|
89
76
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
77
|
+
#### SSR with a different locale
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
const html = renderBrickHelloworld({
|
|
81
|
+
dataText: 'Hej verden!',
|
|
82
|
+
dataVersion: 'baseHeadlineM',
|
|
83
|
+
dataLocale: 'da-DK',
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### SSR for client-side hydration only (no server markup)
|
|
93
88
|
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
```ts
|
|
90
|
+
const html = renderBrickHelloworld({
|
|
91
|
+
dataText: 'Will be rendered client-side',
|
|
92
|
+
dataVersion: 'baseBodyM',
|
|
93
|
+
dataLocale: 'nb-NO',
|
|
94
|
+
isRendered: false,
|
|
95
|
+
});
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
-
###
|
|
98
|
+
### Client-side (declarative HTML)
|
|
99
|
+
|
|
100
|
+
Use the custom element directly in HTML after registering the component:
|
|
99
101
|
|
|
100
102
|
```html
|
|
101
|
-
<
|
|
103
|
+
<script
|
|
104
|
+
type="module"
|
|
105
|
+
src="https://assets.acdn.no/pkg/@amedia/brick-helloworld/v2/brick-helloworld.js"
|
|
106
|
+
></script>
|
|
107
|
+
|
|
108
|
+
<brick-helloworld-v2
|
|
109
|
+
data-text="Hello, World!"
|
|
110
|
+
data-version="baseBodyM"
|
|
111
|
+
data-locale="nb-NO"
|
|
112
|
+
>
|
|
113
|
+
</brick-helloworld-v2>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### With template slots
|
|
117
|
+
|
|
118
|
+
```html
|
|
119
|
+
<brick-helloworld-v2
|
|
120
|
+
data-text="Main content"
|
|
121
|
+
data-version="baseBodyM"
|
|
122
|
+
data-locale="nb-NO"
|
|
123
|
+
>
|
|
102
124
|
<template name="content">
|
|
103
|
-
<
|
|
104
|
-
<h2>Custom Template Content</h2>
|
|
105
|
-
<p>This content is processed by the component</p>
|
|
106
|
-
</div>
|
|
125
|
+
<p>I am a paragraph inside a template named content</p>
|
|
107
126
|
</template>
|
|
108
127
|
</brick-helloworld-v2>
|
|
109
128
|
```
|
|
110
129
|
|
|
111
|
-
|
|
130
|
+
After the component's children have rendered (tracked via the `children-rendered` attribute), the component processes `<template name="content">` elements: it extracts the template content, wraps it in a `<div>`, appends it to the component, and removes the original `<template>` element.
|
|
112
131
|
|
|
113
|
-
|
|
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';
|
|
132
|
+
#### JavaScript createElement
|
|
121
133
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
134
|
+
```js
|
|
135
|
+
const el = document.createElement('brick-helloworld-v2');
|
|
136
|
+
el.dataset.text = 'The quick brown fox jumps over the lazy dog';
|
|
137
|
+
el.dataset.version = 'baseBodyM';
|
|
138
|
+
el.dataset.locale = 'nb-NO';
|
|
139
|
+
document.body.appendChild(el);
|
|
126
140
|
```
|
|
127
141
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
```javascript
|
|
131
|
-
import { BrickHelloworld } from '@amedia/brick-helloworld';
|
|
142
|
+
#### npm import
|
|
132
143
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
component.dataVersion = 'v2';
|
|
136
|
-
document.body.appendChild(component);
|
|
144
|
+
```js
|
|
145
|
+
import '@amedia/brick-helloworld';
|
|
137
146
|
```
|
|
138
147
|
|
|
139
|
-
##
|
|
148
|
+
## Localisation
|
|
140
149
|
|
|
141
|
-
|
|
150
|
+
Added in version 2.1.0. The component supports localisation via `data-locale` and the `@amedia/brick-template` i18n utilities.
|
|
142
151
|
|
|
143
|
-
|
|
152
|
+
Supported locales and their translations for the `helloworld:text` key:
|
|
144
153
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
<div class="hello-v2">v2</div>
|
|
151
|
-
</div>
|
|
152
|
-
<!-- Child components rendered server-side -->
|
|
153
|
-
</brick-helloworld-v2>
|
|
154
|
+
| Locale | Translation |
|
|
155
|
+
| ------- | -------------------------- |
|
|
156
|
+
| `nb-NO` | Spraket er norsk bokmal |
|
|
157
|
+
| `nn-NO` | Spraket er norsk nynorsk |
|
|
158
|
+
| `da-DK` | Sproget er dansk |
|
|
154
159
|
|
|
155
|
-
|
|
156
|
-
<script
|
|
157
|
-
type="module"
|
|
158
|
-
src="https://assets.acdn.no/pkg/@amedia/brick-helloworld/v2/brick-helloworld.js"
|
|
159
|
-
></script>
|
|
160
|
-
```
|
|
160
|
+
The component calls `requireLocale()` which throws an error if an unsupported locale is provided. This is a deliberate fail-fast approach: the component will not silently fall back to a default locale.
|
|
161
161
|
|
|
162
|
-
|
|
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
|
-
```
|
|
162
|
+
Translations are defined in `src/i18n.ts` and must conform to the `I18n` type from `@amedia/brick-template`.
|
|
181
163
|
|
|
182
|
-
|
|
164
|
+
## Accessibility
|
|
183
165
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
```
|
|
166
|
+
- This is a development/demo component and does not implement specific ARIA patterns
|
|
167
|
+
- Child components (brick-input, brick-toggle) handle their own accessibility concerns
|
|
168
|
+
- Not intended for production use; accessibility testing is disabled in Storybook (`a11y: { disable: true }`)
|
|
191
169
|
|
|
192
170
|
## Technical Details
|
|
193
171
|
|
|
194
|
-
- **
|
|
195
|
-
- **
|
|
196
|
-
- **
|
|
197
|
-
- **
|
|
198
|
-
- **
|
|
199
|
-
- **Mirrored Props**: `data-text`, `data-version` (automatically synced between attributes and properties)
|
|
172
|
+
- **Package version**: `2.1.0`
|
|
173
|
+
- **Custom Element tag**: `brick-helloworld-v2` -- must match the `selector` in frontmatter; the tag uses only the **major** version, not the full semver
|
|
174
|
+
- **Base Class**: `BrickElement` (from `@amedia/brick-template`)
|
|
175
|
+
- **Dependencies**: `@amedia/brick-tokens@6.2.2`, `@amedia/brick-template@2.1.0`, `@amedia/brick-input@4.0.9`, `@amedia/brick-toggle@3.1.34`
|
|
176
|
+
- **Mirrored Props**: `data-text`, `data-version` (automatically synced between HTML attributes and JS properties)
|
|
200
177
|
- **Observed Attributes**: `children-rendered`
|
|
178
|
+
- **Styling**: Stitches-based via `@amedia/brick-tokens`; typography variants controlled by `data-version`
|
|
179
|
+
- **SSR export**: `@amedia/brick-helloworld/template` exports `renderBrickHelloworld` and `getCssText`
|
|
201
180
|
|
|
202
181
|
## Important Notes
|
|
203
182
|
|
|
204
|
-
- This is a demonstration/example component
|
|
205
|
-
-
|
|
206
|
-
-
|
|
207
|
-
-
|
|
208
|
-
-
|
|
209
|
-
-
|
|
210
|
-
-
|
|
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
|
|
183
|
+
- This is a demonstration/example component for development and testing purposes; it is not intended for production use
|
|
184
|
+
- The `data-version` attribute controls typography styling variants, not the package version; valid values are Stitches variant keys like `baseBodyM`, `baseHeadlineL`, etc.
|
|
185
|
+
- `requireLocale()` will throw if `data-locale` is missing or unsupported -- this is intentional fail-fast behaviour
|
|
186
|
+
- Template processing (named `<template>` slots) occurs only after all children have rendered, triggered by the `children-rendered` attribute
|
|
187
|
+
- The component automatically includes brick-input and brick-toggle as child dependencies in both SSR and client-side modes
|
|
188
|
+
- Server-side rendering requires the `/template` export path; CSS must be manually included via `getCssText()`
|
|
189
|
+
- The package is ESM only -- there is no CommonJS export
|
|
220
190
|
|
|
221
|
-
|
|
191
|
+
## Changelog (recent)
|
|
222
192
|
|
|
223
|
-
|
|
193
|
+
### 2.1.0
|
|
224
194
|
|
|
225
|
-
-
|
|
226
|
-
-
|
|
227
|
-
-
|
|
228
|
-
- **Template (SSR)**: `template/index.mjs`
|
|
195
|
+
- Added localisation support via `data-locale` attribute (proof of concept)
|
|
196
|
+
- Created component-specific translations in `src/i18n.ts`
|
|
197
|
+
- Updated dependency on `@amedia/brick-template@2.1.0` which provides `getTranslation`, `requireLocale`, `SupportedLocales` type, and `I18n` type
|