forked from Polymer/old-docs-site
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo-tabs.html
More file actions
101 lines (96 loc) · 2.5 KB
/
demo-tabs.html
File metadata and controls
101 lines (96 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<link rel="import" href="../components/polymer-selector/polymer-selector.html">
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="demo-tab" attributes="heading">
<template>
<style>
:host {
display: block;
}
/* @polyfill :host > * */
::content > * {
display: none;
}
/* @polyfill :host.selected > * */
:host(.selected) ::content > * {
display: block;
}
</style>
<content></content>
</template>
<script>
Polymer('demo-tab', {
heading: '',
selected: false,
selectedChanged: function() {
this.selected ? this.classList.add('selected') :
this.classList.remove('selected');
}
});
</script>
</polymer-element>
<polymer-element name="demo-tabs" attributes="selectedIndex">
<template>
<link rel="stylesheet" href="../css/polymer.css">
<style>
:host {
display: block;
}
.tab-strip {
height: 60px;
white-space: nowrap;
}
.tab-strip span {
line-height: 60px;
text-align: center;
padding: 0px 12px;
cursor: pointer;
opacity: 0.4;
background: #5c6bc0; /*rgb(85, 153, 255);*/
color: white;
}
.tab-wrapper {
display: flex;
-webkit-user-select: none;
user-select: none;
}
.polymer-selected {
opacity: 1 !important;
}
#contents {
padding: 20px;
/*min-height: 250px;*/
overflow: auto;
}
/* @polyfill :host pre */
::content pre {
margin: 0 !important;
}
</style>
<div id="container">
<div class="tab-strip">
<polymer-selector selected="{{selectedIndex}}" class="tab-wrapper">
<template repeat="{{panel in panels}}">
<span>{{panel.heading}}</span>
</template>
</polymer-selector>
</div>
<div id="contents" class="main-bg">
<content id="contentpanels" select="demo-tab"></content>
</div>
</div>
</template>
<script>
Polymer('demo-tabs', {
selectedIndexChanged: function(oldVal) {
this.panels = [].slice.call(this.$.contentpanels.getDistributedNodes());
if (!this.panels.length) {
return;
}
[].forEach.call(this.panels, function(panel, i) {
panel.selected = false;
});
this.panels[this.selectedIndex].selected = true;
}
});
</script>
</polymer-element>