@amedia/brick-mcp 0.1.3 → 0.1.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/README.md +50 -1
- package/data/components/brick-mcp.md +259 -0
- package/data/components/brick-pill.md +362 -0
- package/data/components/brick-player.md +331 -0
- package/data/components/brick-published.md +219 -0
- package/data/components/brick-share.md +335 -0
- package/data/components/brick-stepper.md +319 -0
- package/data/components/brick-tab.md +241 -0
- package/data/components/brick-tabs.md +420 -0
- package/data/components/brick-tag.md +335 -0
- package/data/components/brick-teaser-player.md +248 -0
- package/data/components/brick-teaser-reels.md +190 -0
- package/data/components/brick-teaser.md +262 -0
- package/data/components/brick-template.md +226 -0
- package/data/components/brick-textarea.md +191 -0
- package/data/components/brick-themes.md +104 -0
- package/data/components/brick-toast.md +271 -0
- package/data/components/brick-toggle.md +268 -0
- package/data/components/brick-tokens.md +287 -0
- package/data/components/brick-tooltip.md +249 -0
- package/data/components-metadata.json +34 -34
- package/data/tokens.json +0 -7
- package/dist/data/components/brick-mcp.md +259 -0
- package/dist/data/components/brick-pill.md +362 -0
- package/dist/data/components/brick-player.md +331 -0
- package/dist/data/components/brick-published.md +219 -0
- package/dist/data/components/brick-share.md +335 -0
- package/dist/data/components/brick-stepper.md +319 -0
- package/dist/data/components/brick-tab.md +241 -0
- package/dist/data/components/brick-tabs.md +420 -0
- package/dist/data/components/brick-tag.md +335 -0
- package/dist/data/components/brick-teaser-player.md +248 -0
- package/dist/data/components/brick-teaser-reels.md +190 -0
- package/dist/data/components/brick-teaser.md +262 -0
- package/dist/data/components/brick-template.md +226 -0
- package/dist/data/components/brick-textarea.md +191 -0
- package/dist/data/components/brick-themes.md +104 -0
- package/dist/data/components/brick-toast.md +271 -0
- package/dist/data/components/brick-toggle.md +268 -0
- package/dist/data/components/brick-tokens.md +287 -0
- package/dist/data/components/brick-tooltip.md +249 -0
- package/dist/data/components-metadata.json +34 -34
- package/dist/data/tokens.json +0 -7
- package/package.json +37 -37
- package/data/components/brick-mcp.json +0 -6
- package/data/components/brick-pill.json +0 -6
- package/data/components/brick-player.json +0 -7
- package/data/components/brick-published.json +0 -7
- package/data/components/brick-share.json +0 -7
- package/data/components/brick-stepper.json +0 -7
- package/data/components/brick-tab.json +0 -7
- package/data/components/brick-tabs.json +0 -9
- package/data/components/brick-tag.json +0 -7
- package/data/components/brick-teaser-player.json +0 -9
- package/data/components/brick-teaser-reels.json +0 -9
- package/data/components/brick-teaser.json +0 -9
- package/data/components/brick-template.json +0 -9
- package/data/components/brick-textarea.json +0 -7
- package/data/components/brick-themes.json +0 -6
- package/data/components/brick-toast.json +0 -9
- package/data/components/brick-toggle.json +0 -7
- package/data/components/brick-tokens.json +0 -8
- package/data/components/brick-tooltip.json +0 -7
- package/dist/data/components/brick-mcp.json +0 -6
- package/dist/data/components/brick-pill.json +0 -6
- package/dist/data/components/brick-player.json +0 -7
- package/dist/data/components/brick-published.json +0 -7
- package/dist/data/components/brick-share.json +0 -7
- package/dist/data/components/brick-stepper.json +0 -7
- package/dist/data/components/brick-tab.json +0 -7
- package/dist/data/components/brick-tabs.json +0 -9
- package/dist/data/components/brick-tag.json +0 -7
- package/dist/data/components/brick-teaser-player.json +0 -9
- package/dist/data/components/brick-teaser-reels.json +0 -9
- package/dist/data/components/brick-teaser.json +0 -9
- package/dist/data/components/brick-template.json +0 -9
- package/dist/data/components/brick-textarea.json +0 -7
- package/dist/data/components/brick-themes.json +0 -6
- package/dist/data/components/brick-toast.json +0 -9
- package/dist/data/components/brick-toggle.json +0 -7
- package/dist/data/components/brick-tokens.json +0 -8
- package/dist/data/components/brick-tooltip.json +0 -7
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
|
-
The Brick MCP Server is a Model Context Protocol (MCP) server that provides AI assistants (like Claude Code) with direct access to the Brick design system. It enables accurate, context-aware assistance when developers implement Brick components by exposing component documentation, design tokens, and usage examples through standardized MCP tools.
|
|
5
|
+
The Brick MCP Server is a Model Context Protocol (MCP) server that provides AI assistants (like Claude Code or Copilot) with direct access to the Brick design system. It enables accurate, context-aware assistance when developers implement Brick components by exposing component documentation, design tokens, and usage examples through standardized MCP tools.
|
|
6
6
|
|
|
7
7
|
## Prerequisites
|
|
8
8
|
|
|
@@ -206,6 +206,55 @@ Claude: [Calls list-components with filter: "button"]
|
|
|
206
206
|
|
|
207
207
|
---
|
|
208
208
|
|
|
209
|
+
## Maintaining Component Documentation
|
|
210
|
+
|
|
211
|
+
The MCP server includes prompts to help maintain component documentation as components evolve.
|
|
212
|
+
|
|
213
|
+
### Updating Component Docs
|
|
214
|
+
|
|
215
|
+
Use [prompts/update-component-docs.md](prompts/update-component-docs.md) to check if component documentation needs updating based on version changes.
|
|
216
|
+
|
|
217
|
+
**When to use:**
|
|
218
|
+
|
|
219
|
+
- After component versions have been updated
|
|
220
|
+
- To audit which components have outdated documentation
|
|
221
|
+
- Before publishing a new version of the MCP server
|
|
222
|
+
|
|
223
|
+
**What it does:**
|
|
224
|
+
|
|
225
|
+
1. Compares versions in `data/components/*.md` frontmatter against `packages/*/package.json`
|
|
226
|
+
2. Identifies components with major or minor version changes (patch changes are skipped)
|
|
227
|
+
3. Generates updated documentation for components that need it
|
|
228
|
+
4. Provides a summary of what was updated
|
|
229
|
+
|
|
230
|
+
**Example usage with Claude Code:**
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
User: "Check if any component docs need updating using prompts/update-component-docs.md"
|
|
234
|
+
|
|
235
|
+
Claude: [Reads the prompt file and follows the instructions]
|
|
236
|
+
[Checks all components in data/components/]
|
|
237
|
+
[Identifies version mismatches]
|
|
238
|
+
[Updates documentation for components with major/minor changes]
|
|
239
|
+
|
|
240
|
+
## Documentation Update Summary
|
|
241
|
+
|
|
242
|
+
### Components Checked: 45
|
|
243
|
+
|
|
244
|
+
### Updates Required:
|
|
245
|
+
- brick-modal: 3.2.1 → 4.0.0 (major change)
|
|
246
|
+
- brick-image: 6.0.5 → 6.1.0 (minor change)
|
|
247
|
+
|
|
248
|
+
### Up to Date: 42 components
|
|
249
|
+
|
|
250
|
+
### Skipped (patch changes only):
|
|
251
|
+
- brick-button: 9.0.2 → 9.0.5
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
The prompt references [prompts/generate-llm-docs.md](prompts/generate-llm-docs.md) for the documentation generation process.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
209
258
|
### Adding New Tools
|
|
210
259
|
|
|
211
260
|
To add a new MCP tool:
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brick-mcp
|
|
3
|
+
version: 0.1.3
|
|
4
|
+
selector: N/A
|
|
5
|
+
category: Utilities
|
|
6
|
+
tags: [mcp, model-context-protocol, ai, llm, development-tools, cli, design-system]
|
|
7
|
+
use_cases: [ai-assisted-development, component-discovery, design-tokens-access, code-generation]
|
|
8
|
+
related: [brick-tokens, brick-template]
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Brick MCP
|
|
12
|
+
|
|
13
|
+
A Model Context Protocol (MCP) server that provides AI assistants with direct access to the Brick design system through standardized tools for component documentation, design tokens, and usage examples.
|
|
14
|
+
|
|
15
|
+
## Key Capabilities
|
|
16
|
+
|
|
17
|
+
- Exposes three MCP tools for AI assistants to query Brick components and design tokens
|
|
18
|
+
- Provides component discovery with filtering by name, category, or tags
|
|
19
|
+
- Delivers detailed component documentation including props, examples, and Storybook links
|
|
20
|
+
- Gives access to design tokens filtered by category or theme
|
|
21
|
+
- Runs in stdio mode (for Claude Code) or HTTP mode (for local development)
|
|
22
|
+
- Pre-generates and bundles all data as JSON for fast, standalone operation
|
|
23
|
+
- Enables accurate, context-aware AI assistance when implementing Brick components
|
|
24
|
+
|
|
25
|
+
## MCP Tools
|
|
26
|
+
|
|
27
|
+
The server provides three tools that AI assistants can call:
|
|
28
|
+
|
|
29
|
+
### list-components
|
|
30
|
+
|
|
31
|
+
Lists all available Brick components with optional filtering.
|
|
32
|
+
|
|
33
|
+
**Input Schema:**
|
|
34
|
+
```typescript
|
|
35
|
+
{
|
|
36
|
+
filter?: string; // Filter by name, category, or tag
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Returns:**
|
|
41
|
+
```typescript
|
|
42
|
+
{
|
|
43
|
+
components: Array<{
|
|
44
|
+
name: string; // e.g., "brick-button"
|
|
45
|
+
version: string; // e.g., "9.0.0"
|
|
46
|
+
selector: string; // e.g., "brick-button-v9"
|
|
47
|
+
description?: string;
|
|
48
|
+
category?: string; // Forms, Navigation, Layout, Feedback, Display, Utilities
|
|
49
|
+
tags?: string[];
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### get-component-docs
|
|
55
|
+
|
|
56
|
+
Retrieves detailed documentation for one or more components.
|
|
57
|
+
|
|
58
|
+
**Input Schema:**
|
|
59
|
+
```typescript
|
|
60
|
+
{
|
|
61
|
+
components: string[]; // e.g., ["brick-button", "brick-modal"]
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Returns:**
|
|
66
|
+
```typescript
|
|
67
|
+
{
|
|
68
|
+
docs: Array<{
|
|
69
|
+
name: string;
|
|
70
|
+
version: string;
|
|
71
|
+
selector: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
examples: {
|
|
74
|
+
webComponent?: string;
|
|
75
|
+
storybook?: string; // Link to Chromatic Storybook
|
|
76
|
+
};
|
|
77
|
+
cdnPath?: string; // Eik CDN URL
|
|
78
|
+
}>;
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### get-design-tokens
|
|
83
|
+
|
|
84
|
+
Accesses design tokens from brick-tokens with filtering options.
|
|
85
|
+
|
|
86
|
+
**Input Schema:**
|
|
87
|
+
```typescript
|
|
88
|
+
{
|
|
89
|
+
category?: 'colors' | 'spacing' | 'typography' | 'shadows' | 'borders';
|
|
90
|
+
theme?: string; // e.g., "bergen", "alfa", "bt"
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Returns:**
|
|
95
|
+
```typescript
|
|
96
|
+
{
|
|
97
|
+
tokens: Array<{
|
|
98
|
+
name: string;
|
|
99
|
+
value: string;
|
|
100
|
+
type: string;
|
|
101
|
+
description?: string;
|
|
102
|
+
category?: string;
|
|
103
|
+
theme?: string;
|
|
104
|
+
}>;
|
|
105
|
+
themes: string[];
|
|
106
|
+
documentation: {
|
|
107
|
+
anOverview?: string;
|
|
108
|
+
formats?: string;
|
|
109
|
+
naming?: string;
|
|
110
|
+
themes?: string;
|
|
111
|
+
usage?: string;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Examples
|
|
117
|
+
|
|
118
|
+
### Installation via npx (Recommended)
|
|
119
|
+
|
|
120
|
+
Add the Brick MCP server to Claude Code using npx:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
claude mcp add --transport stdio Brick -- npx -y @amedia/brick-mcp@latest
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Install as Package Dependency
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
npm install @amedia/brick-mcp
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Running in HTTP Mode
|
|
133
|
+
|
|
134
|
+
For local development with HTTP transport:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Install and build
|
|
138
|
+
npm install
|
|
139
|
+
npm run build
|
|
140
|
+
|
|
141
|
+
# Start HTTP server (default: http://localhost:3000)
|
|
142
|
+
npm run dev:http
|
|
143
|
+
|
|
144
|
+
# Add to Claude Code
|
|
145
|
+
claude mcp add Brick-http --transport sse --scope user -- http://0.0.0.0:3000/sse
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Environment Variables
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
PORT=3000 # Server port (default: 3000)
|
|
152
|
+
HOST=0.0.0.0 # Server host (default: 0.0.0.0)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Usage Workflow
|
|
156
|
+
|
|
157
|
+
Once configured, AI assistants can use the MCP tools:
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
User: "I need to add a button to my app using Brick"
|
|
161
|
+
|
|
162
|
+
AI Assistant:
|
|
163
|
+
1. Calls list-components with filter: "button"
|
|
164
|
+
2. Calls get-component-docs with components: ["brick-button"]
|
|
165
|
+
3. Provides implementation guidance with examples and CDN links
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## HTTP Endpoints (HTTP Mode Only)
|
|
169
|
+
|
|
170
|
+
When running in HTTP mode, the server exposes:
|
|
171
|
+
|
|
172
|
+
- `http://localhost:3000/health` - Health check endpoint
|
|
173
|
+
- `http://localhost:3000/sse` - SSE endpoint for MCP protocol communication
|
|
174
|
+
- `http://localhost:3000/message` - Message endpoint for client-to-server communication
|
|
175
|
+
|
|
176
|
+
## Programmatic Usage
|
|
177
|
+
|
|
178
|
+
### Extending with Custom Tools
|
|
179
|
+
|
|
180
|
+
To add a new MCP tool:
|
|
181
|
+
|
|
182
|
+
1. Create a new file in `src/tools/yourTool.ts`
|
|
183
|
+
2. Implement the tool function with input/output types using Zod
|
|
184
|
+
3. Register the tool in `src/server.ts` using `server.registerTool()`
|
|
185
|
+
|
|
186
|
+
Example tool structure:
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
import { z } from 'zod';
|
|
190
|
+
|
|
191
|
+
const InputSchema = z.object({
|
|
192
|
+
parameter: z.string().optional(),
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const OutputSchema = z.object({
|
|
196
|
+
result: z.string(),
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
export const yourTool = {
|
|
200
|
+
name: 'your-tool',
|
|
201
|
+
description: 'Description of what your tool does',
|
|
202
|
+
inputSchema: InputSchema,
|
|
203
|
+
handler: async (input: z.infer<typeof InputSchema>) => {
|
|
204
|
+
// Tool implementation
|
|
205
|
+
return { result: 'output' };
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Data Sources
|
|
211
|
+
|
|
212
|
+
The MCP server aggregates data from multiple sources during build:
|
|
213
|
+
|
|
214
|
+
- **Component Metadata**: `data/components-metadata.json` (auto-generated)
|
|
215
|
+
- **Component Documentation**: `data/components/*.md` (LLM-optimized docs)
|
|
216
|
+
- **Design Tokens**: `brick-tokens/publications/publication/*.json`
|
|
217
|
+
- **Token Documentation**: `data/tokens-documentation.json`
|
|
218
|
+
- **Package Information**: Each component's `package.json`
|
|
219
|
+
|
|
220
|
+
## Technical Details
|
|
221
|
+
|
|
222
|
+
- **Runtime**: Node.js
|
|
223
|
+
- **Protocol**: Model Context Protocol (MCP) 1.25.2+
|
|
224
|
+
- **Transport Modes**: stdio (recommended for Claude Code) or HTTP/SSE
|
|
225
|
+
- **Dependencies**:
|
|
226
|
+
- @modelcontextprotocol/sdk (MCP implementation)
|
|
227
|
+
- fastify (HTTP server)
|
|
228
|
+
- zod (schema validation)
|
|
229
|
+
- **Build System**: Custom build script that pre-generates all JSON data
|
|
230
|
+
- **Distribution**: Published to npm as `@amedia/brick-mcp`
|
|
231
|
+
|
|
232
|
+
## Publishing
|
|
233
|
+
|
|
234
|
+
### Standard Release
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
# From Brick monorepo root
|
|
238
|
+
npx changeset # Create a changeset
|
|
239
|
+
# Create PR → merge → "Version Packages" PR created automatically
|
|
240
|
+
# Merge "Version Packages" PR to publish to npm
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Snapshot Release (Testing)
|
|
244
|
+
|
|
245
|
+
1. Create a changeset
|
|
246
|
+
2. Run the [snapshot GitHub action](https://github.com/amedia/brick/actions/workflows/snapshotRelease.yml) for your branch and this package
|
|
247
|
+
|
|
248
|
+
## Important Notes
|
|
249
|
+
|
|
250
|
+
- The MCP server is designed to be run as a standalone npm package via npx
|
|
251
|
+
- All data is pre-generated during build time for optimal performance
|
|
252
|
+
- The server does not require access to the Brick monorepo at runtime
|
|
253
|
+
- stdio mode is recommended for Claude Code integration
|
|
254
|
+
- HTTP mode is useful for local development and testing
|
|
255
|
+
- The server provides read-only access to Brick design system information
|
|
256
|
+
|
|
257
|
+
## Version
|
|
258
|
+
|
|
259
|
+
Current version: 0.1.3
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brick-pill
|
|
3
|
+
version: 9.0.9
|
|
4
|
+
selector: brick-pill-v9
|
|
5
|
+
category: Data Display
|
|
6
|
+
tags: [pill, label, badge, status, meta, countdown, icon, vignette]
|
|
7
|
+
use_cases:
|
|
8
|
+
[
|
|
9
|
+
article-metadata,
|
|
10
|
+
content-labels,
|
|
11
|
+
status-indicators,
|
|
12
|
+
countdown-timers,
|
|
13
|
+
breaking-news,
|
|
14
|
+
content-categorization,
|
|
15
|
+
]
|
|
16
|
+
related: [brick-pillbox, brick-icon, brick-tokens]
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# Brick Pill
|
|
20
|
+
|
|
21
|
+
A read-only status indicator or label component that displays small pieces of meta information with optional icons and background fills.
|
|
22
|
+
|
|
23
|
+
## Key Capabilities
|
|
24
|
+
|
|
25
|
+
- Multiple visual versions: vignette, video, gallery, breaking, plus, alt, plusall, icon, countdown
|
|
26
|
+
- Customizable skins for different content categories (sport, opinion, highlight, commercial, shopping, betting)
|
|
27
|
+
- Optional filled or outlined styles
|
|
28
|
+
- Icon support with configurable size
|
|
29
|
+
- Live countdown timer functionality with automatic toggle to fallback version
|
|
30
|
+
- Locale support for countdown text (Norwegian Bokmal and Nynorsk)
|
|
31
|
+
- Can be used standalone or wrapped in brick-pillbox container
|
|
32
|
+
- CSS custom properties for advanced styling
|
|
33
|
+
|
|
34
|
+
## Props/Attributes
|
|
35
|
+
|
|
36
|
+
| Attribute | Type | Default | Required | Description |
|
|
37
|
+
| -------------------------------- | -------------------------------------------------------------------------------------- | ----------- | -------- | -------------------------------------------------------------- |
|
|
38
|
+
| `data-text` | string | - | no | Text content to display in the pill |
|
|
39
|
+
| `data-version` | `'vignette' \| 'video' \| 'gallery' \| 'breaking' \| 'untold' \| 'icon' \| 'plus' \| 'alt' \| 'plusall' \| 'countdown'` | `'vignette'` | no | Visual style variant of the pill |
|
|
40
|
+
| `data-filled` | boolean | `false` | no | When true, pill has background color fill |
|
|
41
|
+
| `data-skin` | `'none' \| 'black' \| 'custom-one' \| 'custom-two' \| 'custom-three' \| 'sport' \| 'highlight' \| 'commercial' \| 'shopping' \| 'betting' \| 'opinion'` | `'none'` | no | Predefined color theme for the pill |
|
|
42
|
+
| `data-icon-id` | string | - | no | ID of icon from brick-icon to display |
|
|
43
|
+
| `data-icon-text` | string | - | no | Alternative text for the icon |
|
|
44
|
+
| `data-icon-size` | string | `'small'` | no | Size of the icon |
|
|
45
|
+
| `data-countdown-date` | EpochTimeStamp | - | no | Unix timestamp for countdown end time (required for countdown) |
|
|
46
|
+
| `data-countdown-toggle-version` | `'vignette' \| 'video' \| 'gallery' \| 'breaking' \| 'untold'` | `'vignette'` | no | Version to display after countdown ends |
|
|
47
|
+
| `data-countdown-toggle-text` | string | - | no | Text to display after countdown ends |
|
|
48
|
+
| `data-locale` | `'nb_NO' \| 'nn_NO'` | `'nb_NO'` | no | Locale for countdown text (day/days translation) |
|
|
49
|
+
|
|
50
|
+
## Examples
|
|
51
|
+
|
|
52
|
+
### Basic Pill
|
|
53
|
+
|
|
54
|
+
```html
|
|
55
|
+
<brick-pill-v9 data-text="News" data-version="vignette"> </brick-pill-v9>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Filled Pill with Skin
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<brick-pill-v9
|
|
62
|
+
data-text="Sport"
|
|
63
|
+
data-version="vignette"
|
|
64
|
+
data-filled="true"
|
|
65
|
+
data-skin="sport"
|
|
66
|
+
>
|
|
67
|
+
</brick-pill-v9>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Breaking News Pill
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<brick-pill-v9
|
|
74
|
+
data-text="Breaking"
|
|
75
|
+
data-version="breaking"
|
|
76
|
+
data-filled="true"
|
|
77
|
+
>
|
|
78
|
+
</brick-pill-v9>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Pill with Icon
|
|
82
|
+
|
|
83
|
+
```html
|
|
84
|
+
<brick-pill-v9
|
|
85
|
+
data-text="1t 10m"
|
|
86
|
+
data-version="vignette"
|
|
87
|
+
data-icon-id="pill-podcast"
|
|
88
|
+
data-icon-size="small"
|
|
89
|
+
>
|
|
90
|
+
</brick-pill-v9>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Countdown Pill
|
|
94
|
+
|
|
95
|
+
Displays a live countdown timer that automatically switches to a different pill when time expires:
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<brick-pill-v9
|
|
99
|
+
data-version="countdown"
|
|
100
|
+
data-countdown-date="1676460023618"
|
|
101
|
+
data-countdown-toggle-text="Direkte"
|
|
102
|
+
data-countdown-toggle-version="breaking"
|
|
103
|
+
data-filled="true"
|
|
104
|
+
>
|
|
105
|
+
</brick-pill-v9>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Note: The countdown date should be a Unix epoch timestamp in milliseconds.
|
|
109
|
+
|
|
110
|
+
### Content Category Pills
|
|
111
|
+
|
|
112
|
+
```html
|
|
113
|
+
<!-- Opinion content -->
|
|
114
|
+
<brick-pill-v9
|
|
115
|
+
data-text="Opinion"
|
|
116
|
+
data-version="vignette"
|
|
117
|
+
data-skin="opinion"
|
|
118
|
+
data-filled="true"
|
|
119
|
+
>
|
|
120
|
+
</brick-pill-v9>
|
|
121
|
+
|
|
122
|
+
<!-- Commercial content -->
|
|
123
|
+
<brick-pill-v9
|
|
124
|
+
data-text="Commercial"
|
|
125
|
+
data-version="vignette"
|
|
126
|
+
data-skin="commercial"
|
|
127
|
+
data-filled="true"
|
|
128
|
+
>
|
|
129
|
+
</brick-pill-v9>
|
|
130
|
+
|
|
131
|
+
<!-- Highlight -->
|
|
132
|
+
<brick-pill-v9
|
|
133
|
+
data-text="Recommended"
|
|
134
|
+
data-version="vignette"
|
|
135
|
+
data-skin="highlight"
|
|
136
|
+
data-filled="true"
|
|
137
|
+
>
|
|
138
|
+
</brick-pill-v9>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Using with brick-pillbox
|
|
142
|
+
|
|
143
|
+
When wrapping multiple pills in brick-pillbox, the container manages spacing and styling:
|
|
144
|
+
|
|
145
|
+
```html
|
|
146
|
+
<brick-pillbox-v0 data-filled="true">
|
|
147
|
+
<brick-pill-v9
|
|
148
|
+
data-text="Breaking"
|
|
149
|
+
data-version="breaking"
|
|
150
|
+
data-filled="true"
|
|
151
|
+
>
|
|
152
|
+
</brick-pill-v9>
|
|
153
|
+
<brick-pill-v9 data-text="Politics" data-version="vignette" data-filled="true">
|
|
154
|
+
</brick-pill-v9>
|
|
155
|
+
</brick-pillbox-v0>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Framework Integration
|
|
159
|
+
|
|
160
|
+
### Svelte
|
|
161
|
+
|
|
162
|
+
```svelte
|
|
163
|
+
<script>
|
|
164
|
+
import '@amedia/brick-pill';
|
|
165
|
+
</script>
|
|
166
|
+
|
|
167
|
+
<brick-pill-v9
|
|
168
|
+
data-text="News"
|
|
169
|
+
data-version="vignette"
|
|
170
|
+
data-filled="true"
|
|
171
|
+
/>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
See this REPL for full example: https://svelte.dev/repl/b124e26657b944908566c8c21f985415
|
|
175
|
+
|
|
176
|
+
### React/Vue
|
|
177
|
+
|
|
178
|
+
```javascript
|
|
179
|
+
import '@amedia/brick-pill';
|
|
180
|
+
|
|
181
|
+
// React
|
|
182
|
+
function ArticleMeta() {
|
|
183
|
+
return (
|
|
184
|
+
<brick-pill-v9
|
|
185
|
+
data-text="Breaking"
|
|
186
|
+
data-version="breaking"
|
|
187
|
+
data-filled="true"
|
|
188
|
+
/>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Vue
|
|
193
|
+
<template>
|
|
194
|
+
<brick-pill-v9
|
|
195
|
+
data-text="Breaking"
|
|
196
|
+
data-version="breaking"
|
|
197
|
+
data-filled="true"
|
|
198
|
+
/>
|
|
199
|
+
</template>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Programmatic Usage
|
|
203
|
+
|
|
204
|
+
```javascript
|
|
205
|
+
import { BrickPill } from '@amedia/brick-pill';
|
|
206
|
+
|
|
207
|
+
const pill = document.createElement('brick-pill-v9');
|
|
208
|
+
pill.dataset.version = 'vignette';
|
|
209
|
+
pill.dataset.text = 'Latest';
|
|
210
|
+
pill.dataset.filled = 'true';
|
|
211
|
+
pill.dataset.skin = 'sport';
|
|
212
|
+
|
|
213
|
+
document.body.appendChild(pill);
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Creating Countdown with JavaScript
|
|
217
|
+
|
|
218
|
+
```javascript
|
|
219
|
+
const timestamp = new Date('2024-12-31T23:59:59').getTime();
|
|
220
|
+
// or: const timestamp = +new Date('2024-12-31T23:59:59');
|
|
221
|
+
|
|
222
|
+
const countdownPill = document.createElement('brick-pill-v9');
|
|
223
|
+
countdownPill.dataset.version = 'countdown';
|
|
224
|
+
countdownPill.dataset.countdownDate = timestamp.toString();
|
|
225
|
+
countdownPill.dataset.countdownToggleText = 'Live Now';
|
|
226
|
+
countdownPill.dataset.countdownToggleVersion = 'breaking';
|
|
227
|
+
countdownPill.dataset.filled = 'true';
|
|
228
|
+
|
|
229
|
+
document.body.appendChild(countdownPill);
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Server-Side Rendering
|
|
233
|
+
|
|
234
|
+
```javascript
|
|
235
|
+
import { renderBrickPill } from '@amedia/brick-pill/template';
|
|
236
|
+
|
|
237
|
+
const pillHTML = renderBrickPill({
|
|
238
|
+
dataText: 'Breaking',
|
|
239
|
+
dataVersion: 'breaking',
|
|
240
|
+
dataFilled: true,
|
|
241
|
+
dataSkin: 'none',
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// Include CSS file
|
|
245
|
+
// <link rel="stylesheet" href="https://assets.acdn.no/pkg/@amedia/brick-pill/v9/css/styles.css">
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Accessibility
|
|
249
|
+
|
|
250
|
+
- Color contrasts adhere to WCAG 2.1 AA guidelines
|
|
251
|
+
- Icons are decorative and hidden from screen readers (aria-hidden)
|
|
252
|
+
- Text content is accessible to assistive technologies
|
|
253
|
+
- Countdown updates are announced to screen readers using aria-live regions
|
|
254
|
+
|
|
255
|
+
## Common Patterns
|
|
256
|
+
|
|
257
|
+
### Article Teaser Metadata
|
|
258
|
+
|
|
259
|
+
```html
|
|
260
|
+
<brick-pillbox-v0 data-filled="true">
|
|
261
|
+
<brick-pill-v9 data-text="Breaking" data-version="breaking" data-filled="true">
|
|
262
|
+
</brick-pill-v9>
|
|
263
|
+
<brick-pill-v9 data-text="Politics" data-version="vignette" data-filled="true">
|
|
264
|
+
</brick-pill-v9>
|
|
265
|
+
<brick-pill-v9 data-text="5 min read" data-version="vignette" data-filled="true">
|
|
266
|
+
</brick-pill-v9>
|
|
267
|
+
</brick-pillbox-v0>
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Live Event Countdown
|
|
271
|
+
|
|
272
|
+
```html
|
|
273
|
+
<brick-pill-v9
|
|
274
|
+
data-version="countdown"
|
|
275
|
+
data-countdown-date="1703001600000"
|
|
276
|
+
data-countdown-toggle-text="Live"
|
|
277
|
+
data-countdown-toggle-version="breaking"
|
|
278
|
+
data-filled="true"
|
|
279
|
+
data-locale="nb_NO"
|
|
280
|
+
>
|
|
281
|
+
</brick-pill-v9>
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Custom Publication Logo Pill
|
|
285
|
+
|
|
286
|
+
```html
|
|
287
|
+
<brick-pill-v9
|
|
288
|
+
data-text="Laagendalsposten"
|
|
289
|
+
data-version="alt"
|
|
290
|
+
data-filled="true"
|
|
291
|
+
style="--b-pill-svg: url('https://r.acdn.no/local/v3/publications/www.ao.no/gfx/square.svg')"
|
|
292
|
+
>
|
|
293
|
+
</brick-pill-v9>
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## Styling and CSS Properties
|
|
297
|
+
|
|
298
|
+
Customize pill appearance using CSS custom properties:
|
|
299
|
+
|
|
300
|
+
```css
|
|
301
|
+
brick-pill-v9 {
|
|
302
|
+
/* Background color for filled pills */
|
|
303
|
+
--b-pill-color-bg: var(--brick-colors-surfaceBrand);
|
|
304
|
+
|
|
305
|
+
/* Text color */
|
|
306
|
+
--b-pill-color-fg: var(--brick-colors-textOnBrand);
|
|
307
|
+
|
|
308
|
+
/* Breaking version background color */
|
|
309
|
+
--b-pill-color-breakingBg: var(--brick-colors-utilityDangerBg);
|
|
310
|
+
|
|
311
|
+
/* Breaking version text color */
|
|
312
|
+
--b-pill-color-breakingFg: var(--brick-colors-utilityDangerFg);
|
|
313
|
+
|
|
314
|
+
/* Custom SVG icon for "icon" version */
|
|
315
|
+
--b-pill-svg: url('path/to/icon.svg');
|
|
316
|
+
|
|
317
|
+
/* SVG icon dimensions */
|
|
318
|
+
--b-pill-svg-width: 11px;
|
|
319
|
+
--b-pill-svg-height: 11px;
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Opinion Skin Custom Colors
|
|
324
|
+
|
|
325
|
+
When using `data-skin="opinion"` with `data-filled="true"`:
|
|
326
|
+
|
|
327
|
+
```css
|
|
328
|
+
brick-pill-v9 {
|
|
329
|
+
--opinion-background-color: #yourcolor;
|
|
330
|
+
--opinion-color-text: #yourtextcolor;
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
**Note:** When overriding colors, ensure your customizations adhere to WCAG 2.1 AA contrast requirements.
|
|
335
|
+
|
|
336
|
+
## Technical Details
|
|
337
|
+
|
|
338
|
+
- **Custom Element**: `brick-pill-v9`
|
|
339
|
+
- **Base Class**: BrickElement
|
|
340
|
+
- **Dependencies**:
|
|
341
|
+
- @amedia/brick-tokens (design tokens)
|
|
342
|
+
- @amedia/brick-icon (icon support)
|
|
343
|
+
- @amedia/brick-template (base class)
|
|
344
|
+
- **Renders as**: `<span>` element with shadow DOM
|
|
345
|
+
- **SSR Compatible**: Yes, with client-side hydration for countdown version
|
|
346
|
+
- **Framework**: Framework-agnostic web component
|
|
347
|
+
|
|
348
|
+
## Important Notes
|
|
349
|
+
|
|
350
|
+
- Pills are read-only status indicators and are not interactive
|
|
351
|
+
- The countdown version always renders its inner markup (icon and clock) client-side
|
|
352
|
+
- When the countdown expires, it automatically switches to the version specified in `data-countdown-toggle-version`
|
|
353
|
+
- When used inside `brick-pillbox`, the container affects pill styling:
|
|
354
|
+
- Removes individual pill border radius
|
|
355
|
+
- Truncates text on the last pill
|
|
356
|
+
- Adds dividers between eligible pills
|
|
357
|
+
- The breaking version has special animation that requires overflow to be visible, so it will not get text ellipsis
|
|
358
|
+
- Version 9.0.0 uses the `brick-pill-v9` selector
|
|
359
|
+
|
|
360
|
+
## Version
|
|
361
|
+
|
|
362
|
+
Current version: 9.0.9
|