@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,355 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brick-carousel
|
|
3
|
+
version: 2.0.10
|
|
4
|
+
selector: brick-carousel-v2
|
|
5
|
+
category: Layout
|
|
6
|
+
tags:
|
|
7
|
+
[
|
|
8
|
+
carousel,
|
|
9
|
+
slider,
|
|
10
|
+
content-slider,
|
|
11
|
+
gallery,
|
|
12
|
+
navigation,
|
|
13
|
+
scroll,
|
|
14
|
+
responsive,
|
|
15
|
+
accessible,
|
|
16
|
+
]
|
|
17
|
+
use_cases:
|
|
18
|
+
[
|
|
19
|
+
content-carousels,
|
|
20
|
+
image-galleries,
|
|
21
|
+
article-sliders,
|
|
22
|
+
video-carousels,
|
|
23
|
+
product-listings,
|
|
24
|
+
teaser-collections,
|
|
25
|
+
media-galleries,
|
|
26
|
+
responsive-layouts,
|
|
27
|
+
]
|
|
28
|
+
related: [brick-teaser, brick-image, brick-player]
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
# Brick Carousel
|
|
32
|
+
|
|
33
|
+
A simple, accessible carousel component for displaying any type of content in a horizontal scrolling layout with navigation controls.
|
|
34
|
+
|
|
35
|
+
## Key Capabilities
|
|
36
|
+
|
|
37
|
+
- Fully accessible with semantic markup, keyboard navigation, and ARIA support
|
|
38
|
+
- Supports three layout types: carousel (default), gallery (full-width single items), and compact (dense layout)
|
|
39
|
+
- Responsive design that adapts to container width (1-3 items visible depending on space)
|
|
40
|
+
- Client-side and server-side rendering support
|
|
41
|
+
- Drag-to-scroll functionality on desktop
|
|
42
|
+
- Automatic mutation detection for dynamically added content
|
|
43
|
+
- Template tag support for custom elements to prevent early initialization
|
|
44
|
+
- Customizable navigation button visibility
|
|
45
|
+
|
|
46
|
+
## Props/Attributes
|
|
47
|
+
|
|
48
|
+
| Attribute | Type | Default | Required | Description |
|
|
49
|
+
| ------------------------- | -------------------------------------- | ------------ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
50
|
+
| `data-version` | `"carousel" \| "gallery" \| "compact"` | `"carousel"` | No | Layout type. "carousel" shows 1-3 items, "gallery" shows 1 full-width item, "compact" provides a denser layout |
|
|
51
|
+
| `data-min-slides-to-show` | `string` (number) | `"1"` | No | Minimum number of slides to show. When set to "2" and only 2 children exist, shows both in a fraction grid without scrolling |
|
|
52
|
+
| `data-hide-btn-start-end` | `boolean` | `false` | No | Hides navigation buttons when at start/end of carousel. Not recommended for content wrapped in links to avoid misclicks |
|
|
53
|
+
| `dataItems` | `string[]` | - | No (Yes for SSR) | Array of HTML content strings for server-side rendering. Each item is automatically wrapped with proper `<li>` markup |
|
|
54
|
+
|
|
55
|
+
## Examples
|
|
56
|
+
|
|
57
|
+
### Basic Carousel (Client-side)
|
|
58
|
+
|
|
59
|
+
```html
|
|
60
|
+
<script
|
|
61
|
+
type="module"
|
|
62
|
+
src="https://assets.acdn.no/pkg/@amedia/brick-carousel/2.0.10/brick-carousel.js"
|
|
63
|
+
></script>
|
|
64
|
+
|
|
65
|
+
<brick-carousel-v2>
|
|
66
|
+
<article>Article 1 content</article>
|
|
67
|
+
<article>Article 2 content</article>
|
|
68
|
+
<article>Article 3 content</article>
|
|
69
|
+
<article>Article 4 content</article>
|
|
70
|
+
<article>Article 5 content</article>
|
|
71
|
+
</brick-carousel-v2>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Gallery Mode
|
|
75
|
+
|
|
76
|
+
Shows one full-width item at a time, ideal for image galleries.
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<brick-carousel-v2 data-version="gallery">
|
|
80
|
+
<brick-image-v9
|
|
81
|
+
src="https://example.com/image1.jpg"
|
|
82
|
+
alt="Image 1"
|
|
83
|
+
></brick-image-v9>
|
|
84
|
+
<brick-image-v9
|
|
85
|
+
src="https://example.com/image2.jpg"
|
|
86
|
+
alt="Image 2"
|
|
87
|
+
></brick-image-v9>
|
|
88
|
+
<brick-image-v9
|
|
89
|
+
src="https://example.com/image3.jpg"
|
|
90
|
+
alt="Image 3"
|
|
91
|
+
></brick-image-v9>
|
|
92
|
+
</brick-carousel-v2>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Compact Layout
|
|
96
|
+
|
|
97
|
+
Provides a denser layout with adjusted grid column widths.
|
|
98
|
+
|
|
99
|
+
```html
|
|
100
|
+
<brick-carousel-v2 data-version="compact">
|
|
101
|
+
<brick-teaser-v13 title="Compact teaser 1"></brick-teaser-v13>
|
|
102
|
+
<brick-teaser-v13 title="Compact teaser 2"></brick-teaser-v13>
|
|
103
|
+
<brick-teaser-v13 title="Compact teaser 3"></brick-teaser-v13>
|
|
104
|
+
<brick-teaser-v13 title="Compact teaser 4"></brick-teaser-v13>
|
|
105
|
+
</brick-carousel-v2>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Minimum Slides to Show
|
|
109
|
+
|
|
110
|
+
Forces minimum 2 slides visible even on smaller screens. When exactly 2 children exist, displays both without navigation.
|
|
111
|
+
|
|
112
|
+
```html
|
|
113
|
+
<brick-carousel-v2 data-min-slides-to-show="2">
|
|
114
|
+
<article>Article 1</article>
|
|
115
|
+
<article>Article 2</article>
|
|
116
|
+
</brick-carousel-v2>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Using Template Tags for Custom Elements
|
|
120
|
+
|
|
121
|
+
Wrap content in `<template>` tags to prevent custom elements (like brick-player) from initializing too early. The template content is added to the DOM after being placed in the carousel.
|
|
122
|
+
|
|
123
|
+
```html
|
|
124
|
+
<brick-carousel-v2>
|
|
125
|
+
<template>
|
|
126
|
+
<brick-player
|
|
127
|
+
mediaid="abc123"
|
|
128
|
+
playerid="xyz789"
|
|
129
|
+
aspectratio="16:9"
|
|
130
|
+
title="Video title"
|
|
131
|
+
>
|
|
132
|
+
</brick-player>
|
|
133
|
+
</template>
|
|
134
|
+
<template>
|
|
135
|
+
<brick-player
|
|
136
|
+
mediaid="def456"
|
|
137
|
+
playerid="xyz789"
|
|
138
|
+
aspectratio="16:9"
|
|
139
|
+
title="Another video"
|
|
140
|
+
>
|
|
141
|
+
</brick-player>
|
|
142
|
+
</template>
|
|
143
|
+
</brick-carousel-v2>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Server-Side Rendering
|
|
147
|
+
|
|
148
|
+
### Basic SSR Example
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { renderBrickCarousel } from '@amedia/brick-carousel/template';
|
|
152
|
+
|
|
153
|
+
const carouselHTML = renderBrickCarousel({
|
|
154
|
+
dataItems: [
|
|
155
|
+
'<article>Article 1</article>',
|
|
156
|
+
'<article>Article 2</article>',
|
|
157
|
+
'<article>Article 3</article>',
|
|
158
|
+
'<article>Article 4</article>',
|
|
159
|
+
],
|
|
160
|
+
dataVersion: 'carousel',
|
|
161
|
+
dataMinSlidesToShow: '2',
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### SSR Gallery Example
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
import { renderBrickCarousel } from '@amedia/brick-carousel/template';
|
|
169
|
+
|
|
170
|
+
const galleryHTML = renderBrickCarousel({
|
|
171
|
+
dataItems: [
|
|
172
|
+
'<brick-image-v9 src="image1.jpg" alt="Image 1"></brick-image-v9>',
|
|
173
|
+
'<brick-image-v9 src="image2.jpg" alt="Image 2"></brick-image-v9>',
|
|
174
|
+
'<brick-image-v9 src="image3.jpg" alt="Image 3"></brick-image-v9>',
|
|
175
|
+
],
|
|
176
|
+
dataVersion: 'gallery',
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### SSR with Hide Buttons
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { renderBrickCarousel } from '@amedia/brick-carousel/template';
|
|
184
|
+
|
|
185
|
+
const carouselHTML = renderBrickCarousel({
|
|
186
|
+
dataItems: [
|
|
187
|
+
'<div class="content">Slide 1</div>',
|
|
188
|
+
'<div class="content">Slide 2</div>',
|
|
189
|
+
'<div class="content">Slide 3</div>',
|
|
190
|
+
],
|
|
191
|
+
dataHideBtnStartEnd: true,
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Programmatic Usage
|
|
196
|
+
|
|
197
|
+
```javascript
|
|
198
|
+
import { BrickCarousel } from '@amedia/brick-carousel';
|
|
199
|
+
|
|
200
|
+
const carousel = new BrickCarousel({
|
|
201
|
+
dataVersion: 'carousel',
|
|
202
|
+
dataMinSlidesToShow: '2',
|
|
203
|
+
dataHideBtnStartEnd: false,
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// Append to DOM
|
|
207
|
+
document.querySelector('#container').appendChild(carousel);
|
|
208
|
+
|
|
209
|
+
// Add items dynamically
|
|
210
|
+
const article = document.createElement('article');
|
|
211
|
+
article.textContent = 'Dynamic content';
|
|
212
|
+
carousel.appendChild(article);
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Accessibility
|
|
216
|
+
|
|
217
|
+
### Built-in Accessibility Features
|
|
218
|
+
|
|
219
|
+
- **Semantic HTML**: Uses `<section>`, `<ul>`, and `<li>` elements with proper ARIA roles
|
|
220
|
+
- **Screen Reader Support**:
|
|
221
|
+
- `aria-describedby` connects carousel to descriptive text
|
|
222
|
+
- Each slide announces "Article X of Y" (or "Image X of Y" for gallery mode)
|
|
223
|
+
- Skip link allows users to bypass carousel content
|
|
224
|
+
- **Keyboard Navigation**:
|
|
225
|
+
- `Arrow Left/Right`: Navigate between slides
|
|
226
|
+
- `Tab`: Navigate through focusable elements within slides
|
|
227
|
+
- `Escape`: Skip to content after carousel
|
|
228
|
+
- **Navigation Buttons**: Properly labeled with `aria-label` and disabled states
|
|
229
|
+
- **Reduced Motion**: Respects `prefers-reduced-motion` user preference
|
|
230
|
+
- **Focus Management**: Automatically manages focus when navigating to start/end
|
|
231
|
+
|
|
232
|
+
### WCAG 2.1 AA Compliance
|
|
233
|
+
|
|
234
|
+
Component is tested for accessibility and meets WCAG 2.1 AA standards with automated axe tests via Playwright.
|
|
235
|
+
|
|
236
|
+
## Responsive Behavior
|
|
237
|
+
|
|
238
|
+
The carousel automatically adjusts the number of visible slides based on container width:
|
|
239
|
+
|
|
240
|
+
- **< 460px**: Shows 1 slide
|
|
241
|
+
- **460px - 768px**: Shows 2 slides
|
|
242
|
+
- **> 768px**: Shows 3 slides (or fewer if `data-slides` is less than 3)
|
|
243
|
+
- **Gallery mode**: Always shows 1 full-width slide
|
|
244
|
+
- **When `data-min-slides-to-show="2"`**: Forces minimum 2 slides visible
|
|
245
|
+
|
|
246
|
+
## Styling and CSS Properties
|
|
247
|
+
|
|
248
|
+
### Custom CSS Properties
|
|
249
|
+
|
|
250
|
+
| Property | Description | Default |
|
|
251
|
+
| --------------------------- | ---------------------------------------------------------- | ----------------- |
|
|
252
|
+
| `--b-carousel-btn-min` | Minimum width and height for navigation buttons | `2rem` |
|
|
253
|
+
| `--b-carousel-btn-max` | Maximum width and height for navigation buttons | `3.125rem` |
|
|
254
|
+
| `--b-carousel-btns-display` | Display state of navigation buttons (set programmatically) | `block` or `none` |
|
|
255
|
+
|
|
256
|
+
### Example: Customizing Button Size
|
|
257
|
+
|
|
258
|
+
```css
|
|
259
|
+
brick-carousel-v2 {
|
|
260
|
+
--b-carousel-btn-min: 2.5rem;
|
|
261
|
+
--b-carousel-btn-max: 4rem;
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## Common Patterns
|
|
266
|
+
|
|
267
|
+
### Article Carousel with Teasers
|
|
268
|
+
|
|
269
|
+
```html
|
|
270
|
+
<brick-carousel-v2 data-min-slides-to-show="2">
|
|
271
|
+
<brick-teaser-v13 title="Breaking news story" type="story" vignette="News">
|
|
272
|
+
</brick-teaser-v13>
|
|
273
|
+
<brick-teaser-v13 title="Opinion piece" type="opinion" vignette="Opinion">
|
|
274
|
+
</brick-teaser-v13>
|
|
275
|
+
<brick-teaser-v13 title="Photo gallery" type="gallery" vignette="Photos">
|
|
276
|
+
</brick-teaser-v13>
|
|
277
|
+
</brick-carousel-v2>
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Video Carousel
|
|
281
|
+
|
|
282
|
+
```html
|
|
283
|
+
<brick-carousel-v2>
|
|
284
|
+
<template>
|
|
285
|
+
<brick-player
|
|
286
|
+
mediaid="video1"
|
|
287
|
+
playerid="player123"
|
|
288
|
+
aspectratio="16:9"
|
|
289
|
+
title="Video 1"
|
|
290
|
+
>
|
|
291
|
+
</brick-player>
|
|
292
|
+
</template>
|
|
293
|
+
<template>
|
|
294
|
+
<brick-player
|
|
295
|
+
mediaid="video2"
|
|
296
|
+
playerid="player123"
|
|
297
|
+
aspectratio="16:9"
|
|
298
|
+
title="Video 2"
|
|
299
|
+
>
|
|
300
|
+
</brick-player>
|
|
301
|
+
</template>
|
|
302
|
+
</brick-carousel-v2>
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Image Gallery with Hidden End Buttons
|
|
306
|
+
|
|
307
|
+
```html
|
|
308
|
+
<brick-carousel-v2 data-version="gallery" data-hide-btn-start-end="true">
|
|
309
|
+
<brick-image-v9 src="image1.jpg" alt="Gallery image 1"></brick-image-v9>
|
|
310
|
+
<brick-image-v9 src="image2.jpg" alt="Gallery image 2"></brick-image-v9>
|
|
311
|
+
<brick-image-v9 src="image3.jpg" alt="Gallery image 3"></brick-image-v9>
|
|
312
|
+
</brick-carousel-v2>
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
## Technical Details
|
|
316
|
+
|
|
317
|
+
- **Custom Element**: `brick-carousel-v2`
|
|
318
|
+
- **Base Class**: BrickElement
|
|
319
|
+
- **Dependencies**: @amedia/brick-template (1.3.1), @amedia/brick-tokens (5.19.6)
|
|
320
|
+
- **Renders as**: `<section>` containing navigation and content
|
|
321
|
+
- **Browser Support**: Modern browsers with custom element support
|
|
322
|
+
- **Mutation Observer**: Automatically detects and handles dynamically added children
|
|
323
|
+
- **Scroll Behavior**: Uses CSS scroll-snap for smooth scrolling
|
|
324
|
+
- **Drag Support**: Click-and-drag navigation on desktop (disabled on touch devices)
|
|
325
|
+
|
|
326
|
+
## Important Notes
|
|
327
|
+
|
|
328
|
+
### CSS Subgrid Issue
|
|
329
|
+
|
|
330
|
+
There is a known issue with using CSS subgrid in carousel content. The `overflow: hidden` rule on `li.content-wrapper` can interfere with subgrid behavior. If you need to use subgrid, you must override the overflow rule in your own CSS and handle any overflow issues yourself.
|
|
331
|
+
|
|
332
|
+
```css
|
|
333
|
+
brick-carousel-v2 [data-content-wrapper] {
|
|
334
|
+
overflow: visible; /* Override for subgrid support */
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Template Tag Usage (Client-side only)
|
|
339
|
+
|
|
340
|
+
When using custom elements like `brick-player`, wrap them in `<template>` tags to prevent early initialization. The content must be a template string, not created with `createElement`, to avoid premature custom element initialization.
|
|
341
|
+
|
|
342
|
+
### SSR vs Client-side Differences
|
|
343
|
+
|
|
344
|
+
- **Client-side**: Direct children are automatically wrapped in `<li>` elements
|
|
345
|
+
- **Server-side**: Use `dataItems` array with HTML strings that are wrapped by the template function
|
|
346
|
+
- **Server-side parameters**: All parameters are strings (e.g., `dataMinSlidesToShow: '2'`)
|
|
347
|
+
- **Validation**: Server-side function includes built-in validation with helpful error messages
|
|
348
|
+
|
|
349
|
+
### Hide Buttons Caution
|
|
350
|
+
|
|
351
|
+
The `data-hide-btn-start-end` attribute should generally not be used when carousel content is wrapped in links (like teasers), as disappearing buttons can cause users to accidentally click the underlying link.
|
|
352
|
+
|
|
353
|
+
## Version
|
|
354
|
+
|
|
355
|
+
Current version: 2.0.10
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brick-classnames
|
|
3
|
+
version: 2.1.0
|
|
4
|
+
category: Utility
|
|
5
|
+
tags: [utility, css, theming, design-system, classnames]
|
|
6
|
+
use_cases: [theming, styling, design-tokens, css-variables]
|
|
7
|
+
related: [brick-themes, brick-tokens]
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Brick Classnames
|
|
11
|
+
|
|
12
|
+
A utility module that converts design theme names into CSS-safe class names for use with Brick design tokens.
|
|
13
|
+
|
|
14
|
+
## Key Capabilities
|
|
15
|
+
|
|
16
|
+
- Converts design theme names to CSS-safe class names
|
|
17
|
+
- Ensures correct scoping for theme-specific CSS variables
|
|
18
|
+
- Works seamlessly with brick-tokens theme CSS files
|
|
19
|
+
- TypeScript support with type-safe design names
|
|
20
|
+
- Simple, single-function API
|
|
21
|
+
|
|
22
|
+
## API
|
|
23
|
+
|
|
24
|
+
### `designNameToClassName(designName: Design): string`
|
|
25
|
+
|
|
26
|
+
Converts a design theme name to a CSS-safe class name that corresponds with theme classes in brick-tokens.
|
|
27
|
+
|
|
28
|
+
**Parameters:**
|
|
29
|
+
|
|
30
|
+
- `designName`: `Design` - One of: `'nettavisen' | 'alt' | 'alfa' | 'bravo' | 'charlie'`
|
|
31
|
+
|
|
32
|
+
**Returns:** `string` - A CSS class name (e.g., `'themeAlt'`, `'themeBravo'`)
|
|
33
|
+
|
|
34
|
+
## Examples
|
|
35
|
+
|
|
36
|
+
### Basic Usage
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
import { designNameToClassName } from '@amedia/brick-classnames';
|
|
40
|
+
|
|
41
|
+
const cssClass = designNameToClassName('alt');
|
|
42
|
+
// Returns: 'themeAlt'
|
|
43
|
+
|
|
44
|
+
const html = `<div class="${cssClass}">
|
|
45
|
+
<amedia-foo>bar</amedia-foo>
|
|
46
|
+
</div>`;
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### With CSS Variables
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
const className = designNameToClassName('bravo');
|
|
53
|
+
// Returns: 'themeBravo'
|
|
54
|
+
|
|
55
|
+
// In your HTML
|
|
56
|
+
const markup = `<div class="${className}">
|
|
57
|
+
<button>Styled with Bravo theme</button>
|
|
58
|
+
</div>`;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```css
|
|
62
|
+
/* Your component CSS can reference theme variables */
|
|
63
|
+
.button {
|
|
64
|
+
color: var(--brick-colors-adText);
|
|
65
|
+
background: var(--brick-colors-primary);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### All Available Themes
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
import { designNameToClassName } from '@amedia/brick-classnames';
|
|
73
|
+
|
|
74
|
+
designNameToClassName('nettavisen'); // 'themeNettavisen'
|
|
75
|
+
designNameToClassName('alt'); // 'themeAlt'
|
|
76
|
+
designNameToClassName('alfa'); // 'themeAlfa'
|
|
77
|
+
designNameToClassName('bravo'); // 'themeBravo'
|
|
78
|
+
designNameToClassName('charlie'); // 'themeCharlie'
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Framework Integration
|
|
82
|
+
|
|
83
|
+
### Svelte
|
|
84
|
+
|
|
85
|
+
```svelte
|
|
86
|
+
<script>
|
|
87
|
+
import { designNameToClassName } from '@amedia/brick-classnames';
|
|
88
|
+
|
|
89
|
+
export let design = 'alt';
|
|
90
|
+
|
|
91
|
+
$: themeClass = designNameToClassName(design);
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<div class={themeClass}>
|
|
95
|
+
<slot />
|
|
96
|
+
</div>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### React
|
|
100
|
+
|
|
101
|
+
```jsx
|
|
102
|
+
import { designNameToClassName } from '@amedia/brick-classnames';
|
|
103
|
+
|
|
104
|
+
function ThemedContainer({ design, children }) {
|
|
105
|
+
const themeClass = designNameToClassName(design);
|
|
106
|
+
|
|
107
|
+
return <div className={themeClass}>{children}</div>;
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Technical Details
|
|
112
|
+
|
|
113
|
+
- **Package**: `@amedia/brick-classnames`
|
|
114
|
+
- **Type**: Utility function
|
|
115
|
+
- **Dependencies**: `@amedia/brick-themes`
|
|
116
|
+
- **Output format**: Camel-cased class name with 'theme' prefix
|
|
117
|
+
|
|
118
|
+
## Important Notes
|
|
119
|
+
|
|
120
|
+
- You must load the corresponding theme CSS file from Eik to use the CSS variables
|
|
121
|
+
- Theme CSS files are available at: `https://assets.acdn.no/pkg/@amedia/brick-tokens/v2/css/theme-{name}.css`
|
|
122
|
+
- The class name provides scoping for CSS variables defined in brick-tokens
|
|
123
|
+
- TypeScript provides autocomplete and validation for design names
|
|
124
|
+
|
|
125
|
+
## Common Patterns
|
|
126
|
+
|
|
127
|
+
### Loading Theme CSS
|
|
128
|
+
|
|
129
|
+
```javascript
|
|
130
|
+
import { designNameToClassName } from '@amedia/brick-classnames';
|
|
131
|
+
|
|
132
|
+
const design = 'bravo';
|
|
133
|
+
const className = designNameToClassName(design);
|
|
134
|
+
|
|
135
|
+
// Load the corresponding CSS file
|
|
136
|
+
const link = document.createElement('link');
|
|
137
|
+
link.rel = 'stylesheet';
|
|
138
|
+
link.href = `https://assets.acdn.no/pkg/@amedia/brick-tokens/v2/css/theme-${design}.css`;
|
|
139
|
+
document.head.appendChild(link);
|
|
140
|
+
|
|
141
|
+
// Apply the class to enable scoped variables
|
|
142
|
+
document.body.className = className;
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Version
|
|
146
|
+
|
|
147
|
+
Current version: 2.1.0
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brick-countdown
|
|
3
|
+
version: 2.0.9
|
|
4
|
+
selector: brick-countdown-v2
|
|
5
|
+
category: Feedback
|
|
6
|
+
tags: [countdown, timer, animation, teaser, time-based]
|
|
7
|
+
use_cases:
|
|
8
|
+
[product-launches, event-countdown, limited-offers, time-sensitive-content]
|
|
9
|
+
related: [brick-teaser]
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Brick Countdown
|
|
13
|
+
|
|
14
|
+
An animated countdown component that displays time remaining until a specified date, with automatic updates and localization support.
|
|
15
|
+
|
|
16
|
+
## Key Capabilities
|
|
17
|
+
|
|
18
|
+
- Animated digit transitions with flip animation
|
|
19
|
+
- Automatic countdown updates every second
|
|
20
|
+
- Supports days, hours, minutes, and seconds display
|
|
21
|
+
- Localization support (Norwegian Bokmål and Nynorsk)
|
|
22
|
+
- Automatically hides when countdown reaches zero
|
|
23
|
+
- Server-side rendering support via template function
|
|
24
|
+
- Accessible with screen reader support
|
|
25
|
+
|
|
26
|
+
## Props/Attributes
|
|
27
|
+
|
|
28
|
+
| Attribute | Type | Default | Required | Description |
|
|
29
|
+
| ------------- | ------------------ | ------- | -------- | -------------------------------------------------- |
|
|
30
|
+
| `data-date` | EpochTimeStamp | - | yes | Unix timestamp in milliseconds for the target date |
|
|
31
|
+
| `data-text` | string | - | no | Optional text to display with the countdown |
|
|
32
|
+
| `data-locale` | 'nb_NO' \| 'nn_NO' | 'nb_NO' | no | Locale for time unit labels |
|
|
33
|
+
|
|
34
|
+
## Examples
|
|
35
|
+
|
|
36
|
+
### Basic Countdown
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
<brick-countdown-v2 data-date="1713515269513"></brick-countdown-v2>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### With Custom Text
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<brick-countdown-v2
|
|
46
|
+
data-date="1713515269513"
|
|
47
|
+
data-text="Starts in"
|
|
48
|
+
></brick-countdown-v2>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### With Locale
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<brick-countdown-v2
|
|
55
|
+
data-date="1713515269513"
|
|
56
|
+
data-text="Tid igjen"
|
|
57
|
+
data-locale="nn_NO"
|
|
58
|
+
></brick-countdown-v2>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### JavaScript Creation
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
const el = document.createElement('brick-countdown-v2');
|
|
65
|
+
el.dataset.date = '1713515269513';
|
|
66
|
+
el.dataset.text = 'Event starts in';
|
|
67
|
+
el.dataset.locale = 'nb_NO';
|
|
68
|
+
document.body.appendChild(el);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Server-Side Rendering
|
|
72
|
+
|
|
73
|
+
### Import and Render
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
import { renderBrickCountdown } from '@amedia/brick-countdown/template';
|
|
77
|
+
|
|
78
|
+
const markup = renderBrickCountdown({
|
|
79
|
+
dataDate: 1713515269513,
|
|
80
|
+
dataText: 'Starts in',
|
|
81
|
+
dataLocale: 'nb_NO',
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Client-Side Hydration
|
|
86
|
+
|
|
87
|
+
After server-side rendering, load the client-side JavaScript for interactivity:
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
import '@amedia/brick-countdown';
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Behavior
|
|
94
|
+
|
|
95
|
+
### Countdown Logic
|
|
96
|
+
|
|
97
|
+
- Updates every second with animated digit transitions
|
|
98
|
+
- Hides days unit when less than 1 day remains
|
|
99
|
+
- Automatically removes itself from DOM when countdown reaches zero
|
|
100
|
+
- Validates date and logs error if invalid timestamp provided
|
|
101
|
+
|
|
102
|
+
### Animation
|
|
103
|
+
|
|
104
|
+
- Digits animate vertically using CSS custom properties
|
|
105
|
+
- Smooth transitions between numbers
|
|
106
|
+
- No animation for units that haven't changed
|
|
107
|
+
|
|
108
|
+
## Accessibility
|
|
109
|
+
|
|
110
|
+
- Uses semantic `<time>` element with `datetime` attribute
|
|
111
|
+
- Screen reader text updates with countdown progress
|
|
112
|
+
- Visual and screen reader content synchronized
|
|
113
|
+
- Proper ARIA labeling for time remaining
|
|
114
|
+
|
|
115
|
+
## Localization
|
|
116
|
+
|
|
117
|
+
### Supported Locales
|
|
118
|
+
|
|
119
|
+
**Norwegian Bokmål (nb_NO - default):**
|
|
120
|
+
|
|
121
|
+
- days: "dager"
|
|
122
|
+
- hours: "timer"
|
|
123
|
+
- minutes: "minutter"
|
|
124
|
+
- seconds: "sekunder"
|
|
125
|
+
|
|
126
|
+
**Norwegian Nynorsk (nn_NO):**
|
|
127
|
+
|
|
128
|
+
- days: "dagar"
|
|
129
|
+
- hours: "timar"
|
|
130
|
+
- minutes: "minutt"
|
|
131
|
+
- seconds: "sekund"
|
|
132
|
+
|
|
133
|
+
## Common Patterns
|
|
134
|
+
|
|
135
|
+
### Event Countdown in Teaser
|
|
136
|
+
|
|
137
|
+
```html
|
|
138
|
+
<brick-teaser-v9>
|
|
139
|
+
<brick-countdown-v2
|
|
140
|
+
data-date="1713515269513"
|
|
141
|
+
data-text="Direktesending starter om"
|
|
142
|
+
></brick-countdown-v2>
|
|
143
|
+
<!-- Other teaser content -->
|
|
144
|
+
</brick-teaser-v9>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Dynamic Countdown Creation
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
function createCountdown(targetDate, text) {
|
|
151
|
+
const countdown = document.createElement('brick-countdown-v2');
|
|
152
|
+
countdown.dataset.date = targetDate.getTime().toString();
|
|
153
|
+
countdown.dataset.text = text;
|
|
154
|
+
return countdown;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const eventDate = new Date('2024-12-31T23:59:59');
|
|
158
|
+
const countdownEl = createCountdown(eventDate, 'New Year in');
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Technical Details
|
|
162
|
+
|
|
163
|
+
- **Custom Element**: `brick-countdown-v2`
|
|
164
|
+
- **Base Class**: BrickElement
|
|
165
|
+
- **Dependencies**: `@amedia/brick-template`, `@amedia/brick-tokens`
|
|
166
|
+
- **Renders as**: Custom element with `<time>` element inside
|
|
167
|
+
- **Update Interval**: 1000ms (1 second)
|
|
168
|
+
|
|
169
|
+
## Important Notes
|
|
170
|
+
|
|
171
|
+
- Date must be provided as Unix timestamp in milliseconds
|
|
172
|
+
- Component automatically removes itself when countdown ends
|
|
173
|
+
- Days display is hidden when less than 24 hours remain
|
|
174
|
+
- Invalid dates will log an error and prevent countdown from starting
|
|
175
|
+
- Countdown stops updating when only days remain (no sub-day updates needed)
|
|
176
|
+
- Uses `setInterval` which is automatically cleared on component disconnect
|
|
177
|
+
|
|
178
|
+
## Version
|
|
179
|
+
|
|
180
|
+
Current version: 2.0.9
|