forked from LRNWebComponents/hax-body
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hax-context-item-textop.html
183 lines (175 loc) · 5.13 KB
/
hax-context-item-textop.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-a11y-keys/iron-a11y-keys.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-context-item-textop`
A single button in the hax context menus for consistency. This one uses the mousedown event becasue tap won't work in safari / firefox / IE while maintaining focus inside the contenteditable area (stupid, I know)
@demo demo/index.html
@microcopy - the mental model for this element
- context - menu in the page the user can select an item from, this being 1 option in that list
- button - an item that expresses what interaction you will have with the content.
-->
<dom-module id="hax-context-item-textop">
<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;
margin: 0;
box-sizing: border-box;
}
paper-icon-button:hover {
background-color: var(--paper-grey-300, grey);
}
:host[wide] paper-button {
width: unset;
}
.flip-icon {
transform: rotateY(180deg);
}
</style>
<iron-a11y-keys id="a11y" target="[[target]]" keys="enter"
on-keys-pressed="_fireEvent"></iron-a11y-keys>
<paper-icon-button id="button" icon="[[icon]]" hidden$="[[!icon]]" class$="[[iconClass]]" on-mousedown="_fireEvent"></paper-icon-button>
<paper-tooltip
for="button"
position="[[direction]]"
offset="10">
[[label]]
</paper-tooltip>
</template>
<script>
Polymer({
is: 'hax-context-item-textop',
properties: {
/**
* target for the iron-a11y-keys element.
*/
target: {
type: Object
},
/**
* 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,
},
},
/**
* Ready.
*/
ready: function() {
// bind keyboard to button press
this.target = this.$.button;
},
/**
* 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>