@threadlabs/looma 0.52.4 → 0.52.6
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/components/ui-button/ui-button.html +1 -0
- package/components/ui-editor-link-card/ui-editor-link-card.html +32 -7
- package/components/ui-editor-link-card/ui-editor-link-card.js +10 -0
- package/components/ui-notice-stripe/ui-notice-stripe.html +109 -0
- package/components/ui-notice-stripe/ui-notice-stripe.js +13 -0
- package/dist/index.js +28 -27
- package/docs/catalog.json +248 -1
- package/docs/examples/ui-notice-stripe/examples/02-service-notice.behavior.js +7 -0
- package/editor/components.css +1 -0
- package/package.json +1 -1
- package/styles/ui-button.css +1 -0
- package/styles/ui-notice-stripe.css +172 -0
- package/vanilla/UiEditorLinkCard.js +165 -70
- package/vanilla/UiNoticeStripe.d.ts +26 -0
- package/vanilla/UiNoticeStripe.js +89 -0
- package/vanilla/index.js +1 -0
|
@@ -273,6 +273,7 @@
|
|
|
273
273
|
|
|
274
274
|
/* Projected marks may be images or composed elements, including block-level image resets. */
|
|
275
275
|
.label:has(> *) {
|
|
276
|
+
max-inline-size: 100%;
|
|
276
277
|
display: inline-flex !important;
|
|
277
278
|
align-items: center !important;
|
|
278
279
|
gap: var(--ui-space-2) !important;
|
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
<defs>
|
|
11
11
|
<prop name="href" type="string" default="">The link's destination, shown when there is no label.</prop>
|
|
12
12
|
<prop name="openHref" type="string" default=""
|
|
13
|
-
>The
|
|
14
|
-
mailto, tel, or relative address.</prop>
|
|
13
|
+
>The navigable destination for the label and Open link. Same-origin addresses open in the current tab; other destinations open in a new tab. Without it the
|
|
14
|
+
destination is plain text. The editor passes the destination only when it is an http, https, mailto, tel, or relative address.</prop>
|
|
15
15
|
<prop name="label" type="string" default="">The resolved destination's name, such as a page title, shown in place of the address.</prop>
|
|
16
16
|
<prop name="detail" type="string" default="">A second line under the label, such as where the destination lives.</prop>
|
|
17
17
|
<prop name="targetLabel" type="string" default="Item">What a resolved destination is called, as in "Page: Guide" for a screen reader.</prop>
|
|
18
|
+
<state name="openTarget" type="string" value="_blank"></state>
|
|
18
19
|
<state name="base" type="string" value="ui-editor-link-card"></state>
|
|
19
20
|
<computed name="resolved" from="$label != ''"></computed>
|
|
20
21
|
<computed name="shown" from="{ true: $label, false: $href }[concat($resolved)]"></computed>
|
|
@@ -24,10 +25,34 @@
|
|
|
24
25
|
<div>
|
|
25
26
|
<ui-card variant="elevated" padding="xs" size="sm">
|
|
26
27
|
<ui-cluster gap="xs" wrap="nowrap" role="group" aria-label="Link actions">
|
|
27
|
-
<ui-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
<ui-stack fill gap="none">
|
|
29
|
+
<ui-button
|
|
30
|
+
$if="$openHref != ''"
|
|
31
|
+
variant="link"
|
|
32
|
+
tone="neutral"
|
|
33
|
+
stretch
|
|
34
|
+
align="start"
|
|
35
|
+
from:href="$openHref"
|
|
36
|
+
from:target="$openTarget"
|
|
37
|
+
rel="noopener noreferrer"
|
|
38
|
+
from:title="$href"
|
|
39
|
+
from:aria-label="concat({ true: $targetLabel, false: 'URL' }[concat($resolved)], ': ', $shown)"
|
|
40
|
+
>
|
|
41
|
+
<ui-cluster gap="xs" wrap="nowrap">
|
|
42
|
+
<ui-icon from:name="{ true: 'file-text', false: 'link' }[concat($resolved)]"></ui-icon>
|
|
43
|
+
<ui-stack gap="none" fill>
|
|
44
|
+
<ui-text as="strong" size="sm" weight="medium" font="sans" truncate>{$shown}</ui-text>
|
|
45
|
+
<ui-text $if="$detail != ''" as="small" size="xs" tone="secondary" font="sans" truncate>{$detail}</ui-text>
|
|
46
|
+
</ui-stack>
|
|
47
|
+
</ui-cluster>
|
|
48
|
+
</ui-button>
|
|
49
|
+
<ui-cluster $if="$openHref = ''" gap="xs" wrap="nowrap">
|
|
50
|
+
<ui-icon from:name="{ true: 'file-text', false: 'link' }[concat($resolved)]"></ui-icon>
|
|
51
|
+
<ui-stack gap="none" fill from:title="$href" from:aria-label="concat({ true: $targetLabel, false: 'URL' }[concat($resolved)], ': ', $shown)">
|
|
52
|
+
<ui-text as="strong" size="sm" weight="medium" font="sans" truncate>{$shown}</ui-text>
|
|
53
|
+
<ui-text $if="$detail != ''" as="small" size="xs" tone="secondary" font="sans" truncate>{$detail}</ui-text>
|
|
54
|
+
</ui-stack>
|
|
55
|
+
</ui-cluster>
|
|
31
56
|
</ui-stack>
|
|
32
57
|
<template $if="$openHref != ''">
|
|
33
58
|
<ui-button
|
|
@@ -36,7 +61,7 @@
|
|
|
36
61
|
tone="neutral"
|
|
37
62
|
size="sm"
|
|
38
63
|
from:href="$openHref"
|
|
39
|
-
target="
|
|
64
|
+
from:target="$openTarget"
|
|
40
65
|
rel="noopener noreferrer"
|
|
41
66
|
aria-label="Open link"
|
|
42
67
|
><ui-icon name="external-link"></ui-icon></ui-button>
|
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
export function connect(host) {
|
|
4
4
|
const element = host.element;
|
|
5
5
|
if (host.state.base === "ui-editor-link-card") host.state.base = `ui-editor-link-card-${Math.random().toString(36).slice(2, 11)}`;
|
|
6
|
+
const stop = host.effect(() => {
|
|
7
|
+
const href = host.props.openHref.value;
|
|
8
|
+
const base = element.ownerDocument.baseURI;
|
|
9
|
+
try {
|
|
10
|
+
host.state.openTarget = new URL(href, base).origin === element.ownerDocument.location.origin ? "_self" : "_blank";
|
|
11
|
+
} catch {
|
|
12
|
+
host.state.openTarget = "_blank";
|
|
13
|
+
}
|
|
14
|
+
});
|
|
6
15
|
const action = (event) => {
|
|
7
16
|
const control = event.target.closest?.("[data-link-action]");
|
|
8
17
|
return control && element.contains(control) ? control.dataset.linkAction : null;
|
|
@@ -16,6 +25,7 @@ export function connect(host) {
|
|
|
16
25
|
element.addEventListener("pointerdown", onPointerDown);
|
|
17
26
|
element.addEventListener("click", onClick);
|
|
18
27
|
return () => {
|
|
28
|
+
stop();
|
|
19
29
|
element.removeEventListener("pointerdown", onPointerDown);
|
|
20
30
|
element.removeEventListener("click", onClick);
|
|
21
31
|
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<link rel="component" href="../ui-icon-button/ui-icon-button.html">
|
|
2
|
+
<link rel="component" href="../ui-icon/ui-icon.html">
|
|
3
|
+
<template component="ui-notice-stripe" module="./ui-notice-stripe.js">
|
|
4
|
+
<defs>
|
|
5
|
+
<prop name="tone" type="keyword" values="neutral, info, success, warning, danger" default="info"
|
|
6
|
+
>Semantic message tone. Danger uses alert semantics; other tones use a polite status.</prop>
|
|
7
|
+
<prop name="dismissible" type="boolean" default="false"
|
|
8
|
+
>Show a close control that requests dismissal. The consumer owns removing or hiding the stripe.</prop>
|
|
9
|
+
<prop name="dismissLabel" type="string" default="Dismiss notification"
|
|
10
|
+
>Accessible name of the close control, including translated or message-specific wording.</prop>
|
|
11
|
+
<event name="dismiss" type="object">
|
|
12
|
+
<prop name="reason" required type="keyword" values="action"></prop>
|
|
13
|
+
<prop name="trigger" required type="keyword" values="keyboard, pointer, programmatic"></prop>
|
|
14
|
+
</event>
|
|
15
|
+
</defs>
|
|
16
|
+
<div from:role="{ neutral: 'status', info: 'status', success: 'status', warning: 'status', danger: 'alert' }[$tone]">
|
|
17
|
+
<div class="content">
|
|
18
|
+
<div class="message"><slot></slot></div>
|
|
19
|
+
<div class="actions"><slot name="actions"></slot></div>
|
|
20
|
+
</div>
|
|
21
|
+
<ui-icon-button $if="$dismissible" class="dismiss" size="sm" variant="ghost" from:label="$dismissLabel">
|
|
22
|
+
<ui-icon name="x"></ui-icon>
|
|
23
|
+
</ui-icon-button>
|
|
24
|
+
</div>
|
|
25
|
+
<style>
|
|
26
|
+
:host {
|
|
27
|
+
--_ui-notice-stripe-surface: var(--ui-info-soft);
|
|
28
|
+
--_ui-notice-stripe-border: var(--ui-info-soft-border);
|
|
29
|
+
--_ui-surface-text: var(--ui-info-subtle-text);
|
|
30
|
+
display: flex !important;
|
|
31
|
+
align-items: center !important;
|
|
32
|
+
gap: var(--ui-space-2) !important;
|
|
33
|
+
box-sizing: border-box !important;
|
|
34
|
+
inline-size: 100%;
|
|
35
|
+
min-inline-size: 0;
|
|
36
|
+
min-block-size: 44px;
|
|
37
|
+
margin: 0 !important;
|
|
38
|
+
padding: var(--ui-space-1) var(--ui-space-3) !important;
|
|
39
|
+
border: 0;
|
|
40
|
+
border-block-end: var(--ui-border-width) solid var(--_ui-notice-stripe-border);
|
|
41
|
+
border-radius: 0;
|
|
42
|
+
background: var(--_ui-notice-stripe-surface);
|
|
43
|
+
color: var(--_ui-surface-text);
|
|
44
|
+
font-family: var(--ui-font-family-sans);
|
|
45
|
+
font-size: var(--ui-font-size-sm);
|
|
46
|
+
font-weight: var(--ui-font-normal);
|
|
47
|
+
line-height: var(--ui-line-height-md);
|
|
48
|
+
}
|
|
49
|
+
:host([tone="neutral"]) {
|
|
50
|
+
--_ui-notice-stripe-surface: var(--ui-surface-muted);
|
|
51
|
+
--_ui-notice-stripe-border: var(--ui-border-strong);
|
|
52
|
+
--_ui-surface-text: var(--ui-text-primary);
|
|
53
|
+
}
|
|
54
|
+
:host([tone="success"]) {
|
|
55
|
+
--_ui-notice-stripe-surface: var(--ui-success-soft);
|
|
56
|
+
--_ui-notice-stripe-border: var(--ui-success-soft-border);
|
|
57
|
+
--_ui-surface-text: var(--ui-success-subtle-text);
|
|
58
|
+
}
|
|
59
|
+
:host([tone="warning"]) {
|
|
60
|
+
--_ui-notice-stripe-surface: var(--ui-warning-soft);
|
|
61
|
+
--_ui-notice-stripe-border: var(--ui-warning-soft-border);
|
|
62
|
+
--_ui-surface-text: var(--ui-warning-subtle-text);
|
|
63
|
+
}
|
|
64
|
+
:host([tone="danger"]) {
|
|
65
|
+
--_ui-notice-stripe-surface: var(--ui-danger-soft);
|
|
66
|
+
--_ui-notice-stripe-border: var(--ui-danger-soft-border);
|
|
67
|
+
--_ui-surface-text: var(--ui-danger-subtle-text);
|
|
68
|
+
}
|
|
69
|
+
.content {
|
|
70
|
+
display: flex !important;
|
|
71
|
+
flex: 1;
|
|
72
|
+
flex-wrap: wrap !important;
|
|
73
|
+
align-items: center !important;
|
|
74
|
+
gap: var(--ui-space-1) var(--ui-space-3) !important;
|
|
75
|
+
min-inline-size: 0;
|
|
76
|
+
}
|
|
77
|
+
.message {
|
|
78
|
+
flex: 1 1 16rem;
|
|
79
|
+
min-inline-size: 0;
|
|
80
|
+
overflow-wrap: anywhere;
|
|
81
|
+
}
|
|
82
|
+
.actions {
|
|
83
|
+
display: flex !important;
|
|
84
|
+
flex-wrap: wrap !important;
|
|
85
|
+
align-items: center !important;
|
|
86
|
+
justify-content: flex-end !important;
|
|
87
|
+
gap: var(--ui-space-2) !important;
|
|
88
|
+
min-inline-size: 0;
|
|
89
|
+
max-inline-size: 100%;
|
|
90
|
+
overflow-wrap: anywhere;
|
|
91
|
+
margin-inline-start: auto !important;
|
|
92
|
+
}
|
|
93
|
+
.actions:empty {
|
|
94
|
+
display: none !important;
|
|
95
|
+
}
|
|
96
|
+
.dismiss {
|
|
97
|
+
flex: none;
|
|
98
|
+
}
|
|
99
|
+
.message :slotted(a),
|
|
100
|
+
.actions :slotted(a) {
|
|
101
|
+
color: inherit;
|
|
102
|
+
text-decoration: underline;
|
|
103
|
+
text-underline-offset: 0.18em;
|
|
104
|
+
}
|
|
105
|
+
:host[hidden] {
|
|
106
|
+
display: none !important;
|
|
107
|
+
}
|
|
108
|
+
</style>
|
|
109
|
+
</template>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { trackTrigger } from "../shared/trigger.js";
|
|
2
|
+
|
|
3
|
+
/** Report dismissal intent without changing the consumer-owned visibility or message. */
|
|
4
|
+
export function connect(host) {
|
|
5
|
+
const [takeTrigger, stopTrigger] = trackTrigger(host);
|
|
6
|
+
const dismiss = (event) => {
|
|
7
|
+
const control = event.target.closest?.(".dismiss");
|
|
8
|
+
if (!control || control.parentElement !== host.element || !host.props.dismissible.value || event.defaultPrevented) return;
|
|
9
|
+
host.dispatch("dismiss", { reason: "action", trigger: takeTrigger() });
|
|
10
|
+
};
|
|
11
|
+
host.element.addEventListener("click", dismiss);
|
|
12
|
+
return () => { stopTrigger(); host.element.removeEventListener("click", dismiss); };
|
|
13
|
+
}
|