1+ /**
2+ @license MIT
3+
4+ Copyright (c) 2017 Jacob Phillips
5+
6+ Permission is hereby granted, free of charge, to any person obtaining a copy
7+ of this software and associated documentation files (the "Software"), to deal
8+ in the Software without restriction, including without limitation the rights
9+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ copies of the Software, and to permit persons to whom the Software is
11+ furnished to do so, subject to the following conditions:
12+
13+ The above copyright notice and this permission notice shall be included in all
14+ copies or substantial portions of the Software.
15+
16+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ SOFTWARE.
23+ */
24+ import '@polymer/polymer/polymer-legacy.js' ;
25+
26+ import '@polymer/iron-flex-layout/iron-flex-layout.js' ;
27+ import '@polymer/iron-iconset-svg/iron-iconset-svg.js' ;
28+ import '@polymer/iron-icon/iron-icon.js' ;
29+ import '@polymer/iron-collapse/iron-collapse.js' ;
30+
31+ import { Polymer } from '@polymer/polymer/lib/legacy/polymer-fn.js' ;
32+ import { html } from '@polymer/polymer/lib/utils/html-tag.js' ;
33+
34+ Polymer ( {
35+ _template : html `
36+ < style >
37+ : host {
38+ dis play: block;
39+ }
40+ # trigger {
41+ @apply --layout-horizontal;
42+ @apply --layout-center;
43+ }
44+ </ style >
45+
46+ < iron-iconset-svg name ="iron-collapse-button-icons " size ="24 ">
47+ < svg > < defs >
48+ < g id ="expand-less "> < path d ="M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z "/> </ g >
49+ < g id ="expand-more "> < path d ="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z "/> </ g >
50+ </ defs > </ svg >
51+ </ iron-iconset-svg >
52+
53+ < div id ="trigger " on-tap ="toggle ">
54+ < slot name ="collapse-trigger "> </ slot >
55+ < iron-icon icon ="[[_toggle(opened, collapseIcon, expandIcon)]] " hidden$ ="[[noIcons]] "> </ iron-icon >
56+ </ div >
57+ < iron-collapse id ="collapse " horizontal ="[[horizontal]] " no-animation ="[[noAnimation]] " opened ="[[opened]] ">
58+ < slot name ="collapse-content "> </ slot >
59+ </ iron-collapse >
60+ ` ,
61+
62+ is : 'iron-collapse-button' ,
63+ properties : {
64+ /**
65+ * @deprecated
66+ * Corresponds to the iron-collapse's horizontal property.
67+ */
68+ horizontal : {
69+ type : Boolean ,
70+ value : false
71+ } ,
72+ /**
73+ * Corresponds to the iron-collapse's noAnimation property.
74+ */
75+ noAnimation : {
76+ type : Boolean ,
77+ value : false
78+ } ,
79+ /**
80+ * Whether currently expanded.
81+ */
82+ opened : {
83+ type : Boolean ,
84+ value : false ,
85+ notify : true
86+ } ,
87+ /**
88+ * The icon when collapsed.
89+ */
90+ expandIcon : {
91+ type : String ,
92+ value : 'iron-collapse-button-icons:expand-more'
93+ } ,
94+ /**
95+ * The icon when expanded.
96+ */
97+ collapseIcon : {
98+ type : String ,
99+ value : 'iron-collapse-button-icons:expand-less'
100+ } ,
101+ /**
102+ * Whether to hide the expand/collapse icon.
103+ */
104+ noIcons : {
105+ type : Boolean ,
106+ value : false
107+ } ,
108+ } ,
109+ /** @depricated Use `open()`. */
110+ show : function ( ) { this . open ( ) ; } ,
111+ /** @depricated Use `close()`. */
112+ hide : function ( ) { this . close ( ) ; } ,
113+ open : function ( ) { this . opened = true ; } ,
114+ close : function ( ) { this . opened = false ; } ,
115+ toggle : function ( ) { this . opened = ! this . opened ; } ,
116+ _toggle : function ( cond , t , f ) { return cond ? t : f ; }
117+ } ) ;
0 commit comments