@lemonadejs/tabs 1.1.0 → 2.0.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/dist/index.js +19 -17
- package/dist/style.css +23 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
if (!
|
|
1
|
+
if (!lemonade && typeof (require) === 'function') {
|
|
2
2
|
var lemonade = require('lemonadejs');
|
|
3
3
|
}
|
|
4
4
|
|
|
@@ -21,17 +21,6 @@ if (! lemonade && typeof(require) === 'function') {
|
|
|
21
21
|
|
|
22
22
|
self.tabs = [];
|
|
23
23
|
|
|
24
|
-
self.onload = function () {
|
|
25
|
-
for (let i = 0; i < self.content.children.length; i++) {
|
|
26
|
-
self.tabs.push({ title: self.content.children[i].title });
|
|
27
|
-
}
|
|
28
|
-
self.refresh('tabs');
|
|
29
|
-
|
|
30
|
-
if (! isNaN(parseInt(self.selected))) {
|
|
31
|
-
select(self.selected);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
24
|
const select = function (index) {
|
|
36
25
|
index = parseInt(index);
|
|
37
26
|
|
|
@@ -43,6 +32,19 @@ if (! lemonade && typeof(require) === 'function') {
|
|
|
43
32
|
self.content.children[index].classList.add('selected');
|
|
44
33
|
}
|
|
45
34
|
|
|
35
|
+
self.onload = function () {
|
|
36
|
+
for (let i = 0; i < self.content.children.length; i++) {
|
|
37
|
+
self.tabs.push({ title: self.content.children[i].title });
|
|
38
|
+
}
|
|
39
|
+
self.refresh('tabs');
|
|
40
|
+
|
|
41
|
+
let index = 0;
|
|
42
|
+
if (! isNaN(parseInt(self.selected))) {
|
|
43
|
+
index = parseInt(self.selected);
|
|
44
|
+
}
|
|
45
|
+
select(index);
|
|
46
|
+
}
|
|
47
|
+
|
|
46
48
|
self.onchange = function (property) {
|
|
47
49
|
if (property === 'selected') {
|
|
48
50
|
select(self.selected);
|
|
@@ -53,14 +55,14 @@ if (! lemonade && typeof(require) === 'function') {
|
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
self.click = function (
|
|
57
|
-
if (
|
|
58
|
-
self.selected = Array.prototype.indexOf.call(
|
|
58
|
+
self.click = function (e) {
|
|
59
|
+
if (e.target.tagName === 'LI') {
|
|
60
|
+
self.selected = Array.prototype.indexOf.call(e.target.parentNode.children, e.target);
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
return `<div class="lm-tabs"
|
|
63
|
-
<ul :ref="self.headers" :loop="self.tabs" :selected="self.selected" onclick="self.click
|
|
64
|
+
return `<div class="lm-tabs" data-position="{{self.position}}" data-round="{{self.round}}">
|
|
65
|
+
<ul :ref="self.headers" :loop="self.tabs" :selected="self.selected" onclick="self.click"><li class="lm-tab-list-item">{{self.title}}</li></ul>
|
|
64
66
|
<div :ref="self.content" class="lm-tabs-content">${content}</div>
|
|
65
67
|
</div>`
|
|
66
68
|
}
|
package/dist/style.css
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
display: flex;
|
|
8
8
|
margin: 0;
|
|
9
9
|
padding: 0;
|
|
10
|
-
margin-bottom: 5px;
|
|
11
10
|
width: fit-content;
|
|
12
11
|
align-self: center;
|
|
13
12
|
}
|
|
@@ -15,15 +14,35 @@
|
|
|
15
14
|
.lm-tabs > ul > li {
|
|
16
15
|
cursor: pointer;
|
|
17
16
|
user-select: none;
|
|
18
|
-
padding:
|
|
19
|
-
|
|
17
|
+
padding: 4px 12px 4px 12px;
|
|
18
|
+
border: 1px solid #ccc;
|
|
20
19
|
background-position: center;
|
|
21
20
|
transition: background 0.8s;
|
|
22
21
|
}
|
|
23
22
|
|
|
23
|
+
.lm-tabs > ul > li.selected {
|
|
24
|
+
background-color: #eee;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.lm-tabs[data-round="true"] > ul > li:first-child {
|
|
28
|
+
border-top-left-radius: 3px;
|
|
29
|
+
border-bottom-left-radius: 3px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.lm-tabs[data-round="true"] > ul > li:last-child {
|
|
33
|
+
border-top-right-radius: 3px;
|
|
34
|
+
border-bottom-right-radius: 3px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
.lm-tabs > ul > li:not(:first-child) {
|
|
39
|
+
border-left: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
24
42
|
.lm-tabs > ul > li:hover {
|
|
25
43
|
background: #eee radial-gradient(circle, transparent 1%, #eee 1%) center/15000%;
|
|
26
44
|
}
|
|
45
|
+
|
|
27
46
|
.lm-tabs > ul > li:active {
|
|
28
47
|
background-color: #ddd;
|
|
29
48
|
background-size: 100%;
|
|
@@ -38,6 +57,6 @@
|
|
|
38
57
|
display: block;
|
|
39
58
|
}
|
|
40
59
|
|
|
41
|
-
.lm-tabs[position="center"] > ul {
|
|
60
|
+
.lm-tabs[data-position="center"] > ul {
|
|
42
61
|
margin: 0 auto;
|
|
43
62
|
}
|