ochreui 0.0.0-stage → 0.0.2
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 +153 -2
- package/cli/ochreui.mjs +601 -0
- package/mcp/core.mjs +126 -0
- package/mcp/docs.json +906 -0
- package/mcp/server.mjs +23 -0
- package/package.json +393 -3
- package/registry/agent-team.ts +350 -0
- package/registry/avatar.ts +300 -0
- package/registry/badge.ts +207 -0
- package/registry/breadcrumb.ts +435 -0
- package/registry/button.ts +238 -0
- package/registry/card.ts +221 -0
- package/registry/change-summary.ts +200 -0
- package/registry/checkbox.ts +204 -0
- package/registry/code-block.ts +332 -0
- package/registry/color-picker.ts +720 -0
- package/registry/comment-thread.ts +503 -0
- package/registry/context-menu.ts +281 -0
- package/registry/cover-flow.ts +623 -0
- package/registry/date-picker.ts +799 -0
- package/registry/decision-inbox.ts +340 -0
- package/registry/dialog.ts +577 -0
- package/registry/dropdown-menu.ts +864 -0
- package/registry/email-draft.ts +916 -0
- package/registry/empty-calendar.ts +199 -0
- package/registry/empty-state.ts +164 -0
- package/registry/enrichment-orbit.ts +164 -0
- package/registry/filter-menu.ts +541 -0
- package/registry/form-field.ts +308 -0
- package/registry/frost-cloud.ts +381 -0
- package/registry/ghosted-chat.ts +210 -0
- package/registry/glow-cloud.ts +402 -0
- package/registry/grid-background.ts +164 -0
- package/registry/hover-card.ts +401 -0
- package/registry/icon-button.ts +133 -0
- package/registry/index.json +2124 -0
- package/registry/integration-beam.ts +588 -0
- package/registry/integration-grid.ts +209 -0
- package/registry/kbd.ts +176 -0
- package/registry/layer-stack.ts +351 -0
- package/registry/lead-sourcing.ts +285 -0
- package/registry/logo-cluster.ts +239 -0
- package/registry/logo-marquee.ts +505 -0
- package/registry/message-actions.ts +833 -0
- package/registry/model-orbit.ts +583 -0
- package/registry/model-wheel.ts +372 -0
- package/registry/notification-stack.ts +301 -0
- package/registry/number-input.ts +552 -0
- package/registry/number-ticker.ts +261 -0
- package/registry/ochre.css +917 -0
- package/registry/otp-input.ts +704 -0
- package/registry/overlay.ts +312 -0
- package/registry/pagination.ts +362 -0
- package/registry/popover.ts +296 -0
- package/registry/profile-menu.ts +332 -0
- package/registry/progress-tracker.ts +291 -0
- package/registry/rating.ts +461 -0
- package/registry/reaction-bar.ts +322 -0
- package/registry/region-map.ts +537 -0
- package/registry/resizable.ts +489 -0
- package/registry/scroll-area.ts +271 -0
- package/registry/segmented-control.ts +433 -0
- package/registry/select.ts +769 -0
- package/registry/separator.ts +97 -0
- package/registry/shimmer-loader.ts +211 -0
- package/registry/side-folder.ts +152 -0
- package/registry/skeleton.ts +136 -0
- package/registry/skill/INSTRUCTIONS.md +11 -0
- package/registry/skill/SKILL.md +65 -0
- package/registry/skill/checklist.md +45 -0
- package/registry/skill/references/agent-team.md +105 -0
- package/registry/skill/references/avatar.md +88 -0
- package/registry/skill/references/badge.md +92 -0
- package/registry/skill/references/breadcrumb.md +99 -0
- package/registry/skill/references/button.md +82 -0
- package/registry/skill/references/card.md +111 -0
- package/registry/skill/references/catalog.md +114 -0
- package/registry/skill/references/change-summary.md +103 -0
- package/registry/skill/references/checkbox.md +105 -0
- package/registry/skill/references/code-block.md +109 -0
- package/registry/skill/references/color-picker.md +138 -0
- package/registry/skill/references/comment-thread.md +164 -0
- package/registry/skill/references/context-menu.md +205 -0
- package/registry/skill/references/cover-flow.md +128 -0
- package/registry/skill/references/date-picker.md +154 -0
- package/registry/skill/references/decision-inbox.md +126 -0
- package/registry/skill/references/dialog.md +155 -0
- package/registry/skill/references/dropdown-menu.md +144 -0
- package/registry/skill/references/email-draft.md +182 -0
- package/registry/skill/references/empty-calendar.md +74 -0
- package/registry/skill/references/empty-state.md +118 -0
- package/registry/skill/references/enrichment-orbit.md +71 -0
- package/registry/skill/references/filter-menu.md +143 -0
- package/registry/skill/references/form-field.md +118 -0
- package/registry/skill/references/frost-cloud.md +80 -0
- package/registry/skill/references/ghosted-chat.md +75 -0
- package/registry/skill/references/glow-cloud.md +84 -0
- package/registry/skill/references/grid-background.md +76 -0
- package/registry/skill/references/hover-card.md +125 -0
- package/registry/skill/references/icon-button.md +99 -0
- package/registry/skill/references/integration-beam.md +107 -0
- package/registry/skill/references/integration-grid.md +100 -0
- package/registry/skill/references/kbd.md +65 -0
- package/registry/skill/references/layer-stack.md +115 -0
- package/registry/skill/references/lead-sourcing.md +92 -0
- package/registry/skill/references/logo-cluster.md +92 -0
- package/registry/skill/references/logo-marquee.md +123 -0
- package/registry/skill/references/message-actions.md +146 -0
- package/registry/skill/references/model-orbit.md +106 -0
- package/registry/skill/references/model-wheel.md +84 -0
- package/registry/skill/references/notification-stack.md +138 -0
- package/registry/skill/references/number-input.md +117 -0
- package/registry/skill/references/number-ticker.md +73 -0
- package/registry/skill/references/otp-input.md +142 -0
- package/registry/skill/references/pagination.md +112 -0
- package/registry/skill/references/popover.md +143 -0
- package/registry/skill/references/profile-menu.md +123 -0
- package/registry/skill/references/progress-tracker.md +122 -0
- package/registry/skill/references/rating.md +111 -0
- package/registry/skill/references/reaction-bar.md +128 -0
- package/registry/skill/references/region-map.md +109 -0
- package/registry/skill/references/resizable.md +127 -0
- package/registry/skill/references/scroll-area.md +113 -0
- package/registry/skill/references/segmented-control.md +96 -0
- package/registry/skill/references/select.md +122 -0
- package/registry/skill/references/separator.md +69 -0
- package/registry/skill/references/shimmer-loader.md +83 -0
- package/registry/skill/references/side-folder.md +75 -0
- package/registry/skill/references/skeleton.md +95 -0
- package/registry/skill/references/smart-recommendation.md +132 -0
- package/registry/skill/references/spinner.md +84 -0
- package/registry/skill/references/switch.md +79 -0
- package/registry/skill/references/tab-overload.md +70 -0
- package/registry/skill/references/tag-input.md +126 -0
- package/registry/skill/references/team-invite.md +94 -0
- package/registry/skill/references/testimonial-wall.md +110 -0
- package/registry/skill/references/text-area.md +115 -0
- package/registry/skill/references/text-field.md +126 -0
- package/registry/skill/references/text-reveal.md +71 -0
- package/registry/skill/references/thinking-loader.md +87 -0
- package/registry/skill/references/time-picker.md +122 -0
- package/registry/skill/references/tips-panel.md +115 -0
- package/registry/skill/references/toggle-group.md +98 -0
- package/registry/skill/references/tool-call-card.md +151 -0
- package/registry/skill/references/tooltip.md +94 -0
- package/registry/skill/references/tree-view.md +172 -0
- package/registry/skill/theming.md +57 -0
- package/registry/smart-recommendation.ts +415 -0
- package/registry/spinner.ts +67 -0
- package/registry/switch.ts +146 -0
- package/registry/tab-overload.ts +211 -0
- package/registry/tag-input.ts +620 -0
- package/registry/team-invite.ts +248 -0
- package/registry/testimonial-wall.ts +521 -0
- package/registry/text-area.ts +432 -0
- package/registry/text-field.ts +415 -0
- package/registry/text-reveal.ts +175 -0
- package/registry/theme.ts +68 -0
- package/registry/thinking-loader.ts +302 -0
- package/registry/time-picker.ts +828 -0
- package/registry/tips-panel.ts +312 -0
- package/registry/toggle-group.ts +357 -0
- package/registry/tool-call-card.ts +578 -0
- package/registry/tooltip.ts +486 -0
- package/registry/tree-view.ts +454 -0
- package/styles/base.css +500 -0
- package/styles/tokens.css +415 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Ochre (https://ochreui.dev), MIT License, Copyright (c) 2026 Ochre. Keep this notice in copies of this file.
|
|
2
|
+
/**
|
|
3
|
+
* Spinner, from Ochre (https://ochreui.dev).
|
|
4
|
+
* Needs ochre.css (the --ui-* tokens and the ui-spin keyframes), which `npx ochreui init` adds once.
|
|
5
|
+
* Draws in the surrounding text color: set `color` to recolor it.
|
|
6
|
+
*
|
|
7
|
+
* Public styling hooks (set them on the element or any ancestor):
|
|
8
|
+
* --ui-spinner-size width and height (default --ui-icon-sm, 14px)
|
|
9
|
+
* --ui-spinner-speed one turn (default 800ms; 750ms with data-ui-look="tray"; three times slower with reduced motion)
|
|
10
|
+
*/
|
|
11
|
+
import { Component, input } from '@angular/core';
|
|
12
|
+
|
|
13
|
+
const toSize = (v: unknown): number | undefined => {
|
|
14
|
+
const n = v === null || v === undefined || v === '' ? NaN : Number(v);
|
|
15
|
+
return Number.isFinite(n) && n > 0 ? n : undefined;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
@Component({
|
|
19
|
+
selector: 'ui-spinner',
|
|
20
|
+
host: {
|
|
21
|
+
class: 'ui-spinner',
|
|
22
|
+
'[style.inline-size.px]': 'size() ?? null',
|
|
23
|
+
'[style.block-size.px]': 'size() ?? null',
|
|
24
|
+
'[attr.role]': "label() ? 'status' : null",
|
|
25
|
+
'[attr.aria-label]': 'label() || null',
|
|
26
|
+
'[attr.aria-hidden]': "label() ? null : 'true'",
|
|
27
|
+
},
|
|
28
|
+
template: `
|
|
29
|
+
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor">
|
|
30
|
+
<circle class="track" cx="8" cy="8" r="6" />
|
|
31
|
+
<circle class="arc" cx="8" cy="8" r="6" pathLength="4" stroke-dasharray="1 3" transform="rotate(-90 8 8)" />
|
|
32
|
+
</svg>
|
|
33
|
+
`,
|
|
34
|
+
styles: `
|
|
35
|
+
:host {
|
|
36
|
+
--_t: var(--ui-look-tray, 0);
|
|
37
|
+
--_speed: var(--ui-spinner-speed, calc(800ms - 50ms * var(--_t)));
|
|
38
|
+
display: inline-block;
|
|
39
|
+
inline-size: var(--ui-spinner-size, var(--ui-icon-sm));
|
|
40
|
+
block-size: var(--ui-spinner-size, var(--ui-icon-sm));
|
|
41
|
+
flex-shrink: 0;
|
|
42
|
+
vertical-align: middle;
|
|
43
|
+
line-height: 0;
|
|
44
|
+
}
|
|
45
|
+
svg {
|
|
46
|
+
display: block;
|
|
47
|
+
inline-size: 100%;
|
|
48
|
+
block-size: 100%;
|
|
49
|
+
stroke-width: calc(1.8 + 0.2 * var(--_t));
|
|
50
|
+
animation: ui-spin var(--_speed) linear infinite;
|
|
51
|
+
}
|
|
52
|
+
.track { stroke-opacity: calc(0.18 + 0.02 * var(--_t)); }
|
|
53
|
+
.arc { stroke-linecap: round; }
|
|
54
|
+
@media (prefers-reduced-motion: reduce) {
|
|
55
|
+
svg { animation-duration: calc(var(--_speed) * 3); }
|
|
56
|
+
}
|
|
57
|
+
@container style(--ui-motion-scale: 0) {
|
|
58
|
+
svg { animation-duration: calc(var(--_speed) * 3); }
|
|
59
|
+
}
|
|
60
|
+
`,
|
|
61
|
+
})
|
|
62
|
+
export class UiSpinner {
|
|
63
|
+
/** Width and height in pixels. The stroke scales with it. Defaults to --ui-spinner-size, else 14px. */
|
|
64
|
+
readonly size = input<number | undefined, unknown>(undefined, { transform: toSize });
|
|
65
|
+
/** Makes it a status with this name. Leave it out when visible text next to it already says what is running. */
|
|
66
|
+
readonly label = input<string>();
|
|
67
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Ochre (https://ochreui.dev), MIT License, Copyright (c) 2026 Ochre. Keep this notice in copies of this file.
|
|
2
|
+
/**
|
|
3
|
+
* Switch, from Ochre (https://ochreui.dev).
|
|
4
|
+
* Needs ochre.css (the --ui-* tokens), added once by `npx ochreui init`.
|
|
5
|
+
*
|
|
6
|
+
* <ui-switch label="Daily digest" description="…" placement="end"><input type="checkbox" uiSwitch [formField]="form.digest" /></ui-switch>
|
|
7
|
+
* Your own checkbox goes inside, so every kind of form, reset and native submission work on it.
|
|
8
|
+
*
|
|
9
|
+
* Public styling hooks (set them on the element or any ancestor):
|
|
10
|
+
* --ui-switch-track off track (default: pale; the input border under prefers-contrast: more)
|
|
11
|
+
* --ui-switch-track-hover off track on hover (default: a step darker)
|
|
12
|
+
* --ui-switch-track-on on track (default: ink)
|
|
13
|
+
* --ui-switch-thumb off thumb (default: light in both themes)
|
|
14
|
+
* --ui-switch-thumb-on on thumb (default: the text colour on ink)
|
|
15
|
+
*/
|
|
16
|
+
import { Component, Directive, ElementRef, afterNextRender, computed, contentChild, inject, input, isDevMode } from '@angular/core';
|
|
17
|
+
|
|
18
|
+
export type SwitchSize = 'sm' | 'md';
|
|
19
|
+
export type SwitchPlacement = 'start' | 'end';
|
|
20
|
+
|
|
21
|
+
let nextId = 0;
|
|
22
|
+
|
|
23
|
+
/** Put it on the `<input type="checkbox">` inside a `<ui-switch>`. Write `type="checkbox"` yourself, so Angular forms bind it. */
|
|
24
|
+
@Directive({
|
|
25
|
+
selector: 'input[type=checkbox][uiSwitch]',
|
|
26
|
+
host: {
|
|
27
|
+
role: 'switch',
|
|
28
|
+
style: 'position: absolute; inset: calc(var(--ui-space-1-5) * -1); z-index: 1; margin: 0; opacity: 0; cursor: inherit',
|
|
29
|
+
'[id]': 'id()',
|
|
30
|
+
'[attr.aria-labelledby]': 'labelledBy',
|
|
31
|
+
'[attr.aria-describedby]': 'describedBy()',
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
export class UiSwitchInput {
|
|
35
|
+
readonly id = input(`ui-switch-${nextId++}`);
|
|
36
|
+
/** Your own descriptions, kept alongside the switch's. Set it as `aria-describedby="…"`, not `[attr.aria-describedby]`. */
|
|
37
|
+
readonly ariaDescribedby = input<string>(undefined, { alias: 'aria-describedby' });
|
|
38
|
+
|
|
39
|
+
readonly el = inject<ElementRef<HTMLInputElement>>(ElementRef).nativeElement;
|
|
40
|
+
protected readonly field = inject(UiSwitch);
|
|
41
|
+
private readonly named = this.el.hasAttribute('aria-label') || this.el.hasAttribute('aria-labelledby');
|
|
42
|
+
protected get labelledBy() {
|
|
43
|
+
return !this.named && this.field.label() ? this.field.titleId : null;
|
|
44
|
+
}
|
|
45
|
+
protected readonly describedBy = computed(
|
|
46
|
+
() => [this.ariaDescribedby(), this.field.description() ? this.field.descId : ''].filter(Boolean).join(' ') || null,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@Component({
|
|
51
|
+
selector: 'ui-switch',
|
|
52
|
+
host: {
|
|
53
|
+
'[attr.data-size]': 'size()',
|
|
54
|
+
'[attr.data-placement]': 'placement()',
|
|
55
|
+
},
|
|
56
|
+
template: `
|
|
57
|
+
<label class="row">
|
|
58
|
+
<span class="ctl" style="position: relative; display: grid; align-items: center; flex: none; block-size: max(var(--_lh), var(--_h))">
|
|
59
|
+
<ng-content select="input" />
|
|
60
|
+
<span class="track" aria-hidden="true" style="position: relative; inline-size: var(--_w); block-size: var(--_h); border-radius: var(--ui-radius-full); transition: background-color var(--ui-duration-3) var(--ui-ease-out)">
|
|
61
|
+
<span class="thumb" style="position: absolute; inset: var(--ui-space-0-5); border-radius: inherit; transition: translate calc(260ms * var(--ui-motion-scale)) var(--ui-ease-out), inline-size var(--ui-duration-2) var(--ui-ease-out)"></span>
|
|
62
|
+
</span>
|
|
63
|
+
</span>
|
|
64
|
+
@if (label() || description()) {
|
|
65
|
+
<span style="display: grid; min-inline-size: 0; overflow-wrap: anywhere">
|
|
66
|
+
@if (label()) {<span [id]="titleId">{{ label() }}</span>}
|
|
67
|
+
@if (description()) {<span class="desc" [id]="descId">{{ description() }}</span>}
|
|
68
|
+
</span>
|
|
69
|
+
}
|
|
70
|
+
</label>
|
|
71
|
+
`,
|
|
72
|
+
styles: `
|
|
73
|
+
:host {
|
|
74
|
+
--_t: var(--ui-look-tray, 0);
|
|
75
|
+
--_w: var(--ui-space-8);
|
|
76
|
+
--_h: var(--ui-space-5);
|
|
77
|
+
--_lh: var(--ui-leading-base);
|
|
78
|
+
--_dir: 1;
|
|
79
|
+
--_s: calc(var(--_h) - var(--ui-space-0-5) * 2);
|
|
80
|
+
--_go: calc((var(--_w) - var(--_h)) * var(--_dir));
|
|
81
|
+
--_p: calc(var(--ui-space-1) + 1px);
|
|
82
|
+
--_on: var(--ui-switch-track-on, var(--ui-bg-neutral-solid));
|
|
83
|
+
--_bg: var(--ui-switch-track, color-mix(in srgb, var(--ui-text) 14%, var(--ui-bg-surface)));
|
|
84
|
+
display: block;
|
|
85
|
+
color: var(--ui-text);
|
|
86
|
+
font: calc(var(--ui-text-base) + 0.5px * var(--_t)) / var(--_lh) var(--ui-font-sans);
|
|
87
|
+
}
|
|
88
|
+
:host([data-size='sm']) { --_w: calc(var(--ui-space-6) + 2px); --_h: var(--ui-space-4); }
|
|
89
|
+
:host(:dir(rtl)) { --_dir: -1; }
|
|
90
|
+
:host(:has(:checked)) { --_bg: var(--_on); }
|
|
91
|
+
:host(:has(:disabled)) { opacity: var(--ui-disabled-opacity); }
|
|
92
|
+
.row { display: flex; align-items: flex-start; gap: var(--ui-space-2-5); cursor: pointer; }
|
|
93
|
+
:host([data-placement='end']) .row { flex-direction: row-reverse; justify-content: space-between; gap: var(--ui-space-4); }
|
|
94
|
+
:host(:has(:disabled)) .row { cursor: not-allowed; }
|
|
95
|
+
@media (hover: hover) {
|
|
96
|
+
.row:hover { --_bg: var(--ui-switch-track-hover, color-mix(in srgb, var(--ui-text) 20%, var(--ui-bg-surface))); }
|
|
97
|
+
:host(:has(:checked)) .row:hover { --_bg: color-mix(in srgb, var(--_on) 85%, var(--ui-bg-surface)); }
|
|
98
|
+
:host(:has(:disabled)) .row:hover { --_bg: inherit; }
|
|
99
|
+
}
|
|
100
|
+
.track { background: var(--_bg); }
|
|
101
|
+
.ctl:has(:focus-visible) .track { outline: var(--ui-focus-width) solid var(--ui-focus-ring); outline-offset: var(--ui-focus-offset); }
|
|
102
|
+
.thumb { inline-size: var(--_s); background: var(--ui-switch-thumb, var(--ui-bg-knob)); box-shadow: var(--ui-shadow-sm); }
|
|
103
|
+
:host(:has(:checked)) .thumb { translate: var(--_go); background: var(--ui-switch-thumb-on, var(--ui-text-on-neutral)); }
|
|
104
|
+
:host(:not(:has(:disabled))) .row:active .thumb { inline-size: calc(var(--_s) + var(--_p)); }
|
|
105
|
+
:host(:has(:checked):not(:has(:disabled))) .row:active .thumb { translate: calc(var(--_go) - var(--_p) * var(--_dir)); }
|
|
106
|
+
.desc { color: var(--ui-text-muted); font-size: calc(var(--ui-text-sm) + 0.5px * var(--_t)); line-height: calc(var(--ui-leading-xs) + 1px * var(--_t)); }
|
|
107
|
+
@media (pointer: coarse) {
|
|
108
|
+
:host { --_w: var(--ui-space-10); --_h: var(--ui-space-6); --_lh: calc(var(--ui-leading-base) + 2px); font-size: calc(var(--ui-text-base) + 2px); }
|
|
109
|
+
:host([data-size='sm']) { --_w: calc(var(--ui-space-8) + 2px); --_h: var(--ui-space-5); }
|
|
110
|
+
}
|
|
111
|
+
@media (prefers-contrast: more) {
|
|
112
|
+
:host { --_bg: var(--ui-switch-track, var(--ui-border-input)); }
|
|
113
|
+
@media (hover: hover) { .row:hover { --_bg: var(--ui-switch-track-hover, color-mix(in srgb, var(--ui-text) 25%, var(--ui-border-input))); } }
|
|
114
|
+
}
|
|
115
|
+
@media (forced-colors: active) {
|
|
116
|
+
:host(:has(:disabled)) { --_fc: GrayText; }
|
|
117
|
+
.track { forced-color-adjust: none; border: 1px solid var(--_fc, CanvasText); background: Canvas; }
|
|
118
|
+
.thumb { background: var(--_fc, CanvasText); }
|
|
119
|
+
:host(:has(:checked)) .track { border-color: var(--_fc, Highlight); background: var(--_fc, Highlight); }
|
|
120
|
+
:host(:has(:checked)) .thumb { background: Canvas; }
|
|
121
|
+
}
|
|
122
|
+
`,
|
|
123
|
+
})
|
|
124
|
+
export class UiSwitch {
|
|
125
|
+
/** The name of the setting, next to the switch. Clicking it toggles. */
|
|
126
|
+
readonly label = input<string>();
|
|
127
|
+
/** A quiet line under the label. Screen readers hear it as the switch's description. */
|
|
128
|
+
readonly description = input<string>();
|
|
129
|
+
/** `start` puts the switch before the text; `end` puts it at the far end of the row, as in settings lists. */
|
|
130
|
+
readonly placement = input<SwitchPlacement>('start');
|
|
131
|
+
/** 32 × 20px, or 26 × 16px for `sm`. Larger on touch screens. */
|
|
132
|
+
readonly size = input<SwitchSize>('md');
|
|
133
|
+
|
|
134
|
+
protected readonly control = contentChild(UiSwitchInput);
|
|
135
|
+
readonly titleId = `ui-switch-title-${nextId++}`;
|
|
136
|
+
readonly descId = `${this.titleId}-desc`;
|
|
137
|
+
|
|
138
|
+
constructor() {
|
|
139
|
+
afterNextRender(() => {
|
|
140
|
+
const el = this.control()?.el;
|
|
141
|
+
if (isDevMode() && el && !this.label() && !el.ariaLabel && !el.hasAttribute('aria-labelledby')) {
|
|
142
|
+
console.warn('ui-switch: give it a label, or an aria-label on the input.', el);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// Ochre (https://ochreui.dev), MIT License, Copyright (c) 2026 Ochre. Keep this notice in copies of this file.
|
|
2
|
+
/**
|
|
3
|
+
* Tab Overload, from Ochre (https://ochreui.dev).
|
|
4
|
+
* Needs ochre.css (the --ui-* tokens), which `npx ochreui init` adds once.
|
|
5
|
+
*
|
|
6
|
+
* <ui-tab-overload />
|
|
7
|
+
* A card illustration of three stacked browser windows with softly pulsing placeholder blocks; hovering a
|
|
8
|
+
* window lights it. Screen readers hear one image with `label`. Still under reduced motion.
|
|
9
|
+
*
|
|
10
|
+
* Public styling hooks (set them on the element or any ancestor):
|
|
11
|
+
* --ui-tab-overload-bar title bar (default: the subtle background, a near-black in dark mode)
|
|
12
|
+
* --ui-tab-overload-panel page inside each window (default: the surface)
|
|
13
|
+
* --ui-tab-overload-edge window and page outlines (default: the hairline)
|
|
14
|
+
* --ui-tab-overload-dot grey title-bar dots (default: the text color at 20%)
|
|
15
|
+
* --ui-tab-overload-block placeholder blocks (default: the placeholder background)
|
|
16
|
+
* --ui-tab-overload-pulse the darker end of the pulse (default: the block a step darker)
|
|
17
|
+
*/
|
|
18
|
+
import { Component, DOCUMENT, DestroyRef, ElementRef, afterNextRender, computed, inject, input, signal } from '@angular/core';
|
|
19
|
+
|
|
20
|
+
const WINDOWS = [
|
|
21
|
+
[30, 68],
|
|
22
|
+
[125, 56],
|
|
23
|
+
[220, 44],
|
|
24
|
+
] as const;
|
|
25
|
+
|
|
26
|
+
const BLOCKS = [
|
|
27
|
+
[12, 36, 30, 30, 4],
|
|
28
|
+
[52, 38, 100, 6, 2],
|
|
29
|
+
[52, 46, 100, 6, 2],
|
|
30
|
+
[52, 54, 35, 6, 2],
|
|
31
|
+
[12, 72, 140, 6, 2],
|
|
32
|
+
[12, 80, 140, 6, 2],
|
|
33
|
+
[12, 88, 55, 6, 2],
|
|
34
|
+
] as const;
|
|
35
|
+
|
|
36
|
+
let nextId = 0;
|
|
37
|
+
|
|
38
|
+
@Component({
|
|
39
|
+
selector: 'ui-tab-overload',
|
|
40
|
+
host: {
|
|
41
|
+
'[attr.role]': "label() ? 'img' : null",
|
|
42
|
+
'[attr.aria-label]': 'label() || null',
|
|
43
|
+
'[attr.aria-hidden]': "label() ? null : 'true'",
|
|
44
|
+
'[attr.data-run]': "ready() && !still() ? '' : null",
|
|
45
|
+
'[style.--_p]': "awake() ? null : 'paused'",
|
|
46
|
+
},
|
|
47
|
+
template: `
|
|
48
|
+
<svg viewBox="0 0 360 240" width="560" aria-hidden="true" focusable="false">
|
|
49
|
+
<defs>
|
|
50
|
+
<filter [attr.id]="id + 'b'" filterUnits="userSpaceOnUse" x="-80" y="-80" width="360" height="360">
|
|
51
|
+
<feGaussianBlur stdDeviation="12" />
|
|
52
|
+
</filter>
|
|
53
|
+
<filter [attr.id]="id + 'x'" filterUnits="userSpaceOnUse" x="-80" y="-80" width="360" height="360">
|
|
54
|
+
<feGaussianBlur stdDeviation="12" /><feComponentTransfer><feFuncA type="linear" slope="4" /></feComponentTransfer>
|
|
55
|
+
</filter>
|
|
56
|
+
<mask [attr.id]="id + 'm'" maskUnits="userSpaceOnUse" x="-4" y="-4" width="388" height="308">
|
|
57
|
+
<rect width="380" height="300" rx="6" fill="none" stroke="#fff" stroke-width="0.9" />
|
|
58
|
+
</mask>
|
|
59
|
+
<linearGradient [attr.id]="id + 'h'" gradientUnits="userSpaceOnUse" x1="-20" y1="0" x2="160" y2="0">
|
|
60
|
+
<stop class="pk" offset="0.05" /><stop class="li" offset="0.3" /><stop class="pw" offset="1" />
|
|
61
|
+
</linearGradient>
|
|
62
|
+
<linearGradient [attr.id]="id + 'v'" x1="0" y1="0" x2="0" y2="1">
|
|
63
|
+
<stop class="pk" offset="0" /><stop class="co" offset="0.4" /><stop class="co" offset="0.7" /><stop class="s0" offset="1" />
|
|
64
|
+
</linearGradient>
|
|
65
|
+
</defs>
|
|
66
|
+
@for (w of windows; track $index) {
|
|
67
|
+
<g [attr.class]="'w w' + $index" [attr.transform]="'translate(' + w[0] + ' ' + w[1] + ')'">
|
|
68
|
+
<g class="lt gl" [attr.filter]="ref('b')">
|
|
69
|
+
<ellipse cx="70" cy="8" rx="90" ry="14" [attr.fill]="ref('h')" />
|
|
70
|
+
<ellipse cx="8" cy="96" rx="14" ry="90" [attr.fill]="ref('v')" />
|
|
71
|
+
</g>
|
|
72
|
+
<rect class="fr" width="380" height="300" rx="6" />
|
|
73
|
+
<g class="lt gl" [attr.mask]="ref('m')">
|
|
74
|
+
<g [attr.filter]="ref('x')">
|
|
75
|
+
<ellipse cx="70" cy="8" rx="90" ry="14" [attr.fill]="ref('h')" />
|
|
76
|
+
<ellipse cx="8" cy="96" rx="14" ry="90" [attr.fill]="ref('v')" />
|
|
77
|
+
</g>
|
|
78
|
+
</g>
|
|
79
|
+
<rect class="lt hl" width="380" height="300" rx="6" />
|
|
80
|
+
<circle class="dt" cx="14" cy="14" r="3" /><circle class="dt" cx="24" cy="14" r="3" /><circle class="dt" cx="34" cy="14" r="3" />
|
|
81
|
+
<rect class="pn" x="4" y="24" width="372" height="272" rx="5" />
|
|
82
|
+
<g class="ph">
|
|
83
|
+
@for (b of blocks; track $index) {
|
|
84
|
+
<rect [attr.x]="b[0]" [attr.y]="b[1]" [attr.width]="b[2]" [attr.height]="b[3]" [attr.rx]="b[4]" />
|
|
85
|
+
}
|
|
86
|
+
</g>
|
|
87
|
+
</g>
|
|
88
|
+
}
|
|
89
|
+
@for (w of windows; track $index) {
|
|
90
|
+
<g [attr.class]="'d d' + $index" [attr.transform]="'translate(' + w[0] + ' ' + w[1] + ')'">
|
|
91
|
+
<circle class="c1" cx="14" cy="14" r="3" /><circle class="c2" cx="24" cy="14" r="3" /><circle class="c3" cx="34" cy="14" r="3" />
|
|
92
|
+
</g>
|
|
93
|
+
}
|
|
94
|
+
</svg>
|
|
95
|
+
`,
|
|
96
|
+
styles: `
|
|
97
|
+
@layer ui {
|
|
98
|
+
:host { display: block; position: relative; overflow: hidden; inline-size: min(560px, 100%); aspect-ratio: 3 / 2; }
|
|
99
|
+
}
|
|
100
|
+
:host {
|
|
101
|
+
--_m: var(--ui-motion-scale, 1);
|
|
102
|
+
--_bar: var(--ui-tab-overload-bar, light-dark(color-mix(in srgb, var(--ui-bg-subtle) 85%, var(--ui-bg-surface)), color-mix(in srgb, var(--ui-bg-surface) 70%, var(--ui-gray-1050))));
|
|
103
|
+
--_pn: var(--ui-tab-overload-panel, var(--ui-bg-surface));
|
|
104
|
+
--_eg: var(--ui-tab-overload-edge, var(--ui-hairline));
|
|
105
|
+
--_blk: var(--ui-tab-overload-block, var(--ui-bg-placeholder));
|
|
106
|
+
--_hi: var(--ui-tab-overload-pulse, color-mix(in srgb, var(--_blk), var(--ui-text) 6%));
|
|
107
|
+
--_co: color-mix(in srgb, color-mix(in srgb, var(--ui-orange-dark) 45%, var(--ui-red-dark)) 65%, var(--ui-gray-0));
|
|
108
|
+
--_pk: color-mix(in srgb, var(--ui-pink-dark) 60%, var(--ui-purple-dark));
|
|
109
|
+
--_li: color-mix(in srgb, var(--ui-purple-dark) 70%, var(--ui-gray-0));
|
|
110
|
+
--_pw: color-mix(in srgb, color-mix(in srgb, var(--ui-indigo-dark), var(--ui-blue-dark)) 70%, var(--ui-gray-0));
|
|
111
|
+
box-sizing: border-box;
|
|
112
|
+
mask: linear-gradient(to right, #000 70%, transparent), linear-gradient(#000 70%, transparent);
|
|
113
|
+
mask-composite: intersect;
|
|
114
|
+
user-select: none;
|
|
115
|
+
-webkit-user-select: none;
|
|
116
|
+
}
|
|
117
|
+
svg { display: block; inline-size: 100%; block-size: auto; --_0: 0; --_1: 0; --_2: 1; }
|
|
118
|
+
.w0, .d0 { --_on: var(--_0); }
|
|
119
|
+
.w1, .d1 { --_on: var(--_1); }
|
|
120
|
+
.w2, .d2 { --_on: var(--_2); }
|
|
121
|
+
@media (hover: hover) {
|
|
122
|
+
svg:has(.w:hover) { --_2: 0; }
|
|
123
|
+
svg:has(.w0:hover) { --_0: 1; }
|
|
124
|
+
svg:has(.w1:hover) { --_1: 1; }
|
|
125
|
+
svg:has(.w2:hover) { --_2: 1; }
|
|
126
|
+
}
|
|
127
|
+
.lt, .d, .ph { transition: opacity var(--ui-duration-4) ease; }
|
|
128
|
+
.lt, .d { opacity: var(--_on); pointer-events: none; }
|
|
129
|
+
.ph { opacity: calc(0.2 + 0.8 * var(--_on)); fill: color-mix(in srgb, var(--_blk) 90%, var(--_pn)); }
|
|
130
|
+
.fr { fill: var(--_bar); stroke: var(--_eg); stroke-width: 0.7; }
|
|
131
|
+
.pn { fill: var(--_pn); stroke: var(--_eg); stroke-width: 0.7; }
|
|
132
|
+
.hl { display: none; }
|
|
133
|
+
.dt { fill: var(--ui-tab-overload-dot, color-mix(in srgb, var(--ui-text) 20%, transparent)); }
|
|
134
|
+
.c1 { fill: oklch(from var(--ui-red-dark) calc(l - 0.03) calc(c + 0.03) 29); }
|
|
135
|
+
.c2 { fill: var(--_co); }
|
|
136
|
+
.c3 { fill: var(--_pw); }
|
|
137
|
+
.s0 { stop-color: transparent; }
|
|
138
|
+
.pk { stop-color: light-dark(color-mix(in srgb, var(--_pk) 25%, transparent), color-mix(in srgb, var(--_pk) 35%, transparent)); }
|
|
139
|
+
.li { stop-color: light-dark(color-mix(in srgb, var(--_li) 25%, transparent), color-mix(in srgb, var(--_li) 35%, transparent)); }
|
|
140
|
+
.pw { stop-color: light-dark(color-mix(in srgb, var(--_pw) 25%, transparent), color-mix(in srgb, var(--_pw) 35%, transparent)); }
|
|
141
|
+
.co { stop-color: light-dark(color-mix(in srgb, var(--_co) 35%, transparent), color-mix(in srgb, var(--_co) 45%, transparent)); }
|
|
142
|
+
:host([data-run]) .ph { animation: ui-to-p calc(2400ms * var(--_m)) ease-in-out infinite var(--_p, running); }
|
|
143
|
+
@keyframes ui-to-p { 50% { fill: var(--_hi); } }
|
|
144
|
+
@media (forced-colors: active) {
|
|
145
|
+
.fr, .pn { fill: Canvas; stroke: CanvasText; }
|
|
146
|
+
.hl { display: inline; fill: none; stroke: Highlight; stroke-width: 1.4; }
|
|
147
|
+
.ph, .dt { fill: GrayText; animation: none !important; }
|
|
148
|
+
.d circle { fill: Highlight; }
|
|
149
|
+
.gl { display: none; }
|
|
150
|
+
}
|
|
151
|
+
`,
|
|
152
|
+
})
|
|
153
|
+
export class UiTabOverload {
|
|
154
|
+
/** What screen readers hear for the whole picture. Leave it empty to hide the picture from them. */
|
|
155
|
+
readonly label = input('Three overlapping browser windows filled with placeholder blocks');
|
|
156
|
+
|
|
157
|
+
protected readonly windows = WINDOWS;
|
|
158
|
+
protected readonly blocks = BLOCKS;
|
|
159
|
+
protected readonly id = `ui-to-${nextId++}-`;
|
|
160
|
+
|
|
161
|
+
private readonly doc = inject(DOCUMENT);
|
|
162
|
+
private readonly win = this.doc.defaultView;
|
|
163
|
+
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
|
|
164
|
+
protected readonly ready = signal(false);
|
|
165
|
+
private readonly seen = signal(false);
|
|
166
|
+
private readonly shown = signal(true);
|
|
167
|
+
protected readonly still = signal(false);
|
|
168
|
+
/** On screen in a visible tab: the pulse only plays then, and carries on from the same pose when it comes back. */
|
|
169
|
+
protected readonly awake = computed(() => this.seen() && this.shown());
|
|
170
|
+
|
|
171
|
+
constructor() {
|
|
172
|
+
let io: IntersectionObserver | undefined;
|
|
173
|
+
const mq = this.win?.matchMedia?.('(prefers-reduced-motion: reduce)');
|
|
174
|
+
const onMotion = () =>
|
|
175
|
+
this.still.set(!!mq?.matches || parseFloat(this.win?.getComputedStyle(this.host).getPropertyValue('--ui-motion-scale') ?? '') === 0);
|
|
176
|
+
const onVisibility = () => {
|
|
177
|
+
onMotion();
|
|
178
|
+
this.shown.set(this.doc.visibilityState !== 'hidden');
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
afterNextRender(() => {
|
|
182
|
+
onVisibility();
|
|
183
|
+
this.doc.addEventListener('visibilitychange', onVisibility);
|
|
184
|
+
mq?.addEventListener?.('change', onMotion);
|
|
185
|
+
const IO = this.win?.IntersectionObserver;
|
|
186
|
+
if (IO) {
|
|
187
|
+
io = new IO(
|
|
188
|
+
(entries) => {
|
|
189
|
+
onMotion();
|
|
190
|
+
this.seen.set(entries[entries.length - 1].isIntersecting);
|
|
191
|
+
},
|
|
192
|
+
{ threshold: [0] },
|
|
193
|
+
);
|
|
194
|
+
io.observe(this.host);
|
|
195
|
+
} else {
|
|
196
|
+
this.seen.set(true);
|
|
197
|
+
}
|
|
198
|
+
this.ready.set(true);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
inject(DestroyRef).onDestroy(() => {
|
|
202
|
+
io?.disconnect();
|
|
203
|
+
this.doc.removeEventListener('visibilitychange', onVisibility);
|
|
204
|
+
mq?.removeEventListener?.('change', onMotion);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
protected ref(k: string) {
|
|
209
|
+
return `url(#${this.id}${k})`;
|
|
210
|
+
}
|
|
211
|
+
}
|