-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
chips.html
407 lines (374 loc) · 11.7 KB
/
chips.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
<!DOCTYPE html>
<html lang="en">
<head> {{> head }} </head>
<body>
{{> navbar }}
<main>
{{> intro}}
<div class="container">
<div class="row">
<div class="s12 m8 offset-m1 xl7 offset-xl1">
<div id="introduction" class="section scrollspy">
<p class="caption">
Chips can be used to represent small blocks of information. They are most commonly used either for contacts or for tags.
</p>
<div class="chip">
<img src="images/yuna.jpg" alt="Contact Person"> Jane Doe
</div>
<div class="chip">
Tag
<i class="close material-icons">close</i>
</div>
<div class="chip">
<i class="material-icons">check</i>
Filter
<i class="close material-icons">close</i>
</div>
<div class="chip outlined">Information</div>
<div class="chip outlined">
<i class="material-icons">check</i>
Filter
<i class="close material-icons">close</i>
</div>
<pre style="padding-top: 0px;">
<span class="copyMessage">Copied!</span>
<i class="material-icons copyButton">content_copy</i>
<code class="language-html copiedText">
<xmp>
<div class="chip">
<img src="images/yuna.jpg" alt="Contact Person"> Jane Doe
</div>
<div class="chip">
Tag
<i class="close material-icons">close</i>
</div>
<div class="chip">
<i class="material-icons">check</i>
Filter
<i class="close material-icons">close</i>
</div>
<div class="chip outlined">Information</div>
<div class="chip outlined">
<i class="material-icons">check</i>
Filter
<i class="close material-icons">close</i>
</div>
</xmp>
</code>
</pre>
</div>
<!-- ### -->
<div id="contact" class="section scrollspy">
<h3 class="header">Contacts</h3>
<p class="caption">
To create a contact chip just add an img inside.
<div class="chip">
<img src="images/yuna.jpg" alt="Contact Person"> Jane Doe
</div>
</p>
<pre style="padding-top: 0px;">
<span class="copyMessage">Copied!</span>
<i class="material-icons copyButton">content_copy</i>
<code class="language-html copiedText">
<xmp>
<div class="chip">
<img src="images/yuna.jpg" alt="Contact Person">
Jane Doe
</div>
</xmp>
</code>
</pre>
</div>
<!-- ### -->
<div id="tag" class="section scrollspy">
<h3 class="header">Tags</h3>
<p class="caption">
To create a tag chip just add a close icon inside with the class
<code class="language-html">close</code>.
<div class="chip">
Tag
<i class="close material-icons">close</i>
</div>
</p>
<pre style="padding-top: 0px;">
<span class="copyMessage">Copied!</span>
<i class="material-icons copyButton">content_copy</i>
<code class="language-html copiedText">
<xmp>
<div class="chip">
Tag
<i class="close material-icons">close</i>
</div>
</xmp>
</code>
</pre>
</div>
<!-- ### -->
<div id="basic" class="section scrollspy">
<h3 class="header">Javascript Plugin</h4>
<p class="caption">To add tags, just enter your tag text and press enter. You can delete them by clicking on the close icon or by
using your delete button.</p>
<!-- Update Info -->
<div class="s12">
<p class="red-text"><strong>ATTENTION:</strong> Data-Format has changed from version 1.X.X to 2.0.0! Please update option 'data'.</p>
</div>
<div class="chips"></div>
<p class="caption">Set initial tags.</p>
<div class="chips chips-initial"></div>
<p class="caption">Use placeholders and override hint texts.</p>
<div class="chips chips-placeholder"></div>
<p class="caption">Use autocomplete with chips.</p>
<div class="chips chips-autocomplete"></div>
</div>
<div id="options" class="section scrollspy">
<pre style="padding-top: 0px;">
<span class="copyMessage">Copied!</span>
<i class="material-icons copyButton">content_copy</i>
<code class="language-html copiedText">
<xmp>
<!-- Default with no input (automatically generated) -->
<div class="chips"></div>
<div class="chips chips-initial"></div>
<div class="chips chips-placeholder"></div>
<div class="chips chips-autocomplete"></div>
<!-- Customizable input -->
<div class="chips">
<input class="custom-class">
</div>
</xmp>
</code>
</pre>
<h3 class="header">Initialization</h3>
<pre style="padding-top: 0px;">
<span class="copyMessage">Copied!</span>
<i class="material-icons copyButton">content_copy</i>
<code class="language-javascript copiedText">
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.chips');
var instances = M.Chips.init(elems, {
// specify options here
autocompleteOptions: {
data: [
{id: 12, text: "Apple"},
{id: 13, text: "Microsoft"},
{id: 42, text: "Google", image: 'http://placehold.it/250x250'}
]
},
placeholder: 'Enter a tag',
secondaryPlaceholder: '+Tag',
});
});
</code>
</pre>
<p class="caption">Chip data object</p>
<pre style="padding-top: 0px;">
<span class="copyMessage">Copied!</span>
<i class="material-icons copyButton">content_copy</i>
<code class="language-javascript copiedText">
var chip = {
id: '4711', // unique identifier (can be a string too)
text: 'Title' // optional Text
image: '', // optional Image-Url
};
</code>
</pre>
<h3 class="header">Options</h3>
<table class="table highlight">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>data</td>
<td>Array</td>
<td>[]</td>
<td>Set the chip data (look at the Chip data object)</td>
</tr>
<tr>
<td>placeholder</td>
<td>String</td>
<td>''</td>
<td>Set first placeholder when there are no tags.</td>
</tr>
<tr>
<td>secondaryPlaceholder</td>
<td>String</td>
<td>''</td>
<td>Set second placeholder when adding additional tags.</td>
</tr>
<tr>
<td>closeIconClass</td>
<td>String</td>
<td>'material-icons'</td>
<td>Specifies class to be used in "close" button (useful when working with Material Symbols icon set).</td>
</tr>
<tr>
<td>autocompleteOptions</td>
<td>Object</td>
<td>{}</td>
<td>Set autocomplete options.</td>
</tr>
<tr>
<td>autocompleteOnly</td>
<td>Boolean</td>
<td>false</td>
<td>Toggles abililty to add custom value not in autocomplete list.</td>
</tr>
<tr>
<td>limit</td>
<td>Integer</td>
<td>Infinity</td>
<td>Set chips limit.</td>
</tr>
<tr>
<td>onChipAdd</td>
<td>Function</td>
<td>null</td>
<td>Callback for chip add.</td>
</tr>
<tr>
<td>onChipSelect</td>
<td>Function</td>
<td>null</td>
<td>Callback for chip select.</td>
</tr>
<tr>
<td>onChipDelete</td>
<td>Function</td>
<td>null</td>
<td>Callback for chip delete.</td>
</tr>
<tr>
</tbody>
</table>
</div>
<div id="methods" class="section scrollspy">
<h3 class="header">Methods</h3>
<p class="caption">
Use these methods to interact with chips.
</p>
<blockquote>
<p>All the methods are called on the plugin instance. You can get the plugin instance like this: </p>
<pre style="padding-top: 0px;">
<span class="copyMessage">Copied!</span>
<i class="material-icons copyButton">content_copy</i>
<code class="language-javascript copiedText">
var instance = M.Chips.getInstance(elem);
</code>
</pre>
</blockquote>
<h5 class="method-header">
.addChip();
</h5>
<p>Add chip to input.</p>
<h6>Arguments</h6>
<p>
<b>Chip:</b> Chip data object.</p>
<pre><code class="language-javascript col s12">
instance.addChip({
id: 1337,
text: 'John Doe', // optional
image: '', // optional
});
</code></pre>
<h5 class="method-header">
.deleteChip();
</h5>
<p>Delete nth chip.</p>
<h6>Arguments</h6>
<p>
<b>Integer:</b> Index of chip.</p>
<pre><code class="language-javascript col s12">
instance.deleteChip(3); // Delete 3rd chip.
</code></pre>
<h5 class="method-header">
.selectChip();
</h5>
<p>Select nth chip.</p>
<h6>Arguments</h6>
<p>
<b>Integer:</b> Index of chip.</p>
<pre><code class="language-javascript col s12">
instance.selectChip(2); // Select 2nd chip
</code></pre>
</div>
<div id="properties" class="scrollspy section">
<h3 class="header">Properties</h3>
<table class="striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>el</td>
<td>Element</td>
<td>The DOM element the plugin was initialized with.</td>
</tr>
<tr>
<td>options</td>
<td>Object</td>
<td>The options the instance was initialized with.</td>
</tr>
<tr>
<td>chipsData</td>
<td>Array</td>
<td>Array of the current chips data.</td>
</tr>
<tr>
<td>hasAutocomplete</td>
<td>Boolean</td>
<td>If the chips has autocomplete enabled.</td>
</tr>
<tr>
<td>autocomplete</td>
<td>Object</td>
<td>
<a href="autocomplete.html">Autocomplete</a> instance, if any.</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Table of Contents -->
<div class="col hide-on-small-only m3 xl3">
<div class="toc-wrapper">
<div style="height: 1px;">
<ul class="section table-of-contents">
<li>
<a href="#contact">Contacts</a>
</li>
<li>
<a href="#tag">Tags</a>
</li>
<li>
<a href="#basic">Plugin</a>
</li>
<li>
<a href="#options">Options</a>
</li>
<li>
<a href="#methods">Methods</a>
</li>
<li>
<a href="#properties">Properties</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</main>
{{> footer }}
<script type="module" src="/src/main.ts"></script>
</body>
</html>