Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Unified Diff: third_party/polymer/components/paper-tabs/paper-tabs.html

Issue 582873003: Polymer elements added to third_party/polymer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/components/paper-tabs/paper-tabs.html
diff --git a/third_party/polymer/components/paper-tabs/paper-tabs.html b/third_party/polymer/components/paper-tabs/paper-tabs.html
new file mode 100644
index 0000000000000000000000000000000000000000..28c4f29624565f9144d79bed5eaab277929a8eec
--- /dev/null
+++ b/third_party/polymer/components/paper-tabs/paper-tabs.html
@@ -0,0 +1,128 @@
+<!--
+Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
+This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
+The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
+The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
+Code distributed by Google as part of the polymer project is also
+subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
+-->
+
+<!--
+`paper-tabs` is a `core-selector` styled to look like tabs. Tabs make it easy to
+explore and switch between different views or functional aspects of an app, or
+to browse categorized data sets.
+
+Use `selected` property to get or set the selected tab.
+
+Example:
+
+ <paper-tabs selected="0">
+ <paper-tab>TAB 1</paper-tab>
+ <paper-tab>TAB 2</paper-tab>
+ <paper-tab>TAB 3</paper-tab>
+ </paper-tabs>
+
+See <a href="#paper-tab">paper-tab</a> for more information about
+`paper-tab`.
+
+Styling tabs:
+
+To change the sliding bar color:
+
+ paper-tabs.pink::shadow #selectionBar {
+ background-color: #ff4081;
+ }
+
+@group Paper Elements
+@element paper-tabs
+@extends core-selector
+@homepage github.io
+-->
+
+<link rel="import" href="../core-selector/core-selector.html">
+<link rel="import" href="paper-tab.html">
+
+<polymer-element name="paper-tabs" extends="core-selector" attributes="noink nobar" role="tablist">
+<template>
+
+ <link rel="stylesheet" href="paper-tabs.css">
+
+ <div id="tabsContainer" horizontal layout>
+
+ <shadow></shadow>
+ <div id="selectionBar" hidden?="{{nobar}}" on-transitionend="{{barTransitionEnd}}"></div>
+
+ </div>
+
+</template>
+<script>
+
+ Polymer('paper-tabs', {
+
+ /**
+ * If true, ink effect is disabled.
+ *
+ * @attribute noink
+ * @type boolean
+ * @default false
+ */
+ noink: false,
+
+ /**
+ * If true, the bottom bar to indicate the selected tab will not be shown.
+ *
+ * @attribute nobar
+ * @type boolean
+ * @default false
+ */
+ nobar: false,
+
+ activateEvent: 'down',
+
+ nostretch: false,
+
+ selectedIndexChanged: function(old) {
+ var s = this.$.selectionBar.style;
+
+ if (!this.selectedItem) {
+ s.width = 0;
+ s.left = 0;
+ return;
+ }
+
+ var w = 100 / this.items.length;
+
+ if (this.nostretch || old === null || old === -1) {
+ s.width = w + '%';
+ s.left = this.selectedIndex * w + '%';
+ return;
+ }
+
+ var m = 5;
+ this.$.selectionBar.classList.add('expand');
+ if (old < this.selectedIndex) {
+ s.width = w + w * (this.selectedIndex - old) - m + '%';
+ } else {
+ s.width = w + w * (old - this.selectedIndex) - m + '%';
+ s.left = this.selectedIndex * w + m + '%';
+ }
+ },
+
+ barTransitionEnd: function() {
+ var cl = this.$.selectionBar.classList;
+ if (cl.contains('expand')) {
+ cl.remove('expand');
+ cl.add('contract');
+ var s = this.$.selectionBar.style;
+ var w = 100 / this.items.length;
+ s.width = w + '%';
+ s.left = this.selectedIndex * w + '%';
+ } else if (cl.contains('contract')) {
+ cl.remove('contract');
+ }
+ }
+
+ });
+
+</script>
+</polymer-element>
« no previous file with comments | « third_party/polymer/components/paper-tabs/paper-tabs.css ('k') | third_party/polymer/components/paper-toast/.bower.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698