CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/components/icon.tsx
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
declare var DEBUG: boolean; // comes from static webpack; not defined in other contexts.
7
8
import React from "react";
9
10
import { CSS } from "@cocalc/frontend/app-framework";
11
import useOnFrontend from "./use-on-frontend";
12
13
import {
14
AimOutlined,
15
AlignCenterOutlined,
16
AlignLeftOutlined,
17
AlignRightOutlined,
18
ApiOutlined,
19
AppstoreOutlined,
20
AreaChartOutlined,
21
ArrowDownOutlined,
22
ArrowLeftOutlined,
23
ArrowRightOutlined,
24
ArrowUpOutlined,
25
ArrowsAltOutlined,
26
AudioOutlined,
27
BackwardOutlined,
28
BankOutlined,
29
BellFilled,
30
BellOutlined,
31
BoldOutlined,
32
BookOutlined,
33
BorderOutlined,
34
BugOutlined,
35
BulbOutlined,
36
CalculatorOutlined,
37
CalendarOutlined,
38
CameraOutlined,
39
CaretDownFilled,
40
CaretLeftFilled,
41
CaretRightFilled,
42
CaretUpFilled,
43
CheckCircleOutlined,
44
CheckOutlined,
45
CheckSquareOutlined,
46
ClearOutlined,
47
ClockCircleOutlined,
48
CloseCircleFilled,
49
CloseCircleOutlined,
50
CloseCircleTwoTone,
51
CloseOutlined,
52
CloudDownloadOutlined,
53
CloudFilled,
54
CloudServerOutlined,
55
CloudUploadOutlined,
56
ClusterOutlined,
57
CodeOutlined,
58
CoffeeOutlined,
59
ColumnHeightOutlined,
60
ColumnWidthOutlined,
61
CommentOutlined,
62
CompassOutlined,
63
ControlOutlined,
64
CopyOutlined,
65
CreditCardOutlined,
66
DashboardOutlined,
67
DatabaseFilled,
68
DatabaseOutlined,
69
DeleteOutlined,
70
DeliveredProcedureOutlined,
71
DeploymentUnitOutlined,
72
DesktopOutlined,
73
DoubleLeftOutlined,
74
DoubleRightOutlined,
75
DownCircleOutlined,
76
DownOutlined,
77
DownSquareOutlined,
78
DownloadOutlined,
79
EditFilled,
80
EditOutlined,
81
EllipsisOutlined,
82
ExclamationCircleFilled,
83
ExpandOutlined,
84
ExperimentOutlined,
85
ExportOutlined,
86
EyeInvisibleOutlined,
87
EyeOutlined,
88
FacebookFilled,
89
FacebookOutlined,
90
FieldTimeOutlined,
91
FileImageOutlined,
92
FileOutlined,
93
FilePdfOutlined,
94
FileTextOutlined,
95
FileZipOutlined,
96
FireOutlined,
97
FolderOpenOutlined,
98
FolderOutlined,
99
FontSizeOutlined,
100
ForkOutlined,
101
ForwardOutlined,
102
FrownOutlined,
103
FunctionOutlined,
104
FundProjectionScreenOutlined,
105
GatewayOutlined,
106
GiftOutlined,
107
GiftTwoTone,
108
GithubFilled,
109
GithubOutlined,
110
GlobalOutlined,
111
GoogleOutlined,
112
GroupOutlined,
113
HddOutlined,
114
HighlightOutlined,
115
HistoryOutlined,
116
HomeOutlined,
117
HourglassOutlined,
118
Html5Outlined,
119
IdcardOutlined,
120
InfoCircleOutlined,
121
InfoOutlined,
122
InstagramFilled,
123
InstagramOutlined,
124
ItalicOutlined,
125
KeyOutlined,
126
LaptopOutlined,
127
LayoutOutlined,
128
LeftCircleOutlined,
129
LeftOutlined,
130
LeftSquareFilled,
131
LineChartOutlined,
132
LineHeightOutlined,
133
LinkOutlined,
134
LinkedinFilled,
135
LinkedinOutlined,
136
LoadingOutlined,
137
LockFilled,
138
LockOutlined,
139
LoginOutlined,
140
MailOutlined,
141
MedicineBoxOutlined,
142
MehOutlined,
143
MenuOutlined,
144
MergeCellsOutlined,
145
MinusCircleOutlined,
146
MinusOutlined,
147
MinusSquareOutlined,
148
OrderedListOutlined,
149
PauseCircleOutlined,
150
PercentageOutlined,
151
PicCenterOutlined,
152
PlayCircleFilled,
153
PlayCircleOutlined,
154
PlaySquareOutlined,
155
PlusCircleFilled,
156
PlusCircleOutlined,
157
PlusOutlined,
158
PlusSquareOutlined,
159
PoweroffOutlined,
160
PrinterOutlined,
161
ProjectOutlined,
162
QuestionCircleOutlined,
163
RedoOutlined,
164
ReloadOutlined,
165
RetweetOutlined,
166
RightCircleFilled,
167
RightCircleOutlined,
168
RightOutlined,
169
RightSquareFilled,
170
RiseOutlined,
171
RobotOutlined,
172
RocketOutlined,
173
SaveOutlined,
174
ScissorOutlined,
175
SearchOutlined,
176
SelectOutlined,
177
SendOutlined,
178
SettingOutlined,
179
ShareAltOutlined,
180
ShoppingCartOutlined,
181
ShrinkOutlined,
182
SlidersOutlined,
183
SmileOutlined,
184
SolutionOutlined,
185
SoundOutlined,
186
StarFilled,
187
StarOutlined,
188
StepBackwardOutlined,
189
StepForwardOutlined,
190
StopFilled,
191
StopOutlined,
192
StrikethroughOutlined,
193
SwapOutlined,
194
SyncOutlined,
195
TableOutlined,
196
TagFilled,
197
TagOutlined,
198
TagTwoTone,
199
TagsFilled,
200
TagsOutlined,
201
TagsTwoTone,
202
TeamOutlined,
203
ThunderboltOutlined,
204
ToolOutlined,
205
TranslationOutlined,
206
UnderlineOutlined,
207
UndoOutlined,
208
UnlockFilled,
209
UnorderedListOutlined,
210
UpCircleOutlined,
211
UpOutlined,
212
UpSquareOutlined,
213
UploadOutlined,
214
UserAddOutlined,
215
UserDeleteOutlined,
216
UserOutlined,
217
UsergroupAddOutlined,
218
VerticalAlignBottomOutlined,
219
VerticalAlignMiddleOutlined,
220
VerticalLeftOutlined,
221
VerticalRightOutlined,
222
VideoCameraOutlined,
223
WalletOutlined,
224
WarningOutlined,
225
WifiOutlined,
226
XOutlined,
227
YoutubeFilled,
228
YoutubeOutlined,
229
} from "@ant-design/icons";
230
231
// Unfortunately -- "error TS7056: The inferred type of this node exceeds the maximum length the
232
// compiler will serialize. An explicit type annotation is needed."
233
const IconSpec: { [name: string]: any } = {
234
"address-card": IdcardOutlined,
235
aim: AimOutlined,
236
"align-left": AlignLeftOutlined,
237
"align-center": AlignCenterOutlined,
238
"align-justify": { IconFont: "align-justify" },
239
"align-right": AlignRightOutlined,
240
"angle-double-left": DoubleLeftOutlined,
241
"angle-double-right": DoubleRightOutlined,
242
"angle-down": DownOutlined,
243
"angle-right": RightOutlined,
244
"arrow-circle-o-left": { IconFont: "arrowcircleoleft" },
245
"arrow-circle-down": DownCircleOutlined,
246
"arrow-circle-up": UpCircleOutlined,
247
"arrow-down": ArrowDownOutlined,
248
"arrow-left": ArrowLeftOutlined,
249
"arrow-right": ArrowRightOutlined,
250
"arrow-up": ArrowUpOutlined,
251
atom: { IconFont: "Atom" },
252
api: ApiOutlined,
253
audio: AudioOutlined,
254
aws: { IconFont: "aws" },
255
backward: BackwardOutlined,
256
"battery-empty": { IconFont: "battery-empty" },
257
"battery-quarter": { IconFont: "battery-quarter" },
258
"battery-half": { IconFont: "battery-half" },
259
"battery-three-quarters": { IconFont: "battery-three-quarters" },
260
"battery-full": { IconFont: "battery-full" },
261
ban: StopOutlined,
262
bank: BankOutlined,
263
bars: { IconFont: "bars" },
264
bell: BellFilled,
265
"bell-o": BellOutlined,
266
blog: { IconFont: "blog" },
267
bold: BoldOutlined,
268
bolt: ThunderboltOutlined,
269
book: BookOutlined,
270
briefcase: { IconFont: "briefcase" },
271
brush: { IconFont: "brush" },
272
bullhorn: { IconFont: "bullhorn" },
273
bug: BugOutlined,
274
calculator: CalculatorOutlined,
275
calendar: CalendarOutlined,
276
"calendar-week": { IconFont: "calendar-week" },
277
"calendar-check": { IconFont: "calendar-check" },
278
"calendar-times": { IconFont: "calendar-times" },
279
camera: CameraOutlined,
280
"caret-down": CaretDownFilled,
281
"caret-left": CaretLeftFilled,
282
"caret-right": CaretRightFilled,
283
"caret-up": CaretUpFilled,
284
"caret-square-left": LeftSquareFilled,
285
"caret-square-right": RightSquareFilled,
286
"cc-discover": { IconFont: "cc-discover" },
287
"cc-mastercard": { IconFont: "cc-mastercard" },
288
"cc-visa": { IconFont: "cc-visa" },
289
"cc-stripe": { IconFont: "cc-stripe" },
290
areaChart: AreaChartOutlined,
291
check: CheckOutlined,
292
"check-circle": CheckCircleOutlined,
293
"check-square": CheckSquareOutlined,
294
"check-square-o": CheckSquareOutlined,
295
"chevron-down": DownOutlined,
296
"chevron-left": LeftOutlined,
297
"chevron-right": RightOutlined,
298
"chevron-circle-right": RightCircleFilled,
299
"chevron-up": UpOutlined,
300
circle: { IconFont: "circle" },
301
"circle-notch": LoadingOutlined,
302
clipboard: { IconFont: "clipboard" },
303
"clipboard-check": { IconFont: "clipboard-check" },
304
clock: ClockCircleOutlined,
305
"close-circle-two-tone": CloseCircleTwoTone,
306
"close-circle-filled": CloseCircleFilled,
307
clone: { IconFont: "clone" },
308
cloud: CloudFilled,
309
"cloud-dev": { IconFont: "cloud-dev" },
310
"cloud-download": CloudDownloadOutlined,
311
"cloud-download-alt": CloudDownloadOutlined,
312
"cloud-upload": CloudUploadOutlined,
313
"cocalc-ring": { IconFont: "cocalc-ring" },
314
code: { IconFont: "code" },
315
"code-outlined": CodeOutlined,
316
CodeOutlined,
317
coffee: CoffeeOutlined,
318
cog: ControlOutlined,
319
cogs: ControlOutlined,
320
colors: { IconFont: "colors" },
321
ColumnHeightOutlined,
322
ColumnWidthOutlined,
323
comment: CommentOutlined,
324
comments: CommentOutlined,
325
compass: CompassOutlined,
326
compress: ShrinkOutlined,
327
copy: CopyOutlined,
328
"credit-card": CreditCardOutlined,
329
csv: { IconFont: "csv" },
330
cube: { IconFont: "cube" },
331
cut: ScissorOutlined,
332
dashboard: DashboardOutlined,
333
database: DatabaseOutlined,
334
"database-filled": DatabaseFilled,
335
"deployment-unit": DeploymentUnitOutlined,
336
dedicated: DatabaseOutlined, // icon for "dedicated resources", looks like a server rack
337
desktop: DesktopOutlined,
338
"delivered-procedure-outlined": DeliveredProcedureOutlined,
339
digitalocean: { IconFont: "digitalocean" },
340
discord: { IconFont: "discord" },
341
"disk-drive": { IconFont: "disk-drive" },
342
"disk-round": { IconFont: "disk-round" },
343
"disk-snapshot": { IconFont: "disk-snapshot" },
344
dns: { IconFont: "dns" },
345
docker: { IconFont: "docker" },
346
download: DownloadOutlined,
347
"dot-circle": { IconFont: "dot-circle" },
348
edit: EditOutlined,
349
"edit-filled": EditFilled,
350
eraser: { IconFont: "Eraser-Tool" },
351
ellipsis: EllipsisOutlined,
352
envelope: { IconFont: "envelope" },
353
exchange: { IconFont: "exchange" },
354
"exclamation-circle": ExclamationCircleFilled,
355
"exclamation-triangle": WarningOutlined,
356
expand: ExpandOutlined,
357
"expand-arrows": ArrowsAltOutlined,
358
experiment: ExperimentOutlined,
359
"external-link": { IconFont: "external-link-alt" },
360
eye: EyeOutlined,
361
"eye-slash": EyeInvisibleOutlined,
362
"facebook-filled": FacebookFilled,
363
facebook: FacebookOutlined,
364
file: FileOutlined,
365
"file-archive": FileZipOutlined,
366
"file-alt": FileTextOutlined,
367
"file-code": FileTextOutlined,
368
"file-image": FileImageOutlined,
369
"file-pdf": FilePdfOutlined,
370
"file-zip": FileZipOutlined,
371
files: CopyOutlined,
372
"file-export": ExportOutlined,
373
fire: FireOutlined,
374
firefox: { IconFont: "firefox" },
375
flash: ThunderboltOutlined,
376
"flow-chart": { IconFont: "flow-chart" },
377
folder: FolderOutlined,
378
"folder-open": FolderOpenOutlined,
379
font: { IconFont: "font" },
380
"font-size": FontSizeOutlined,
381
forward: ForwardOutlined,
382
frame: { IconFont: "frame" },
383
frown: FrownOutlined,
384
fx: FunctionOutlined,
385
slides: FundProjectionScreenOutlined,
386
"project-outlined": ProjectOutlined,
387
"gateway-outlined": GatewayOutlined,
388
gavel: { IconFont: "gavel" },
389
gears: ControlOutlined,
390
gear: ControlOutlined,
391
gift: GiftOutlined,
392
gift2: GiftTwoTone,
393
"github-filled": GithubFilled,
394
github: GithubOutlined,
395
git: { IconFont: "git1" },
396
"git-square": { IconFont: "git-square" },
397
global: GlobalOutlined,
398
emacs: { IconFont: "gnuemacs" },
399
google: GoogleOutlined,
400
googlecloud: { IconFont: "googlecloud" },
401
"graduation-cap": { IconFont: "graduation" },
402
graph: { IconFont: "graph" },
403
grass: { IconFont: "grass" },
404
group: { IconFont: "group" },
405
"group-outlined": GroupOutlined,
406
gpu: { IconFont: "gpu" },
407
hand: { IconFont: "hand" },
408
"hand-stop": PoweroffOutlined,
409
header: { IconFont: "header" },
410
heart: { IconFont: "heart" },
411
hdd: HddOutlined,
412
highlighter: HighlightOutlined,
413
history: HistoryOutlined,
414
home: HomeOutlined,
415
"horizontal-split": { IconFont: "horizontal-split" },
416
"hourglass-half": HourglassOutlined,
417
html5: Html5Outlined,
418
image: { IconFont: "image" },
419
icons: { IconFont: "icons" },
420
"info-circle": InfoCircleOutlined,
421
indent: { IconFont: "indent" },
422
info: InfoOutlined,
423
inkscape: { IconFont: "inkscape" },
424
"instagram-filled": InstagramFilled,
425
instagram: InstagramOutlined,
426
ipynb: { IconFont: "ipynb" },
427
italic: ItalicOutlined,
428
"js-square": { IconFont: "js-square" },
429
julia: { IconFont: "julia" },
430
jupyter: { IconFont: "ipynb" },
431
key: KeyOutlined,
432
keyboard: { IconFont: "keyboard" },
433
laptop: LaptopOutlined,
434
layout: LayoutOutlined,
435
"skull-crossbones": { IconFont: "leave_conference" },
436
libreoffice: { IconFont: "libreoffice" },
437
"life-ring": { IconFont: "life-ring" },
438
"life-saver": { IconFont: "life-ring" },
439
lightbulb: BulbOutlined,
440
"line-chart": LineChartOutlined,
441
link: LinkOutlined,
442
"linkedin-filled": LinkedinFilled,
443
linkedin: LinkedinOutlined,
444
linux: { IconFont: "linux" },
445
list: UnorderedListOutlined,
446
"list-ul": UnorderedListOutlined,
447
"list-alt": UnorderedListOutlined,
448
"list-ol": OrderedListOutlined,
449
"lock-open": UnlockFilled,
450
lock: LockFilled,
451
"lock-outlined": LockOutlined,
452
magic: { IconFont: "magic" },
453
mail: MailOutlined,
454
map: { IconFont: "map" },
455
markdown: { IconFont: "markdown" },
456
mask: { IconFont: "mask" },
457
maple: { IconFont: "maple" },
458
mathematica: { IconFont: "mathematica" },
459
matlab: { IconFont: "matlab" },
460
medkit: MedicineBoxOutlined,
461
"menu-outlined": MenuOutlined,
462
meh: MehOutlined,
463
microchip: { IconFont: "microchip" },
464
microsoft: { IconFont: "microsoft" },
465
"minus-circle": MinusCircleOutlined,
466
"minus-square": MinusSquareOutlined,
467
money: CreditCardOutlined,
468
"money-check": { IconFont: "money-check" },
469
mousepointer: { IconFont: "mousepointer" },
470
move: { IconFont: "move" },
471
arrows: { IconFont: "move" }, // fa-arrows is used by the bqplot custom widget
472
network: { IconFont: "network" },
473
"network-server": { IconFont: "network-server" },
474
"network-wired": ClusterOutlined,
475
"node-js": { IconFont: "node-js" },
476
note: { IconFont: "note-text" },
477
nvidia: { IconFont: "nvidia" },
478
octave: { IconFont: "octave" },
479
overview: AppstoreOutlined,
480
outdent: { IconFont: "outdent" },
481
pause: PauseCircleOutlined,
482
"paper-plane": SendOutlined,
483
paste: { IconFont: "paste" },
484
"pic-centered": PicCenterOutlined,
485
pen: { IconFont: "pen" },
486
pencil: EditOutlined,
487
"pencil-alt": EditOutlined,
488
percentage: PercentageOutlined,
489
play: PlayCircleOutlined,
490
"play-circle": PlayCircleFilled,
491
"play-square": PlaySquareOutlined,
492
plus: PlusOutlined,
493
minus: MinusOutlined,
494
"plus-circle": PlusCircleOutlined,
495
"plus-circle-o": PlusCircleOutlined,
496
"plus-circle-filled": PlusCircleFilled,
497
"plus-one": { IconFont: "plus-one" },
498
"plus-square": PlusSquareOutlined,
499
"plus-square-o": PlusSquareOutlined,
500
PoweroffOutlined,
501
print: PrinterOutlined,
502
python: { IconFont: "python" },
503
pytorch: { IconFont: "pytorch" },
504
qgis: { IconFont: "qgis" },
505
"question-circle": QuestionCircleOutlined,
506
"quote-left": { IconFont: "quote-left" },
507
r: { IconFont: "r" },
508
racket: { IconFont: "racket" },
509
redo: RedoOutlined,
510
refresh: RedoOutlined,
511
reload: ReloadOutlined,
512
remove: CloseOutlined,
513
repeat: RedoOutlined,
514
replace: { IconFont: "find-replace" },
515
reply: { IconFont: "reply" },
516
retweet: RetweetOutlined,
517
robot: RobotOutlined,
518
rocket: RocketOutlined,
519
run: { IconFont: "run" },
520
sagemath: { IconFont: "sagemath" },
521
"sagemath-bold": { IconFont: "sagemath-bold" },
522
"sagemath-file": { IconFont: "sagemath-file" },
523
save: SaveOutlined,
524
scheme: { IconFont: "scheme" },
525
scissors: ScissorOutlined,
526
search: SearchOutlined,
527
"search-minus": MinusOutlined, // we actually use this for zoom
528
"search-plus": PlusOutlined,
529
"select-outlined": SelectOutlined,
530
settings: SettingOutlined,
531
server: CloudServerOutlined,
532
servers: { IconFont: "servers" },
533
"sign-in": LoginOutlined,
534
"sign-out-alt": LoginOutlined, // Yes, since the logout one breaks darkreader, weirdly! they both look reasonable.
535
sitemap: ClusterOutlined,
536
"share-square": ShareAltOutlined,
537
"shopping-cart": ShoppingCartOutlined,
538
sliders: SlidersOutlined,
539
smile: SmileOutlined,
540
"sort-amount-up": { IconFont: "sort-amount-up" },
541
spinner: { IconFont: "cocalc-ring" },
542
square: BorderOutlined,
543
solution: SolutionOutlined,
544
"square-o": BorderOutlined,
545
"square-root-alt": { IconFont: "square-root-alt" },
546
"star-filled": StarFilled,
547
star: StarOutlined,
548
"step-backward": StepBackwardOutlined,
549
"step-forward": StepForwardOutlined,
550
stop: { IconFont: "stop" }, // the ant-design "stop" looks weird.
551
"stop-filled": StopFilled,
552
stopwatch: FieldTimeOutlined,
553
store: { IconFont: "store" },
554
strikethrough: StrikethroughOutlined,
555
subscript: { IconFont: "subscript" },
556
sun: { IconFont: "sun" },
557
superscript: { IconFont: "superscript" },
558
support: { IconFont: "life-ring" },
559
sync: { IconFont: "sync" },
560
"sync-alt": SyncOutlined,
561
tab: { IconFont: "tab" },
562
table: TableOutlined,
563
"tachometer-alt": DashboardOutlined,
564
tasks: { IconFont: "tasks" },
565
"tag-outlined": TagOutlined,
566
"tags-outlined": TagsOutlined,
567
"tag-filled": TagFilled,
568
"tags-filled": TagsFilled,
569
"tag-two-tone": TagTwoTone,
570
"tags-two-tone": TagsTwoTone,
571
"team-outlined": TeamOutlined,
572
tensorflow: { IconFont: "tensorflow" },
573
terminal: CodeOutlined,
574
tex: { IconFont: "tex" },
575
text: { IconFont: "text" },
576
text1: { IconFont: "text1" },
577
"tex-file": { IconFont: "tex-file" },
578
"text-height": LineHeightOutlined,
579
times: CloseOutlined,
580
"times-circle": CloseCircleOutlined,
581
"times-rectangle": { IconFont: "times-rectangle" },
582
"thumbs-down": { IconFont: "thumbs-down" },
583
"thumbs-up": { IconFont: "thumbs-up" },
584
"toggle-off": { IconFont: "toggle-off" },
585
"toggle-on": { IconFont: "toggle-on" },
586
tool: ToolOutlined,
587
trash: DeleteOutlined,
588
"twitter-filled": XOutlined,
589
twitter: XOutlined,
590
ubuntu: { IconFont: "ubuntu" },
591
underline: UnderlineOutlined,
592
undo: UndoOutlined,
593
ungroup: { IconFont: "ungroup" },
594
swap: SwapOutlined,
595
unlink: { IconFont: "unlink" },
596
upload: UploadOutlined,
597
user: UserOutlined,
598
"user-secret": { IconFont: "user-secret" },
599
UserAddOutlined,
600
"user-check": { IconFont: "user-check" },
601
"user-plus": UsergroupAddOutlined,
602
"user-slash": { IconFont: "user-slash" },
603
"user-times": UserDeleteOutlined,
604
users: UsergroupAddOutlined,
605
"vertical-split": { IconFont: "vertical-split" },
606
"vertical-right-outlined": VerticalRightOutlined,
607
"video-camera": VideoCameraOutlined,
608
"vertical-align-middle": VerticalAlignMiddleOutlined,
609
"vertical-align-bottom": VerticalAlignBottomOutlined,
610
"vertical-left-outlined": VerticalLeftOutlined,
611
vim: { IconFont: "vim" },
612
vscode: { IconFont: "vscode" },
613
wallet: WalletOutlined,
614
warning: WarningOutlined,
615
wifi: WifiOutlined,
616
"window-maximize": { IconFont: "window-maximize" },
617
"window-restore": DesktopOutlined, // we only use for x11 and this has big X.
618
wrench: { IconFont: "wrench" },
619
youtube: YoutubeOutlined,
620
"youtube-filled": YoutubeFilled,
621
"left-circle-o": LeftCircleOutlined,
622
"right-circle-o": RightCircleOutlined,
623
"down-circle-o": DownCircleOutlined,
624
"translation-outlined": TranslationOutlined,
625
"clean-outlined": ClearOutlined,
626
"sound-outlined": SoundOutlined,
627
"rise-outlined": RiseOutlined,
628
"up-square-outlined": UpSquareOutlined,
629
"down-square-outlined": DownSquareOutlined,
630
"merge-cells-outlined": MergeCellsOutlined,
631
"fork-outlined": ForkOutlined,
632
};
633
634
// Icon Fonts coming from https://www.iconfont.cn/?lang=en-us
635
import { createFromIconfontCN } from "@ant-design/icons";
636
export let IconFont: any = undefined;
637
try {
638
if (typeof window != "undefined") {
639
// obviously won't work if window is undefined based on looking at the code...
640
// This loads a bunch of svg elements of the form <svg id="icon-<name>"... into the DOM.
641
// The antd Icon code then duplicates these via the <use> html tag
642
// (https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use)
643
require("./iconfont.cn");
644
// note -- we do NOT pass scriptUrl in, as in the docs! Why? Because
645
// we want everything bundled up into webpack, rather than having to pull
646
// from some random place, which just causes confusion with releases
647
// and caching. Fortunately, just evaluating the js from iconfont, then
648
// running createFromIconfontCN with no arguments does work, as I deduced
649
// by reading the code, then trying this.
650
// https://github.com/ant-design/ant-design-icons/blob/5be2afd296636ab4cfec5d3a2793d6cd41b1789b/packages/icons-vue/src/components/IconFont.tsx
651
652
IconFont = createFromIconfontCN();
653
654
// It would be easy to screw up and put an entry like
655
// "arrow-circle-o-left": { IconFont: "arrowcircleoleft" }
656
// in IconSpec, but forget to actually include "arrowcircleoleft" in
657
// iconfont.cn, or -- just as bad -- make a typo or put the wrong name in.
658
// So we double check that all iconfonts are actually defined here:
659
if (typeof DEBUG != "undefined" && DEBUG) {
660
setTimeout(() => {
661
// only do this during dev to save time.
662
for (const name in IconSpec) {
663
const spec = IconSpec[name];
664
const x = spec?.IconFont;
665
if (x != null) {
666
const id = `icon-${x}`;
667
if (document.getElementById(id) == null) {
668
console.error(
669
`ERROR -- the IconFont ${x} is not in components/iconfont.cn! Fix this or the icon ${name} will be broken.`,
670
);
671
}
672
}
673
}
674
}, 5000);
675
}
676
}
677
} catch (err) {
678
// Might as well have option for a graceful fallback, e.g., when
679
// used from node.js...
680
console.log(`IconFont not available -- ${err}`);
681
}
682
683
// This was nice but unfortunately it exceeds typescript limits.
684
//export type IconName = keyof typeof IconSpec;
685
export type IconName = string;
686
export const IconName = undefined; // Javascript needs this, though we are only using IconName for the type
687
688
// Typeguard so can tell if a string is name of an icon and also
689
// make typescript happy.
690
export function isIconName(name?: string): name is IconName {
691
if (name == null) return false;
692
return IconSpec[name] != null;
693
}
694
695
export const iconNames: IconName[] = Object.keys(IconSpec) as any;
696
697
export type IconRotation = "45" | "90" | "135" | "180" | "225" | "270" | "315";
698
699
interface Props {
700
name?: IconName;
701
unicode?: number; // (optional) set a hex 16 bit charcode to render a unicode char, e.g. 0x2620
702
className?: string;
703
size?: "lg" | "2x" | "3x" | "4x" | "5x";
704
rotate?: IconRotation;
705
flip?: "horizontal" | "vertical";
706
spin?: boolean;
707
pulse?: boolean;
708
stack?: "1x" | "2x";
709
inverse?: boolean;
710
style?: CSS;
711
onClick?: (event?: React.MouseEvent) => void; // https://fettblog.eu/typescript-react/events/
712
onMouseOver?: () => void;
713
onMouseOut?: () => void;
714
onMouseEnter?: () => void;
715
onMouseLeave?: () => void;
716
}
717
718
const UNICODE_STYLE = {
719
fontSize: "120%",
720
fontWeight: "bold",
721
lineHeight: "1",
722
verticalAlign: "middle",
723
} as React.CSSProperties;
724
725
const missing: any = {};
726
// Converted from https://github.com/andreypopp/react-fa
727
728
export const Icon: React.FC<Props> = (props: Props) => {
729
// IMPORTANT: This hook is needed for next.js to support server side rendering.
730
// Otherwise, at least with next 13, it crashes when rendering icons.
731
const onFrontend = useOnFrontend();
732
if (!onFrontend) return null;
733
734
if (props.unicode != null) {
735
return (
736
<span style={{ ...UNICODE_STYLE, ...props.style }}>
737
{String.fromCharCode(props.unicode!)}
738
</span>
739
);
740
}
741
742
let name: IconName = props.name ?? "square";
743
let C;
744
C = IconSpec[name];
745
if (C == null && name.endsWith("-o")) {
746
// should be impossible because of typescript...
747
// try without -o
748
C = IconSpec[name.slice(0, name.length - 2)];
749
}
750
if (C != null) {
751
if (typeof C.IconFont == "string") {
752
// @ts-ignore
753
if (IconFont == null) {
754
return <span>(IconFonts not available)</span>;
755
}
756
return <IconFont type={"icon-" + C.IconFont} {...props} alt={name} />;
757
}
758
return <C {...props} alt={name} />;
759
}
760
761
// this is when the icon is broken.
762
if (typeof DEBUG != "undefined" && DEBUG) {
763
if (missing[props.name ?? ""] == null) {
764
missing[props.name ?? ""] = true;
765
console.warn(
766
`Icon "${props.name}" is not defined -- fix this in components/icon.tsx.`,
767
);
768
}
769
// make it hopefully clear to devs that this icon is broken
770
return (
771
<span
772
style={{ background: "red", color: "white" }}
773
className="blink"
774
title={`Icon "${props.name}" is not defined -- fix this in components/icon.tsx.`}
775
>
776
{/* @ts-ignore */}
777
<BugOutlined {...props} alt={name} />
778
</span>
779
);
780
} else {
781
// In production, just show a very generic icon so the user
782
// doesn't realize we messed up.
783
// @ts-ignore
784
return <BorderOutlined {...props} alt={name} />;
785
}
786
};
787
788
// TOOD move this to a shared lib, which can import the IconName type
789
export const PAYASYOUGO_ICON: IconName = "compass";
790
791