@wcomp/elementum 0.0.0-stage → 0.1.0

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.
Files changed (101) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +266 -2
  3. package/custom-elements.json +3613 -0
  4. package/mcp/server.js +408 -0
  5. package/package.json +72 -4
  6. package/skills/elementum-break-ui/CATALOG.md +11 -0
  7. package/skills/elementum-break-ui/SKILL.md +16 -0
  8. package/skills/elementum-mobile/SKILL.md +18 -0
  9. package/skills/elementum-motion/SKILL.md +18 -0
  10. package/skills/elementum-motion/STANDARDS.md +15 -0
  11. package/skills/elementum-penpot/SKILL.md +45 -0
  12. package/skills/elementum-ui/CATALOG.md +14 -0
  13. package/skills/elementum-ui/SKILL.md +21 -0
  14. package/src/ag-ui.js +474 -0
  15. package/src/components/el-accordion.js +201 -0
  16. package/src/components/el-alert-dialog.js +186 -0
  17. package/src/components/el-alert.js +254 -0
  18. package/src/components/el-aspect-ratio.js +73 -0
  19. package/src/components/el-autocomplete.js +775 -0
  20. package/src/components/el-avatar.js +271 -0
  21. package/src/components/el-badge.js +131 -0
  22. package/src/components/el-border-beam.js +135 -0
  23. package/src/components/el-breadcrumb.js +203 -0
  24. package/src/components/el-button.js +220 -0
  25. package/src/components/el-calendar.js +413 -0
  26. package/src/components/el-callout.js +158 -0
  27. package/src/components/el-card.js +298 -0
  28. package/src/components/el-carousel.js +308 -0
  29. package/src/components/el-chart.js +632 -0
  30. package/src/components/el-checkbox-card.js +221 -0
  31. package/src/components/el-checkbox.js +208 -0
  32. package/src/components/el-chip.js +276 -0
  33. package/src/components/el-code-block.js +228 -0
  34. package/src/components/el-collapsible.js +124 -0
  35. package/src/components/el-command.js +556 -0
  36. package/src/components/el-context-menu.js +328 -0
  37. package/src/components/el-data-list.js +210 -0
  38. package/src/components/el-datepicker.js +192 -0
  39. package/src/components/el-dialog.js +272 -0
  40. package/src/components/el-diff-viewer.js +441 -0
  41. package/src/components/el-drawer.js +782 -0
  42. package/src/components/el-dropdown.js +182 -0
  43. package/src/components/el-dropzone.js +242 -0
  44. package/src/components/el-empty-state.js +130 -0
  45. package/src/components/el-field.js +394 -0
  46. package/src/components/el-form.js +185 -0
  47. package/src/components/el-input.js +212 -0
  48. package/src/components/el-inset.js +90 -0
  49. package/src/components/el-insight-card.js +263 -0
  50. package/src/components/el-kbd.js +151 -0
  51. package/src/components/el-menubar.js +254 -0
  52. package/src/components/el-meter.js +182 -0
  53. package/src/components/el-navbar.js +294 -0
  54. package/src/components/el-navigation-menu.js +327 -0
  55. package/src/components/el-number-field.js +510 -0
  56. package/src/components/el-number-flow.js +153 -0
  57. package/src/components/el-otp-input.js +266 -0
  58. package/src/components/el-pagination.js +229 -0
  59. package/src/components/el-popover.js +288 -0
  60. package/src/components/el-preview-card.js +202 -0
  61. package/src/components/el-progress.js +179 -0
  62. package/src/components/el-prompt-input.js +383 -0
  63. package/src/components/el-radio-card.js +360 -0
  64. package/src/components/el-radio.js +257 -0
  65. package/src/components/el-rating.js +165 -0
  66. package/src/components/el-reasoning-card.js +293 -0
  67. package/src/components/el-resizable.js +324 -0
  68. package/src/components/el-router.js +305 -0
  69. package/src/components/el-scroll-area.js +150 -0
  70. package/src/components/el-segmented-control.js +282 -0
  71. package/src/components/el-select.js +219 -0
  72. package/src/components/el-separator.js +85 -0
  73. package/src/components/el-sidebar.js +386 -0
  74. package/src/components/el-skeleton.js +156 -0
  75. package/src/components/el-slider.js +351 -0
  76. package/src/components/el-sources.js +288 -0
  77. package/src/components/el-spinner.js +159 -0
  78. package/src/components/el-streaming-text.js +199 -0
  79. package/src/components/el-switch.js +221 -0
  80. package/src/components/el-table.js +397 -0
  81. package/src/components/el-tabs.js +235 -0
  82. package/src/components/el-task-list.js +230 -0
  83. package/src/components/el-textarea.js +175 -0
  84. package/src/components/el-theme-switch.js +120 -0
  85. package/src/components/el-timeline.js +254 -0
  86. package/src/components/el-toast.js +778 -0
  87. package/src/components/el-toggle.js +311 -0
  88. package/src/components/el-tool-call.js +386 -0
  89. package/src/components/el-toolbar.js +183 -0
  90. package/src/components/el-tooltip.js +172 -0
  91. package/src/components/el-tree-view.js +261 -0
  92. package/src/components/el-visually-hidden.js +32 -0
  93. package/src/elementum.js +485 -0
  94. package/src/index.d.ts +1007 -0
  95. package/src/index.js +99 -0
  96. package/src/signal.js +194 -0
  97. package/src/ssr.js +136 -0
  98. package/src/template.js +321 -0
  99. package/src/tokens.css +416 -0
  100. package/tokens/figma-tokens.json +69 -0
  101. package/tokens/penpot-tokens.json +98 -0
