@neovici/cosmoz-tabs 5.1.2 → 5.3.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.
@@ -60,7 +60,7 @@ const CosmozTabCard = ({ heading }) => html`
60
60
  </style>
61
61
 
62
62
  <div id="header" part="header">
63
- <h1 class="heading">${ heading }<slot name="after-title"></slot></h1>
63
+ <h1 class="heading" part="heading">${ heading }<slot name="after-title"></slot></h1>
64
64
  <slot name="card-actions"></slot>
65
65
  </div>
66
66
 
package/cosmoz-tabs.js CHANGED
@@ -17,8 +17,8 @@ using tabs.
17
17
 
18
18
  The following custom properties and mixins are available for styling:
19
19
 
20
- Custom property | Description | Default
21
- ----------------|-------------|----------
20
+ Custom property | Description | Default
21
+ ------------------------------------|-----------------------------|----------
22
22
  `--cosmoz-tabs-selection-bar-color` | Color for the selection bar | `#00b4db`
23
23
 
24
24
  */
@@ -28,6 +28,7 @@ const Tabs = host => {
28
28
  return html`
29
29
  <style>${ style }</style>
30
30
  <div class="tabs" part="tabs" role="tablist">
31
+ <slot name="tabs"></slot>
31
32
  ${ tabs.map(renderTab(opts)) }
32
33
  </div>
33
34
 
package/lib/render.js CHANGED
@@ -12,17 +12,20 @@ const style = `
12
12
  }
13
13
 
