@neovici/cosmoz-bottom-bar 4.1.0 → 4.4.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.
@@ -1,12 +1,8 @@
1
1
  import { component } from 'haunted';
2
2
  import { html } from 'lit-html';
3
3
  import { ifDefined } from 'lit-html/directives/if-defined';
4
- import { ref } from '@neovici/cosmoz-utils/lib/directives/ref';
5
- import { useBottomBarView } from './lib/use-bottom-bar-view';
6
4
  import { bottomBarSlots } from './cosmoz-bottom-bar';
7
5
 
8
-
9
-
10
6
  /**
11
7
  * `cosmoz-bottom-bar-view` contains a content section and a bottom bar with actions.
12
8
  *
@@ -18,49 +14,41 @@ import { bottomBarSlots } from './cosmoz-bottom-bar';
18
14
  */
19
15
 
20
16
  const CosmozBottomBarView = ({
21
- barHeight,
22
- ...pass
23
- }) => { /*eslint-disable no-return-assign */
24
- const {
25
- active,
26
- info
27
- } = useBottomBarView(pass);
28
-
29
- return html`
30
- <style>
31
- :host {
32
- position: relative;
33
- display: flex;
34
- flex-direction: column;
35
- flex: var(--cosmoz-bottom-bar-view-flex, auto);
36
- overflow: hidden;
37
- }
38
-
39
- #content {
40
- display: flex;
41
- flex-direction: column;
42
- flex: auto;
43
- -webkit-overflow-scrolling: touch;
44
- overflow-y: auto;
45
- }
46
-
47
- #bar {
48
- background-color: var(--cosmoz-bottom-bar-view-bar-color, rgba(230, 230, 230, 0.8));
49
- box-shadow: var(--cosmoz-bottom-bar-view-bar-shadow, none);
50
- position: static;
51
- flex: none;
52
- }
53
- </style>
54
- <div id="content" part="content">
55
- ${ ref(info) }
56
- <slot name="content"></slot>
57
- <slot name="scroller-content"></slot>
58
- </div>
59
- <cosmoz-bottom-bar id="bar" ?active=${ active } bar-height=${ ifDefined(barHeight) } part="bar">
60
- <slot></slot>
61
- ${ bottomBarSlots }
62
- </cosmoz-bottom-bar>
63
- `;
64
- };
17
+ active = true,
18
+ barHeight
19
+ }) => html`
20
+ <style>
21
+ :host {
22
+ position: relative;
23
+ display: flex;
24
+ flex-direction: column;
25
+ flex: var(--cosmoz-bottom-bar-view-flex, auto);
26
+ overflow: hidden;
27
+ }
28
+
29
+ #content {
30
+ display: flex;
31
+ flex-direction: column;
32
+ flex: auto;
33
+ -webkit-overflow-scrolling: touch;
34
+ overflow-y: auto;
35
+ }
36
+
37
+ #bar {
38
+ background-color: var(--cosmoz-bottom-bar-view-bar-color, rgba(230, 230, 230, 0.8));
39
+ box-shadow: var(--cosmoz-bottom-bar-view-bar-shadow, none);
40
+ position: static;
41
+ flex: none;
42
+ }
43
+ </style>
44
+ <div id="content" part="content">
45
+ <slot name="content"></slot>
46
+ <slot name="scroller-content"></slot>
47
+ </div>
48
+ <cosmoz-bottom-bar id="bar" ?active=${ active } bar-height=${ ifDefined(barHeight) } part="bar">
49
+ <slot></slot>
50
+ ${ bottomBarSlots }
51
+ </cosmoz-bottom-bar>
52
+ `;
65
53
  customElements.define('cosmoz-bottom-bar-view', component(CosmozBottomBarView));
66
54
 
@@ -1,133 +1,80 @@
1
- import '@webcomponents/shadycss/entrypoints/apply-shim';
2
-
3
- import '@polymer/iron-icons';
4
- import '@polymer/paper-icon-button';
5
- import '@polymer/paper-menu-button';
6
- import '@polymer/paper-listbox';
7
- import '@polymer/iron-selector/iron-selector';
8
-
1
+ import '@neovici/cosmoz-dropdown';
9
2
  import { html } from '@polymer/polymer/lib/utils/html-tag';
