Passed
Push — master ( 6f06f2...0b516b )
by Markus
04:01 queued 16s
created

createFeatherIconSelectChoices()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Flynt\Components\ListIcons;
4
5
use Flynt\Api;
6
7
function createFeatherIconSelectChoices($iconKeys = [])
8
{
9
    return array_reduce($iconKeys, function ($acc, $iconKey) {
10
        $acc[$iconKey] = "<i style='width: 16px; height: 16px; vertical-align: middle; position: relative; top: -2px;margin-right: 5px' data-feather='{$iconKey}'></i> {$iconKey}";
11
        return $acc;
12
    }, []);
13
}
14
15
$iconKeys = [
16
    'activity',
17
    'airplay',
18
    'alert-circle',
19
    'alert-octagon',
20
    'alert-triangle',
21
    'align-center',
22
    'align-justify',
23
    'align-left',
24
    'align-right',
25
    'anchor',
26
    'aperture',
27
    'archive',
28
    'arrow-down-circle',
29
    'arrow-down-left',
30
    'arrow-down-right',
31
    'arrow-down',
32
    'arrow-left-circle',
33
    'arrow-left',
34
    'arrow-right-circle',
35
    'arrow-right',
36
    'arrow-up-circle',
37
    'arrow-up-left',
38
    'arrow-up-right',
39
    'arrow-up',
40
    'at-sign',
41
    'award',
42
    'bar-chart-2',
43
    'bar-chart',
44
    'battery-charging',
45
    'battery',
46
    'bell-off',
47
    'bell',
48
    'bluetooth',
49
    'bold',
50
    'book-open',
51
    'book',
52
    'bookmark',
53
    'box',
54
    'briefcase',
55
    'calendar',
56
    'camera-off',
57
    'camera',
58
    'cast',
59
    'check-circle',
60
    'check-square',
61
    'check',
62
    'chevron-down',
63
    'chevron-left',
64
    'chevron-right',
65
    'chevron-up',
66
    'chevrons-down',
67
    'chevrons-left',
68
    'chevrons-right',
69
    'chevrons-up',
70
    'chrome',
71
    'circle',
72
    'clipboard',
73
    'clock',
74
    'cloud-drizzle',
75
    'cloud-lightning',
76
    'cloud-off',
77
    'cloud-rain',
78
    'cloud-snow',
79
    'cloud',
80
    'code',
81
    'codepen',
82
    'codesandbox',
83
    'coffee',
84
    'columns',
85
    'command',
86
    'compass',
87
    'copy',
88
    'corner-down-left',
89
    'corner-down-right',
90
    'corner-left-down',
91
    'corner-left-up',
92
    'corner-right-down',
93
    'corner-right-up',
94
    'corner-up-left',
95
    'corner-up-right',
96
    'cpu',
97
    'credit-card',
98
    'crop',
99
    'crosshair',
100
    'database',
101
    'delete',
102
    'disc',
103
    'dollar-sign',
104
    'download-cloud',
105
    'download',
106
    'droplet',
107
    'edit-2',
108
    'edit-3',
109
    'edit',
110
    'external-link',
111
    'eye-off',
112
    'eye',
113
    'facebook',
114
    'fast-forward',
115
    'feather',
116
    'figma',
117
    'file-minus',
118
    'file-plus',
119
    'file-text',
120
    'file',
121
    'film',
122
    'filter',
123
    'flag',
124
    'folder-minus',
125
    'folder-plus',
126
    'folder',
127
    'framer',
128
    'frown',
129
    'gift',
130
    'git-branch',
131
    'git-commit',
132
    'git-merge',
133
    'git-pull-request',
134
    'github',
135
    'gitlab',
136
    'globe',
137
    'grid',
138
    'hard-drive',
139
    'hash',
140
    'headphones',
141
    'heart',
142
    'help-circle',
143
    'hexagon',
144
    'home',
145
    'image',
146
    'inbox',
147
    'info',
148
    'instagram',
149
    'italic',
150
    'key',
151
    'layers',
152
    'layout',
153
    'life-buoy',
154
    'link-2',
155
    'link',
156
    'linkedin',
157
    'list',
158
    'loader',
159
    'lock',
160
    'log-in',
161
    'log-out',
162
    'mail',
163
    'map-pin',
164
    'map',
165
    'maximize-2',
166
    'maximize',
167
    'meh',
168
    'menu',
169
    'message-circle',
170
    'message-square',
171
    'mic-off',
172
    'mic',
173
    'minimize-2',
174
    'minimize',
175
    'minus-circle',
176
    'minus-square',
177
    'minus',
178
    'monitor',
179
    'moon',
180
    'more-horizontal',
181
    'more-vertical',
182
    'mouse-pointer',
183
    'move',
184
    'music',
185
    'navigation-2',
186
    'navigation',
187
    'octagon',
188
    'package',
189
    'paperclip',
190
    'pause-circle',
191
    'pause',
192
    'pen-tool',
193
    'percent',
194
    'phone-call',
195
    'phone-forwarded',
196
    'phone-incoming',
197
    'phone-missed',
198
    'phone-off',
199
    'phone-outgoing',
200
    'phone',
201
    'pie-chart',
202
    'play-circle',
203
    'play',
204
    'plus-circle',
205
    'plus-square',
206
    'plus',
207
    'pocket',
208
    'power',
209
    'printer',
210
    'radio',
211
    'refresh-ccw',
212
    'refresh-cw',
213
    'repeat',
214
    'rewind',
215
    'rotate-ccw',
216
    'rotate-cw',
217
    'rss',
218
    'save',
219
    'scissors',
220
    'search',
221
    'send',
222
    'server',
223
    'settings',
224
    'share-2',
225
    'share',
226
    'shield-off',
227
    'shield',
228
    'shopping-bag',
229
    'shopping-cart',
230
    'shuffle',
231
    'sidebar',
232
    'skip-back',
233
    'skip-forward',
234
    'slack',
235
    'slash',
236
    'sliders',
237
    'smartphone',
238
    'smile',
239
    'speaker',
240
    'square',
241
    'star',
242
    'stop-circle',
243
    'sun',
244
    'sunrise',
245
    'sunset',
246
    'tablet',
247
    'tag',
248
    'target',
249
    'terminal',
250
    'thermometer',
251
    'thumbs-down',
252
    'thumbs-up',
253
    'toggle-left',
254
    'toggle-right',
255
    'trash-2',
256
    'trash',
257
    'trello',
258
    'trending-down',
259
    'trending-up',
260
    'triangle',
261
    'truck',
262
    'tv',
263
    'twitter',
264
    'type',
265
    'umbrella',
266
    'underline',
267
    'unlock',
268
    'upload-cloud',
269
    'upload',
270
    'user-check',
271
    'user-minus',
272
    'user-plus',
273
    'user-x',
274
    'user',
275
    'users',
276
    'video-off',
277
    'video',
278
    'voicemail',
279
    'volume-1',
280
    'volume-2',
281
    'volume-x',
282
    'volume',
283
    'watch',
284
    'wifi-off',
285
    'wifi',
286
    'wind',
287
    'x-circle',
288
    'x-octagon',
289
    'x-square',
290
    'x',
291
    'youtube',
292
    'zap-off',
293
    'zap',
294
    'zoom-in',
295
    'zoom-out',
296
];
297
298
Api::registerFields('ListIcons', [
299
    'layout' => [
300
        'name' => 'ListIcons',
301
        'label' => 'List: Icons',
302
        'sub_fields' => [
303
            [
304
                'label' => 'Title',
305
                'name' => 'preContentHtml',
306
                'type' => 'wysiwyg',
307
                'tabs' => 'visual,text',
308
                'toolbar' => 'full',
309
                'media_upload' => 0,
310
                'delay' => 1
311
            ],
312
            [
313
                'label' => 'General',
314
                'name' => 'generalTab',
315
                'type' => 'tab',
316
                'placement' => 'top',
317
                'endpoint' => 0
318
            ],
319
            [
320
                'label' => 'Items',
321
                'name' => 'items',
322
                'type' => 'repeater',
323
                'min' => 1,
324
                'layout' => 'row',
325
                'button_label' => 'Add Item',
326
                'sub_fields' => [
327
                    [
328
                        'label' => 'Icon',
329
                        'name' => 'icon',
330
                        'type' => 'select',
331
                        'allow_null' => 1,
332
                        'multiple' => 0,
333
                        'ui' => 1,
334
                        'ajax' => 0,
335
                        'choices' => createFeatherIconSelectChoices($iconKeys),
336
                        'default_value' => ''
337
                    ],
338
                    [
339
                        'label' => 'Text content',
340
                        'name' => 'textContentHtml',
341
                        'type' => 'wysiwyg',
342
                        'tabs' => 'visual,text',
343
                        'toolbar' => 'full',
344
                        'media_upload' => 0,
345
                        'delay' => 1
346
                    ],
347
                    [
348
                        'label' => 'Link',
349
                        'name' => 'link',
350
                        'type' => 'link',
351
                    ],
352
                ]
353
            ],
354
            [
355
                'label' => 'Options',
356
                'name' => 'optionsTab',
357
                'type' => 'tab',
358
                'placement' => 'top',
359
                'endpoint' => 0
360
            ],
361
            [
362
                'label' => '',
363
                'name' => 'options',
364
                'type' => 'group',
365
                'layout' => 'row',
366
                'sub_fields' => [
367
                    [
368
                        'label' => 'Theme',
369
                        'name' => 'theme',
370
                        'type' => 'select',
371
                        'allow_null' => 0,
372
                        'multiple' => 0,
373
                        'ui' => 0,
374
                        'ajax' => 0,
375
                        'choices' => [
376
                            '' => 'Default',
377
                            'themeLight' => 'Light',
378
                            'themeDark' => 'Dark',
379
                            'themeHero' => 'Hero'
380
                        ]
381
                    ]
382
                ]
383
            ],
384
        ]
385
    ]
386
]);
387