scb-wc 0.1.84 → 0.1.85
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/fonts/material-symbols-outlined/files/material-symbols-outlined-subset.woff2 +0 -0
- package/icons.json +178 -178
- package/mvc/components/scb-horizontal-scroller/scb-horizontal-scroller.js +2 -2
- package/mvc/components/scb-nav/scb-nav.js +27 -5
- package/mvc/fonts/material-symbols-outlined/files/material-symbols-outlined-subset.woff2 +0 -0
- package/mvc/scb-logo.svg +20 -20
- package/mvc/scb.svg +13 -13
- package/package.json +2 -2
- package/scb-components/scb-nav/scb-nav.d.ts +14 -0
- package/scb-horizontal-scroller/scb-horizontal-scroller.js +50 -6
- package/scb-nav/scb-nav.js +289 -31
- package/scb-wc.bundle.js +269 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.85",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -460,5 +460,5 @@
|
|
|
460
460
|
},
|
|
461
461
|
"./mvc/*": "./mvc/*"
|
|
462
462
|
},
|
|
463
|
-
"buildHash": "
|
|
463
|
+
"buildHash": "7E093C4E18AA9C904CFA5A86818505F4696ABD4F84BE76B47D2A36FB76D2157C"
|
|
464
464
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { LitElement, TemplateResult } from 'lit';
|
|
2
2
|
export declare class ScbNav extends LitElement {
|
|
3
3
|
private __removeLazyFocusRingListeners?;
|
|
4
|
+
private __itemsEl;
|
|
5
|
+
private __resizeObserver;
|
|
6
|
+
private __resizeRaf;
|
|
7
|
+
private __canScrollLeft;
|
|
8
|
+
private __canScrollRight;
|
|
4
9
|
/** Aria-label för navigeringen (används om hosten saknar aria-label). */
|
|
5
10
|
label: string;
|
|
6
11
|
/** Matchar href-attributet på en item i slotten och markerar den som aktiv. */
|
|
@@ -42,6 +47,15 @@ export declare class ScbNav extends LitElement {
|
|
|
42
47
|
private __getItemHref;
|
|
43
48
|
private __applyActiveHref;
|
|
44
49
|
private __onSlotChange;
|
|
50
|
+
private __getScrollStep;
|
|
51
|
+
private __scrollBy;
|
|
52
|
+
private __scrollLeft;
|
|
53
|
+
private __scrollRight;
|
|
54
|
+
private __normalizeWheelDelta;
|
|
55
|
+
private __onWheel;
|
|
56
|
+
private __onItemsScroll;
|
|
57
|
+
private __scheduleScrollControlUpdate;
|
|
58
|
+
private __updateScrollControls;
|
|
45
59
|
private __onClick;
|
|
46
60
|
render(): TemplateResult;
|
|
47
61
|
}
|
|
@@ -57,6 +57,50 @@ var u = class extends n {
|
|
|
57
57
|
scrollbar-width: none;
|
|
58
58
|
width: 100%;
|
|
59
59
|
}
|
|
60
|
+
:host([data-scroll-left]:not([variant='inline'])) .scb-horizontal-scroller {
|
|
61
|
+
-webkit-mask-image: linear-gradient(
|
|
62
|
+
to right,
|
|
63
|
+
transparent 0,
|
|
64
|
+
black var(--scb-horizontal-scroller-edge-fade-size, 56px),
|
|
65
|
+
black 100%
|
|
66
|
+
);
|
|
67
|
+
mask-image: linear-gradient(
|
|
68
|
+
to right,
|
|
69
|
+
transparent 0,
|
|
70
|
+
black var(--scb-horizontal-scroller-edge-fade-size, 56px),
|
|
71
|
+
black 100%
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
:host([data-scroll-right]:not([variant='inline'])) .scb-horizontal-scroller {
|
|
75
|
+
-webkit-mask-image: linear-gradient(
|
|
76
|
+
to right,
|
|
77
|
+
black 0,
|
|
78
|
+
black calc(100% - var(--scb-horizontal-scroller-edge-fade-size, 56px)),
|
|
79
|
+
transparent 100%
|
|
80
|
+
);
|
|
81
|
+
mask-image: linear-gradient(
|
|
82
|
+
to right,
|
|
83
|
+
black 0,
|
|
84
|
+
black calc(100% - var(--scb-horizontal-scroller-edge-fade-size, 56px)),
|
|
85
|
+
transparent 100%
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
:host([data-scroll-left][data-scroll-right]:not([variant='inline'])) .scb-horizontal-scroller {
|
|
89
|
+
-webkit-mask-image: linear-gradient(
|
|
90
|
+
to right,
|
|
91
|
+
transparent 0,
|
|
92
|
+
black var(--scb-horizontal-scroller-edge-fade-size, 56px),
|
|
93
|
+
black calc(100% - var(--scb-horizontal-scroller-edge-fade-size, 56px)),
|
|
94
|
+
transparent 100%
|
|
95
|
+
);
|
|
96
|
+
mask-image: linear-gradient(
|
|
97
|
+
to right,
|
|
98
|
+
transparent 0,
|
|
99
|
+
black var(--scb-horizontal-scroller-edge-fade-size, 56px),
|
|
100
|
+
black calc(100% - var(--scb-horizontal-scroller-edge-fade-size, 56px)),
|
|
101
|
+
transparent 100%
|
|
102
|
+
);
|
|
103
|
+
}
|
|
60
104
|
:host([show-scrollbar]) .scb-horizontal-scroller {
|
|
61
105
|
scrollbar-width: auto;
|
|
62
106
|
}
|
|
@@ -223,10 +267,10 @@ var u = class extends n {
|
|
|
223
267
|
right: 0;
|
|
224
268
|
}
|
|
225
269
|
:host([data-scroll-left]) .scroll-shadow-left {
|
|
226
|
-
background:
|
|
270
|
+
background: transparent;
|
|
227
271
|
box-shadow:
|
|
228
|
-
12px 0 30px
|
|
229
|
-
4px 0 12px
|
|
272
|
+
12px 0 30px color-mix(in srgb, currentColor 18%, transparent),
|
|
273
|
+
4px 0 12px color-mix(in srgb, currentColor 12%, transparent);
|
|
230
274
|
}
|
|
231
275
|
:host([data-scroll-left]) .scroll-shadow-left::after {
|
|
232
276
|
content: '';
|
|
@@ -234,10 +278,10 @@ var u = class extends n {
|
|
|
234
278
|
inset-block: 0;
|
|
235
279
|
}
|
|
236
280
|
:host([data-scroll-right]) .scroll-shadow-right {
|
|
237
|
-
background:
|
|
281
|
+
background: transparent;
|
|
238
282
|
box-shadow:
|
|
239
|
-
-12px 0 30px
|
|
240
|
-
-4px 0 12px
|
|
283
|
+
-12px 0 30px color-mix(in srgb, currentColor 18%, transparent),
|
|
284
|
+
-4px 0 12px color-mix(in srgb, currentColor 12%, transparent);
|
|
241
285
|
}
|
|
242
286
|
:host([data-scroll-right]) .scroll-shadow-right::after {
|
|
243
287
|
content: '';
|
package/scb-nav/scb-nav.js
CHANGED
|
@@ -1,16 +1,33 @@
|
|
|
1
1
|
import { addLazyFocusRingListeners as e } from "../shared/lazy-focus-ring.js";
|
|
2
2
|
import { __decorate as t } from "../_virtual/_@oxc-project_runtime@0.126.0/helpers/decorate.js";
|
|
3
|
+
import { renderScbIcon as n } from "../shared/scb-icon-svg.js";
|
|
3
4
|
import "./scb-nav-item.js";
|
|
4
|
-
import { LitElement as
|
|
5
|
-
import { customElement as
|
|
5
|
+
import { LitElement as r, css as i, html as a } from "lit";
|
|
6
|
+
import { customElement as o, property as s, state as c } from "lit/decorators.js";
|
|
6
7
|
import "@material/web/ripple/ripple.js";
|
|
7
8
|
//#region src/scb-components/scb-nav/scb-nav.ts
|
|
8
|
-
var
|
|
9
|
+
var l = { fromAttribute(e) {
|
|
9
10
|
return e === null ? !1 : e.toLowerCase() !== "false";
|
|
10
|
-
} },
|
|
11
|
+
} }, u = class extends r {
|
|
11
12
|
constructor(...e) {
|
|
12
|
-
super(...e), this.label = "", this.activeHref = "", this.activateOnClick = !0, this.sticky = !1, this.stickyTop = "0px", this.stickyZIndex = 5, this.stickyBackground = "", this.spacing = void 0, this.spacingTop = void 0, this.spacingBottom = void 0, this.spacingLeft = void 0, this.spacingRight = void 0, this.__autoAriaLabel = !1, this.__itemIdPrefix = `scb-nav-${Math.random().toString(36).slice(2)}`, this.__itemIdCounter = 0, this.__onSlotChange = async () => {
|
|
13
|
-
await this.__decorateItems(), this.__applyActiveHref();
|
|
13
|
+
super(...e), this.__itemsEl = null, this.__resizeObserver = null, this.__resizeRaf = null, this.__canScrollLeft = !1, this.__canScrollRight = !1, this.label = "", this.activeHref = "", this.activateOnClick = !0, this.sticky = !1, this.stickyTop = "0px", this.stickyZIndex = 5, this.stickyBackground = "", this.spacing = void 0, this.spacingTop = void 0, this.spacingBottom = void 0, this.spacingLeft = void 0, this.spacingRight = void 0, this.__autoAriaLabel = !1, this.__itemIdPrefix = `scb-nav-${Math.random().toString(36).slice(2)}`, this.__itemIdCounter = 0, this.__onSlotChange = async () => {
|
|
14
|
+
await this.__decorateItems(), this.__applyActiveHref(), this.__scheduleScrollControlUpdate();
|
|
15
|
+
}, this.__scrollLeft = () => {
|
|
16
|
+
this.__scrollBy(-this.__getScrollStep());
|
|
17
|
+
}, this.__scrollRight = () => {
|
|
18
|
+
this.__scrollBy(this.__getScrollStep());
|
|
19
|
+
}, this.__onWheel = (e) => {
|
|
20
|
+
if (e.ctrlKey) return;
|
|
21
|
+
let t = this.__itemsEl;
|
|
22
|
+
if (!t) return;
|
|
23
|
+
let n = t.scrollWidth - t.clientWidth;
|
|
24
|
+
if (n <= 1) return;
|
|
25
|
+
let r = this.__normalizeWheelDelta(e);
|
|
26
|
+
if (r === 0) return;
|
|
27
|
+
let i = Math.max(0, Math.min(n, t.scrollLeft + r));
|
|
28
|
+
i !== t.scrollLeft && (e.preventDefault(), t.scrollLeft = i, this.__updateScrollControls());
|
|
29
|
+
}, this.__onItemsScroll = () => {
|
|
30
|
+
this.__updateScrollControls();
|
|
14
31
|
}, this.__onClick = (e) => {
|
|
15
32
|
let t = e.composedPath().find((e) => e instanceof HTMLElement && (e.tagName === "A" || e.tagName === "BUTTON" || e.tagName === "SCB-NAV-ITEM"));
|
|
16
33
|
if (!t) return;
|
|
@@ -33,17 +50,28 @@ var s = { fromAttribute(e) {
|
|
|
33
50
|
};
|
|
34
51
|
}
|
|
35
52
|
static {
|
|
36
|
-
this.styles =
|
|
53
|
+
this.styles = i`
|
|
37
54
|
:host {
|
|
55
|
+
--_scb-nav-scroll-shadow-color: rgba(0, 0, 0, 0.24);
|
|
56
|
+
--_scb-nav-scroll-shadow-soft-color: rgba(0, 0, 0, 0.14);
|
|
57
|
+
|
|
38
58
|
display: block;
|
|
39
59
|
color: var(--md-sys-color-on-surface);
|
|
40
|
-
font-family: var(--brand-font, Inter);
|
|
60
|
+
font-family: var(--brand-font, Inter);
|
|
41
61
|
margin-block-start: var(--scb-nav-spacing-block-start, 0);
|
|
42
62
|
margin-block-end: var(--scb-nav-spacing-block-end, 0);
|
|
43
63
|
margin-inline-start: var(--scb-nav-spacing-inline-start, 0);
|
|
44
64
|
margin-inline-end: var(--scb-nav-spacing-inline-end, 0);
|
|
45
|
-
|
|
46
|
-
|
|
65
|
+
min-inline-size: 0;
|
|
66
|
+
overflow-x: hidden;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@supports (color: color-mix(in srgb, black, white)) {
|
|
70
|
+
:host {
|
|
71
|
+
--_scb-nav-scroll-shadow-color: color-mix(in srgb, currentColor 24%, transparent);
|
|
72
|
+
--_scb-nav-scroll-shadow-soft-color: color-mix(in srgb, currentColor 14%, transparent);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
47
75
|
|
|
48
76
|
:host([sticky]) {
|
|
49
77
|
position: sticky;
|
|
@@ -57,28 +85,84 @@ var s = { fromAttribute(e) {
|
|
|
57
85
|
);
|
|
58
86
|
background: var(
|
|
59
87
|
--_scb-nav-sticky-background,
|
|
60
|
-
var(--scb-nav-sticky-background,
|
|
88
|
+
var(--scb-nav-sticky-background, transparent)
|
|
61
89
|
);
|
|
62
90
|
}
|
|
63
91
|
|
|
64
92
|
.scb-nav {
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
position: relative;
|
|
65
96
|
max-inline-size: var(--scb-nav-max-width, 1400px);
|
|
66
97
|
margin-inline: auto;
|
|
67
98
|
padding-block: var(--scb-nav-padding-block, var(--spacing-5, 16px));
|
|
68
99
|
padding-inline: var(--scb-nav-padding-inline, var(--spacing-0, 0px));
|
|
69
100
|
box-sizing: border-box;
|
|
101
|
+
min-inline-size: 0;
|
|
102
|
+
overflow-x: hidden;
|
|
70
103
|
}
|
|
71
104
|
|
|
72
105
|
.scb-nav__items {
|
|
73
106
|
display: flex;
|
|
107
|
+
flex: 1 1 auto;
|
|
74
108
|
align-items: center;
|
|
75
109
|
gap: var(--scb-nav-gap, var(--spacing-3, 8px));
|
|
110
|
+
min-inline-size: 0;
|
|
76
111
|
|
|
77
112
|
overflow-x: auto;
|
|
78
|
-
overflow-y:
|
|
113
|
+
overflow-y: hidden;
|
|
79
114
|
-webkit-overflow-scrolling: touch;
|
|
80
115
|
scrollbar-width: none;
|
|
81
|
-
|
|
116
|
+
inline-size: 100%;
|
|
117
|
+
max-inline-size: 100%;
|
|
118
|
+
--_scb-nav-edge-fade-size: var(--scb-nav-edge-fade-size, 64px);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
:host([data-scroll-left]) .scb-nav__items {
|
|
122
|
+
-webkit-mask-image: linear-gradient(
|
|
123
|
+
to right,
|
|
124
|
+
transparent 0,
|
|
125
|
+
#000 var(--_scb-nav-edge-fade-size),
|
|
126
|
+
#000 100%
|
|
127
|
+
);
|
|
128
|
+
mask-image: linear-gradient(
|
|
129
|
+
to right,
|
|
130
|
+
transparent 0,
|
|
131
|
+
#000 var(--_scb-nav-edge-fade-size),
|
|
132
|
+
#000 100%
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
:host([data-scroll-right]) .scb-nav__items {
|
|
137
|
+
-webkit-mask-image: linear-gradient(
|
|
138
|
+
to right,
|
|
139
|
+
#000 0,
|
|
140
|
+
#000 calc(100% - var(--_scb-nav-edge-fade-size)),
|
|
141
|
+
transparent 100%
|
|
142
|
+
);
|
|
143
|
+
mask-image: linear-gradient(
|
|
144
|
+
to right,
|
|
145
|
+
#000 0,
|
|
146
|
+
#000 calc(100% - var(--_scb-nav-edge-fade-size)),
|
|
147
|
+
transparent 100%
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
:host([data-scroll-left][data-scroll-right]) .scb-nav__items {
|
|
152
|
+
-webkit-mask-image: linear-gradient(
|
|
153
|
+
to right,
|
|
154
|
+
transparent 0,
|
|
155
|
+
#000 var(--_scb-nav-edge-fade-size),
|
|
156
|
+
#000 calc(100% - var(--_scb-nav-edge-fade-size)),
|
|
157
|
+
transparent 100%
|
|
158
|
+
);
|
|
159
|
+
mask-image: linear-gradient(
|
|
160
|
+
to right,
|
|
161
|
+
transparent 0,
|
|
162
|
+
#000 var(--_scb-nav-edge-fade-size),
|
|
163
|
+
#000 calc(100% - var(--_scb-nav-edge-fade-size)),
|
|
164
|
+
transparent 100%
|
|
165
|
+
);
|
|
82
166
|
}
|
|
83
167
|
|
|
84
168
|
.scb-nav__items::-webkit-scrollbar {
|
|
@@ -89,6 +173,7 @@ var s = { fromAttribute(e) {
|
|
|
89
173
|
::slotted(button),
|
|
90
174
|
::slotted(scb-nav-item) {
|
|
91
175
|
display: inline-flex;
|
|
176
|
+
flex: 0 0 auto;
|
|
92
177
|
align-items: center;
|
|
93
178
|
justify-content: center;
|
|
94
179
|
|
|
@@ -132,6 +217,125 @@ var s = { fromAttribute(e) {
|
|
|
132
217
|
color: var(--md-sys-color-on-secondary-container);
|
|
133
218
|
font-weight: 600;
|
|
134
219
|
}
|
|
220
|
+
|
|
221
|
+
.scb-nav__scroll-control {
|
|
222
|
+
position: absolute;
|
|
223
|
+
z-index: 3;
|
|
224
|
+
display: inline-flex;
|
|
225
|
+
align-items: center;
|
|
226
|
+
justify-content: center;
|
|
227
|
+
box-sizing: border-box;
|
|
228
|
+
inline-size: var(--scb-icon-button-container-size, 40px);
|
|
229
|
+
block-size: var(--scb-icon-button-container-size, 40px);
|
|
230
|
+
padding: 0;
|
|
231
|
+
border: 0;
|
|
232
|
+
border-radius: var(--radius-full, 1000px);
|
|
233
|
+
background: var(--md-filled-tonal-icon-button-container-color, var(--md-sys-color-secondary-container, var(--p-90, #d6f1ff)));
|
|
234
|
+
color: var(--md-filled-tonal-icon-button-icon-color, var(--md-sys-color-on-secondary-container, var(--p-30, #1e00be)));
|
|
235
|
+
cursor: pointer;
|
|
236
|
+
font-family: var(--brand-font, var(--brand, "Inter"), sans-serif);
|
|
237
|
+
font-weight: var(--weight-semibold, 600);
|
|
238
|
+
overflow: hidden;
|
|
239
|
+
appearance: none;
|
|
240
|
+
-webkit-appearance: none;
|
|
241
|
+
-webkit-tap-highlight-color: transparent;
|
|
242
|
+
touch-action: manipulation;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.scb-nav__scroll-control::before {
|
|
246
|
+
content: '';
|
|
247
|
+
position: absolute;
|
|
248
|
+
inset: 0;
|
|
249
|
+
border-radius: inherit;
|
|
250
|
+
background: currentColor;
|
|
251
|
+
opacity: 0;
|
|
252
|
+
pointer-events: none;
|
|
253
|
+
transition: opacity var(--motion-duration-short, 150ms) var(--motion-easing-standard, ease);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.scb-nav__scroll-control:hover::before {
|
|
257
|
+
opacity: var(--md-sys-state-hover-state-layer-opacity, 0.08);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.scb-nav__scroll-control:active::before {
|
|
261
|
+
opacity: var(--md-sys-state-pressed-state-layer-opacity, 0.12);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.scb-nav__scroll-control:focus {
|
|
265
|
+
outline: none;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.scb-nav__scroll-control:focus-visible {
|
|
269
|
+
outline: var(--stroke-border-m, 2px) solid var(--md-focus-ring-color, var(--md-sys-color-primary, var(--p-40, #1f44ff)));
|
|
270
|
+
outline-offset: var(--spacing-1, 2px);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.scb-nav__scroll-control-icon {
|
|
274
|
+
position: relative;
|
|
275
|
+
display: inline-block;
|
|
276
|
+
inline-size: var(--icon-size-medium, 24px);
|
|
277
|
+
block-size: var(--icon-size-medium, 24px);
|
|
278
|
+
overflow: hidden;
|
|
279
|
+
font-family: 'Material Symbols Outlined';
|
|
280
|
+
font-size: var(--icon-size-medium, 24px);
|
|
281
|
+
line-height: 1;
|
|
282
|
+
text-align: center;
|
|
283
|
+
white-space: nowrap;
|
|
284
|
+
text-transform: none;
|
|
285
|
+
word-wrap: normal;
|
|
286
|
+
direction: ltr;
|
|
287
|
+
font-feature-settings: 'liga' 1;
|
|
288
|
+
font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
|
|
289
|
+
-webkit-font-smoothing: antialiased;
|
|
290
|
+
-moz-osx-font-smoothing: grayscale;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.scb-nav__scroll-control-icon.scb-svg-icon {
|
|
294
|
+
fill: currentColor;
|
|
295
|
+
font: inherit;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.scb-nav__scroll-control--left {
|
|
299
|
+
inset-inline-start: 0;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.scb-nav__scroll-control--right {
|
|
303
|
+
inset-inline-end: 2px;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.scb-nav__scroll-shadow-left,
|
|
307
|
+
.scb-nav__scroll-shadow-right {
|
|
308
|
+
position: absolute;
|
|
309
|
+
inset-block: 0;
|
|
310
|
+
z-index: 2;
|
|
311
|
+
inline-size: 5px;
|
|
312
|
+
pointer-events: none;
|
|
313
|
+
background: none;
|
|
314
|
+
box-shadow: none;
|
|
315
|
+
transition: box-shadow 0.2s;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.scb-nav__scroll-shadow-left {
|
|
319
|
+
inset-inline-start: 0;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.scb-nav__scroll-shadow-right {
|
|
323
|
+
inset-inline-end: 0;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
:host([data-scroll-left]) .scb-nav__scroll-shadow-left {
|
|
327
|
+
background: transparent;
|
|
328
|
+
box-shadow:
|
|
329
|
+
12px 0 30px var(--scb-nav-scroll-shadow-color, var(--_scb-nav-scroll-shadow-color)),
|
|
330
|
+
4px 0 12px var(--scb-nav-scroll-shadow-soft-color, var(--_scb-nav-scroll-shadow-soft-color));
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
:host([data-scroll-right]) .scb-nav__scroll-shadow-right {
|
|
334
|
+
background: transparent;
|
|
335
|
+
box-shadow:
|
|
336
|
+
-12px 0 30px var(--scb-nav-scroll-shadow-color, var(--_scb-nav-scroll-shadow-color)),
|
|
337
|
+
-4px 0 12px var(--scb-nav-scroll-shadow-soft-color, var(--_scb-nav-scroll-shadow-soft-color));
|
|
338
|
+
}
|
|
135
339
|
`;
|
|
136
340
|
}
|
|
137
341
|
mapSpacingToken(e) {
|
|
@@ -164,10 +368,14 @@ var s = { fromAttribute(e) {
|
|
|
164
368
|
super.connectedCallback(), this.__removeLazyFocusRingListeners = e(this, this.renderRoot), this.hasAttribute("role") || this.setAttribute("role", "navigation"), this.__syncStickyStyles(), this.__syncAriaLabel();
|
|
165
369
|
}
|
|
166
370
|
disconnectedCallback() {
|
|
167
|
-
this.__removeLazyFocusRingListeners?.(), this.__removeLazyFocusRingListeners = void 0, super.disconnectedCallback();
|
|
371
|
+
this.__removeLazyFocusRingListeners?.(), this.__removeLazyFocusRingListeners = void 0, this.__itemsEl?.removeEventListener("scroll", this.__onItemsScroll), this.__itemsEl = null, this.__resizeObserver?.disconnect(), this.__resizeObserver = null, this.__resizeRaf !== null && (cancelAnimationFrame(this.__resizeRaf), this.__resizeRaf = null), super.disconnectedCallback();
|
|
168
372
|
}
|
|
169
373
|
async firstUpdated() {
|
|
170
|
-
|
|
374
|
+
this.__itemsEl = this.renderRoot.querySelector(".scb-nav__items"), this.__itemsEl && this.__itemsEl.addEventListener("scroll", this.__onItemsScroll, { passive: !0 }), this.__resizeObserver = new ResizeObserver(() => {
|
|
375
|
+
this.__scheduleScrollControlUpdate();
|
|
376
|
+
}), this.__resizeObserver.observe(this), this.__itemsEl && this.__resizeObserver.observe(this.__itemsEl), await this.__decorateItems(), this.__applyActiveHref(), this.__applySpacing(), this.__scheduleScrollControlUpdate(), document.fonts?.ready?.then(() => {
|
|
377
|
+
this.isConnected && this.__scheduleScrollControlUpdate();
|
|
378
|
+
});
|
|
171
379
|
}
|
|
172
380
|
updated(e) {
|
|
173
381
|
e.has("label") && this.__syncAriaLabel(), (e.has("sticky") || e.has("stickyTop") || e.has("stickyZIndex") || e.has("stickyBackground")) && this.__syncStickyStyles(), e.has("activeHref") && this.__applyActiveHref(), (e.has("spacing") || e.has("spacingTop") || e.has("spacingBottom") || e.has("spacingLeft") || e.has("spacingRight")) && this.__applySpacing();
|
|
@@ -218,54 +426,104 @@ var s = { fromAttribute(e) {
|
|
|
218
426
|
e && a === e ? (n.setAttribute("aria-current", "location"), n.setAttribute("data-scb-nav-managed", "true"), n.setAttribute("data-active", "true")) : (n.getAttribute("data-scb-nav-managed") === "true" && (n.removeAttribute("aria-current"), n.removeAttribute("data-scb-nav-managed")), n.removeAttribute("data-active"));
|
|
219
427
|
}
|
|
220
428
|
}
|
|
429
|
+
__getScrollStep() {
|
|
430
|
+
let e = this.__itemsEl;
|
|
431
|
+
return e ? Math.max(Math.round(e.clientWidth * .8), 120) : 200;
|
|
432
|
+
}
|
|
433
|
+
__scrollBy(e) {
|
|
434
|
+
this.__itemsEl?.scrollBy({
|
|
435
|
+
left: e,
|
|
436
|
+
behavior: "smooth"
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
__normalizeWheelDelta(e) {
|
|
440
|
+
let t = this.__itemsEl, n = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY;
|
|
441
|
+
return t ? e.deltaMode === WheelEvent.DOM_DELTA_LINE ? n * 16 : e.deltaMode === WheelEvent.DOM_DELTA_PAGE ? n * t.clientWidth : n : n;
|
|
442
|
+
}
|
|
443
|
+
__scheduleScrollControlUpdate() {
|
|
444
|
+
this.__resizeRaf === null && (this.__resizeRaf = requestAnimationFrame(() => {
|
|
445
|
+
this.__resizeRaf = null, this.__updateScrollControls();
|
|
446
|
+
}));
|
|
447
|
+
}
|
|
448
|
+
__updateScrollControls() {
|
|
449
|
+
let e = this.__itemsEl;
|
|
450
|
+
if (!e) {
|
|
451
|
+
this.__canScrollLeft = !1, this.__canScrollRight = !1, this.toggleAttribute("data-scroll-left", !1), this.toggleAttribute("data-scroll-right", !1);
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
let t = e.scrollLeft > 0, n = e.scrollLeft + e.clientWidth < e.scrollWidth - 1;
|
|
455
|
+
this.__canScrollLeft = t, this.__canScrollRight = n, this.toggleAttribute("data-scroll-left", t), this.toggleAttribute("data-scroll-right", n);
|
|
456
|
+
}
|
|
221
457
|
render() {
|
|
222
|
-
return
|
|
458
|
+
return a`
|
|
223
459
|
<div class="scb-nav">
|
|
224
|
-
|
|
460
|
+
${this.__canScrollLeft ? a`
|
|
461
|
+
<button
|
|
462
|
+
class="scb-nav__scroll-control scb-nav__scroll-control--left"
|
|
463
|
+
type="button"
|
|
464
|
+
aria-label="Scrolla vänster"
|
|
465
|
+
@click=${this.__scrollLeft}
|
|
466
|
+
>
|
|
467
|
+
${n("chevron_left", "scb-nav__scroll-control-icon")}
|
|
468
|
+
</button>
|
|
469
|
+
` : ""}
|
|
470
|
+
<div class="scb-nav__scroll-shadow-left"></div>
|
|
471
|
+
<div class="scb-nav__items" @click=${this.__onClick} @wheel=${this.__onWheel}>
|
|
225
472
|
<slot @slotchange=${this.__onSlotChange}></slot>
|
|
226
473
|
</div>
|
|
474
|
+
<div class="scb-nav__scroll-shadow-right"></div>
|
|
475
|
+
${this.__canScrollRight ? a`
|
|
476
|
+
<button
|
|
477
|
+
class="scb-nav__scroll-control scb-nav__scroll-control--right"
|
|
478
|
+
type="button"
|
|
479
|
+
aria-label="Scrolla höger"
|
|
480
|
+
@click=${this.__scrollRight}
|
|
481
|
+
>
|
|
482
|
+
${n("chevron_right", "scb-nav__scroll-control-icon")}
|
|
483
|
+
</button>
|
|
484
|
+
` : ""}
|
|
227
485
|
</div>
|
|
228
486
|
`;
|
|
229
487
|
}
|
|
230
488
|
};
|
|
231
|
-
t([
|
|
489
|
+
t([c()], u.prototype, "__canScrollLeft", void 0), t([c()], u.prototype, "__canScrollRight", void 0), t([s({ type: String })], u.prototype, "label", void 0), t([s({
|
|
232
490
|
type: String,
|
|
233
491
|
attribute: "active-href"
|
|
234
|
-
})],
|
|
492
|
+
})], u.prototype, "activeHref", void 0), t([s({
|
|
235
493
|
type: Boolean,
|
|
236
494
|
attribute: "activate-on-click",
|
|
237
|
-
converter:
|
|
238
|
-
})],
|
|
495
|
+
converter: l
|
|
496
|
+
})], u.prototype, "activateOnClick", void 0), t([s({
|
|
239
497
|
type: Boolean,
|
|
240
498
|
reflect: !0
|
|
241
|
-
})],
|
|
499
|
+
})], u.prototype, "sticky", void 0), t([s({
|
|
242
500
|
type: String,
|
|
243
501
|
attribute: "sticky-top"
|
|
244
|
-
})],
|
|
502
|
+
})], u.prototype, "stickyTop", void 0), t([s({
|
|
245
503
|
type: Number,
|
|
246
504
|
attribute: "sticky-z-index"
|
|
247
|
-
})],
|
|
505
|
+
})], u.prototype, "stickyZIndex", void 0), t([s({
|
|
248
506
|
type: String,
|
|
249
507
|
attribute: "sticky-background"
|
|
250
|
-
})],
|
|
508
|
+
})], u.prototype, "stickyBackground", void 0), t([s({
|
|
251
509
|
type: String,
|
|
252
510
|
reflect: !0
|
|
253
|
-
})],
|
|
511
|
+
})], u.prototype, "spacing", void 0), t([s({
|
|
254
512
|
type: String,
|
|
255
513
|
attribute: "spacing-top",
|
|
256
514
|
reflect: !0
|
|
257
|
-
})],
|
|
515
|
+
})], u.prototype, "spacingTop", void 0), t([s({
|
|
258
516
|
type: String,
|
|
259
517
|
attribute: "spacing-bottom",
|
|
260
518
|
reflect: !0
|
|
261
|
-
})],
|
|
519
|
+
})], u.prototype, "spacingBottom", void 0), t([s({
|
|
262
520
|
type: String,
|
|
263
521
|
attribute: "spacing-left",
|
|
264
522
|
reflect: !0
|
|
265
|
-
})],
|
|
523
|
+
})], u.prototype, "spacingLeft", void 0), t([s({
|
|
266
524
|
type: String,
|
|
267
525
|
attribute: "spacing-right",
|
|
268
526
|
reflect: !0
|
|
269
|
-
})],
|
|
527
|
+
})], u.prototype, "spacingRight", void 0), u = t([o("scb-nav")], u);
|
|
270
528
|
//#endregion
|
|
271
|
-
export {
|
|
529
|
+
export { u as ScbNav };
|