@brightspace-ui/labs 2.43.0 → 2.44.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/package.json
CHANGED
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"author": "D2L Corporation",
|
|
75
75
|
"license": "Apache-2.0",
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@brightspace-ui/stylelint-config": "^
|
|
77
|
+
"@brightspace-ui/stylelint-config": "^2",
|
|
78
78
|
"@brightspace-ui/testing": "^1",
|
|
79
79
|
"@rollup/plugin-dynamic-import-vars": "^2",
|
|
80
80
|
"@rollup/plugin-node-resolve": "^16",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"rollup-plugin-copy": "^3",
|
|
90
90
|
"rollup-plugin-delete": "^3",
|
|
91
91
|
"sinon": "^21",
|
|
92
|
-
"stylelint": "^
|
|
92
|
+
"stylelint": "^17"
|
|
93
93
|
},
|
|
94
94
|
"files": [
|
|
95
95
|
"labs.serge.json",
|
|
@@ -114,5 +114,5 @@
|
|
|
114
114
|
"resize-observer-polyfill": "^1",
|
|
115
115
|
"webvtt-parser": "^2"
|
|
116
116
|
},
|
|
117
|
-
"version": "2.
|
|
117
|
+
"version": "2.44.0"
|
|
118
118
|
}
|
|
@@ -4,13 +4,11 @@ import './navigation-link-back.js';
|
|
|
4
4
|
import { css, html, LitElement } from 'lit';
|
|
5
5
|
import { bodyCompactStyles } from '@brightspace-ui/core/components/typography/styles.js';
|
|
6
6
|
import { classMap } from 'lit/directives/class-map.js';
|
|
7
|
-
import { getFlag } from '@brightspace-ui/core/helpers/flags.js';
|
|
8
7
|
import { navigationSharedStyle } from './navigation-shared-styles.js';
|
|
9
8
|
import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
|
|
10
9
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
11
10
|
|
|
12
11
|
const mediaQueryList = window.matchMedia('(max-width: 615px)');
|
|
13
|
-
const immersiveNavTextSpacingFlag = getFlag('GAUD-8465-immersive-nav-text-spacing', true);
|
|
14
12
|
|
|
15
13
|
class NavigationImmersive extends LitElement {
|
|
16
14
|
|
|
@@ -39,7 +37,6 @@ class NavigationImmersive extends LitElement {
|
|
|
39
37
|
reflect: true
|
|
40
38
|
},
|
|
41
39
|
_dynamicSpacingHeight: { state: true },
|
|
42
|
-
_spacingUseHeightVar: { attribute: '_spacing-use-height-var', type: Boolean, reflect: true },
|
|
43
40
|
_middleHidden: { state: true },
|
|
44
41
|
_middleNoRightBorder: { state: true },
|
|
45
42
|
_smallWidth: { state: true }
|
|
@@ -135,10 +132,6 @@ class NavigationImmersive extends LitElement {
|
|
|
135
132
|
position: unset;
|
|
136
133
|
}
|
|
137
134
|
|
|
138
|
-
:host([_spacing-use-height-var]) .d2l-labs-navigation-immersive-spacing {
|
|
139
|
-
height: calc(var(--d2l-labs-navigation-immersive-height-main) + 5px);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
135
|
@media (max-width: 929px) {
|
|
143
136
|
.d2l-labs-navigation-immersive-margin {
|
|
144
137
|
margin: 0 24px;
|
|
@@ -178,12 +171,8 @@ class NavigationImmersive extends LitElement {
|
|
|
178
171
|
this._middleNoRightBorder = true;
|
|
179
172
|
this._middleObserver = new ResizeObserver(this._onMiddleResize.bind(this));
|
|
180
173
|
this._rightObserver = new ResizeObserver(this._onRightResize.bind(this));
|
|
181
|
-
this._spacingUseHeightVar = !immersiveNavTextSpacingFlag;
|
|
182
174
|
|
|
183
|
-
|
|
184
|
-
if (immersiveNavTextSpacingFlag) {
|
|
185
|
-
this._navigationObserver = new ResizeObserver(this._onNavigationResize.bind(this));
|
|
186
|
-
}
|
|
175
|
+
this._navigationObserver = new ResizeObserver(this._onNavigationResize.bind(this));
|
|
187
176
|
|
|
188
177
|
this._smallWidth = false;
|
|
189
178
|
this._dynamicSpacingHeight = undefined;
|
|
@@ -289,12 +278,9 @@ class NavigationImmersive extends LitElement {
|
|
|
289
278
|
this._rightObserver.observe(right);
|
|
290
279
|
}
|
|
291
280
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (navigation) {
|
|
296
|
-
this._navigationObserver.observe(navigation);
|
|
297
|
-
}
|
|
281
|
+
const navigation = this.shadowRoot?.querySelector('.d2l-navigiation-immersive-fixed');
|
|
282
|
+
if (navigation) {
|
|
283
|
+
this._navigationObserver.observe(navigation);
|
|
298
284
|
}
|
|
299
285
|
}
|
|
300
286
|
|
|
@@ -227,6 +227,17 @@ describe('Page Routing', () => {
|
|
|
227
227
|
});
|
|
228
228
|
```
|
|
229
229
|
|
|
230
|
+
## Router Navigation Hooks
|
|
231
|
+
|
|
232
|
+
If you want to execute code that doesn't belong to a web component before or after navigation, you can use the RouterHooks class. This is helpful for data models that care about changes in navigation, like a module responsible for timing page loads.
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
import { RouterHooks } from '@brightspace-ui/labs/utilities/lit-router';
|
|
236
|
+
|
|
237
|
+
RouterHooks.registerPreNavigate((context) => { console.log('this runs before we navigate', context);});
|
|
238
|
+
RouterHooks.registerPostNavigate((context) => { console.log('post', context);});
|
|
239
|
+
```
|
|
240
|
+
|
|
230
241
|
## Known Issues
|
|
231
242
|
|
|
232
243
|
### Route order inversion issue
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ContextReactor, redirect, navigate, registerRoutes, RouterTesting } from './router.js';
|
|
1
|
+
export { ContextReactor, redirect, navigate, registerRoutes, RouterTesting, RouterHooks } from './router.js';
|
|
2
2
|
export { RouteReactor } from './RouteReactor.js';
|
|
@@ -85,6 +85,37 @@ const _registerRoutes = routes => {
|
|
|
85
85
|
});
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
export class RouterHooks {
|
|
89
|
+
static registerPreNavigate = (callback) => {
|
|
90
|
+
RouterHooks.preNavigate.push(callback);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
static registerPostNavigate = (callback) => {
|
|
94
|
+
RouterHooks.postNavigate.push(callback);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
static reset() {
|
|
98
|
+
this.preNavigate = [];
|
|
99
|
+
this.postNavigate = [];
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
RouterHooks.reset();
|
|
104
|
+
|
|
105
|
+
const _registerPreNavigateHooks = () => {
|
|
106
|
+
activePage('*', (context, next) => {
|
|
107
|
+
RouterHooks.preNavigate.forEach(h => h(context));
|
|
108
|
+
next();
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const _registerPostNavigateHooks = () => {
|
|
113
|
+
activePage('*', (context, next) => {
|
|
114
|
+
RouterHooks.postNavigate.forEach(h => h(context));
|
|
115
|
+
next();
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
88
119
|
const configure = options => {
|
|
89
120
|
if (options && options.customPage) activePage = page.create();
|
|
90
121
|
if (options && options.basePath) activePage.base(options.basePath);
|
|
@@ -110,7 +141,9 @@ export const registerRoutes = (routes, options) => {
|
|
|
110
141
|
});
|
|
111
142
|
next();
|
|
112
143
|
});
|
|
144
|
+
_registerPreNavigateHooks();
|
|
113
145
|
_registerRoutes(routes);
|
|
146
|
+
_registerPostNavigateHooks();
|
|
114
147
|
_storeCtx();
|
|
115
148
|
};
|
|
116
149
|
|
|
@@ -175,6 +208,7 @@ export const RouterTesting = {
|
|
|
175
208
|
activePage = page.create();
|
|
176
209
|
hasRegistered = false;
|
|
177
210
|
ContextReactor.reset();
|
|
211
|
+
RouterHooks.reset();
|
|
178
212
|
},
|
|
179
213
|
|
|
180
214
|
restart: () => {
|