polymer-paper-elements-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +51 -0
- data/Rakefile +1 -0
- data/app/assets/components/iron-a11y-announcer/iron-a11y-announcer.html +125 -0
- data/app/assets/components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html +418 -0
- data/app/assets/components/iron-autogrow-textarea/hero.svg +33 -0
- data/app/assets/components/iron-autogrow-textarea/iron-autogrow-textarea.html +263 -0
- data/app/assets/components/iron-behaviors/iron-button-state.html +195 -0
- data/app/assets/components/iron-behaviors/iron-control-state.html +102 -0
- data/app/assets/components/iron-fit-behavior/iron-fit-behavior.html +230 -0
- data/app/assets/components/iron-flex-layout/classes/iron-flex-layout.html +307 -0
- data/app/assets/components/iron-flex-layout/classes/iron-shadow-flex-layout.html +302 -0
- data/app/assets/components/iron-flex-layout/iron-flex-layout.html +313 -0
- data/app/assets/components/iron-form-element-behavior/iron-form-element-behavior.html +50 -0
- data/app/assets/components/iron-icon/hero.svg +19 -0
- data/app/assets/components/iron-icon/iron-icon.html +187 -0
- data/app/assets/components/iron-icons/av-icons.html +73 -0
- data/app/assets/components/iron-icons/communication-icons.html +59 -0
- data/app/assets/components/iron-icons/device-icons.html +94 -0
- data/app/assets/components/iron-icons/editor-icons.html +70 -0
- data/app/assets/components/iron-icons/hardware-icons.html +61 -0
- data/app/assets/components/iron-icons/hero.svg +35 -0
- data/app/assets/components/iron-icons/image-icons.html +164 -0
- data/app/assets/components/iron-icons/iron-icons.html +303 -0
- data/app/assets/components/iron-icons/maps-icons.html +71 -0
- data/app/assets/components/iron-icons/notification-icons.html +62 -0
- data/app/assets/components/iron-icons/social-icons.html +40 -0
- data/app/assets/components/iron-iconset-svg/iron-iconset-svg.html +191 -0
- data/app/assets/components/iron-input/hero.svg +19 -0
- data/app/assets/components/iron-input/iron-input.html +235 -0
- data/app/assets/components/iron-media-query/hero.svg +29 -0
- data/app/assets/components/iron-media-query/iron-media-query.html +84 -0
- data/app/assets/components/iron-menu-behavior/iron-menu-behavior.html +214 -0
- data/app/assets/components/iron-menu-behavior/iron-menubar-behavior.html +65 -0
- data/app/assets/components/iron-meta/hero.svg +33 -0
- data/app/assets/components/iron-meta/iron-meta.html +352 -0
- data/app/assets/components/iron-overlay-behavior/iron-overlay-backdrop.html +132 -0
- data/app/assets/components/iron-overlay-behavior/iron-overlay-behavior.html +432 -0
- data/app/assets/components/iron-overlay-behavior/iron-overlay-manager.html +107 -0
- data/app/assets/components/iron-range-behavior/iron-range-behavior.html +101 -0
- data/app/assets/components/iron-resizable-behavior/iron-resizable-behavior.html +139 -0
- data/app/assets/components/iron-selector/iron-multi-selectable.html +120 -0
- data/app/assets/components/iron-selector/iron-selectable.html +307 -0
- data/app/assets/components/iron-selector/iron-selection.html +115 -0
- data/app/assets/components/iron-selector/iron-selector.html +71 -0
- data/app/assets/components/iron-validatable-behavior/iron-validatable-behavior.html +100 -0
- data/app/assets/components/neon-animation/animations/cascaded-animation.html +84 -0
- data/app/assets/components/neon-animation/animations/fade-in-animation.html +49 -0
- data/app/assets/components/neon-animation/animations/fade-out-animation.html +49 -0
- data/app/assets/components/neon-animation/animations/hero-animation.html +83 -0
- data/app/assets/components/neon-animation/animations/opaque-animation.html +46 -0
- data/app/assets/components/neon-animation/animations/ripple-animation.html +92 -0
- data/app/assets/components/neon-animation/animations/scale-down-animation.html +65 -0
- data/app/assets/components/neon-animation/animations/scale-up-animation.html +58 -0
- data/app/assets/components/neon-animation/animations/slide-down-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/slide-from-left-animation.html +60 -0
- data/app/assets/components/neon-animation/animations/slide-from-right-animation.html +60 -0
- data/app/assets/components/neon-animation/animations/slide-left-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/slide-right-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/slide-up-animation.html +59 -0
- data/app/assets/components/neon-animation/animations/transform-animation.html +61 -0
- data/app/assets/components/neon-animation/guides/neon-animation.md +313 -0
- data/app/assets/components/neon-animation/neon-animatable-behavior.html +156 -0
- data/app/assets/components/neon-animation/neon-animatable.html +54 -0
- data/app/assets/components/neon-animation/neon-animated-pages.html +208 -0
- data/app/assets/components/neon-animation/neon-animation-behavior.html +88 -0
- data/app/assets/components/neon-animation/neon-animation-runner-behavior.html +110 -0
- data/app/assets/components/neon-animation/neon-animation.html +17 -0
- data/app/assets/components/neon-animation/neon-animations.html +25 -0
- data/app/assets/components/neon-animation/neon-shared-element-animatable-behavior.html +37 -0
- data/app/assets/components/neon-animation/neon-shared-element-animation-behavior.html +66 -0
- data/app/assets/components/neon-animation/web-animations.html +11 -0
- data/app/assets/components/paper-behaviors/paper-button-behavior.html +55 -0
- data/app/assets/components/paper-behaviors/paper-inky-focus-behavior.html +44 -0
- data/app/assets/components/paper-button/paper-button.html +177 -0
- data/app/assets/components/paper-checkbox/metadata.html +17 -0
- data/app/assets/components/paper-checkbox/paper-checkbox.css +149 -0
- data/app/assets/components/paper-checkbox/paper-checkbox.html +163 -0
- data/app/assets/components/paper-dialog-behavior/hero.svg +51 -0
- data/app/assets/components/paper-dialog-behavior/paper-dialog-behavior.html +236 -0
- data/app/assets/components/paper-dialog-behavior/paper-dialog-common.css +58 -0
- data/app/assets/components/paper-dialog-scrollable/hero.svg +69 -0
- data/app/assets/components/paper-dialog-scrollable/paper-dialog-scrollable.html +150 -0
- data/app/assets/components/paper-dialog/hero.svg +58 -0
- data/app/assets/components/paper-dialog/paper-dialog.html +122 -0
- data/app/assets/components/paper-drawer-panel/hero.svg +21 -0
- data/app/assets/components/paper-drawer-panel/paper-drawer-panel.css +142 -0
- data/app/assets/components/paper-drawer-panel/paper-drawer-panel.html +585 -0
- data/app/assets/components/paper-fab/paper-fab.html +159 -0
- data/app/assets/components/paper-header-panel/hero.svg +38 -0
- data/app/assets/components/paper-header-panel/paper-header-panel.html +496 -0
- data/app/assets/components/paper-icon-button/paper-icon-button.html +141 -0
- data/app/assets/components/paper-input/all-imports.html +12 -0
- data/app/assets/components/paper-input/hero.svg +19 -0
- data/app/assets/components/paper-input/paper-input-addon-behavior.html +43 -0
- data/app/assets/components/paper-input/paper-input-behavior.html +293 -0
- data/app/assets/components/paper-input/paper-input-char-counter.html +95 -0
- data/app/assets/components/paper-input/paper-input-container.html +495 -0
- data/app/assets/components/paper-input/paper-input-error.html +99 -0
- data/app/assets/components/paper-input/paper-input.html +126 -0
- data/app/assets/components/paper-input/paper-textarea.html +100 -0
- data/app/assets/components/paper-item/all-imports.html +13 -0
- data/app/assets/components/paper-item/paper-icon-item.html +86 -0
- data/app/assets/components/paper-item/paper-item-body.html +93 -0
- data/app/assets/components/paper-item/paper-item-shared.css +19 -0
- data/app/assets/components/paper-item/paper-item.html +95 -0
- data/app/assets/components/paper-material/paper-material.html +98 -0
- data/app/assets/components/paper-menu/hero.svg +35 -0
- data/app/assets/components/paper-menu/paper-menu.html +133 -0
- data/app/assets/components/paper-progress/hero.svg +21 -0
- data/app/assets/components/paper-progress/paper-progress.html +199 -0
- data/app/assets/components/paper-radio-button/hero.svg +22 -0
- data/app/assets/components/paper-radio-button/paper-radio-button.css +109 -0
- data/app/assets/components/paper-radio-button/paper-radio-button.html +148 -0
- data/app/assets/components/paper-radio-group/hero.svg +25 -0
- data/app/assets/components/paper-radio-group/paper-radio-group.html +186 -0
- data/app/assets/components/paper-ripple/hero.svg +30 -0
- data/app/assets/components/paper-ripple/paper-ripple.html +714 -0
- data/app/assets/components/paper-scroll-header-panel/hero.svg +41 -0
- data/app/assets/components/paper-scroll-header-panel/paper-scroll-header-panel.html +455 -0
- data/app/assets/components/paper-slider/hero.svg +20 -0
- data/app/assets/components/paper-slider/paper-slider.css +252 -0
- data/app/assets/components/paper-slider/paper-slider.html +449 -0
- data/app/assets/components/paper-spinner/hero.svg +27 -0
- data/app/assets/components/paper-spinner/paper-spinner.css +325 -0
- data/app/assets/components/paper-spinner/paper-spinner.html +222 -0
- data/app/assets/components/paper-styles/classes/global.html +96 -0
- data/app/assets/components/paper-styles/classes/shadow-layout.html +302 -0
- data/app/assets/components/paper-styles/classes/shadow.html +39 -0
- data/app/assets/components/paper-styles/classes/typography.html +171 -0
- data/app/assets/components/paper-styles/color.html +333 -0
- data/app/assets/components/paper-styles/default-theme.html +39 -0
- data/app/assets/components/paper-styles/paper-styles-classes.html +14 -0
- data/app/assets/components/paper-styles/paper-styles.html +17 -0
- data/app/assets/components/paper-styles/shadow.html +61 -0
- data/app/assets/components/paper-styles/typography.html +240 -0
- data/app/assets/components/paper-tabs/hero.svg +23 -0
- data/app/assets/components/paper-tabs/paper-tab.html +158 -0
- data/app/assets/components/paper-tabs/paper-tabs-icons.html +18 -0
- data/app/assets/components/paper-tabs/paper-tabs.html +483 -0
- data/app/assets/components/paper-toast/hero.svg +20 -0
- data/app/assets/components/paper-toast/paper-toast.html +164 -0
- data/app/assets/components/paper-toggle-button/hero.svg +22 -0
- data/app/assets/components/paper-toggle-button/paper-toggle-button.css +108 -0
- data/app/assets/components/paper-toggle-button/paper-toggle-button.html +183 -0
- data/app/assets/components/paper-toolbar/paper-toolbar.html +375 -0
- data/app/assets/components/polymer-gestures/Gruntfile.js +60 -0
- data/app/assets/components/polymer-gestures/banner.txt +9 -0
- data/app/assets/components/polymer-gestures/build.json +17 -0
- data/app/assets/components/polymer-gestures/conf/karma.conf.js +39 -0
- data/app/assets/components/polymer-gestures/package.json +20 -0
- data/app/assets/components/polymer-gestures/polymer-gestures.html +21 -0
- data/app/assets/components/polymer-gestures/polymer-gestures.js +46 -0
- data/app/assets/components/polymer-gestures/src/dispatcher.js +474 -0
- data/app/assets/components/polymer-gestures/src/eventFactory.js +127 -0
- data/app/assets/components/polymer-gestures/src/hold.js +129 -0
- data/app/assets/components/polymer-gestures/src/mouse.js +135 -0
- data/app/assets/components/polymer-gestures/src/ms.js +80 -0
- data/app/assets/components/polymer-gestures/src/pinch.js +186 -0
- data/app/assets/components/polymer-gestures/src/platform-events.js +39 -0
- data/app/assets/components/polymer-gestures/src/pointer.js +68 -0
- data/app/assets/components/polymer-gestures/src/pointermap.js +67 -0
- data/app/assets/components/polymer-gestures/src/scope.js +10 -0
- data/app/assets/components/polymer-gestures/src/tap.js +103 -0
- data/app/assets/components/polymer-gestures/src/targetfind.js +244 -0
- data/app/assets/components/polymer-gestures/src/touch-action.js +60 -0
- data/app/assets/components/polymer-gestures/src/touch.js +341 -0
- data/app/assets/components/polymer-gestures/src/track.js +230 -0
- data/app/assets/components/web-animations-js/web-animations-next-lite.min.js +17 -0
- data/app/assets/components/web-animations-js/web-animations-next.min.js +17 -0
- data/app/assets/components/web-animations-js/web-animations.min.js +17 -0
- data/app/assets/components/webcomponentsjs/CustomElements.js +956 -0
- data/app/assets/components/webcomponentsjs/CustomElements.min.js +11 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.js +1078 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.min.js +11 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.js +344 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.min.js +11 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.js +4414 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.min.js +15 -0
- data/app/assets/components/webcomponentsjs/package.json +31 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.js +2300 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.min.js +13 -0
- data/app/assets/components/webcomponentsjs/webcomponents.js +7112 -0
- data/app/assets/components/webcomponentsjs/webcomponents.min.js +15 -0
- data/lib/polymer-paper-elements-rails.rb +2 -0
- data/lib/polymer-paper-elements-rails/engine.rb +4 -0
- data/lib/polymer-paper-elements-rails/version.rb +3 -0
- metadata +272 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
5
|
+
viewBox="0 0 225 126" enable-background="new 0 0 225 126" xml:space="preserve">
|
6
|
+
<g id="background" display="none">
|
7
|
+
<rect display="inline" fill="#B0BEC5" width="225" height="126"/>
|
8
|
+
</g>
|
9
|
+
<g id="label">
|
10
|
+
</g>
|
11
|
+
<g id="art">
|
12
|
+
<path d="M164,114H13V88h151V114z M15,112h147V90H15V112z"/>
|
13
|
+
<rect x="26" y="100" width="79" height="2"/>
|
14
|
+
<rect x="135" y="100" width="16" height="2"/>
|
15
|
+
<g id="ic_x5F_add_x0D_">
|
16
|
+
</g>
|
17
|
+
</g>
|
18
|
+
<g id="Guides">
|
19
|
+
</g>
|
20
|
+
</svg>
|
@@ -0,0 +1,164 @@
|
|
1
|
+
<!--
|
2
|
+
@license
|
3
|
+
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
4
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
+
Code distributed by Google as part of the polymer project is also
|
8
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
+
-->
|
10
|
+
|
11
|
+
<link rel="import" href="../polymer/polymer.html">
|
12
|
+
<link rel="import" href="../paper-styles/typography.html">
|
13
|
+
<link rel="import" href="../iron-a11y-announcer/iron-a11y-announcer.html">
|
14
|
+
|
15
|
+
<!--
|
16
|
+
`paper-toast` provides a subtle notification toast.
|
17
|
+
|
18
|
+
@group Paper Elements
|
19
|
+
@element paper-toast
|
20
|
+
@demo demo/index.html
|
21
|
+
@hero hero.svg
|
22
|
+
-->
|
23
|
+
<dom-module id="paper-toast">
|
24
|
+
<style>
|
25
|
+
:host {
|
26
|
+
display: inline-block;
|
27
|
+
position: fixed;
|
28
|
+
|
29
|
+
background: #323232;
|
30
|
+
color: #f1f1f1;
|
31
|
+
min-height: 48px;
|
32
|
+
min-width: 288px;
|
33
|
+
padding: 16px 24px 12px;
|
34
|
+
box-sizing: border-box;
|
35
|
+
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
|
36
|
+
border-radius: 2px;
|
37
|
+
bottom: 12px;
|
38
|
+
left: 12px;
|
39
|
+
font-size: 14px;
|
40
|
+
cursor: default;
|
41
|
+
|
42
|
+
-webkit-transition: visibility 0.3s, -webkit-transform 0.3s;
|
43
|
+
transition: visibility 0.3s, transform 0.3s;
|
44
|
+
|
45
|
+
-webkit-transform: translateY(100px);
|
46
|
+
transform: translateY(100px);
|
47
|
+
|
48
|
+
visibility: hidden;
|
49
|
+
}
|
50
|
+
|
51
|
+
:host(.capsule) {
|
52
|
+
border-radius: 24px;
|
53
|
+
}
|
54
|
+
|
55
|
+
:host(.fit-bottom) {
|
56
|
+
bottom: 0;
|
57
|
+
left: 0;
|
58
|
+
width: 100%;
|
59
|
+
min-width: 0;
|
60
|
+
border-radius: 0;
|
61
|
+
}
|
62
|
+
|
63
|
+
:host(.paper-toast-open){
|
64
|
+
visibility: visible;
|
65
|
+
|
66
|
+
-webkit-transform: translateY(0px);
|
67
|
+
transform: translateY(0px);
|
68
|
+
}
|
69
|
+
</style>
|
70
|
+
<template>
|
71
|
+
<span id="label">{{text}}</span>
|
72
|
+
<content></content>
|
73
|
+
</template>
|
74
|
+
</dom-module>
|
75
|
+
<script>
|
76
|
+
(function() {
|
77
|
+
|
78
|
+
var PaperToast = Polymer({
|
79
|
+
is: 'paper-toast',
|
80
|
+
|
81
|
+
properties: {
|
82
|
+
/**
|
83
|
+
* The duration in milliseconds to show the toast.
|
84
|
+
*/
|
85
|
+
duration: {
|
86
|
+
type: Number,
|
87
|
+
value: 3000
|
88
|
+
},
|
89
|
+
|
90
|
+
/**
|
91
|
+
* The text to display in the toast.
|
92
|
+
*/
|
93
|
+
text: {
|
94
|
+
type: String,
|
95
|
+
value: ""
|
96
|
+
},
|
97
|
+
|
98
|
+
/**
|
99
|
+
* True if the toast is currently visible.
|
100
|
+
*/
|
101
|
+
visible: {
|
102
|
+
type: Boolean,
|
103
|
+
readOnly: true,
|
104
|
+
value: false,
|
105
|
+
observer: '_visibleChanged'
|
106
|
+
}
|
107
|
+
},
|
108
|
+
|
109
|
+
created: function() {
|
110
|
+
Polymer.IronA11yAnnouncer.requestAvailability();
|
111
|
+
},
|
112
|
+
|
113
|
+
ready: function() {
|
114
|
+
this.async(function() {
|
115
|
+
this.hide();
|
116
|
+
});
|
117
|
+
},
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Show the toast.
|
121
|
+
* @method show
|
122
|
+
*/
|
123
|
+
show: function() {
|
124
|
+
if (PaperToast.currentToast) {
|
125
|
+
PaperToast.currentToast.hide();
|
126
|
+
}
|
127
|
+
PaperToast.currentToast = this;
|
128
|
+
this.removeAttribute('aria-hidden');
|
129
|
+
this._setVisible(true);
|
130
|
+
this.fire('iron-announce', {
|
131
|
+
text: this.text
|
132
|
+
});
|
133
|
+
this.debounce('hide', this.hide, this.duration);
|
134
|
+
},
|
135
|
+
|
136
|
+
/**
|
137
|
+
* Hide the toast
|
138
|
+
*/
|
139
|
+
hide: function() {
|
140
|
+
this.setAttribute('aria-hidden', 'true');
|
141
|
+
this._setVisible(false);
|
142
|
+
},
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Toggle the opened state of the toast.
|
146
|
+
* @method toggle
|
147
|
+
*/
|
148
|
+
toggle: function() {
|
149
|
+
if (!this.visible) {
|
150
|
+
this.show();
|
151
|
+
} else {
|
152
|
+
this.hide();
|
153
|
+
}
|
154
|
+
},
|
155
|
+
|
156
|
+
_visibleChanged: function(visible) {
|
157
|
+
this.toggleClass('paper-toast-open', visible);
|
158
|
+
}
|
159
|
+
});
|
160
|
+
|
161
|
+
PaperToast.currentToast = null;
|
162
|
+
|
163
|
+
})();
|
164
|
+
</script>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
5
|
+
viewBox="0 0 225 126" enable-background="new 0 0 225 126" xml:space="preserve">
|
6
|
+
<g id="background" display="none">
|
7
|
+
<rect display="inline" fill="#B0BEC5" width="225" height="126"/>
|
8
|
+
</g>
|
9
|
+
<g id="label">
|
10
|
+
</g>
|
11
|
+
<g id="art">
|
12
|
+
<g>
|
13
|
+
<circle cx="123.8" cy="63" r="15.7"/>
|
14
|
+
<path d="M123,77H98.5c-7.7,0-14-6.3-14-14s6.3-14,14-14H123c7.7,0,14,6.3,14,14S130.7,77,123,77z M98.5,51c-6.6,0-12,5.4-12,12
|
15
|
+
s5.4,12,12,12H123c6.6,0,12-5.4,12-12s-5.4-12-12-12H98.5z"/>
|
16
|
+
</g>
|
17
|
+
<g id="ic_x5F_add_x0D_">
|
18
|
+
</g>
|
19
|
+
</g>
|
20
|
+
<g id="Guides">
|
21
|
+
</g>
|
22
|
+
</svg>
|
@@ -0,0 +1,108 @@
|
|
1
|
+
/*
|
2
|
+
@license
|
3
|
+
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
4
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
+
Code distributed by Google as part of the polymer project is also
|
8
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
+
*/
|
10
|
+
|
11
|
+
:host {
|
12
|
+
display: inline-block;
|
13
|
+
}
|
14
|
+
|
15
|
+
:host([disabled]) {
|
16
|
+
pointer-events: none;
|
17
|
+
}
|
18
|
+
|
19
|
+
:host(:focus) {
|
20
|
+
outline:none;
|
21
|
+
}
|
22
|
+
|
23
|
+
:host .toggle-bar {
|
24
|
+
background-color: var(--paper-toggle-button-unchecked-bar-color);
|
25
|
+
}
|
26
|
+
|
27
|
+
:host .toggle-button {
|
28
|
+
background-color: var(--paper-toggle-button-unchecked-button-color);
|
29
|
+
}
|
30
|
+
|
31
|
+
:host([checked]) .toggle-bar {
|
32
|
+
background-color: var(--paper-toggle-button-checked-bar-color);
|
33
|
+
}
|
34
|
+
|
35
|
+
:host([checked]) .toggle-button {
|
36
|
+
background-color: var(--paper-toggle-button-checked-button-color);
|
37
|
+
}
|
38
|
+
|
39
|
+
:host .toggle-ink {
|
40
|
+
color: var(--paper-toggle-button-unchecked-ink-color);
|
41
|
+
}
|
42
|
+
|
43
|
+
:host([checked]) .toggle-ink {
|
44
|
+
color: var(--paper-toggle-button-checked-ink-color);
|
45
|
+
}
|
46
|
+
|
47
|
+
/* ID selectors should not be overriden by users. */
|
48
|
+
|
49
|
+
#toggleContainer {
|
50
|
+
position: relative;
|
51
|
+
width: 36px;
|
52
|
+
height: 14px;
|
53
|
+
}
|
54
|
+
|
55
|
+
#toggleBar {
|
56
|
+
position: absolute;
|
57
|
+
height: 100%;
|
58
|
+
width: 100%;
|
59
|
+
border-radius: 8px;
|
60
|
+
pointer-events: none;
|
61
|
+
opacity: 0.4;
|
62
|
+
transition: background-color linear .08s;
|
63
|
+
}
|
64
|
+
|
65
|
+
:host([checked]) #toggleBar {
|
66
|
+
opacity: 0.5;
|
67
|
+
}
|
68
|
+
|
69
|
+
:host([disabled]) #toggleBar {
|
70
|
+
background-color: #000;
|
71
|
+
opacity: 0.12;
|
72
|
+
}
|
73
|
+
|
74
|
+
#toggleButton {
|
75
|
+
position: absolute;
|
76
|
+
top: -3px;
|
77
|
+
height: 20px;
|
78
|
+
width: 20px;
|
79
|
+
border-radius: 50%;
|
80
|
+
box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.6);
|
81
|
+
transition: -webkit-transform linear .08s, background-color linear .08s;
|
82
|
+
transition: transform linear .08s, background-color linear .08s;
|
83
|
+
will-change: transform;
|
84
|
+
}
|
85
|
+
|
86
|
+
#toggleButton.dragging {
|
87
|
+
-webkit-transition: none;
|
88
|
+
transition: none;
|
89
|
+
}
|
90
|
+
|
91
|
+
:host([checked]) #toggleButton {
|
92
|
+
-webkit-transform: translate(16px, 0);
|
93
|
+
transform: translate(16px, 0);
|
94
|
+
}
|
95
|
+
|
96
|
+
:host([disabled]) #toggleButton {
|
97
|
+
background-color: #bdbdbd;
|
98
|
+
opacity: 1;
|
99
|
+
}
|
100
|
+
|
101
|
+
#ink {
|
102
|
+
position: absolute;
|
103
|
+
top: -14px;
|
104
|
+
left: -14px;
|
105
|
+
width: 48px;
|
106
|
+
height: 48px;
|
107
|
+
opacity: 0.5;
|
108
|
+
}
|
@@ -0,0 +1,183 @@
|
|
1
|
+
<!--
|
2
|
+
@license
|
3
|
+
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
4
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
+
Code distributed by Google as part of the polymer project is also
|
8
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
+
-->
|
10
|
+
|
11
|
+
<link rel="import" href="../polymer/polymer.html">
|
12
|
+
<link rel="import" href="../paper-ripple/paper-ripple.html">
|
13
|
+
<link rel="import" href="../paper-behaviors/paper-inky-focus-behavior.html">
|
14
|
+
|
15
|
+
<!--
|
16
|
+
`paper-toggle-button` provides a ON/OFF switch that user can toggle the state
|
17
|
+
by tapping or by dragging the switch.
|
18
|
+
|
19
|
+
Example:
|
20
|
+
|
21
|
+
<paper-toggle-button></paper-toggle-button>
|
22
|
+
|
23
|
+
### Styling
|
24
|
+
|
25
|
+
The following custom properties and mixins are available for styling:
|
26
|
+
|
27
|
+
Custom property | Description | Default
|
28
|
+
----------------|-------------|----------
|
29
|
+
`--paper-toggle-button-unchecked-bar-color` | Slider color when the input is not checked | `#000000`
|
30
|
+
`--paper-toggle-button-unchecked-button-color` | Button color when the input is not checked | `--paper-grey-50`
|
31
|
+
`--paper-toggle-button-unchecked-ink-color` | Selected/focus ripple color when the input is not checked | `--dark-primary-color`
|
32
|
+
`--paper-toggle-button-checked-bar-color` | Slider button color when the input is checked | `--google-green-500`
|
33
|
+
`--paper-toggle-button-checked-button-color` | Button color when the input is checked | `--google-green-500`
|
34
|
+
`--paper-toggle-button-checked-ink-color` | Selected/focus ripple color when the input is checked | `--google-green-500`
|
35
|
+
|
36
|
+
@group Paper Elements
|
37
|
+
@element paper-toggle-button
|
38
|
+
@hero hero.svg
|
39
|
+
@demo demo/index.html
|
40
|
+
-->
|
41
|
+
<style is="custom-style">
|
42
|
+
:root {
|
43
|
+
--paper-toggle-button-unchecked-bar-color: #000000;
|
44
|
+
--paper-toggle-button-unchecked-button-color: var(--paper-grey-50);
|
45
|
+
--paper-toggle-button-unchecked-ink-color: var(--primary-text-color);
|
46
|
+
|
47
|
+
--paper-toggle-button-checked-bar-color: var(--google-green-500);
|
48
|
+
--paper-toggle-button-checked-button-color: var(--google-green-500);
|
49
|
+
--paper-toggle-button-checked-ink-color: var(--google-green-500);
|
50
|
+
}
|
51
|
+
</style>
|
52
|
+
|
53
|
+
<dom-module id="paper-toggle-button">
|
54
|
+
|
55
|
+
<link rel="import" type="css" href="paper-toggle-button.css">
|
56
|
+
|
57
|
+
<template>
|
58
|
+
|
59
|
+
<div id="toggleContainer">
|
60
|
+
<div id="toggleBar" class="toggle-bar"></div>
|
61
|
+
<div id="toggleButton" class="toggle-button">
|
62
|
+
<paper-ripple id="ink" class="toggle-ink circle" recenters></paper-ripple>
|
63
|
+
</div>
|
64
|
+
</div>
|
65
|
+
|
66
|
+
</template>
|
67
|
+
|
68
|
+
<script>
|
69
|
+
Polymer({
|
70
|
+
is: 'paper-toggle-button',
|
71
|
+
|
72
|
+
behaviors: [
|
73
|
+
Polymer.PaperInkyFocusBehavior
|
74
|
+
],
|
75
|
+
|
76
|
+
hostAttributes: {
|
77
|
+
role: 'button',
|
78
|
+
'aria-pressed': 'false',
|
79
|
+
tabindex: 0
|
80
|
+
},
|
81
|
+
|
82
|
+
properties: {
|
83
|
+
/**
|
84
|
+
* Fired when the checked state changes due to user interaction.
|
85
|
+
*
|
86
|
+
* @event change
|
87
|
+
*/
|
88
|
+
/**
|
89
|
+
* Fired when the checked state changes.
|
90
|
+
*
|
91
|
+
* @event iron-change
|
92
|
+
*/
|
93
|
+
/**
|
94
|
+
* Gets or sets the state, `true` is checked and `false` is unchecked.
|
95
|
+
*
|
96
|
+
* @attribute checked
|
97
|
+
* @type boolean
|
98
|
+
* @default false
|
99
|
+
*/
|
100
|
+
checked: {
|
101
|
+
type: Boolean,
|
102
|
+
value: false,
|
103
|
+
reflectToAttribute: true,
|
104
|
+
notify: true,
|
105
|
+
observer: '_checkedChanged'
|
106
|
+
},
|
107
|
+
|
108
|
+
/**
|
109
|
+
* If true, the button toggles the active state with each tap or press
|
110
|
+
* of the spacebar.
|
111
|
+
*
|
112
|
+
* @attribute toggles
|
113
|
+
* @type boolean
|
114
|
+
* @default true
|
115
|
+
*/
|
116
|
+
toggles: {
|
117
|
+
type: Boolean,
|
118
|
+
value: true,
|
119
|
+
reflectToAttribute: true
|
120
|
+
}
|
121
|
+
},
|
122
|
+
|
123
|
+
listeners: {
|
124
|
+
track: '_ontrack'
|
125
|
+
},
|
126
|
+
|
127
|
+
ready: function() {
|
128
|
+
this._isReady = true;
|
129
|
+
},
|
130
|
+
|
131
|
+
// button-behavior hook
|
132
|
+
_buttonStateChanged: function() {
|
133
|
+
if (this.disabled) {
|
134
|
+
return;
|
135
|
+
}
|
136
|
+
if (this._isReady) {
|
137
|
+
this.checked = this.active;
|
138
|
+
}
|
139
|
+
},
|
140
|
+
|
141
|
+
_checkedChanged: function(checked) {
|
142
|
+
this.active = this.checked;
|
143
|
+
this.fire('iron-change');
|
144
|
+
},
|
145
|
+
|
146
|
+
_ontrack: function(event) {
|
147
|
+
var track = event.detail;
|
148
|
+
if (track.state === 'start') {
|
149
|
+
this._trackStart(track);
|
150
|
+
} else if (track.state === 'track') {
|
151
|
+
this._trackMove(track);
|
152
|
+
} else if (track.state === 'end') {
|
153
|
+
this._trackEnd(track);
|
154
|
+
}
|
155
|
+
},
|
156
|
+
|
157
|
+
_trackStart: function(track) {
|
158
|
+
this._width = this.$.toggleBar.offsetWidth / 2;
|
159
|
+
/*
|
160
|
+
* keep an track-only check state to keep the dragging behavior smooth
|
161
|
+
* while toggling activations
|
162
|
+
*/
|
163
|
+
this._trackChecked = this.checked;
|
164
|
+
this.$.toggleButton.classList.add('dragging');
|
165
|
+
},
|
166
|
+
|
167
|
+
_trackMove: function(track) {
|
168
|
+
var dx = track.dx;
|
169
|
+
this._x = Math.min(this._width,
|
170
|
+
Math.max(0, this._trackChecked ? this._width + dx : dx));
|
171
|
+
this.translate3d(this._x + 'px', 0, 0, this.$.toggleButton);
|
172
|
+
this._userActivate(this._x > (this._width / 2));
|
173
|
+
},
|
174
|
+
|
175
|
+
_trackEnd: function(track) {
|
176
|
+
this.$.toggleButton.classList.remove('dragging');
|
177
|
+
this.transform('', this.$.toggleButton);
|
178
|
+
}
|
179
|
+
|
180
|
+
});
|
181
|
+
</script>
|
182
|
+
|
183
|
+
</dom-module>
|