@neovici/cosmoz-bottom-bar 4.1.1 → 4.2.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/cosmoz-bottom-bar-view.js +36 -48
- package/cosmoz-bottom-bar.html.js +1 -1
- package/package.json +10 -12
- package/lib/use-bottom-bar-view.js +0 -62
|
@@ -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
|
-
|
|
22
|
-
|
|
23
|
-
}) =>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
|
|
@@ -103,7 +103,7 @@ export default html`
|
|
|
103
103
|
}
|
|
104
104
|
</style>
|
|
105
105
|
|
|
106
|
-
<div id="bar" style$="[[ _getHeightStyle(computedBarHeight) ]]">
|
|
106
|
+
<div id="bar" style$="[[ _getHeightStyle(computedBarHeight) ]]" part="bar">
|
|
107
107
|
<div id="info">
|
|
108
108
|
<slot name="info"></slot>
|
|
109
109
|
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cosmoz-bottom-bar",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.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,8 +51,7 @@
|
|
|
51
51
|
]
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@neovici/cosmoz-utils": "^3.
|
|
55
|
-
"@neovici/cosmoz-viewinfo": "^3.1.3",
|
|
54
|
+
"@neovici/cosmoz-utils": "^3.21.0",
|
|
56
55
|
"@polymer/iron-icons": "^3.0.1",
|
|
57
56
|
"@polymer/iron-selector": "^3.0.0",
|
|
58
57
|
"@polymer/paper-icon-button": "^3.0.0",
|
|
@@ -64,22 +63,21 @@
|
|
|
64
63
|
"lit-html": "^1.4.0"
|
|
65
64
|
},
|
|
66
65
|
"devDependencies": {
|
|
67
|
-
"@commitlint/cli": "^
|
|
68
|
-
"@commitlint/config-conventional": "^
|
|
66
|
+
"@commitlint/cli": "^15.0.0",
|
|
67
|
+
"@commitlint/config-conventional": "^15.0.0",
|
|
69
68
|
"@neovici/eslint-config": "^1.3.0",
|
|
70
69
|
"@open-wc/testing": "^2.5.0",
|
|
71
70
|
"@polymer/iron-icon": "^3.0.1",
|
|
72
71
|
"@polymer/paper-button": "^3.0.0",
|
|
73
72
|
"@polymer/paper-toggle-button": "^3.0.0",
|
|
74
|
-
"@semantic-release/changelog": "^
|
|
75
|
-
"@semantic-release/git": "^
|
|
76
|
-
"@web/dev-server": "^0.1.
|
|
73
|
+
"@semantic-release/changelog": "^6.0.0",
|
|
74
|
+
"@semantic-release/git": "^10.0.0",
|
|
75
|
+
"@web/dev-server": "^0.1.0",
|
|
77
76
|
"@web/test-runner": "^0.13.0",
|
|
78
77
|
"@web/test-runner-selenium": "^0.5.0",
|
|
79
78
|
"@webcomponents/webcomponentsjs": "^2.5.0",
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"sinon": "^11.0.0"
|
|
79
|
+
"husky": "^7.0.0",
|
|
80
|
+
"semantic-release": "^18.0.0",
|
|
81
|
+
"sinon": "^12.0.0"
|
|
84
82
|
}
|
|
85
83
|
}
|
|
@@ -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 };
|