@@ -0,0 +1,212 @@
1
+ /**
2
+ * <el-input>
3
+ * Accessible text/form input with prefix/suffix slots and design token styling.
4
+ */
5
+
6
+ import { Elementum } from '../elementum.js';
7
+ import { html, css } from '../template.js';
8
+ import { signal } from '../signal.js';
9
+
10
+ export class ElInput extends Elementum {
11
+ static formAssociated = true;
12
+ static observedAttributes = ['value', 'placeholder', 'disabled', 'readonly', 'type', 'size', 'required', 'pattern', 'minlength'];
13
+
14
+ value = signal('');
15
+ placeholder = signal('');
16
+ disabled = signal(false);
17
+ readonly = signal(false);
18
+ required = signal(false);
19
+ pattern = signal('');
20
+ minlength = signal(0);
21
+ type = signal('text');
22
+ size = signal('md'); // 'sm' | 'md' | 'lg'
23
+
24
+ connected() {
25
+ this.required.value = this.hasAttribute('required');
26
+ this.setFormValue(this.value.value);
27
+ this.validate();
28
+ }
29
+
30
+ formReset() {
31
+ this.value.value = this.getAttribute('value') || '';
32
+ this.setFormValue(this.value.value);
33
+ this.validate();
34
+ }
35
+
36
+ attributeChanged(name, oldValue, newValue) {
37
+ if (name === 'required') {
38
+ this.required.value = newValue !== null && newValue !== 'false';
39
+ this.validate();
40
+ } else if (name === 'pattern') {
41
+ this.pattern.value = newValue || '';
42
+ this.validate();
43
+ } else if (name === 'minlength') {
44
+ this.minlength.value = Number(newValue) || 0;
45
+ this.validate();
46
+ }
47
+ }
48
+
49
+ validate() {
50
+ const val = String(this.value.value || '');
51
+ const inputEl = this.root?.querySelector?.('input');
52
+
53
+ if (this.required.value && !val.trim()) {
54
+ this.setValidity({ valueMissing: true }, 'Please fill out this field.', inputEl);
55
+ this.setAttribute('aria-invalid', 'true');
56
+ return false;
57
+ }
58
+
59
+ if (this.pattern.value && val) {
60
+ const reg = new RegExp(`^(?:${this.pattern.value})$`);
61
+ if (!reg.test(val)) {
62
+ this.setValidity({ patternMismatch: true }, 'Please match the requested format.', inputEl);
63
+ this.setAttribute('aria-invalid', 'true');
64
+ return false;
65
+ }
66
+ }
67
+
68
+ const min = Number(this.minlength.value);
69
+ if (min > 0 && val.length > 0 && val.length < min) {
70
+ this.setValidity({ tooShort: true }, `Please lengthen text to at least ${min} characters.`, inputEl);
71
+ this.setAttribute('aria-invalid', 'true');
72
+ return false;
73
+ }
74
+
75
+ this.setValidity({});
76
+ this.removeAttribute('aria-invalid');
77
+ return true;
78
+ }
79
+
80
+ static styles = css`
81
+ :host {
82
+ display: inline-block;
83
+ width: 100%;
84
+ font-family: inherit;
85
+ }
86
+
87
+ .wrapper {
88
+ display: flex;
89
+ align-items: center;
90
+ background: var(--el-surface-base, #ffffff);
91
+ border: 1px solid var(--el-surface-border, #e5e7eb);
92
+ border-radius: var(--el-radius-md, 8px);
93
+ padding: 0 var(--el-spacing-sm, 8px);
94
+ transition: border-color 0.15s ease, box-shadow 0.15s ease;
95
+ box-sizing: border-box;
96
+ gap: var(--el-spacing-xs, 4px);
97
+ }
98
+
99
+ .wrapper:focus-within {
100
+ border-color: var(--el-color-primary, #2563eb);
101
+ box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
102
+ }
103
+
104
+ .wrapper.disabled {
105
+ background: var(--el-surface-muted, #f3f4f6);
106
+ cursor: not-allowed;
107
+ opacity: 0.6;
108
+ }
109
+
110
+ /* Size variants */
111
+ :host([size="sm"]) .wrapper {
112
+ height: 32px;
113
+ font-size: 0.8125rem;
114
+ }
115
+
116
+ :host([size="md"]) .wrapper,
117
+ :host(:not([size])) .wrapper {
118
+ height: 40px;
119
+ font-size: 0.9375rem;
120
+ }
121
+
122
+ :host([size="lg"]) .wrapper {
123
+ height: 48px;
124
+ font-size: 1.0625rem;
125
+ }
126
+
127
+ input {
128
+ flex: 1;
129
+ border: none;
130
+ outline: none;
131
+ background: transparent;
132
+ color: var(--el-text-base, #111827);
133
+ font-family: inherit;
134
+ font-size: inherit;
135
+ width: 100%;
136
+ padding: 0 4px;
137
+ min-width: 0;
138
+ }
139
+
140
+ @media (hover: none) and (pointer: coarse), (max-width: 640px) {
141
+ input {
142
+ font-size: 16px !important;
143
+ }
144
+ }
145
+
146
+ input::placeholder {
147
+ color: var(--el-text-muted, #9ca3af);
148
+ }
149
+
150
+ input:disabled {
151
+ cursor: not-allowed;
152
+ }
153
+
154
+ ::slotted([slot="prefix"]),
155
+ ::slotted([slot="suffix"]) {
156
+ display: flex;
157
+ align-items: center;
158
+ color: var(--el-text-muted, #6b7280);
159
+ user-select: none;
160
+ }
161
+
162
+ @media (pointer: coarse) {
163
+ input {
164
+ font-size: max(16px, 1em);
165
+ }
166
+ }
167
+ `;
168
+
169
+ #onInput = (e) => {
170
+ this.value.value = e.target.value;
171
+ this.setFormValue(e.target.value);
172
+ this.validate();
173
+ this.emit('input', { value: e.target.value });
174
+ };
175
+
176
+ #onChange = (e) => {
177
+ this.value.value = e.target.value;
178
+ this.setFormValue(e.target.value);
179
+ this.validate();
180
+ this.emit('change', { value: e.target.value });
181
+ };
182
+
183
+ focus() {
184
+ this.root.querySelector('input')?.focus();
185
+ }
186
+
187
+ render() {
188
+ return html`
189
+ <div
190
+ class=${() => `wrapper ${this.disabled.value ? 'disabled' : ''}`}
191
+ part="wrapper"
192
+ >
193
+ <slot name="prefix"></slot>
194
+ <input
195
+ part="input"
196
+ type=${this.type}
197
+ .value=${this.value}
198
+ placeholder=${this.placeholder}
199
+ ?disabled=${this.disabled}
200
+ ?readonly=${this.readonly}
201
+ @input=${this.#onInput}
202
+ @change=${this.#onChange}
203
+ />
204
+ <slot name="suffix"></slot>
205
+ </div>
206
+ `;
207
+ }
208
+ }
209
+
210
+ if (typeof customElements !== 'undefined' && !customElements.get('el-input')) {
211
+ customElements.define('el-input', ElInput);
212
+ }
@@ -0,0 +1,90 @@
1
+ import { Elementum } from '../elementum.js';
2
+ import { html, css } from '../template.js';
3
+ import { signal } from '../signal.js';
4
+
5
+ /**
6
+ * <el-inset>
7
+ * Layout utility component inspired by Radix Themes.
8
+ * Extends slotted media, tables, or hero content flush to the edges of its parent container.
9
+ */
10
+ export class ElInset extends Elementum {
11
+ static observedAttributes = ['side', 'clip'];
12
+
13
+ side = signal('all'); // all | top | bottom | x | y
14
+ clip = signal('border-box');
15
+
16
+ static styles = css`
17
+ :host {
18
+ display: block;
19
+ margin: -16px;
20
+ margin-bottom: 16px;
21
+ overflow: hidden;
22
+ box-sizing: border-box;
23
+ }
24
+
25
+ :host([side="top"]) {
26
+ margin-top: -16px;
27
+ margin-left: -16px;
28
+ margin-right: -16px;
29
+ margin-bottom: 16px;
30
+ border-top-left-radius: inherit;
31
+ border-top-right-radius: inherit;
32
+ }
33
+
34
+ :host([side="bottom"]) {
35
+ margin-bottom: -16px;
36
+ margin-left: -16px;
37
+ margin-right: -16px;
38
+ margin-top: 16px;
39
+ border-bottom-left-radius: inherit;
40
+ border-bottom-right-radius: inherit;
41
+ }
42
+
43
+ :host([side="x"]) {
44
+ margin-left: -16px;
45
+ margin-right: -16px;
46
+ margin-top: 0;
47
+ margin-bottom: 0;
48
+ }
49
+
50
+ :host([side="y"]) {
51
+ margin-top: -16px;
52
+ margin-bottom: -16px;
53
+ margin-left: 0;
54
+ margin-right: 0;
55
+ }
56
+
57
+ ::slotted(img),
58
+ ::slotted(video),
59
+ ::slotted(picture) {
60
+ display: block;
61
+ width: 100%;
62
+ height: auto;
63
+ object-fit: cover;
64
+ }
65
+
66
+ ::slotted(table),
67
+ ::slotted(el-table) {
68
+ width: 100%;
69
+ border-radius: 0;
70
+ }
71
+ `;
72
+
73
+ connected() {
74
+ this.side.value = this.getAttribute('side') || 'all';
75
+ this.clip.value = this.getAttribute('clip') || 'border-box';
76
+ }
77
+
78
+ attributeChanged(name, oldValue, newValue) {
79
+ if (name === 'side') this.side.value = newValue || 'all';
80
+ if (name === 'clip') this.clip.value = newValue || 'border-box';
81
+ }
82
+
83
+ render() {
84
+ return html`<slot></slot>`;
85
+ }
86
+ }
87
+
88
+ if (typeof customElements !== 'undefined' && !customElements.get('el-inset')) {
89
+ customElements.define('el-inset', ElInset);
90
+ }
@@ -0,0 +1,263 @@
1
+ import { Elementum } from '../elementum.js';
2
+ import { html, css } from '../template.js';
3
+ import { signal } from '../signal.js';
4
+
5
+ /**
6
+ * <el-insight-card>
7
+ * Structured AI insight / artifact card with metric delta, CTA action, and thumbs feedback.
8
+ *
9
+ * @element el-insight-card
10
+ * @attr {string} title - Insight heading
11
+ * @attr {string} category - Category badge (e.g. 'Anomaly', 'Optimization', 'Artifact')
12
+ * @attr {string} metric - Optional key figure (e.g. '$1,420/mo')
13
+ * @attr {string} delta - Optional delta label (e.g. '-18.4%')
14
+ * @attr {'info' | 'success' | 'warning' | 'danger'} variant - Semantic accent
15
+ * @attr {string} summary - Short explanation text
16
+ * @attr {string} action-label - Optional primary CTA button label
17
+ * @fires action - Fired when CTA button is clicked
18
+ * @fires feedback - Fired when thumbs up/down is toggled ({ vote: 'up' | 'down' | null })
19
+ */
20
+ export class ElInsightCard extends Elementum {
21
+ static observedAttributes = ['title', 'category', 'metric', 'delta', 'variant', 'summary', 'action-label'];
22
+
23
+ title = signal('AI Insight');
24
+ category = signal('Insight');
25
+ metric = signal('');
26
+ delta = signal('');
27
+ variant = signal('info');
28
+ summary = signal('');
29
+ actionLabel = signal('');
30
+ vote = signal(null);
31
+
32
+ connected() {
33
+ this.#sync();
34
+ }
35
+
36
+ attributeChanged() {
37
+ this.#sync();
38
+ }
39
+
40
+ #sync() {
41
+ if (this.hasAttribute('title')) this.title.value = this.getAttribute('title') || 'AI Insight';
42
+ if (this.hasAttribute('category')) this.category.value = this.getAttribute('category') || 'Insight';
43
+ if (this.hasAttribute('metric')) this.metric.value = this.getAttribute('metric') || '';
44
+ if (this.hasAttribute('delta')) this.delta.value = this.getAttribute('delta') || '';
45
+ if (this.hasAttribute('variant')) this.variant.value = this.getAttribute('variant') || 'info';
46
+ if (this.hasAttribute('summary')) this.summary.value = this.getAttribute('summary') || '';
47
+ if (this.hasAttribute('action-label')) this.actionLabel.value = this.getAttribute('action-label') || '';
48
+ }
49
+
50
+ #onAction = () => {
51
+ this.emit('action', { title: this.title.value, metric: this.metric.value });
52
+ };
53
+
54
+ #toggleVote(nextVote) {
55
+ const resolved = this.vote.value === nextVote ? null : nextVote;
56
+ this.vote.value = resolved;
57
+ this.emit('feedback', { vote: resolved, title: this.title.value });
58
+ }
59
+
60
+ static styles = css`
61
+ :host {
62
+ display: block;
63
+ font-family: var(--el-font-sans, system-ui, -apple-system, sans-serif);
64
+ box-sizing: border-box;
65
+ }
66
+
67
+ .card {
68
+ border: 1px solid var(--el-surface-border, #e2e8f0);
69
+ border-radius: var(--el-radius-md, 12px);
70
+ background: var(--el-surface-base, #ffffff);
71
+ padding: 16px 18px;
72
+ display: flex;
73
+ flex-direction: column;
74
+ gap: 10px;
75
+ box-shadow: var(--el-shadow-card, 0 1px 3px rgba(0, 0, 0, 0.05));
76
+ }
77
+
78
+ .top-row {
79
+ display: flex;
80
+ align-items: center;
81
+ justify-content: space-between;
82
+ gap: 8px;
83
+ }
84
+
85
+ .cat-pill {
86
+ display: inline-flex;
87
+ align-items: center;
88
+ padding: 2px 9px;
89
+ border-radius: 9999px;
90
+ font-size: 0.72rem;
91
+ font-weight: 700;
92
+ text-transform: uppercase;
93
+ letter-spacing: 0.04em;
94
+ }
95
+
96
+ .v-info { background: #dbeafe; color: #1d4ed8; }
97
+ .v-success { background: #d1fae5; color: #047857; }
98
+ .v-warning { background: #fef3c7; color: #b45309; }
99
+ .v-danger { background: #fee2e2; color: #b91c1c; }
100
+
101
+ .heading {
102
+ margin: 0;
103
+ font-size: 1rem;
104
+ font-weight: 700;
105
+ letter-spacing: -0.01em;
106
+ color: var(--el-text-primary, #0f172a);
107
+ }
108
+
109
+ .metric-row {
110
+ display: flex;
111
+ align-items: baseline;
112
+ gap: 8px;
113
+ font-variant-numeric: tabular-nums;
114
+ }
115
+
116
+ .metric-val {
117
+ font-size: 1.5rem;
118
+ font-weight: 700;
119
+ color: var(--el-text-primary, #0f172a);
120
+ }
121
+
122
+ .metric-delta {
123
+ font-size: 0.8rem;
124
+ font-weight: 600;
125
+ color: var(--el-text-secondary, #475569);
126
+ }
127
+
128
+ .summary {
129
+ margin: 0;
130
+ font-size: 0.88rem;
131
+ line-height: 1.5;
132
+ color: var(--el-text-secondary, #475569);
133
+ max-width: 65ch;
134
+ }
135
+
136
+ .footer {
137
+ display: flex;
138
+ align-items: center;
139
+ justify-content: space-between;
140
+ flex-wrap: wrap;
141
+ gap: 8px;
142
+ padding-top: 6px;
143
+ border-top: 1px solid var(--el-surface-border, #f1f5f9);
144
+ }
145
+
146
+ .cta-btn,
147
+ .vote-btn {
148
+ font-family: inherit;
149
+ cursor: pointer;
150
+ touch-action: manipulation;
151
+ -webkit-tap-highlight-color: transparent;
152
+ transition: background-color 140ms ease, border-color 140ms ease, transform 120ms var(--el-ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1));
153
+ }
154
+
155
+ .cta-btn {
156
+ padding: 6px 12px;
157
+ border-radius: 7px;
158
+ border: none;
159
+ background: var(--el-color-primary, #2563eb);
160
+ color: #ffffff;
161
+ font-size: 0.8rem;
162
+ font-weight: 600;
163
+ }
164
+
165
+ .cta-btn:active,
166
+ .vote-btn:active {
167
+ transform: scale(0.97);
168
+ }
169
+
170
+ .feedback-group {
171
+ display: inline-flex;
172
+ gap: 6px;
173
+ margin-left: auto;
174
+ }
175
+
176
+ .vote-btn {
177
+ padding: 4px 9px;
178
+ border-radius: 7px;
179
+ border: 1px solid var(--el-surface-border, #e2e8f0);
180
+ background: var(--el-surface-base, #ffffff);
181
+ color: var(--el-text-secondary, #475569);
182
+ font-size: 0.78rem;
183
+ }
184
+
185
+ .vote-btn.active {
186
+ border-color: var(--el-color-primary, #2563eb);
187
+ background: #eff6ff;
188
+ color: #1d4ed8;
189
+ }
190
+
191
+ :root[data-theme="dark"] .card {
192
+ background: #0f172a;
193
+ border-color: #334155;
194
+ }
195
+ :root[data-theme="dark"] .heading,
196
+ :root[data-theme="dark"] .metric-val {
197
+ color: #f8fafc;
198
+ }
199
+ :root[data-theme="dark"] .summary,
200
+ :root[data-theme="dark"] .metric-delta {
201
+ color: #94a3b8;
202
+ }
203
+ :root[data-theme="dark"] .footer {
204
+ border-top-color: #1e293b;
205
+ }
206
+ :root[data-theme="dark"] .vote-btn {
207
+ background: #1e293b;
208
+ border-color: #334155;
209
+ color: #cbd5e1;
210
+ }
211
+
212
+ @media (prefers-reduced-motion: reduce) {
213
+ .cta-btn, .vote-btn { transition: none; }
214
+ .cta-btn:active, .vote-btn:active { transform: none; }
215
+ }
216
+ `;
217
+
218
+ render() {
219
+ return html`
220
+ <article class="card" part="card">
221
+ <div class="top-row">
222
+ <span class=${() => `cat-pill v-${this.variant.value}`}>${this.category}</span>
223
+ </div>
224
+ <h3 class="heading">${this.title}</h3>
225
+ ${() =>
226
+ this.metric.value
227
+ ? html`
228
+ <div class="metric-row">
229
+ <span class="metric-val">${this.metric}</span>
230
+ ${() => (this.delta.value ? html`<span class="metric-delta">${this.delta}</span>` : '')}
231
+ </div>
232
+ `
233
+ : ''}
234
+ ${() => (this.summary.value ? html`<p class="summary">${this.summary}</p>` : '')}
235
+ <slot></slot>
236
+ <div class="footer">
237
+ ${() =>
238
+ this.actionLabel.value
239
+ ? html`<button type="button" class="cta-btn" @click=${this.#onAction}>${this.actionLabel}</button>`
240
+ : ''}
241
+ <div class="feedback-group" role="group" aria-label="Insight feedback">
242
+ <button
243
+ type="button"
244
+ class=${() => `vote-btn ${this.vote.value === 'up' ? 'active' : ''}`}
245
+ aria-pressed=${() => String(this.vote.value === 'up')}
246
+ @click=${() => this.#toggleVote('up')}
247
+ >👍 Helpful</button>
248
+ <button
249
+ type="button"
250
+ class=${() => `vote-btn ${this.vote.value === 'down' ? 'active' : ''}`}
251
+ aria-pressed=${() => String(this.vote.value === 'down')}
252
+ @click=${() => this.#toggleVote('down')}
253
+ >👎</button>
254
+ </div>
255
+ </div>
256
+ </article>
257
+ `;
258
+ }
259
+ }
260
+
261
+ if (typeof customElements !== 'undefined' && !customElements.get('el-insight-card')) {
262
+ customElements.define('el-insight-card', ElInsightCard);
263
+ }
@@ -0,0 +1,151 @@
1
+ /**
2
+ * <el-kbd>
3
+ * Accessible keyboard shortcut badge inspired by shadcn/ui.
4
+ * Automatically parses modifier shortcuts (cmd, ctrl, shift, alt, opt, enter, esc, etc.)
5
+ * or renders custom slotted keycaps.
6
+ */
7
+
8
+ import { Elementum } from '../elementum.js';
9
+ import { html, css } from '../template.js';
10
+ import { signal } from '../signal.js';
11
+
12
+ export class ElKbd extends Elementum {
13
+ static observedAttributes = ['keys', 'size'];
14
+
15
+ keys = signal('');
16
+ size = signal('md'); // 'sm' | 'md' | 'lg'
17
+
18
+ static styles = css`
19
+ :host {
20
+ display: inline-flex;
21
+ align-items: center;
22
+ gap: 3px;
23
+ vertical-align: middle;
24
+ font-family: var(--el-font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
25
+ box-sizing: border-box;
26
+ line-height: 1;
27
+ }
28
+
29
+ .keycap {
30
+ display: inline-flex;
31
+ align-items: center;
32
+ justify-content: center;
33
+ background: var(--el-surface-muted, #f1f5f9);
34
+ border: 1px solid var(--el-surface-border, #cbd5e1);
35
+ border-bottom-width: 2px;
36
+ border-radius: var(--el-radius-sm, 4px);
37
+ color: var(--el-text-secondary, #475569);
38
+ font-weight: 600;
39
+ box-sizing: border-box;
40
+ user-select: none;
41
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
42
+ }
43
+
44
+ :root[data-theme="dark"] .keycap {
45
+ background: #1e293b;
46
+ border-color: #475569;
47
+ border-bottom-color: #64748b;
48
+ color: #cbd5e1;
49
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
50
+ }
51
+
52
+ /* Sizes */
53
+ :host([size="sm"]) .keycap {
54
+ min-width: 18px;
55
+ height: 18px;
56
+ padding: 0 4px;
57
+ font-size: 10px;
58
+ }
59
+
60
+ :host([size="md"]) .keycap,
61
+ :host(:not([size])) .keycap {
62
+ min-width: 22px;
63
+ height: 22px;
64
+ padding: 0 6px;
65
+ font-size: 11px;
66
+ }
67
+
68
+ :host([size="lg"]) .keycap {
69
+ min-width: 26px;
70
+ height: 26px;
71
+ padding: 0 8px;
72
+ font-size: 13px;
73
+ }
74
+ `;
75
+
76
+ connected() {
77
+ this.#syncAttrs();
78
+ }
79
+
80
+ attributeChanged(name, oldValue, newValue) {
81
+ this.#syncAttrs();
82
+ return true;
83
+ }
84
+
85
+ #syncAttrs() {
86
+ this.keys.value = this.getAttribute('keys') || '';
87
+ this.size.value = this.getAttribute('size') || 'md';
88
+ if (!this.hasAttribute('size')) this.setAttribute('size', 'md');
89
+ }
90
+
91
+ #formatKey(key) {
92
+ const k = key.trim().toLowerCase();
93
+ switch (k) {
94
+ case 'cmd':
95
+ case 'command':
96
+ return '⌘';
97
+ case 'ctrl':
98
+ case 'control':
99
+ return '⌃';
100
+ case 'shift':
101
+ return '⇧';
102
+ case 'alt':
103
+ case 'opt':
104
+ case 'option':
105
+ return '⌥';
106
+ case 'enter':
107
+ case 'return':
108
+ return '↵';
109
+ case 'esc':
110
+ case 'escape':
111
+ return '⎋';
112
+ case 'tab':
113
+ return '⇥';
114
+ case 'backspace':
115
+ case 'delete':
116
+ return '⌫';
117
+ case 'up':
118
+ return '↑';
119
+ case 'down':
120
+ return '↓';
121
+ case 'left':
122
+ return '←';
123
+ case 'right':
124
+ return '→';
125
+ default:
126
+ return key.trim().toUpperCase();
127
+ }
128
+ }
129
+
130
+ render() {
131
+ const keyList = () => {
132
+ const raw = this.keys.value;
133
+ if (!raw) return [];
134
+ return raw.split('+').map(k => this.#formatKey(k));
135
+ };
136
+
137
+ return html`
138
+ ${() => {
139
+ const list = keyList();
140
+ if (list.length === 0) {
141
+ return html`<kbd class="keycap" part="key"><slot></slot></kbd>`;
142
+ }
143
+ return list.map(k => html`<kbd class="keycap" part="key">${k}</kbd>`);
144
+ }}
145
+ `;
146
+ }
147
+ }
148
+
149
+ if (typeof customElements !== 'undefined' && !customElements.get('el-kbd')) {
150
+ customElements.define('el-kbd', ElKbd);
151
+ }