@reliability-design/web 1.1.1 → 1.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/dist/components/rel-accordion/rel-accordion.ts +17 -32
- package/dist/components/rel-alert/rel-alert.ts +34 -34
- package/dist/components/rel-avatar/rel-avatar.ts +5 -3
- package/dist/components/rel-badge/rel-badge.ts +2 -1
- package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +6 -6
- package/dist/components/rel-button/rel-button.ts +67 -21
- package/dist/components/rel-calendar/rel-calendar.ts +15 -8
- package/dist/components/rel-card/rel-card.ts +9 -17
- package/dist/components/rel-cardmedia/rel-cardmedia.ts +20 -23
- package/dist/components/rel-carousel/rel-carousel.ts +596 -468
- package/dist/components/rel-checkbox/rel-checkbox.ts +68 -16
- package/dist/components/rel-chip/rel-chip.ts +291 -244
- package/dist/components/rel-container/rel-container.ts +2 -2
- package/dist/components/rel-date-picker/rel-date-picker.ts +23 -19
- package/dist/components/rel-divider/rel-divider.ts +3 -3
- package/dist/components/rel-drawer/rel-drawer-footer.ts +0 -2
- package/dist/components/rel-drawer/rel-drawer.ts +41 -88
- package/dist/components/rel-kbd/rel-kbd.ts +94 -118
- package/dist/components/rel-layout/rel-layout.ts +49 -58
- package/dist/components/rel-menu/rel-menu.ts +359 -359
- package/dist/components/rel-menubar/rel-menubar-menu.css +3 -0
- package/dist/components/rel-menubar/rel-menubar-menu.ts +2 -1
- package/dist/components/rel-menubar/rel-menubar.ts +602 -605
- package/dist/components/rel-otp/rel-otp.ts +22 -25
- package/dist/components/rel-pagination/rel-pagination.ts +101 -57
- package/dist/components/rel-popover/rel-popover-content.ts +6 -5
- package/dist/components/rel-popover/rel-popover.ts +26 -7
- package/dist/components/rel-progress/rel-progress.ts +10 -9
- package/dist/components/rel-radio/rel-radio.ts +228 -172
- package/dist/components/rel-range-picker/rel-range-picker.css +349 -0
- package/dist/components/rel-range-picker/rel-range-picker.ts +1079 -0
- package/dist/components/rel-resizable/rel-resizable-handle.ts +8 -7
- package/dist/components/rel-segmented-button/rel-segmented-button.ts +41 -20
- package/dist/components/rel-select/rel-select.ts +103 -32
- package/dist/components/rel-sheet/rel-sheet.ts +362 -684
- package/dist/components/rel-slider/rel-slider.ts +49 -27
- package/dist/components/rel-snackbar/rel-snackbar.ts +28 -28
- package/dist/components/rel-stepper/rel-stepper.ts +11 -10
- package/dist/components/rel-switch/rel-switch.ts +7 -6
- package/dist/components/rel-tab/rel-tab.ts +15 -29
- package/dist/components/rel-textfield/rel-textfield.ts +144 -35
- package/dist/components/rel-toast/rel-toast.ts +25 -12
- package/dist/components/rel-tooltip/rel-tooltip.ts +123 -123
- package/dist/components/rel-topbar/rel-topbar-actions.ts +1 -0
- package/dist/components/rel-topbar/rel-topbar-brand.ts +1 -0
- package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +32 -2
- package/dist/components/rel-topbar/rel-topbar-dropdown.ts +1 -1
- package/dist/components/rel-topbar/rel-topbar-item.ts +15 -10
- package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +1 -0
- package/dist/components/rel-topbar/rel-topbar-profile.ts +30 -56
- package/dist/components/rel-topbar/rel-topbar-utilities.ts +1 -0
- package/dist/components/rel-topbar/rel-topbar.ts +137 -28
- package/dist/index.d.mts +153 -178
- package/dist/index.d.ts +153 -178
- package/dist/index.js +4711 -3875
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4047 -3202
- package/dist/index.mjs.map +1 -1
- package/dist/rel-menubar-menu-BEEQDAXW.css +3 -0
- package/dist/styles/vars-v2.css +525 -0
- package/dist/styles/vars.css +346 -346
- package/dist/{vars-TBB4BMSD.css → vars-I2PC74XD.css} +346 -346
- package/dist/vars-v2-VMGWTFJZ.css +525 -0
- package/package.json +2 -1
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { LitElement, html, css } from "lit";
|
|
2
2
|
import { customElement, property } from "lit/decorators.js";
|
|
3
|
+
import "../../styles/vars-v2.css";
|
|
3
4
|
|
|
4
5
|
@customElement("rel-topbar-dropdown-item")
|
|
5
6
|
export class RelTopbarDropdownItem extends LitElement {
|
|
6
7
|
@property({ type: String }) label: string = "";
|
|
7
8
|
@property({ type: String }) href: string = "#";
|
|
9
|
+
@property({ type: Boolean, reflect: true }) active = false;
|
|
8
10
|
|
|
9
11
|
static styles = css`
|
|
10
12
|
.dropdown-item {
|
|
11
13
|
display: block;
|
|
12
|
-
padding: var(--rel-spacing-space-xs) var(--rel-spacing-space-md);
|
|
14
|
+
padding: var(--rel-spacing-space-xs, 8px) var(--rel-spacing-space-md, 16px);
|
|
13
15
|
color: var(--rel-color-text-primary);
|
|
14
16
|
text-decoration: none;
|
|
15
17
|
font-size: var(--rel-fontSizes-md);
|
|
@@ -18,11 +20,39 @@ export class RelTopbarDropdownItem extends LitElement {
|
|
|
18
20
|
|
|
19
21
|
.dropdown-item:hover {
|
|
20
22
|
background: var(--rel-color-bg-hover);
|
|
23
|
+
border-radius: 0;
|
|
21
24
|
}
|
|
25
|
+
|
|
26
|
+
:host([active]) .dropdown-item {
|
|
27
|
+
color: var(--rel-topbar-item-active-color, var(--rel-colors-green-tertiary, #00a86b));
|
|
28
|
+
font-weight: var(--rel-fontWeights-semibold, 600);
|
|
29
|
+
}
|
|
30
|
+
|
|
22
31
|
`;
|
|
23
32
|
|
|
33
|
+
private _handleClick(e: MouseEvent) {
|
|
34
|
+
if (this.hasAttribute("disabled")) {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
this.dispatchEvent(new CustomEvent("rel-select", {
|
|
40
|
+
detail: { value: this.href, label: this.label },
|
|
41
|
+
bubbles: true,
|
|
42
|
+
composed: true,
|
|
43
|
+
}));
|
|
44
|
+
this.dispatchEvent(new CustomEvent("rel-nav-select", {
|
|
45
|
+
detail: { value: this.href, label: this.label },
|
|
46
|
+
bubbles: true,
|
|
47
|
+
composed: true,
|
|
48
|
+
}));
|
|
49
|
+
this.active = true;
|
|
50
|
+
const siblings = this.parentElement?.querySelectorAll("rel-topbar-dropdown-item");
|
|
51
|
+
siblings?.forEach(s => { if (s !== this) (s as any).active = false; });
|
|
52
|
+
}
|
|
53
|
+
|
|
24
54
|
render() {
|
|
25
|
-
return html`<a href="${this.href}" class="dropdown-item">${this.label}</a>`;
|
|
55
|
+
return html`<a href="${this.href}" class="dropdown-item" @click=${this._handleClick}>${this.label}</a>`;
|
|
26
56
|
}
|
|
27
57
|
}
|
|
28
58
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LitElement, html, css } from "lit";
|
|
2
2
|
import { customElement } from "lit/decorators.js";
|
|
3
|
+
import "../../styles/vars-v2.css";
|
|
3
4
|
|
|
4
5
|
@customElement("rel-topbar-dropdown")
|
|
5
6
|
export class RelTopbarDropdown extends LitElement {
|
|
@@ -9,7 +10,6 @@ export class RelTopbarDropdown extends LitElement {
|
|
|
9
10
|
flex-direction: column;
|
|
10
11
|
min-width: 160px;
|
|
11
12
|
background: var(--rel-color-bg-primary);
|
|
12
|
-
border: 1px solid var(--rel-color-border-default);
|
|
13
13
|
border-radius: var(--rel-borders-radius-border-radius-200);
|
|
14
14
|
box-shadow: var(--rel-shadow-200);
|
|
15
15
|
padding: var(--rel-spacing-space-2xs) 0;
|
|
@@ -2,6 +2,8 @@ import { LitElement, html, css } from "lit";
|
|
|
2
2
|
import { customElement, property, state } from "lit/decorators.js";
|
|
3
3
|
import "./rel-topbar-dropdown";
|
|
4
4
|
import "./rel-topbar-dropdown-item";
|
|
5
|
+
import "../../styles/vars-v2.css";
|
|
6
|
+
import "@reliability-design/icons/rel-icon";
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* `rel-topbar-item` — A navigation item within rel-topbar.
|
|
@@ -57,6 +59,10 @@ export class RelTopbarItem extends LitElement {
|
|
|
57
59
|
font-family: var(--rel-fontFamilies-primary, Poppins, sans-serif);
|
|
58
60
|
}
|
|
59
61
|
|
|
62
|
+
:host([hidden]) {
|
|
63
|
+
display: none !important;
|
|
64
|
+
}
|
|
65
|
+
|
|
60
66
|
/* ─── Trigger (shared for <a> and <button>) ─────────────────────── */
|
|
61
67
|
.trigger {
|
|
62
68
|
display: inline-flex;
|
|
@@ -113,6 +119,10 @@ export class RelTopbarItem extends LitElement {
|
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
/* Disabled */
|
|
122
|
+
:host([disabled]) {
|
|
123
|
+
cursor: not-allowed;
|
|
124
|
+
}
|
|
125
|
+
|
|
116
126
|
:host([disabled]) .trigger {
|
|
117
127
|
opacity: 0.45;
|
|
118
128
|
cursor: not-allowed;
|
|
@@ -149,8 +159,8 @@ export class RelTopbarItem extends LitElement {
|
|
|
149
159
|
top: calc(100% + 6px);
|
|
150
160
|
left: 0;
|
|
151
161
|
min-width: 200px;
|
|
152
|
-
background: var(--rel-
|
|
153
|
-
border: var(--rel-borders-width-stroke-100, 1px) solid var(--rel-border-default
|
|
162
|
+
background: var(--rel-color-bg-primary);
|
|
163
|
+
border: var(--rel-borders-width-stroke-100, 1px) solid var(--rel-color-border-default);
|
|
154
164
|
border-radius: var(--rel-borders-radius-border-radius-200, 8px);
|
|
155
165
|
box-shadow: var(--rel-shadows-shadow-300);
|
|
156
166
|
padding: var(--rel-spacing-space-2xs, 4px);
|
|
@@ -263,7 +273,9 @@ export class RelTopbarItem extends LitElement {
|
|
|
263
273
|
<slot>${this.label ?? ""}</slot>
|
|
264
274
|
<span class="suffix"><slot name="suffix"></slot></span>
|
|
265
275
|
${showChevron
|
|
266
|
-
? html`<span class="chevron" aria-hidden="true"
|
|
276
|
+
? html`<span class="chevron" aria-hidden="true">
|
|
277
|
+
<rel-icon name="chevron-down" size="sm"></rel-icon>
|
|
278
|
+
</span>`
|
|
267
279
|
: null}
|
|
268
280
|
`;
|
|
269
281
|
|
|
@@ -306,10 +318,3 @@ export class RelTopbarItem extends LitElement {
|
|
|
306
318
|
}
|
|
307
319
|
}
|
|
308
320
|
|
|
309
|
-
function _iconChevron() {
|
|
310
|
-
return html`
|
|
311
|
-
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" aria-hidden="true" focusable="false">
|
|
312
|
-
<path d="M3 5L7 9L11 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
313
|
-
</svg>
|
|
314
|
-
`;
|
|
315
|
-
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { LitElement, html, css } from "lit";
|
|
2
2
|
import { customElement, property } from "lit/decorators.js";
|
|
3
|
+
import "../../styles/vars-v2.css";
|
|
4
|
+
import "../rel-avatar/rel-avatar.js";
|
|
3
5
|
|
|
4
6
|
export type TopbarProfileType = "avatar" | "carrier";
|
|
5
7
|
export type TopbarRewardTier = "gold" | "silver" | "platinum" | "bronze" | "regular";
|
|
@@ -37,7 +39,7 @@ export class RelTopbarProfile extends LitElement {
|
|
|
37
39
|
--_avatar-size: 36px;
|
|
38
40
|
--_avatar-size-sm: 28px;
|
|
39
41
|
--_avatar-bg: var(--rel-colors-green-primary, #00f49c);
|
|
40
|
-
--_avatar-color: var(--rel-
|
|
42
|
+
--_avatar-color: var(--rel-color-text-primary);
|
|
41
43
|
|
|
42
44
|
/* Reward tier colours (reference existing token palette) */
|
|
43
45
|
--rel-topbar-reward-gold: var(--rel-colors-gold, #d6ba00);
|
|
@@ -49,7 +51,7 @@ export class RelTopbarProfile extends LitElement {
|
|
|
49
51
|
--rel-topbar-reward-bronze: var(--rel-colors-bronze, #7d5300);
|
|
50
52
|
--rel-topbar-reward-bronze-bg: var(--rel-colors-bronze-secondary, #e2dac7);
|
|
51
53
|
--rel-topbar-reward-regular: var(--rel-colors-gray-divider, #bdbdbd);
|
|
52
|
-
--rel-topbar-reward-regular-bg: var(--rel-
|
|
54
|
+
--rel-topbar-reward-regular-bg: var(--rel-color-bg-secondary);
|
|
53
55
|
|
|
54
56
|
display: inline-flex;
|
|
55
57
|
align-items: center;
|
|
@@ -58,27 +60,6 @@ export class RelTopbarProfile extends LitElement {
|
|
|
58
60
|
cursor: pointer;
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
/* ─── Avatar circle ─────────────────────────────────────────────── */
|
|
62
|
-
.avatar {
|
|
63
|
-
width: var(--_avatar-size);
|
|
64
|
-
height: var(--_avatar-size);
|
|
65
|
-
border-radius: var(--_profile-radius);
|
|
66
|
-
background: var(--_avatar-bg);
|
|
67
|
-
color: var(--_avatar-color);
|
|
68
|
-
display: flex;
|
|
69
|
-
align-items: center;
|
|
70
|
-
justify-content: center;
|
|
71
|
-
font-size: var(--rel-fontSizes-sm, 12px);
|
|
72
|
-
font-weight: var(--rel-fontWeights-semibold, 600);
|
|
73
|
-
flex-shrink: 0;
|
|
74
|
-
user-select: none;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
:host([compact]) .avatar {
|
|
78
|
-
width: var(--_avatar-size-sm);
|
|
79
|
-
height: var(--_avatar-size-sm);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
63
|
/* ─── Name / subtitle stack ─────────────────────────────────────── */
|
|
83
64
|
.text-stack {
|
|
84
65
|
display: flex;
|
|
@@ -94,7 +75,7 @@ export class RelTopbarProfile extends LitElement {
|
|
|
94
75
|
.name {
|
|
95
76
|
font-size: var(--rel-fontSizes-md, 14px);
|
|
96
77
|
font-weight: var(--rel-fontWeights-medium, 500);
|
|
97
|
-
color: var(--rel-text-primary
|
|
78
|
+
color: var(--rel-color-text-primary);
|
|
98
79
|
line-height: var(--rel-lineHeights-md, 20px);
|
|
99
80
|
white-space: nowrap;
|
|
100
81
|
overflow: hidden;
|
|
@@ -104,7 +85,7 @@ export class RelTopbarProfile extends LitElement {
|
|
|
104
85
|
.subtitle {
|
|
105
86
|
font-size: var(--rel-fontSizes-sm, 12px);
|
|
106
87
|
font-weight: var(--rel-fontWeights-regular, 400);
|
|
107
|
-
color: var(--rel-text-placeholder
|
|
88
|
+
color: var(--rel-color-text-placeholder);
|
|
108
89
|
line-height: var(--rel-lineHeights-sm, 18px);
|
|
109
90
|
white-space: nowrap;
|
|
110
91
|
overflow: hidden;
|
|
@@ -126,56 +107,30 @@ export class RelTopbarProfile extends LitElement {
|
|
|
126
107
|
}
|
|
127
108
|
|
|
128
109
|
/* Gold */
|
|
129
|
-
:host([reward="gold"]) .avatar {
|
|
130
|
-
background: var(--rel-topbar-reward-gold-bg);
|
|
131
|
-
color: var(--rel-topbar-reward-gold);
|
|
132
|
-
border: 1.5px solid var(--rel-topbar-reward-gold);
|
|
133
|
-
}
|
|
134
110
|
:host([reward="gold"]) .reward-badge {
|
|
135
111
|
background: var(--rel-topbar-reward-gold-bg);
|
|
136
112
|
color: var(--rel-topbar-reward-gold);
|
|
137
113
|
}
|
|
138
114
|
|
|
139
115
|
/* Silver */
|
|
140
|
-
:host([reward="silver"]) .avatar {
|
|
141
|
-
background: var(--rel-topbar-reward-silver-bg);
|
|
142
|
-
color: var(--rel-colors-gray-primary, #333);
|
|
143
|
-
border: 1.5px solid var(--rel-topbar-reward-silver);
|
|
144
|
-
}
|
|
145
116
|
:host([reward="silver"]) .reward-badge {
|
|
146
117
|
background: var(--rel-topbar-reward-silver-bg);
|
|
147
118
|
color: var(--rel-colors-gray-primary, #333);
|
|
148
119
|
}
|
|
149
120
|
|
|
150
121
|
/* Platinum */
|
|
151
|
-
:host([reward="platinum"]) .avatar {
|
|
152
|
-
background: var(--rel-topbar-reward-platinum-bg);
|
|
153
|
-
color: var(--rel-topbar-reward-platinum);
|
|
154
|
-
border: 1.5px solid var(--rel-topbar-reward-platinum);
|
|
155
|
-
}
|
|
156
122
|
:host([reward="platinum"]) .reward-badge {
|
|
157
123
|
background: var(--rel-topbar-reward-platinum-bg);
|
|
158
124
|
color: var(--rel-topbar-reward-platinum);
|
|
159
125
|
}
|
|
160
126
|
|
|
161
127
|
/* Bronze */
|
|
162
|
-
:host([reward="bronze"]) .avatar {
|
|
163
|
-
background: var(--rel-topbar-reward-bronze-bg);
|
|
164
|
-
color: var(--rel-topbar-reward-bronze);
|
|
165
|
-
border: 1.5px solid var(--rel-topbar-reward-bronze);
|
|
166
|
-
}
|
|
167
128
|
:host([reward="bronze"]) .reward-badge {
|
|
168
129
|
background: var(--rel-topbar-reward-bronze-bg);
|
|
169
130
|
color: var(--rel-topbar-reward-bronze);
|
|
170
131
|
}
|
|
171
132
|
|
|
172
133
|
/* Regular */
|
|
173
|
-
:host([reward="regular"]) .avatar,
|
|
174
|
-
:host(:not([reward])) .avatar {
|
|
175
|
-
background: var(--rel-topbar-reward-regular-bg);
|
|
176
|
-
color: var(--rel-colors-gray-primary, #333);
|
|
177
|
-
border: 1.5px solid var(--rel-topbar-reward-regular);
|
|
178
|
-
}
|
|
179
134
|
:host([reward="regular"]) .reward-badge {
|
|
180
135
|
background: var(--rel-topbar-reward-regular-bg);
|
|
181
136
|
color: var(--rel-colors-gray-primary, #333);
|
|
@@ -189,7 +144,7 @@ export class RelTopbarProfile extends LitElement {
|
|
|
189
144
|
padding: var(--rel-spacing-space-2xs, 4px) var(--rel-spacing-space-xs, 8px);
|
|
190
145
|
border-radius: var(--rel-borders-radius-border-radius-200, 8px);
|
|
191
146
|
background: var(--rel-surface-secondary, #fafafa);
|
|
192
|
-
border: var(--rel-borders-width-stroke-100, 1px) solid var(--rel-border-default
|
|
147
|
+
border: var(--rel-borders-width-stroke-100, 1px) solid var(--rel-color-border-default);
|
|
193
148
|
}
|
|
194
149
|
|
|
195
150
|
:host([compact]) .carrier-tile {
|
|
@@ -217,9 +172,12 @@ export class RelTopbarProfile extends LitElement {
|
|
|
217
172
|
|
|
218
173
|
private _renderAvatar() {
|
|
219
174
|
return html`
|
|
220
|
-
<
|
|
221
|
-
|
|
222
|
-
|
|
175
|
+
<rel-avatar
|
|
176
|
+
type="text"
|
|
177
|
+
text=${this.initials ?? ""}
|
|
178
|
+
size=${this.compact ? "xs" : "sm"}
|
|
179
|
+
bg=${this._avatarBg()}
|
|
180
|
+
></rel-avatar>
|
|
223
181
|
${!this.compact && (this.name || this.subtitle)
|
|
224
182
|
? html`
|
|
225
183
|
<div class="text-stack">
|
|
@@ -231,12 +189,28 @@ export class RelTopbarProfile extends LitElement {
|
|
|
231
189
|
`;
|
|
232
190
|
}
|
|
233
191
|
|
|
192
|
+
private _avatarBg(): string {
|
|
193
|
+
const map: Record<string, string> = {
|
|
194
|
+
gold: "var(--rel-colors-gold)",
|
|
195
|
+
platinum: "var(--rel-colors-platinum)",
|
|
196
|
+
silver: "var(--rel-colors-silver)",
|
|
197
|
+
bronze: "var(--rel-colors-bronze)",
|
|
198
|
+
regular: "var(--rel-colors-green-primary)",
|
|
199
|
+
};
|
|
200
|
+
return map[this.reward] ?? "var(--rel-colors-green-primary)";
|
|
201
|
+
}
|
|
202
|
+
|
|
234
203
|
private _renderCarrier() {
|
|
235
204
|
const rewardLabel = this.reward.charAt(0).toUpperCase() + this.reward.slice(1);
|
|
236
205
|
|
|
237
206
|
return html`
|
|
238
207
|
<div class="carrier-tile" role="img" aria-label="${this.name ?? "Profile"} – ${rewardLabel} member">
|
|
239
|
-
<
|
|
208
|
+
<rel-avatar
|
|
209
|
+
type="text"
|
|
210
|
+
text=${this.initials ?? ""}
|
|
211
|
+
size="sm"
|
|
212
|
+
bg=${this._avatarBg()}
|
|
213
|
+
></rel-avatar>
|
|
240
214
|
<div class="carrier-meta">
|
|
241
215
|
${this.name ? html`<span class="name">${this.name}</span>` : null}
|
|
242
216
|
<span class="reward-badge">${rewardLabel}</span>
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { LitElement, html, css } from "lit";
|
|
2
|
-
import { customElement, property } from "lit/decorators.js";
|
|
2
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
3
|
+
import "../../styles/vars-v2.css";
|
|
4
|
+
import "@reliability-design/icons/rel-icon";
|
|
3
5
|
import "./rel-topbar-brand";
|
|
4
6
|
import "./rel-topbar-actions";
|
|
5
7
|
import "./rel-topbar-utilities";
|
|
6
8
|
import "./rel-topbar-mobile-panel";
|
|
9
|
+
import "./rel-topbar-dropdown";
|
|
10
|
+
import "./rel-topbar-dropdown-item";
|
|
7
11
|
|
|
8
12
|
export type TopbarVariant = "customer" | "carrier";
|
|
9
13
|
export type TopbarForceLayout = "auto" | "desktop" | "tablet" | "mobile";
|
|
@@ -47,20 +51,28 @@ export class RelTopbar extends LitElement {
|
|
|
47
51
|
*/
|
|
48
52
|
@property({ type: String }) forceLayout: TopbarForceLayout = "auto";
|
|
49
53
|
|
|
54
|
+
private _overflowItems: Element[] = [];
|
|
55
|
+
@state() private _overflowCount: number = 0;
|
|
56
|
+
@state() private _overflowItemsData: Array<{ label: string; href: string; disabled: boolean }> = [];
|
|
57
|
+
private _resizeObserver?: ResizeObserver;
|
|
58
|
+
private _resizeTimer?: number;
|
|
59
|
+
private _measuring = false;
|
|
60
|
+
private _lastNavWidth = 0;
|
|
61
|
+
|
|
50
62
|
static styles = css`
|
|
51
63
|
/* ─── Component tokens ─────────────────────────────────────────── */
|
|
52
64
|
:host {
|
|
53
65
|
--rel-topbar-height: 64px;
|
|
54
66
|
--rel-topbar-height-compact: 48px;
|
|
55
|
-
--rel-topbar-bg: var(--rel-
|
|
67
|
+
--rel-topbar-bg: var(--rel-color-bg-primary);
|
|
56
68
|
--rel-topbar-border-color: var(--rel-border-default, #ddd);
|
|
57
|
-
--rel-topbar-item-color: var(--rel-text-primary
|
|
69
|
+
--rel-topbar-item-color: var(--rel-color-text-primary);
|
|
58
70
|
--rel-topbar-item-active-color: var(--rel-colors-green-tertiary, #00a86b);
|
|
59
71
|
--rel-topbar-item-active-indicator: var(--rel-colors-green-primary, #00f49c);
|
|
60
|
-
--rel-topbar-item-hover-bg: var(--rel-
|
|
72
|
+
--rel-topbar-item-hover-bg: var(--rel-color-bg-secondary);
|
|
61
73
|
--rel-topbar-divider-color: var(--rel-border-divider, #bdbdbd);
|
|
62
|
-
--rel-topbar-carrier-action-bg: var(--rel-
|
|
63
|
-
--rel-topbar-carrier-action-color: var(--rel-
|
|
74
|
+
--rel-topbar-carrier-action-bg: var(--rel-color-text-primary);
|
|
75
|
+
--rel-topbar-carrier-action-color: var(--rel-color-bg-primary);
|
|
64
76
|
--rel-topbar-z: 100;
|
|
65
77
|
|
|
66
78
|
display: block;
|
|
@@ -102,7 +114,7 @@ export class RelTopbar extends LitElement {
|
|
|
102
114
|
.nav-region {
|
|
103
115
|
display: flex;
|
|
104
116
|
align-items: center;
|
|
105
|
-
flex: 1;
|
|
117
|
+
flex: 1 1 0;
|
|
106
118
|
gap: var(--rel-spacing-space-2xs, 4px);
|
|
107
119
|
min-width: 0;
|
|
108
120
|
}
|
|
@@ -112,6 +124,7 @@ export class RelTopbar extends LitElement {
|
|
|
112
124
|
display: flex;
|
|
113
125
|
align-items: center;
|
|
114
126
|
flex-shrink: 0;
|
|
127
|
+
margin-left: auto;
|
|
115
128
|
gap: var(--rel-spacing-space-xs, 8px);
|
|
116
129
|
}
|
|
117
130
|
|
|
@@ -180,6 +193,32 @@ export class RelTopbar extends LitElement {
|
|
|
180
193
|
display: block;
|
|
181
194
|
}
|
|
182
195
|
|
|
196
|
+
.mobile-overflow-nav {
|
|
197
|
+
display: flex;
|
|
198
|
+
flex-direction: column;
|
|
199
|
+
padding: var(--rel-spacing-space-xs, 8px) 0;
|
|
200
|
+
border-top: 1px solid var(--rel-topbar-border-color);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.mobile-overflow-item {
|
|
204
|
+
display: block;
|
|
205
|
+
padding: var(--rel-spacing-space-xs, 8px) var(--rel-spacing-space-xl, 24px);
|
|
206
|
+
color: var(--rel-topbar-item-color);
|
|
207
|
+
font-family: var(--rel-fontFamilies-primary, Poppins, sans-serif);
|
|
208
|
+
font-size: var(--rel-fontSizes-md, 14px);
|
|
209
|
+
font-weight: var(--rel-fontWeights-medium, 500);
|
|
210
|
+
text-decoration: none;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.mobile-overflow-item:hover {
|
|
214
|
+
background: var(--rel-topbar-item-hover-bg);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.mobile-overflow-item.disabled {
|
|
218
|
+
opacity: 0.45;
|
|
219
|
+
pointer-events: none;
|
|
220
|
+
}
|
|
221
|
+
|
|
183
222
|
/* ─── Responsive: auto mode (CSS media queries) ─────────────────── */
|
|
184
223
|
@media (max-width: 768px) {
|
|
185
224
|
.topbar:not(.force-desktop) .nav-region {
|
|
@@ -217,6 +256,69 @@ export class RelTopbar extends LitElement {
|
|
|
217
256
|
}
|
|
218
257
|
`;
|
|
219
258
|
|
|
259
|
+
override firstUpdated() {
|
|
260
|
+
const navRegion = this.renderRoot.querySelector(".nav-region") as HTMLElement;
|
|
261
|
+
if (navRegion) {
|
|
262
|
+
this._resizeObserver = new ResizeObserver(() => {
|
|
263
|
+
clearTimeout(this._resizeTimer);
|
|
264
|
+
this._resizeTimer = window.setTimeout(() => this._measureNav(), 150);
|
|
265
|
+
});
|
|
266
|
+
this._resizeObserver.observe(navRegion);
|
|
267
|
+
}
|
|
268
|
+
requestAnimationFrame(() => this._measureNav());
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
override disconnectedCallback() {
|
|
272
|
+
super.disconnectedCallback();
|
|
273
|
+
this._resizeObserver?.disconnect();
|
|
274
|
+
clearTimeout(this._resizeTimer);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
private _measureNav() {
|
|
278
|
+
if (this._measuring) return;
|
|
279
|
+
this._measuring = true;
|
|
280
|
+
const navRegion = this.renderRoot.querySelector(".nav-region") as HTMLElement;
|
|
281
|
+
if (!navRegion) return;
|
|
282
|
+
const navSlot = this.renderRoot.querySelector('slot[name="nav"]') as HTMLSlotElement;
|
|
283
|
+
if (!navSlot) return;
|
|
284
|
+
const items = Array.from(navSlot.assignedElements()).filter(
|
|
285
|
+
el => el.tagName.toLowerCase() !== "rel-topbar-item" || !el.hasAttribute("data-more")
|
|
286
|
+
);
|
|
287
|
+
const navWidth = navRegion.getBoundingClientRect().width;
|
|
288
|
+
if (Math.abs(navWidth - this._lastNavWidth) < 2) return;
|
|
289
|
+
this._lastNavWidth = navWidth;
|
|
290
|
+
const available = navWidth - 120;
|
|
291
|
+
|
|
292
|
+
let accumulated = 0;
|
|
293
|
+
let firstOverflowIndex = items.length;
|
|
294
|
+
for (let i = 0; i < items.length; i++) {
|
|
295
|
+
accumulated += items[i].getBoundingClientRect().width;
|
|
296
|
+
if (accumulated > available) {
|
|
297
|
+
firstOverflowIndex = i;
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const overflowingElements = Array.from(items).slice(firstOverflowIndex);
|
|
303
|
+
this._overflowItems = overflowingElements;
|
|
304
|
+
this._overflowCount = overflowingElements.length;
|
|
305
|
+
this._overflowItemsData = overflowingElements.map(el => ({
|
|
306
|
+
label: el.getAttribute("label") ?? "",
|
|
307
|
+
href: el.getAttribute("href") ?? "",
|
|
308
|
+
disabled: el.hasAttribute("disabled"),
|
|
309
|
+
}));
|
|
310
|
+
|
|
311
|
+
for (const el of items) {
|
|
312
|
+
if (overflowingElements.includes(el)) {
|
|
313
|
+
el.setAttribute("hidden", "");
|
|
314
|
+
} else {
|
|
315
|
+
el.removeAttribute("hidden");
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
this._measuring = false;
|
|
320
|
+
}
|
|
321
|
+
|
|
220
322
|
private onRouterSlotChange(e: Event) {
|
|
221
323
|
const slot = e.target as HTMLSlotElement;
|
|
222
324
|
for (const el of slot.assignedElements({ flatten: true })) {
|
|
@@ -265,7 +367,20 @@ export class RelTopbar extends LitElement {
|
|
|
265
367
|
</div>
|
|
266
368
|
|
|
267
369
|
<nav class="nav-region" aria-label="Primary">
|
|
268
|
-
<slot name="nav"></slot>
|
|
370
|
+
<slot name="nav" @slotchange=${this._measureNav}></slot>
|
|
371
|
+
${this._overflowCount > 0 ? html`
|
|
372
|
+
<rel-topbar-item label="More" expandable data-more>
|
|
373
|
+
<rel-topbar-dropdown slot="dropdown">
|
|
374
|
+
${this._overflowItemsData.map(item => html`
|
|
375
|
+
<rel-topbar-dropdown-item
|
|
376
|
+
label=${item.label}
|
|
377
|
+
href=${item.href}
|
|
378
|
+
?disabled=${item.disabled}
|
|
379
|
+
></rel-topbar-dropdown-item>
|
|
380
|
+
`)}
|
|
381
|
+
</rel-topbar-dropdown>
|
|
382
|
+
</rel-topbar-item>
|
|
383
|
+
` : null}
|
|
269
384
|
</nav>
|
|
270
385
|
|
|
271
386
|
<div class="right-region">
|
|
@@ -288,7 +403,9 @@ export class RelTopbar extends LitElement {
|
|
|
288
403
|
aria-controls="mobile-panel"
|
|
289
404
|
@click=${this.handleMenuToggle}
|
|
290
405
|
>
|
|
291
|
-
${this.mobileOpen
|
|
406
|
+
${this.mobileOpen
|
|
407
|
+
? html`<rel-icon name="close" size="md"></rel-icon>`
|
|
408
|
+
: html`<rel-icon name="hamburger" size="md"></rel-icon>`}
|
|
292
409
|
</button>
|
|
293
410
|
`
|
|
294
411
|
: null}
|
|
@@ -303,27 +420,19 @@ export class RelTopbar extends LitElement {
|
|
|
303
420
|
aria-label="Mobile navigation"
|
|
304
421
|
>
|
|
305
422
|
<slot name="mobile-panel"></slot>
|
|
423
|
+
${this._overflowItemsData.length > 0 ? html`
|
|
424
|
+
<div class="mobile-overflow-nav">
|
|
425
|
+
${this._overflowItemsData.map(item => html`
|
|
426
|
+
<a
|
|
427
|
+
class="mobile-overflow-item ${item.disabled ? "disabled" : ""}"
|
|
428
|
+
href=${item.href}
|
|
429
|
+
?aria-disabled=${item.disabled}
|
|
430
|
+
>${item.label}</a>
|
|
431
|
+
`)}
|
|
432
|
+
</div>
|
|
433
|
+
` : null}
|
|
306
434
|
</div>
|
|
307
435
|
`;
|
|
308
436
|
}
|
|
309
437
|
}
|
|
310
438
|
|
|
311
|
-
/* ─── Inline SVG helpers ──────────────────────────────────────────────── */
|
|
312
|
-
|
|
313
|
-
function _iconMenu() {
|
|
314
|
-
return html`
|
|
315
|
-
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" aria-hidden="true" focusable="false">
|
|
316
|
-
<rect x="2" y="5" width="16" height="1.5" rx="0.75" fill="currentColor"/>
|
|
317
|
-
<rect x="2" y="9.25" width="16" height="1.5" rx="0.75" fill="currentColor"/>
|
|
318
|
-
<rect x="2" y="13.5" width="16" height="1.5" rx="0.75" fill="currentColor"/>
|
|
319
|
-
</svg>
|
|
320
|
-
`;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function _iconClose() {
|
|
324
|
-
return html`
|
|
325
|
-
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" aria-hidden="true" focusable="false">
|
|
326
|
-
<path d="M5 5L15 15M15 5L5 15" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
327
|
-
</svg>
|
|
328
|
-
`;
|
|
329
|
-
}
|