10
- export default html`
11
- <style>
12
- :host {
13
- display: block;
14
- position: absolute;
15
- bottom: 0;
16
- left: 0;
17
- width: 100%;
18
- max-width: 100%; /* Firefox fix */
19
- background-color: inherit;
20
- transition: max-height 0.3s ease;
21
- z-index: 10;
22
- }
23
-
24
- [hidden] {
25
- display: none !important;
26
- }
27
-
28
- #bar, #info, #toolbar, #extraToolbarSlot, #menu, #dropdown ::slotted(:not(slot)) {
29
- display: flex;
30
- align-items: center;
31
- }
32
-
33
- #bar {
34
- padding: 0 3%;
35
- }
36
-
37
- #info {
38
- min-width: 5px;
39
- padding-right: 3%;
40
- }
41
-
42
- #dropdownButton {
43
- color: var(--cosmoz-bottom-bar-menubutton-color, var(--light-primary-color));
44
- background-color: var(--cosmoz-bottom-bar-menubutton-background-color, var(--dark-primary-color));
45
- @apply --cosmoz-bottom-bar-menubutton;
46
- }
47
-
48
- #extraToolbarSlot ::slotted(:not(slot)) {
49
- @apply --cosmoz-bottom-bar-extra-toolbar-item;
50
- }
51
-
52
- #flex {
53
- flex: 1 0.000000000001px;
54
- }
55
3
 
56
- #toolbar, #extraToolbarSlot {
57
- overflow: hidden;
58
- }
59
- #info,
60
- #menu > div {
61
- white-space: nowrap;
62
- }
63
-
64
- #toolbar ::slotted(:not(slot)) {
65
- margin: 0 0.29em;
66
- min-width: 40px;
67
- min-height: 40px;
68
- text-overflow: ellipsis;
69
- white-space: nowrap;
70
- @apply --cosmoz-bottom-bar-toolbar-item;
71
- }
72
-
73
- #toolbar ::slotted([disabled]),
74
- #dropdown ::slotted([disabled]) {
75
- @apply --cosmoz-bottom-bar-toolbar-item-disabled;
76
- }
77
-
78
- #toolbar ::slotted([hidden]),
79
- #dropdown ::slotted([hidden]) {
80
- display: none !important;
81
- }
82
-
83
- #dropdown {
84
- padding: 0;
85
- --paper-menu-button-content: {
86
- max-width: 300px !important;
87
- };
88
- }
89
-
90
- /** Seems like a shady dom scoping/slotting issue */
91
- #listboxSizer {
92
- max-height: 0;
93
- padding: 0 !important;
94
- }
95
-
96
- #dropdown ::slotted(:not(slot)) {
97
- position: relative;
98
- cursor: pointer;
99
- @apply --cosmoz-bottom-bar-menu-item;
100
- }
101
- #dropdown ::slotted(:not(slot):hover) {
102
- background: #eee;
103
- }
104
- </style>
105
-
106
- <div id="bar" style$="[[ _getHeightStyle(computedBarHeight) ]]">
107
- <div id="info">
108
- <slot name="info"></slot>
109
- </div>
110
- <div id="flex"></div>
111
- <iron-selector id="toolbar" selected-class="[[ selectedClass ]]" on-iron-select="_onActionSelected">
112
- <slot id="bottomBarToolbar" name="bottom-bar-toolbar"></slot>
113
- </iron-selector>
114
- <paper-menu-button id="menu" hidden$="[[ !hasMenuItems ]]" no-animations
115
- vertical-offset="[[ barHeight ]]" vertical-align="bottom" horizontal-align="right">
116
-
117
- <paper-icon-button id="dropdownButton" class="dropdown-trigger" slot="dropdown-trigger" icon="menu" toggles raised>
118
- </paper-icon-button>
119
- <paper-listbox id="dropdown" class="dropdown-content" slot="dropdown-content"
120
- selected-class="[[ selectedClass ]]" on-iron-select="_onActionSelected">
121
- <span id="listboxSizer"></span>
122
- <slot id="bottomBarMenu" name="bottom-bar-menu"></slot>
123
- </paper-listbox>
124
- </paper-menu-button>
125
- <iron-selector id="extraToolbarSlot" on-iron-select="_onActionSelected">
126
- <slot name="extra" id="extraSlot"></slot>
127
- </iron-selector>
128
- </div>
129
-
130
- <div hidden style="display:none">
131
- <slot id="content"></slot>
132
- </div>
4
+ export default html`
5
+ <style>
6
+ :host {
7
+ display: block;
8
+ position: absolute;
9
+ bottom: 0;
10
+ left: 0;
11
+ width: 100%;
12
+ max-width: 100%; /* Firefox fix */
13
+ background-color: inherit;
14
+ transition: max-height 0.3s ease;
15
+ z-index: 10;
16
+ --cosmoz-dropdown-anchor-spacing: 12px 6px;
17
+ --paper-button: {
18
+ background-color: inherit;
19
+ text-transform: none;
20
+ border: 0;
21
+ border-radius: 0;
22
+ font-size: inherit;
23
+ color: inherit;
24
+ font-weight: inherit;
25
+ margin: 0;
26
+ padding: 0;
27
+ };
28
+ }
29
+ [hidden], ::slotted([hidden]) {
30
+ display: none !important;
31
+ }
32
+ #bar {
33
+ padding: 0 3%;
34
+ display: flex;
35
+ align-items: center;
36
+ }
37
+ #info {
38
+ min-width: 5px;
39
+ padding-right: 3%;
40
+ margin-right: auto;
41
+ white-space: nowrap;
42
+ }
43
+ #bottomBarToolbar::slotted(:not(slot)) {
44
+ margin: 0 0.29em;
45
+ min-width: 40px;
46
+ min-height: 40px;
47
+ text-overflow: ellipsis;
48
+ white-space: nowrap;
49
+ background: var(--cosmoz-bottom-bar-button-bg-color, var(--cosmoz-button-bg-color, #101010));
50
+ color: var(--cosmoz-bottom-bar-button-color, var(--cosmoz-button-color, #fff));
51
+ border-radius: 6px;
52
+ padding: 0 18px;
53
+ font-size: 14px;
54
+ font-weight: 500;
55
+ line-height: 40px;
56
+ }
57
+ #bottomBarToolbar::slotted(:not(slot):hover) {
58
+ background: var(--cosmoz-bottom-bar-button-hover-bg-color, var(--cosmoz-button-hover-bg-color, #3A3F44));
59
+ }
60
+ #dropdown::part(dropdown) {
61
+ max-width: 300px;
62
+ }
63
+ </style>
64
+ <div id="bar" style$="[[ _getHeightStyle(computedBarHeight) ]]" part="bar">
65
+ <div id="info"><slot name="info"></slot></div>
66
+ <slot id="bottomBarToolbar" name="bottom-bar-toolbar"></slot>
67
+ <cosmoz-dropdown-menu id="dropdown" hidden="[[ !hasMenuItems ]]" placement="[[ topPlacement ]]">
68
+ <svg slot="button" width="4" height="16" viewBox="0 0 4 16" fill="none" xmlns="http://www.w3.org/2000/svg">
69
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M1.50996e-07 2C1.02714e-07 3.10457 0.89543 4 2 4C3.10457 4 4 3.10457 4 2C4 0.89543 3.10457 -3.91405e-08 2 -8.74228e-08C0.895431 -1.35705e-07 1.99278e-07 0.89543 1.50996e-07 2Z" fill="white"/>
70
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M1.50996e-07 8C1.02714e-07 9.10457 0.89543 10 2 10C3.10457 10 4 9.10457 4 8C4 6.89543 3.10457 6 2 6C0.895431 6 1.99278e-07 6.89543 1.50996e-07 8Z" fill="white"/>
71
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M1.50996e-07 14C1.02714e-07 15.1046 0.89543 16 2 16C3.10457 16 4 15.1046 4 14C4 12.8954 3.10457 12 2 12C0.895431 12 1.99278e-07 12.8954 1.50996e-07 14Z" fill="white"/>
72
+ </svg>
73
+ <slot id="bottomBarMenu" name="bottom-bar-menu"></slot>
74
+ </cosmoz-dropdown-menu>
75
+ <slot name="extra" id="extraSlot"></slot>
76
+ </div>
77
+ <div hidden style="display:none">
78
+ <slot id="content"></slot>
79
+ </div>
133
80
  `;
@@ -7,6 +7,7 @@ import { Debouncer } from '@polymer/polymer/lib/utils/debounce.js';
7
7
  import { timeOut } from '@polymer/polymer/lib/utils/async';
8
8
  import template from './cosmoz-bottom-bar.html.js';
9
9
  import { html } from 'haunted';
10
+ import { defaultPlacement } from '@neovici/cosmoz-dropdown';
10
11
 
11
12
  const
12
13
  BOTTOM_BAR_TOOLBAR_SLOT = 'bottom-bar-toolbar',
@@ -155,6 +156,10 @@ class CosmozBottomBar extends PolymerElement {
155
156
  _matchHeightElement: {
156
157
  type: Object,
157
158
  computed: '_getHeightMatchingElement(matchParent)'
159
+ },
160
+
161
+ topPlacement: {
162
+ value: ['top-right', ...defaultPlacement]
158
163
  }
159
164
  };
160
165
  }
@@ -167,7 +172,6 @@ class CosmozBottomBar extends PolymerElement {
167
172
 
168
173
  constructor() {
169
174
  super();
170
- this._boundDropdownClosed = this._dropdownClosed.bind(this);
171
175
  this._boundChildrenUpdated = this._childrenUpdated.bind(this);
172
176
  this._boundLayoutActions = this._layoutActions.bind(this);
173
177
  this._resizeObserver = new ResizeObserver((...args) => {
@@ -179,7 +183,6 @@ class CosmozBottomBar extends PolymerElement {
179
183
  connectedCallback() {
180
184
  super.connectedCallback();
181
185
 
182
- this.addEventListener('iron-closed-overlay', this._boundDropdownClosed);
183
186
 
184
187
  const layoutOnRemove = info => info.removedNodes.filter(this._isActionNode) && this._debounceLayoutActions();
185
188
  this._nodeObservers = [
@@ -196,7 +199,6 @@ class CosmozBottomBar extends PolymerElement {
196
199
  disconnectedCallback() {
197
200
  super.disconnectedCallback();
198
201
 
199
- this.removeEventListener('iron-closed-overlay', this._boundDropdownClosed);
200
202
  [...this._nodeObservers, this._hiddenMutationObserver].forEach(e => e.disconnect(e));
201
203
  this._layoutDebouncer?.cancel(); /* eslint-disable-line no-unused-expressions */
202
204
  this._resizeObserver.unobserve(this);
@@ -240,10 +242,6 @@ class CosmozBottomBar extends PolymerElement {
240
242
  );
241
243
  }
242
244
 
243
- _dropdownClosed() {
244
- this.$.dropdownButton.active = false;
245
- }
246
-
247
245
  _fireAction(item) {
248
246
  item?.dispatchEvent?.(new window.CustomEvent('action', {
249
247
  bubbles: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-bottom-bar",
3
- "version": "4.1.0",
3
+ "version": "4.4.0",
4
4
  "description": "A responsive bottom-bar that can house buttons/actions and a menu for the buttons that won't fit the available width.",
5
5
  "keywords": [
6
6
  "polymer",
@@ -51,35 +51,28 @@
51
51
  ]
52
52
  },
53
53
  "dependencies": {
54
- "@neovici/cosmoz-utils": "^3.12.0",
55
- "@neovici/cosmoz-viewinfo": "^3.1.3",
56
- "@polymer/iron-icons": "^3.0.1",
57
- "@polymer/iron-selector": "^3.0.0",
58
- "@polymer/paper-icon-button": "^3.0.0",
59
- "@polymer/paper-listbox": "^3.0.0",
60
- "@polymer/paper-menu-button": "^3.0.0",
54
+ "@neovici/cosmoz-dropdown": "^1.1.0",
61
55
  "@polymer/polymer": "^3.3.1",
62
- "@webcomponents/shadycss": "^1.10.2",
63
56
  "haunted": "^4.8.0",
64
57
  "lit-html": "^1.4.0"
65
58
  },
66
59
  "devDependencies": {
67
- "@commitlint/cli": "^12.0.0",
68
- "@commitlint/config-conventional": "^12.0.0",
60
+ "@commitlint/cli": "^15.0.0",
61
+ "@commitlint/config-conventional": "^15.0.0",
69
62
  "@neovici/eslint-config": "^1.3.0",
70
63
  "@open-wc/testing": "^2.5.0",
71
64
  "@polymer/iron-icon": "^3.0.1",
65
+ "@polymer/iron-icons": "^3.0.1",
72
66
  "@polymer/paper-button": "^3.0.0",
73
67
  "@polymer/paper-toggle-button": "^3.0.0",
74
- "@semantic-release/changelog": "^5.0.0",
75
- "@semantic-release/git": "^9.0.0",
76
- "@web/dev-server": "^0.1.17",
68
+ "@semantic-release/changelog": "^6.0.0",
69
+ "@semantic-release/git": "^10.0.0",
70
+ "@web/dev-server": "^0.1.0",
77
71
  "@web/test-runner": "^0.13.0",
78
72
  "@web/test-runner-selenium": "^0.5.0",
79
73
  "@webcomponents/webcomponentsjs": "^2.5.0",
80
- "eslint": "^7.0.0",
81
- "husky": "^6.0.0",
82
- "semantic-release": "^17.4.0",
83
- "sinon": "^11.0.0"
74
+ "husky": "^7.0.0",
75
+ "semantic-release": "^18.0.0",
76
+ "sinon": "^12.0.0"
84
77
  }
85
78
  }
@@ -1,62 +0,0 @@
1
- import {
2
- useEffect,
3
- useState,
4
- useMemo
5
- } from 'haunted';
6
- import { useViewInfo } from '@neovici/cosmoz-viewinfo';
7
-
8
- const useBottomBarView = ({
9
- active: initialActive = true,
10
- fixed
11
- }) => { /* eslint-disable no-return-assign */
12
- const { desktop } = useViewInfo(),
13
- isFixed = fixed ?? desktop,
14
- [active, setActive] = useState(initialActive),
15
- info = useMemo(() => ({}), []);
16
-
17
- useEffect(() => {
18
- if (isFixed) {
19
- return;
20
- }
21
- const
22
- { current: el } = info,
23
- opts = { passive: true },
24
- onScroll = () => {
25
- if (info.raf) {
26
- cancelAnimationFrame(info.raf);
27
- }
28
- info.raf = requestAnimationFrame(() => info.raf = requestAnimationFrame(() => {
29
- const { scrollTop } = el;
30
- setActive(
31
- scrollTop < 2 // at top
32
- || info.scrollTop > scrollTop // scrolling up
33
- || el.scrollHeight - scrollTop - el.offsetHeight < 3 // at bottom
34
- );
35
- Object.assign(info, {
36
- scrollTop,
37
- raf: undefined
38
- });
39
- }));
40
- };
41
- el.addEventListener('scroll', onScroll, opts);
42
- onScroll();
43
- return () => {
44
- el.removeEventListener('scroll', onScroll, opts);
45
- if (info.raf) {
46
- cancelAnimationFrame(info.raf);
47
- info.raf = undefined;
48
- }
49
- };
50
- }, [isFixed, info]);
51
-
52
- useEffect(() => {
53
- setActive(initialActive);
54
- }, [initialActive, setActive]);
55
-
56
- return {
57
- active,
58
- info
59
- };
60
- };
61
-
62
- export { useBottomBarView };