@wcomp/elementum 0.0.0-stage → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +282 -2
- package/custom-elements.json +3613 -0
- package/mcp/server.js +593 -0
- package/package.json +77 -4
- package/skills/elementum-break-ui/CATALOG.md +11 -0
- package/skills/elementum-break-ui/SKILL.md +16 -0
- package/skills/elementum-mobile/SKILL.md +18 -0
- package/skills/elementum-motion/SKILL.md +18 -0
- package/skills/elementum-motion/STANDARDS.md +15 -0
- package/skills/elementum-penpot/SKILL.md +45 -0
- package/skills/elementum-ui/CATALOG.md +14 -0
- package/skills/elementum-ui/SKILL.md +21 -0
- package/src/ag-ui.js +474 -0
- package/src/behaviors/index.js +760 -0
- package/src/components/el-accordion.js +201 -0
- package/src/components/el-alert-dialog.js +186 -0
- package/src/components/el-alert.js +254 -0
- package/src/components/el-aspect-ratio.js +73 -0
- package/src/components/el-autocomplete.js +775 -0
- package/src/components/el-avatar.js +271 -0
- package/src/components/el-badge.js +131 -0
- package/src/components/el-border-beam.js +135 -0
- package/src/components/el-breadcrumb.js +203 -0
- package/src/components/el-button.js +231 -0
- package/src/components/el-calendar.js +436 -0
- package/src/components/el-callout.js +158 -0
- package/src/components/el-card.js +298 -0
- package/src/components/el-carousel.js +308 -0
- package/src/components/el-chart.js +632 -0
- package/src/components/el-checkbox-card.js +221 -0
- package/src/components/el-checkbox.js +208 -0
- package/src/components/el-chip.js +276 -0
- package/src/components/el-code-block.js +230 -0
- package/src/components/el-collapsible.js +124 -0
- package/src/components/el-command.js +556 -0
- package/src/components/el-context-menu.js +328 -0
- package/src/components/el-data-list.js +210 -0
- package/src/components/el-datepicker.js +192 -0
- package/src/components/el-dialog.js +272 -0
- package/src/components/el-diff-viewer.js +441 -0
- package/src/components/el-drawer.js +782 -0
- package/src/components/el-dropdown.js +182 -0
- package/src/components/el-dropzone.js +242 -0
- package/src/components/el-empty-state.js +130 -0
- package/src/components/el-field.js +394 -0
- package/src/components/el-form.js +185 -0
- package/src/components/el-input.js +229 -0
- package/src/components/el-inset.js +90 -0
- package/src/components/el-insight-card.js +263 -0
- package/src/components/el-kbd.js +151 -0
- package/src/components/el-menubar.js +254 -0
- package/src/components/el-meter.js +183 -0
- package/src/components/el-navbar.js +294 -0
- package/src/components/el-navigation-menu.js +327 -0
- package/src/components/el-number-field.js +510 -0
- package/src/components/el-number-flow.js +164 -0
- package/src/components/el-otp-input.js +266 -0
- package/src/components/el-pagination.js +231 -0
- package/src/components/el-popover.js +288 -0
- package/src/components/el-preview-card.js +202 -0
- package/src/components/el-progress.js +179 -0
- package/src/components/el-prompt-input.js +383 -0
- package/src/components/el-radio-card.js +360 -0
- package/src/components/el-radio.js +257 -0
- package/src/components/el-rating.js +165 -0
- package/src/components/el-reasoning-card.js +293 -0
- package/src/components/el-resizable.js +324 -0
- package/src/components/el-router.js +305 -0
- package/src/components/el-scroll-area.js +150 -0
- package/src/components/el-segmented-control.js +282 -0
- package/src/components/el-select.js +220 -0
- package/src/components/el-separator.js +85 -0
- package/src/components/el-sidebar.js +386 -0
- package/src/components/el-skeleton.js +156 -0
- package/src/components/el-slider.js +351 -0
- package/src/components/el-sources.js +288 -0
- package/src/components/el-spinner.js +159 -0
- package/src/components/el-streaming-text.js +199 -0
- package/src/components/el-switch.js +221 -0
- package/src/components/el-table.js +397 -0
- package/src/components/el-tabs.js +235 -0
- package/src/components/el-task-list.js +230 -0
- package/src/components/el-textarea.js +175 -0
- package/src/components/el-theme-switch.js +120 -0
- package/src/components/el-timeline.js +254 -0
- package/src/components/el-toast.js +778 -0
- package/src/components/el-toggle.js +311 -0
- package/src/components/el-tool-call.js +386 -0
- package/src/components/el-toolbar.js +183 -0
- package/src/components/el-tooltip.js +172 -0
- package/src/components/el-tree-view.js +261 -0
- package/src/components/el-visually-hidden.js +32 -0
- package/src/elementum.js +504 -0
- package/src/index.d.ts +1093 -0
- package/src/index.js +112 -0
- package/src/signal.js +215 -0
- package/src/ssr.js +136 -0
- package/src/template.js +321 -0
- package/src/tokens.css +416 -0
- package/tokens/figma-tokens.json +69 -0
- package/tokens/penpot-tokens.json +98 -0
|
@@ -0,0 +1,229 @@
|
|
|
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, effect } 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
|
+
effect(() => {
|
|
27
|
+
const val = String(this.value.value ?? '');
|
|
28
|
+
this.setFormValue(val);
|
|
29
|
+
this.validate();
|
|
30
|
+
}, { signal: this.signal });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
formReset() {
|
|
34
|
+
this.value.value = this.getAttribute('value') || '';
|
|
35
|
+
this.setFormValue(this.value.value);
|
|
36
|
+
this.validate();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
attributeChanged(name, oldValue, newValue) {
|
|
40
|
+
if (name === 'value') {
|
|
41
|
+
this.value.value = newValue ?? '';
|
|
42
|
+
this.setFormValue(this.value.value);
|
|
43
|
+
this.validate();
|
|
44
|
+
} else if (name === 'placeholder') {
|
|
45
|
+
this.placeholder.value = newValue ?? '';
|
|
46
|
+
} else if (name === 'disabled') {
|
|
47
|
+
this.disabled.value = newValue !== null && newValue !== 'false';
|
|
48
|
+
} else if (name === 'readonly') {
|
|
49
|
+
this.readonly.value = newValue !== null && newValue !== 'false';
|
|
50
|
+
} else if (name === 'type') {
|
|
51
|
+
this.type.value = newValue || 'text';
|
|
52
|
+
} else if (name === 'size') {
|
|
53
|
+
this.size.value = newValue || 'md';
|
|
54
|
+
} else if (name === 'required') {
|
|
55
|
+
this.required.value = newValue !== null && newValue !== 'false';
|
|
56
|
+
this.validate();
|
|
57
|
+
} else if (name === 'pattern') {
|
|
58
|
+
this.pattern.value = newValue || '';
|
|
59
|
+
this.validate();
|
|
60
|
+
} else if (name === 'minlength') {
|
|
61
|
+
this.minlength.value = Number(newValue) || 0;
|
|
62
|
+
this.validate();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
validate() {
|
|
67
|
+
const val = String(this.value.value || '');
|
|
68
|
+
const inputEl = this.root?.querySelector?.('input');
|
|
69
|
+
|
|
70
|
+
if (this.required.value && !val.trim()) {
|
|
71
|
+
this.setValidity({ valueMissing: true }, 'Please fill out this field.', inputEl);
|
|
72
|
+
this.setAttribute('aria-invalid', 'true');
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (this.pattern.value && val) {
|
|
77
|
+
const reg = new RegExp(`^(?:${this.pattern.value})$`);
|
|
78
|
+
if (!reg.test(val)) {
|
|
79
|
+
this.setValidity({ patternMismatch: true }, 'Please match the requested format.', inputEl);
|
|
80
|
+
this.setAttribute('aria-invalid', 'true');
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const min = Number(this.minlength.value);
|
|
86
|
+
if (min > 0 && val.length > 0 && val.length < min) {
|
|
87
|
+
this.setValidity({ tooShort: true }, `Please lengthen text to at least ${min} characters.`, inputEl);
|
|
88
|
+
this.setAttribute('aria-invalid', 'true');
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this.setValidity({});
|
|
93
|
+
this.removeAttribute('aria-invalid');
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static styles = css`
|
|
98
|
+
:host {
|
|
99
|
+
display: inline-block;
|
|
100
|
+
width: 100%;
|
|
101
|
+
font-family: inherit;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.wrapper {
|
|
105
|
+
display: flex;
|
|
106
|
+
align-items: center;
|
|
107
|
+
background: var(--el-surface-base, #ffffff);
|
|
108
|
+
border: 1px solid var(--el-surface-border, #e5e7eb);
|
|
109
|
+
border-radius: var(--el-radius-md, 8px);
|
|
110
|
+
padding: 0 var(--el-spacing-sm, 8px);
|
|
111
|
+
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
|
112
|
+
box-sizing: border-box;
|
|
113
|
+
gap: var(--el-spacing-xs, 4px);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.wrapper:focus-within {
|
|
117
|
+
border-color: var(--el-color-primary, #2563eb);
|
|
118
|
+
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.wrapper.disabled {
|
|
122
|
+
background: var(--el-surface-muted, #f3f4f6);
|
|
123
|
+
cursor: not-allowed;
|
|
124
|
+
opacity: 0.6;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* Size variants */
|
|
128
|
+
:host([size="sm"]) .wrapper {
|
|
129
|
+
height: 32px;
|
|
130
|
+
font-size: 0.8125rem;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
:host([size="md"]) .wrapper,
|
|
134
|
+
:host(:not([size])) .wrapper {
|
|
135
|
+
height: 40px;
|
|
136
|
+
font-size: 0.9375rem;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
:host([size="lg"]) .wrapper {
|
|
140
|
+
height: 48px;
|
|
141
|
+
font-size: 1.0625rem;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
input {
|
|
145
|
+
flex: 1;
|
|
146
|
+
border: none;
|
|
147
|
+
outline: none;
|
|
148
|
+
background: transparent;
|
|
149
|
+
color: var(--el-text-base, #111827);
|
|
150
|
+
font-family: inherit;
|
|
151
|
+
font-size: inherit;
|
|
152
|
+
width: 100%;
|
|
153
|
+
padding: 0 4px;
|
|
154
|
+
min-width: 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@media (hover: none) and (pointer: coarse), (max-width: 640px) {
|
|
158
|
+
input {
|
|
159
|
+
font-size: 16px !important;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
input::placeholder {
|
|
164
|
+
color: var(--el-text-muted, #9ca3af);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
input:disabled {
|
|
168
|
+
cursor: not-allowed;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
::slotted([slot="prefix"]),
|
|
172
|
+
::slotted([slot="suffix"]) {
|
|
173
|
+
display: flex;
|
|
174
|
+
align-items: center;
|
|
175
|
+
color: var(--el-text-muted, #6b7280);
|
|
176
|
+
user-select: none;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
@media (pointer: coarse) {
|
|
180
|
+
input {
|
|
181
|
+
font-size: max(16px, 1em);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
`;
|
|
185
|
+
|
|
186
|
+
#onInput = (e) => {
|
|
187
|
+
this.value.value = e.target.value;
|
|
188
|
+
this.setFormValue(e.target.value);
|
|
189
|
+
this.validate();
|
|
190
|
+
this.emit('input', { value: e.target.value });
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
#onChange = (e) => {
|
|
194
|
+
this.value.value = e.target.value;
|
|
195
|
+
this.setFormValue(e.target.value);
|
|
196
|
+
this.validate();
|
|
197
|
+
this.emit('change', { value: e.target.value });
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
focus() {
|
|
201
|
+
this.root.querySelector('input')?.focus();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
render() {
|
|
205
|
+
return html`
|
|
206
|
+
<div
|
|
207
|
+
class=${() => `wrapper ${this.disabled.value ? 'disabled' : ''}`}
|
|
208
|
+
part="wrapper"
|
|
209
|
+
>
|
|
210
|
+
<slot name="prefix"></slot>
|
|
211
|
+
<input
|
|
212
|
+
part="input"
|
|
213
|
+
type=${this.type}
|
|
214
|
+
.value=${this.value}
|
|
215
|
+
placeholder=${this.placeholder}
|
|
216
|
+
?disabled=${this.disabled}
|
|
217
|
+
?readonly=${this.readonly}
|
|
218
|
+
@input=${this.#onInput}
|
|
219
|
+
@change=${this.#onChange}
|
|
220
|
+
/>
|
|
221
|
+
<slot name="suffix"></slot>
|
|
222
|
+
</div>
|
|
223
|
+
`;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-input')) {
|
|
228
|
+
customElements.define('el-input', ElInput);
|
|
229
|
+
}
|
|
@@ -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
|
+
}
|