@exmg/exm-navigation 1.1.4-alpha.6 → 1.1.5-alpha.5

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.
@@ -10,6 +10,8 @@ import './exm-navigation-rail.js';
10
10
  import './exm-navigation-sub-menu.js';
11
11
  import './exm-navigation-drawer-menu.js';
12
12
  import './exm-navigation-drawer.js';
13
+ import '@material/web/icon/icon.js';
14
+ import '@material/web/iconbutton/icon-button.js';
13
15
  declare const ExmNavigationBase_base: (new (...args: any[]) => {
14
16
  media: "mobile" | "tablet" | "desktop";
15
17
  touch: boolean;
@@ -43,6 +45,11 @@ export declare class ExmNavigationBase extends ExmNavigationBase_base {
43
45
  */
44
46
  navigationHasSubmenu: Record<string, boolean>;
45
47
  static styles: import("lit").CSSResult[];
48
+ constructor();
49
+ /**
50
+ * Get the menu items and the current path and set the correct startPath for the navigation
51
+ */
52
+ private setPath;
46
53
  protected updated(changedProperties: PropertyValues): void;
47
54
  protected firstUpdated(changedProperties: PropertyValues): void;
48
55
  connectedCallback(): void;
@@ -14,13 +14,15 @@ import './exm-navigation-rail.js';
14
14
  import './exm-navigation-sub-menu.js';
15
15
  import './exm-navigation-drawer-menu.js';
16
16
  import './exm-navigation-drawer.js';
17
+ import '@material/web/icon/icon.js';
18
+ import '@material/web/iconbutton/icon-button.js';
17
19
  // eslint-disable-next-line new-cap
18
20
  export class ExmNavigationBase extends MediaQueries(ExmgElement) {
19
21
  constructor() {
20
- super(...arguments);
22
+ super();
21
23
  this.items = [];
22
24
  this.path = ['chat'];
23
- this.drawerWidth = 319;
25
+ this.drawerWidth = 275;
24
26
  this.disableNavigate = false;
25
27
  /**
26
28
  * The menu item triggered by hovering and entering submenu's
@@ -43,6 +45,55 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
43
45
  * Object with menuitem and a bool for having that path sub items yes or no
44
46
  */
45
47
  this.navigationHasSubmenu = {};
48
+ /**
49
+ * Listen to popState changes. When the event has a state, the browser navigation buttons have been used and we have to update the path
50
+ */
51
+ window.addEventListener('popstate', (event) => {
52
+ if (event.state) {
53
+ this.setPath();
54
+ }
55
+ });
56
+ }
57
+ /**
58
+ * Get the menu items and the current path and set the correct startPath for the navigation
59
+ */
60
+ setPath() {
61
+ let path = [];
62
+ /**
63
+ * Set to true if we found the path. This is needed because for breaking out of a recursive function
64
+ */
65
+ let finished = false;
66
+ /**
67
+ * Loop through the items with a give depth. For every depth level the id of the route is set to that index
68
+ * If there is a matching path, we set finished to true, so all levels wil break out of their for-loop
69
+ * Every call done with depth 0 will reset the path, so no artifacts of the previous route will remain
70
+ *
71
+ * @param items The items to loop through
72
+ * @param depth The navigation depth
73
+ */
74
+ function checkItems(items, depth = 0) {
75
+ for (const item of items) {
76
+ if (finished) {
77
+ break;
78
+ }
79
+ if (depth === 0) {
80
+ path = [];
81
+ }
82
+ path[depth] = item.id;
83
+ if (item.path === window.location.pathname || `${item.path}/` === window.location.pathname) {
84
+ finished = true;
85
+ break;
86
+ }
87
+ if ((item.items || []).length > 0) {
88
+ checkItems(item.items, depth + 1);
89
+ }
90
+ }
91
+ }
92
+ checkItems(this.items);
93
+ this.path = path;
94
+ this.selectedItem = path;
95
+ this.activeItem = path;
96
+ this.handleDrawerOpen();
46
97
  }
47
98
  updated(changedProperties) {
48
99
  if (changedProperties.has('media')) {
@@ -61,6 +112,11 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
61
112
  if (changedProperties.has('media')) {
62
113
  this.handleMediaTypeChange.bind(this)();
63
114
  }
115
+ document.documentElement.style.setProperty('--exm-navigation-submenu-width', `${this.drawerWidth}px`);
116
+ /**
117
+ * Set the start path
118
+ */
119
+ this.setPath();
64
120
  }
65
121
  connectedCallback() {
66
122
  super.connectedCallback();
@@ -334,7 +390,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
334
390
  }
335
391
  render() {
336
392
  const containerStyle = {
337
- '--exm-drawer-width': `${this.getDrawerWidth()}px`,
393
+ '--exm-navigation-submenu-column-width': `${this.getDrawerWidth()}px`,
338
394
  };
339
395
  const containerClass = { 'show-topbar': !this.railOpen };
340
396
  return html `
@@ -7,8 +7,8 @@ export const MediaQueries = (superClass) => {
7
7
  this.media = 'desktop';
8
8
  this.touch = false;
9
9
  this.mobileMedia = window.matchMedia('(max-width: 960px)');
10
- this.tabletMedia = window.matchMedia('(min-width: 961px) and (max-width: 1200px)');
11
- this.desktopMedia = window.matchMedia('(min-width: 1201px)');
10
+ this.tabletMedia = window.matchMedia('(min-width: 961px) and (max-width: 1600px)');
11
+ this.desktopMedia = window.matchMedia('(min-width: 1601px)');
12
12
  this.hoverMedia = window.matchMedia('(hover: hover)');
13
13
  }
14
14
  updateMedia(media) {
@@ -2,7 +2,7 @@ import { css } from 'lit';
2
2
  export const style = css `
3
3
  .navigation-container {
4
4
  display: grid;
5
- grid-template-columns: auto var(--exm-drawer-width, 500px) 1fr;
5
+ grid-template-columns: auto var(--exm-navigation-submenu-column-width, 500px) 1fr;
6
6
  grid-template-rows: 1fr;
7
7
  width: 100%;
8
8
  transition: grid-template-columns 0.3s ease;
@@ -1,13 +1,10 @@
1
1
  import { css } from 'lit';
2
2
  export const style = css `
3
- :root {
4
- --md-sys-color-background: var(--md-sys-color-surface-container-high);
5
- }
6
-
7
3
  :host {
8
- --exm-drawer-max-width: 319px;
4
+ --md-sys-color-background: var(--md-sys-color-surface-container-high);
5
+ --_exm-navigation-submenu-width: var(--exm-navigation-submenu-width);
9
6
  display: grid;
10
- grid-template-columns: var(--mdc-drawer-width, 300px) 1fr;
7
+ grid-template-columns: var(--_exm-navigation-submenu-width, 300px) 1fr;
11
8
  height: 100vh;
12
9
  width: 100%;
13
10
  box-sizing: border-box;
@@ -17,8 +14,8 @@ export const style = css `
17
14
 
18
15
  aside {
19
16
  position: absolute;
20
- left: -300px;
21
- width: var(--exm-drawer-max-width, 300px);
17
+ left: calc(-1 * var(--_exm-navigation-submenu-width, 300px) - 1px);
18
+ width: var(--_exm-navigation-submenu-width, 300px);
22
19
  height: 100%;
23
20
  transition: left 0.3s ease-out;
24
21
  z-index: 4;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exmg/exm-navigation",
3
- "version": "1.1.4-alpha.6+9122b9a",
3
+ "version": "1.1.5-alpha.5+569284b",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,20 +15,17 @@
15
15
  "./exm-navigation-icon-button.js": "./dist/exm-navigation-icon-button.js",
16
16
  "./exm-navigation-rail.js": "./dist/exm-navigation-rail.js",
17
17
  "./exm-navigation-rail-nav-item.js": "./dist/exm-navigation-rail-nav-item.js",
18
- "./exm-navigation-topbar.js": "./dist/exm-navigation-topbar.js",
19
- "./exm-navigation-base.js": "./dist/ExmNavigationBase.js"
18
+ "./exm-navigation-topbar.js": "./dist/exm-navigation-topbar.js"
20
19
  },
21
20
  "dependencies": {
22
- "@exmg/lit-base": "^3.0.0",
23
- "@lit-labs/motion": "^1.0.7",
24
- "@material/mwc-top-app-bar-fixed": "^0.27.0",
21
+ "@lit-labs/motion": "^1.0.7"
22
+ },
23
+ "peerDependencies": {
24
+ "@exmg/lit-base": "^3.0.3",
25
25
  "@material/web": "^2.2.0",
26
- "lit": "^3.0.0",
26
+ "lit": "^3.2.1",
27
27
  "tslib": "^2.6.2"
28
28
  },
29
- "devDependencies": {
30
- "@exmg/lit-cli": "1.1.13"
31
- },
32
29
  "keywords": [
33
30
  "web-components",
34
31
  "lit",
@@ -50,5 +47,5 @@
50
47
  "publishConfig": {
51
48
  "access": "public"
52
49
  },
53
- "gitHead": "9122b9a8a49bc497349b8577983af1b18a84e359"
50
+ "gitHead": "569284b73ae26df21846b0673aae5a14af49d594"
54
51
  }