This repository has been archived by the owner on Jan 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
ClayButton.js
174 lines (153 loc) · 3.42 KB
/
ClayButton.js
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
import 'clay-icon';
import ClayComponent from 'clay-component';
import defineWebComponent from 'metal-web-component';
import Soy from 'metal-soy';
import {Config} from 'metal-state';
import templates from './ClayButton.soy.js';
/**
* Metal Clay Button component.
*/
class ClayButton extends ClayComponent {}
/**
* State definition.
* @static
* @type {!Object}
*/
ClayButton.STATE = {
/**
* Aria label attribute for the button element.
* @instance
* @memberof ClayButton
* @type {?string|undefined}
* @default undefined
*/
ariaLabel: Config.string(),
/**
* Renders the button as a block element.
* @instance
* @memberof ClayButton
* @type {?boolean}
* @default false
*/
block: Config.bool().value(false),
/**
* Data to add to the element.
* @instance
* @memberof ClayButton
* @type {?object}
* @default undefined
*/
data: Config.object(),
/**
* The button disabled attribute.
* @instance
* @memberof ClayButton
* @type {?boolean}
* @default false
*/
disabled: Config.bool().value(false),
/**
* CSS classes to be applied to the element.
* @instance
* @memberof ClayButton
* @type {?string|undefined}
* @default undefined
*/
elementClasses: Config.string(),
/**
* Icon to be rendered in the button.
* @instance
* @memberof ClayButton
* @type {?string|undefined}
* @default undefined
*/
icon: Config.string(),
/**
* Render ClayIcon in the ClayButton element.
* @instance
* @memberof ClayButton
* @type {?string}
* @default left
*/
iconAlignment: Config.oneOf(['left', 'right']).value('left'),
/**
* Id to be applied to the element.
* @instance
* @memberof ClayButton
* @type {?string|undefined}
* @default undefined
*/
id: Config.string(),
/**
* The label of the button content.
* @instance
* @memberof ClayButton
* @type {?html|string|undefined}
* @default undefined
*/
label: Config.any(),
/**
* Flag to indicate if button should be monospaced.
* @instance
* @memberof ClayButton
* @type {?bool}
* @default false
*/
monospaced: Config.bool().value(false),
/**
* The name attribute value of the element.
* @instance
* @memberof ClayButton
* @type {?string|undefined}
* @default undefined
*/
name: Config.string(),
/**
* The name that will make the CSS class name that will represent the
* button size.
* @instance
* @memberof ClayButton
* @type {?string|undefined}
* @default undefined
*/
size: Config.oneOf(['sm']),
/**
* The path to the SVG spritemap file containing the icons.
* @instance
* @memberof ClayButton
* @type {?string|undefined}
* @default undefined
*/
spritemap: Config.string(),
/**
* The css class that colors the button. Style `unstyled` is only for internal
* purposes.
* @instance
* @memberof ClayButton
* @type {?string|undefined}
* @default primary
*/
style: Config.oneOf(['link', 'primary', 'secondary', 'unstyled']).value(
'primary'
),
/**
* The type attribute value of the element.
* @instance
* @memberof ClayButton
* @type {?string}
* @default button
*/
type: Config.oneOf(['button', 'reset', 'submit']).value('button'),
/**
* The value attribute value of the element.
* @instance
* @memberof ClayButton
* @type {?string|undefined}
* @default undefined
*/
value: Config.string(),
};
defineWebComponent('clay-button', ClayButton);
Soy.register(ClayButton, templates);
export {ClayButton};
export default ClayButton;