forked from LRNWebComponents/hax-body
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhax-context-item.html
167 lines (159 loc) · 4.48 KB
/
hax-context-item.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../paper-tooltip/paper-tooltip.html">
<link rel="import" href="../iron-icons/iron-icons.html">
<link rel="import" href="../iron-icons/editor-icons.html">
<link rel="import" href="../iron-icons/device-icons.html">
<link rel="import" href="../iron-icons/hardware-icons.html">
<link rel="import" href="../iron-icons/social-icons.html">
<link rel="import" href="../iron-icons/av-icons.html">
<link rel="import" href="../iron-icons/image-icons.html">
<link rel="import" href="../iron-icons/maps-icons.html">
<link rel="import" href="../materializecss-styles/colors.html">
<link rel="import" href="../neon-animation/web-animations.html">
<!--
`hax-body-text-context-item`
A single button in the hax panel for consistency.
@demo demo/index.html
@microcopy - the mental model for this element
- panel - the flyout from left or right side that has elements that can be placed
- button - an item that expresses what interaction you will have with the content.
-->
<dom-module id="hax-context-item">
<template>
<style include="materializecss-styles-colors">
:host {
display: inline-flex;
}
:host[wide] {
width: 50%;
}
paper-icon-button {
color: rgba(0,0,0,0.66);
margin: 0;
text-transform: none;
background-color: #ffffff;
min-width: 40px;
display: flex;
padding: 0;
border-radius: 0;
}
paper-icon-button ::shadow iron-icon {
padding: 8px;
height: 24px;
margin: 0;
}
paper-icon-button:hover {
background-color: var(--paper-grey-300, grey);
}
:host[wide] paper-button {
width: unset;
}
.flip-icon {
transform: rotateY(180deg);
}
</style>
<paper-icon-button id="button" icon="[[icon]]" hidden$="[[!icon]]" class$="[[iconClass]]" on-tap="_fireEvent"></paper-icon-button>
<paper-tooltip
for="button"
position="[[direction]]"
offset="10">
[[label]]
</paper-tooltip>
</template>
<script>
Polymer({
is: 'hax-context-item',
properties: {
/**
* Modifier that makes the button wider
*/
wide: {
type: Boolean,
value: false,
reflectToAttribute: true,
},
/**
* Direction for the tooltip
*/
direction: {
type: String,
value: 'top',
},
/**
* Icon for the button.
*/
icon: {
type: String,
value: "editor:text-fields",
reflectToAttribute: true,
},
/**
* Icon for the button.
*/
iconClass: {
type: String,
value: "black-text",
reflectToAttribute: true,
},
/**
* Label for the button.
*/
label: {
type: String,
value: "editor:text-fields",
reflectToAttribute: true,
},
/**
* Name of the event to bubble up as being tapped.
* This can be used to tell other elements what was
* clicked so it can take action appropriately.
*/
eventName: {
type: String,
value: "button",
reflectToAttribute: true,
},
/**
* Method of input to display when activated. This is
* only used when triggered as part of haxProperties
*/
inputMethod: {
type: String,
value: null,
reflectToAttribute: true,
},
/**
* Optional slot to bind this value to.
*/
propertyToBind: {
type: String,
value: null,
reflectToAttribute: true,
},
/**
* Optional slot to bind this value to.
*/
slotToBind: {
type: String,
value: null,
reflectToAttribute: true,
},
/**
* Optional description for this item.
*/
description: {
type: String,
reflectToAttribute: true,
},
},
/**
* Fire an event that includes the eventName of what was just pressed.
*/
_fireEvent: function(e) {
this.fire('hax-context-item-selected', {target: this, eventName: this.eventName});
}
});
</script>
</dom-module>