14
14
  .tabs {
15
- background-color: #fff;
16
- margin-bottom: 3px;
17
- box-shadow: var(--cosmoz-shadow-2dp, var(--shadow-elevation-2dp_-_box-shadow, 0 2px 4px 0 #e5e5e5));
15
+ background-color: var(--cosmoz-tabs-bg-color, #fff);
16
+ color: var(--cosmoz-tabs-text-color, #606c7e);
17
+ font-family: var(--cosmoz-tabs-font-family, inherit);
18
+ font-size: var(--cosmoz-tabs-font-size, 13px);
19
+ line-height: var(--cosmoz-tabs-line-height, 19px);
20
+ box-shadow: var(--cosmoz-tabs-shadow, inset 0 -1px 0 0 #e5e6eb);
18
21
  flex: none;
19
22
  display: flex;
20
23
  align-items: center;
21
24
  overflow-x: auto;
22
25
  -webkit-overflow-scrolling: auto;
23
26
  scrollbar-width: none;
27
+ padding-bottom: 1px;
24
28
  }
25
-
26
29
  .tabs::-webkit-scrollbar {
27
30
  display: none;
28
31
  }
@@ -30,16 +33,15 @@ const style = `
30
33
  .tab {
31
34
  position: relative;
32
35
  display: flex;
36
+ box-sizing: border-box;
33
37
  align-items: center;
34
38
  justify-content: center;
35
39
  flex: 1;
36
- padding: 0.767em 24px;
40
+ padding: 11px 24px;
37
41
  color: inherit;
38
42
  text-decoration: none;
39
43
  text-align: center;
40
- font-size: 1.0714286em;
41
- line-height: 1.27;
42
- font-weight: 300;
44
+ letter-spacing: 0.3px;
43
45
  text-overflow: ellipsis;
44
46
  white-space: nowrap;
45
47
  cursor: pointer;
@@ -48,12 +50,14 @@ const style = `
48
50
  }
49
51
 
50
52
  .tab[aria-selected] {
51
- box-shadow: inset 0 -1.4px 0px 0px var(--cosmoz-tabs-selection-bar-color, #00b4db);
52
- font-weight: 400;
53
+ color: var(--cosmoz-tabs-accent-color, #508aef);
54
+ box-shadow: inset 0 -3px 0px 0px var(--cosmoz-tabs-accent-color, #508aef);
55
+ font-weight: 700;
56
+ letter-spacing: 0;
53
57
  }
54
58
 
55
59
  .tab[disabled] {
56
- opacity: 0.65;
60
+ opacity: 0.4;
57
61
  pointer-events: none;
58
62
  }
59
63
 
@@ -101,10 +105,11 @@ const style = `
101
105
  selectedTab,
102
106
  onSelect,
103
107
  href
104
- }) => tab => {
108
+ }) => (tab, i, tabs) => {
105
109
  const isSelected = selectedTab === tab,
106
110
  icon = getIcon(tab, isSelected);
107
111
  return html`<a class="tab" tabindex="-1" role="tab"
112
+ part=${ ['tab', i === 0 && 'first-tab', i === tabs.length - 1 && 'last-tab', isSelected && 'selected-tab'].filter(Boolean).join(' ') }
108
113
  ?hidden=${ tab.hidden } ?disabled=${ tab.disabled }
109
114
  ?aria-selected=${ isSelected }
110
115
  @click=${ onSelect }
package/lib/use-tabs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { useState, useEffect, useMemo, useCallback } from 'haunted';
2
2
  import { notifyProperty } from '@neovici/cosmoz-utils/lib/hooks/use-notify-property';
3
- import { useHashParam, link } from './use-hash-param';
3
+ import { useHashParam, link } from '@neovici/cosmoz-page-router/lib/use-hash-param';
4
4
  import { choose, collect, getName, isValid } from './utils';
5
5
  import computeScroll from 'compute-scroll-into-view';
6
6
 
@@ -89,9 +89,7 @@ const useTabSelectedEffect = (host, selectedTab) => {
89
89
 
90
90
  e.preventDefault();
91
91
  window.history.pushState({}, '', href(tab));
92
- // TODO: drop this when we drop iron-location/cosmoz-page-location
93
- requestAnimationFrame(() => window.dispatchEvent(new CustomEvent('location-changed')));
94
- requestAnimationFrame(() => window.dispatchEvent(new CustomEvent('hash-changed')));
92
+ requestAnimationFrame(() => window.dispatchEvent(new CustomEvent('hashchange')));
95
93
  }, []),
96
94
  href
97
95
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-tabs",
3
- "version": "5.1.2",
3
+ "version": "5.3.0",
4
4
  "description": "A multi views container element that allow navigation between the views using tabs or an accordion.",
5
5
  "keywords": [
6
6
  "web-components"
@@ -54,7 +54,8 @@
54
54
  ]
55
55
  },
56
56
  "dependencies": {
57
- "@neovici/cosmoz-utils": "^3.21.0",
57
+ "@neovici/cosmoz-page-router": "^7.0.0",
58
+ "@neovici/cosmoz-utils": "^3.25.0",
58
59
  "@polymer/iron-icon": "^3.0.0",
59
60
  "@polymer/iron-icons": "^3.0.0",
60
61
  "compute-scroll-into-view": "^1.0.17",
@@ -62,9 +63,9 @@
62
63
  "lit-html": "^1.4.0"
63
64
  },
64
65
  "devDependencies": {
65
- "@commitlint/cli": "^13.0.0",
66
- "@commitlint/config-conventional": "^13.0.0",
67
- "@neovici/eslint-config": "^1.3.0",
66
+ "@commitlint/cli": "^16.0.0",
67
+ "@commitlint/config-conventional": "^16.0.0",
68
+ "@neovici/cfg": "^1.11.0",
68
69
  "@open-wc/demoing-storybook": "^2.4.0",
69
70
  "@open-wc/testing": "^2.5.0",
70
71
  "@polymer/iron-list": "^3.1.0",
@@ -72,11 +73,9 @@
72
73
  "@semantic-release/git": "^10.0.0",
73
74
  "@storybook/storybook-deployer": "^2.8.0",
74
75
  "@web/test-runner": "^0.13.18",
75
- "@web/test-runner-selenium": "^0.5.2",
76
- "eslint": "^7.32.0",
77
76
  "husky": "^7.0.0",
78
- "semantic-release": "^18.0.0",
79
- "sinon": "^11.1.0",
77
+ "semantic-release": "^19.0.0",
78
+ "sinon": "^13.0.0",
80
79
  "typescript": "^4.4.0"
81
80
  }
82
81
  }
@@ -1,40 +0,0 @@
1
- import {
2
- useState, useEffect, useMemo
3
- } from 'haunted';
4
-
5
- const hashUrl = () => new URL(location.hash.replace(/^#!?/iu, '').replace('%23', '#'), location.origin),
6
- parameterize = hashParam => hashParam ? () => new URLSearchParams(hashUrl().hash.replace('#', '')).get(hashParam) : undefined,
7
- link = (hashParam, value) => {
8
- if (!hashParam) {
9
- return;
10
- }
11
- const url = hashUrl(),
12
- sp = new URLSearchParams(url.hash.replace('#', ''));
13
- sp.set(hashParam, value);
14
- return '#!' + Object.assign(url, { hash: sp }).href.replace(location.origin, '');
15
- },
16
- useHashParam = hashParam => {
17
- const parameterized = useMemo(() => parameterize(hashParam), [hashParam]),
18
- [param, setParam] = useState(parameterized);
19
-
20
- useEffect(() => {
21
- if (parameterized == null) {
22
- return;
23
- }
24
- const readParam = () => requestAnimationFrame(() => setParam(parameterized));
25
- readParam();
26
- window.addEventListener('popstate', readParam);
27
- window.addEventListener('hash-changed', readParam);
28
- return () => {
29
- window.removeEventListener('popstate', readParam);
30
- window.removeEventListener('hash-changed', readParam);
31
- };
32
- }, [parameterized]);
33
-
34
- return param;
35
- };
36
-
37
- export {
38
- link,
39
- useHashParam
40
- };