forked from predixdesignsystem/px-icon-set
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpx-icon.html
124 lines (105 loc) · 3.67 KB
/
px-icon.html
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!--
Copyright (c) 2018, General Electric
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<link rel="import" href="../polymer/polymer.html" />
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html" />
<link rel="import" href="../iron-icon/iron-icon.html" />
<dom-module id="px-icon">
<template>
<style>
:host {
/* Create some vars we can manipulate asour icons change*/
--px-icon-default-width: 22px;
--px-icon-default-height: 22px;
--px-icon-stroke-width: 1;
/* Update iron-icon vars so we can overwrite */
--iron-icon-width: var(--px-icon-default-width);
--iron-icon-height: var(--px-icon-default-height);
/* Ensures the currentColor is overriden by the stroke color so text
elements inside the SVG work correctly */
color: var(--iron-icon-stroke-color, inherit);
/* Reverses the standard iron-icon colors to have the stroke inherit
currentcolor and fill default to none */
fill: var(--iron-icon-fill-color, none);
stroke: var(--iron-icon-stroke-color, currentColor);
/* The rest of the properties are copied exactly from iron-icon */
@apply --layout-inline;
@apply --layout-center-center;
position: relative;
vertical-align: middle;
width: var(--iron-icon-width);
height: var(--iron-icon-height);
stroke-width: var(--px-icon-stroke-width);
@apply --iron-icon;
}
/* Also copied exactly from iron-icon */
:host([hidden]) {
display: none;
}
/* Set default sizes for all icons sets */
:host([icon^='px-utl']),
:host([icon^='px-doc']) {
--px-icon-default-width: 16px;
--px-icon-default-height: 16px;
}
:host([icon^='px-smx']),
:host([icon^='px-obj']),
:host([icon^='px-fea']),
:host([icon^='px-com']) {
--px-icon-default-width: 32px;
--px-icon-default-height: 32px;
}
:host([icon^='px-smxl']) {
--px-icon-default-width: 64px;
--px-icon-default-height: 64px;
}
:host([icon^='px-smxs']) {
--px-icon-default-width: 16px;
--px-icon-default-height: 16px;
}
/* For "RTL" users, the next and prev icon are mirrored which should not be the case ,
So when the direction of render is "RTL" then rotate the icon , just next and Prev
*/
:host([icon^='px-nav:back']):host-context([dir='rtl']) {
transform: rotate(180deg);
}
:host([icon^='px-nav:next']):host-context([dir='rtl']) {
transform: rotate(180deg);
}
/* Forces iron-icon to inherit the :host scoped fill/stroke styles */
iron-icon {
color: inherit;
fill: inherit;
stroke: inherit;
width: inherit;
height: inherit;
}
</style>
<iron-icon icon="[[icon]]"></iron-icon>
</template>
</dom-module>
<script>
Polymer({
is: 'px-icon',
properties: {
icon: {
type: String,
reflectToAttribute: true,
observer: '_updateStylesIndirect'
}
},
_updateStylesIndirect: function () {
//calling this without argument
this.updateStyles();
}
})
</script>