@things-factory/lite-menu 6.0.14 → 6.0.15

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.
@@ -25,7 +25,8 @@ export const LiteMenuPortraitStyles = css`
25
25
  text-transform: uppercase;
26
26
  }
27
27
  a {
28
- display: block;
28
+ display: flex;
29
+ align-items: center;
29
30
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
30
31
  padding: var(--padding-default) var(--padding-default) var(--padding-default) var(--padding-wide);
31
32
  text-decoration: none;
@@ -95,6 +96,14 @@ export const LiteMenuPortraitStyles = css`
95
96
  margin-right: var(--margin-narrow);
96
97
  }
97
98
 
99
+ a [badge] {
100
+ margin-left: auto;
101
+ background-color: var(--primary-background-color);
102
+ color: white;
103
+ border-radius: 999em;
104
+ padding: 0px 6px;
105
+ }
106
+
98
107
  @media only screen and (max-width: 460px) {
99
108
  :host {
100
109
  min-width: 100vw;
@@ -24,28 +24,24 @@ export class LiteMenuPortrait extends LitElement {
24
24
  renderMenus(menus, activeTopLevel, activeMenu) {
25
25
  return html`
26
26
  <ul>
27
- ${menus.map(menu =>
28
- menu.type == 'group'
29
- ? html`<li group-label>${menu.name}</li>`
27
+ ${menus.map(menu => {
28
+ var { type, active, path, name, badge, icon, menus } = menu
29
+ active = active && typeof active === 'function' ? active.call(menu, { path: this.path }) : false
30
+ badge = typeof badge === 'function' ? badge.call(menu) : badge ?? false
31
+
32
+ return type == 'group'
33
+ ? html`<li group-label>${name}</li>`
30
34
  : html`
31
- <li
32
- ?active=${activeTopLevel
33
- ? menu === activeTopLevel
34
- : menu.active && typeof menu.active === 'function'
35
- ? menu.active.call(menu, { path: this.path })
36
- : false}
37
- .menu=${menu}
38
- menu
39
- >
40
- <a href=${menu.path || '#'}>
41
- ${menu.menus?.length > 0 ? html` <mwc-icon submenu-button></mwc-icon> ` : html``}
42
- <mwc-icon>${menu.icon}</mwc-icon>
43
- ${menu.name}
35
+ <li ?active=${activeTopLevel ? menu === activeTopLevel : active} .menu=${menu} menu>
36
+ <a href=${path || '#'}>
37
+ ${menus?.length > 0 ? html` <mwc-icon submenu-button></mwc-icon> ` : html``}
38
+ <mwc-icon>${icon}</mwc-icon>
39
+ ${name} ${badge !== false ? html`<div badge>${badge}</div>` : html``}
44
40
  </a>
45
- ${menu.menus && this.renderMenus(menu.menus, activeMenu)}
41
+ ${menus && this.renderMenus(menus, activeMenu)}
46
42
  </li>
47
43
  `
48
- )}
44
+ })}
49
45
  </ul>
50
46
  `
51
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/lite-menu",
3
- "version": "6.0.14",
3
+ "version": "6.0.15",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -41,5 +41,5 @@
41
41
  "@things-factory/setting-base": "^6.0.12",
42
42
  "@things-factory/utils": "^6.0.7"
43
43
  },
44
- "gitHead": "032db078ae849e84eb5aef75d781dcd17c34b999"
44
+ "gitHead": "7371bc44d75176210235997a56363f09b6a85453"
45
45
  }