Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89cba595a7 | ||
|
|
02456263e0 | ||
|
|
a00f3134a5 | ||
|
|
d1e2c48641 | ||
|
|
b2d0708a51 | ||
|
|
2a8e43aff0 | ||
|
|
a9d1b7e23d | ||
|
|
8f5ebc425c | ||
|
|
809a6d2a45 | ||
|
|
5d34943550 | ||
|
|
f81cf0034b | ||
|
|
76a68e4629 | ||
|
|
53fb2905fd | ||
|
|
a1a8ba85bb | ||
|
|
72e8c23ecd | ||
|
|
d584c93c21 | ||
|
|
0e51cf1595 | ||
|
|
a9556e4901 | ||
|
|
505a7caeaa | ||
|
|
161eb6ad3c | ||
|
|
5d393395d3 | ||
|
|
ac1b23751d | ||
|
|
d9a095dea4 | ||
|
|
3dab196131 | ||
|
|
7f73379a7c | ||
|
|
abda804f39 | ||
|
|
b9858daaab | ||
|
|
0807bbe045 | ||
|
|
0269306a15 | ||
|
|
be3fcd7a70 | ||
|
|
4921d70e32 | ||
|
|
bef34677cd | ||
|
|
2e393282c9 | ||
|
|
ecfff506b9 | ||
|
|
87161a14a5 | ||
|
|
b1893f4ef6 | ||
|
|
fa5244e544 | ||
|
|
d0e18dab3e | ||
|
|
e4d8d28253 | ||
|
|
77e5de20c8 | ||
|
|
17ea00ef3c | ||
|
|
04975203b7 | ||
|
|
2ad4148057 | ||
|
|
5b23d0a963 | ||
|
|
987d118b0b | ||
|
|
a380c95899 | ||
|
|
fe60bd2490 | ||
|
|
ba27560096 | ||
|
|
dcca52d3b2 | ||
|
|
e04eccc868 | ||
|
|
5266d14dac | ||
|
|
4477c02512 | ||
|
|
d55d438ef0 | ||
|
|
70135edf3a | ||
|
|
2ac03a16d4 | ||
|
|
31c83d9d12 | ||
|
|
0c34dde9e8 | ||
|
|
f1794e755a | ||
|
|
87f2094890 | ||
|
|
0963fe20b7 | ||
|
|
19fbe0bde7 | ||
|
|
06a995eebb | ||
|
|
71938d06a2 | ||
|
|
e81ddbdb4b | ||
|
|
89356a9824 | ||
|
|
d3759f9ee1 | ||
|
|
8b041ece8f | ||
|
|
63e60ec44c | ||
|
|
4350c67e44 | ||
|
|
b4ade9d887 | ||
|
|
b63d12b0e4 | ||
|
|
d09ddb6404 | ||
|
|
1c3f59def5 | ||
|
|
fdd70c6607 | ||
|
|
d38cbac770 | ||
|
|
30f23ae9f5 | ||
|
|
707325863d | ||
|
|
5688365fb3 | ||
|
|
9862cec6e8 | ||
|
|
b18e5a9228 | ||
|
|
c1450932cb | ||
|
|
0a299f7118 | ||
|
|
51efbde09f | ||
|
|
eea9396f11 | ||
|
|
35e276a33d | ||
|
|
2586fb26b2 | ||
|
|
c6ed6b629e | ||
|
|
d5a55f8541 | ||
|
|
26aac36334 | ||
|
|
50fe570566 | ||
|
|
fa5e7659fc | ||
|
|
3b85413a05 | ||
|
|
302481846e | ||
|
|
8e22a3dcd1 | ||
|
|
077168dac9 | ||
|
|
e4debc5ecb | ||
|
|
de8b11e892 | ||
|
|
64bbbf997b | ||
|
|
c7f561ce41 | ||
|
|
116d250255 | ||
|
|
49b727ca0d | ||
|
|
811a814ef9 | ||
|
|
54d5a17c13 | ||
|
|
fccc260627 | ||
|
|
f946a3ee3a | ||
|
|
d582e6208e | ||
|
|
625d54fdad | ||
|
|
841fb96543 | ||
|
|
9dab13aef7 | ||
|
|
df6d6f8aeb | ||
|
|
875bfd8300 | ||
|
|
cb640b6208 | ||
|
|
6a032e54cd | ||
|
|
a3902ce3bb | ||
|
|
8237f1ccaa | ||
|
|
90bd5e911e | ||
|
|
8297018cb5 | ||
|
|
0f8ade3867 | ||
|
|
7f7f346af4 | ||
|
|
1b7e8aac04 | ||
|
|
8d36e66a21 | ||
|
|
8369c36e88 | ||
|
|
2e5b6e0d31 | ||
|
|
2752ad19b2 | ||
|
|
b4e942b34f | ||
|
|
1e33313473 | ||
|
|
45c04dda6c | ||
|
|
b1235589bb | ||
|
|
e2fbb3e5fb | ||
|
|
90aee31ff7 | ||
|
|
b3ddc6e77f | ||
|
|
871ad4b97a | ||
|
|
24d92f8f1d | ||
|
|
06fa4a528d | ||
|
|
3992b01883 | ||
|
|
909a6cf1c4 | ||
|
|
cdd0623792 | ||
|
|
0fd63998b9 | ||
|
|
7466383539 | ||
|
|
31ea9450b6 | ||
|
|
e70bf214b8 | ||
|
|
fb46c75128 | ||
|
|
4b2ed58009 | ||
|
|
c86778cc7b | ||
|
|
99bb8f64f6 | ||
|
|
3691e75d77 | ||
|
|
3904e85e61 | ||
|
|
4fcee649df | ||
|
|
e4bf096aaf | ||
|
|
cdb0d80cde | ||
|
|
e358a4f418 | ||
|
|
0f6c84f976 | ||
|
|
63788874db | ||
|
|
ac450cbd28 | ||
|
|
2ffcb6a012 | ||
|
|
998b9207f3 | ||
|
|
c290bea476 | ||
|
|
f2ed84a256 | ||
|
|
7f3f55c94e | ||
|
|
ffcf9f9034 | ||
|
|
6116bc2627 | ||
|
|
b7c9bb024a | ||
|
|
8c412f6748 | ||
|
|
53ce49e929 | ||
|
|
b27268f7db | ||
|
|
2c1b968bff | ||
|
|
3342166f7f | ||
|
|
72f09369de | ||
|
|
6e7ff0defc | ||
|
|
193e7f565a | ||
|
|
65bcbb4777 | ||
|
|
98975ec0f5 | ||
|
|
2e9b493a05 | ||
|
|
8f1f7fe9f3 | ||
|
|
93b4fa449b | ||
|
|
ee16638d07 | ||
|
|
2e76547a79 | ||
|
|
d7b25e79aa | ||
|
|
e0efa5f28d | ||
|
|
1b98f9d99f | ||
|
|
3bb4ba919f | ||
|
|
9cf31324ff | ||
|
|
1af1b48afb | ||
|
|
86ef073aca | ||
|
|
33193e3749 | ||
|
|
9d2dc11e08 | ||
|
|
44da0e40c5 | ||
|
|
cafe8e6541 | ||
|
|
66858926cc | ||
|
|
c37b691dd5 | ||
|
|
0e3ba9922c | ||
|
|
36992fc01b | ||
|
|
5f2aab6cbe | ||
|
|
fd90487afc | ||
|
|
06b9b1fc59 | ||
|
|
0dfccdf016 | ||
|
|
69e0817503 | ||
|
|
19629000ca | ||
|
|
d13cd3333c | ||
|
|
20c396d8d7 | ||
|
|
b6903a0ad8 | ||
|
|
8d898d7170 | ||
|
|
7dd69094d1 | ||
|
|
e79e5cd235 | ||
|
|
86a051ca63 | ||
|
|
28d0338ee0 | ||
|
|
3ec9271e83 | ||
|
|
19dd66469c | ||
|
|
43d61fe909 | ||
|
|
1038a7f682 | ||
|
|
947091adf7 | ||
|
|
728aa746a0 | ||
|
|
32da247bc1 | ||
|
|
f21bb0f097 | ||
|
|
e6a5af1a96 | ||
|
|
36a0c6b103 | ||
|
|
e63653cbe1 | ||
|
|
4ca8139f77 | ||
|
|
24caaad7d9 | ||
|
|
8c2a507fcf | ||
|
|
c76f2a2556 | ||
|
|
0d7f507677 | ||
|
|
b3155d9603 | ||
|
|
9139a01e18 | ||
|
|
0541db0f28 | ||
|
|
200678a619 | ||
|
|
66556ea45c | ||
|
|
b1c23f8dee | ||
|
|
81f2fc1a84 | ||
|
|
1543daa010 | ||
|
|
500d15fec0 | ||
|
|
a30dfb2886 | ||
|
|
f16c5fb13d | ||
|
|
a134c76d50 | ||
|
|
6753d715e2 | ||
|
|
c3722987c5 | ||
|
|
7f96d8c725 | ||
|
|
7666f2d97a | ||
|
|
b73bb075fd | ||
|
|
486ae96765 | ||
|
|
eca4c14f05 | ||
|
|
3dbc0c8263 | ||
|
|
81edbf2387 | ||
|
|
cb0b2124ec | ||
|
|
eef739789f | ||
|
|
98fa89ea57 | ||
|
|
107c075d88 | ||
|
|
2f3effb33f | ||
|
|
c580023063 | ||
|
|
0f77aaf2db | ||
|
|
cc7291248f | ||
|
|
81d9ff1995 | ||
|
|
71c7d80e54 | ||
|
|
95cd90d790 | ||
|
|
c0fb92b87f | ||
|
|
9de2a0760e | ||
|
|
38efaa1e8f | ||
|
|
502d1f7077 | ||
|
|
01b0de6e80 | ||
|
|
7d8e33e12c | ||
|
|
1069d8b4ab | ||
|
|
9992cc07a3 | ||
|
|
3aed6eee31 | ||
|
|
c470b85c34 | ||
|
|
3a2ab6ec27 | ||
|
|
63eee58f89 | ||
|
|
0642e2112b | ||
|
|
e6973d0c55 | ||
|
|
7668a3cf62 | ||
|
|
cfddc2e642 | ||
|
|
1cef0acb10 | ||
|
|
c5e4047206 | ||
|
|
63c9ee02a5 | ||
|
|
2e7fe14315 | ||
|
|
f61e47c698 | ||
|
|
922f43387b | ||
|
|
73526e40b8 | ||
|
|
7ce073d3fe | ||
|
|
1b07d10212 | ||
|
|
8983749600 | ||
|
|
fa8d76e20c | ||
|
|
91fa34ebc7 | ||
|
|
14fd26b38f | ||
|
|
2301be8f6c | ||
|
|
94cf9b52b6 | ||
|
|
00e7012192 | ||
|
|
2204753a37 | ||
|
|
cd791f735c | ||
|
|
b9c65a794d | ||
|
|
b16eed45a3 | ||
|
|
ed44918e29 | ||
|
|
51a431e6ad | ||
|
|
dab04ff606 | ||
|
|
1c6540e770 | ||
|
|
02eabdf6c5 | ||
|
|
5a2e8e9bf4 | ||
|
|
5c8f2468be | ||
|
|
0d757ad96a | ||
|
|
e80b5acb0c | ||
|
|
41bf08cee2 | ||
|
|
3c3ce88192 | ||
|
|
8c0f457f23 | ||
|
|
bc14bfea99 | ||
|
|
8af821f5b8 | ||
|
|
32cb024b42 | ||
|
|
c386872443 | ||
|
|
4c95d03958 | ||
|
|
8a54bf0a71 | ||
|
|
159ceef81e | ||
|
|
c9068ed4c0 | ||
|
|
acab74d2b9 | ||
|
|
3d7ed854c7 | ||
|
|
46afd68218 | ||
|
|
6342807b26 | ||
|
|
03f5914ecf | ||
|
|
f97439c703 | ||
|
|
352c80b8b6 | ||
|
|
cecdb9c0cd | ||
|
|
052f07b103 | ||
|
|
5f31f277db | ||
|
|
793288593c | ||
|
|
bc637cc951 | ||
|
|
993a314eb6 | ||
|
|
5b7fc526bc | ||
|
|
dfb62b67e0 | ||
|
|
b85a855b7e | ||
|
|
57abf83ec5 | ||
|
|
a9eba9ddb4 | ||
|
|
1286103494 | ||
|
|
b9cd35bf20 | ||
|
|
cc15712e03 | ||
|
|
8afeb4c6c9 | ||
|
|
ccb3e41441 | ||
|
|
b74a92328c | ||
|
|
b01be99602 | ||
|
|
279de8512c | ||
|
|
6f1b29a40a | ||
|
|
a76a78c568 | ||
|
|
2207229f25 | ||
|
|
eaee160c88 | ||
|
|
b4c51b089a | ||
|
|
db473aeb45 | ||
|
|
ce43527435 | ||
|
|
174d2ec88d | ||
|
|
7152cfd6c2 | ||
|
|
9e254846f5 | ||
|
|
a1142adfe5 | ||
|
|
2d0f3aa119 | ||
|
|
587e450cdf | ||
|
|
e48b0305d5 | ||
|
|
ecd4406c42 | ||
|
|
fa1c145f94 | ||
|
|
062ca67692 | ||
|
|
0615f89ef8 | ||
|
|
67c8bf0565 | ||
|
|
f0d22ccc26 | ||
|
|
65e1cfabfe | ||
|
|
ac4fbbf247 | ||
|
|
1be0c8eb21 | ||
|
|
f57e4988b0 | ||
|
|
0df64cf8b8 | ||
|
|
444dc18700 | ||
|
|
aacebf599d | ||
|
|
8839341860 | ||
|
|
1557658d90 | ||
|
|
070faa8453 | ||
|
|
020dcf93b7 | ||
|
|
96e62cc26d | ||
|
|
c8b64b1e99 | ||
|
|
0320bf2926 | ||
|
|
668aacae7e | ||
|
|
8fee03af6d | ||
|
|
ce43b6c4af | ||
|
|
38c00319ce | ||
|
|
c67103ae33 | ||
|
|
30b2b9cdf5 | ||
|
|
ced468a360 | ||
|
|
354195d163 | ||
|
|
a3b73a5e3a | ||
|
|
bb6b8c122e | ||
|
|
3d036a08a3 | ||
|
|
1d5e097556 | ||
|
|
94bc599203 | ||
|
|
55fcc4b9f2 | ||
|
|
9f77b8c7a2 | ||
|
|
6398aa0a11 | ||
|
|
1c4399400f | ||
|
|
d1e210990f | ||
|
|
8ac5362c7c | ||
|
|
2542b5ac73 | ||
|
|
510232d6a1 | ||
|
|
2466debdaa | ||
|
|
c4dd4a24aa | ||
|
|
a3ae03e507 | ||
|
|
c14a19435c | ||
|
|
4c700e2beb | ||
|
|
373aad41d5 | ||
|
|
1326c53ae9 | ||
|
|
ce2a55406f | ||
|
|
af5f4019d3 | ||
|
|
81086f94bb | ||
|
|
7baec40185 | ||
|
|
a41f237f74 | ||
|
|
9ca5040457 | ||
|
|
aae7600497 | ||
|
|
b847b3b9c0 | ||
|
|
d8a17ea0db | ||
|
|
c9f08cd1c7 | ||
|
|
5611991490 | ||
|
|
7f24e5ebeb | ||
|
|
b4b6b75c0e | ||
|
|
5c1c6e195f | ||
|
|
12ccf40284 | ||
|
|
d6757c5228 | ||
|
|
367d7f8b30 | ||
|
|
6157a6123d | ||
|
|
7b3a8ae0bb | ||
|
|
b2cb08e0f1 | ||
|
|
50301e6afb | ||
|
|
266411cdc4 | ||
|
|
7e6c9d2106 | ||
|
|
d7b0171f9a | ||
|
|
cef8b5e20e | ||
|
|
34c7f7c0ad | ||
|
|
f293988f4f | ||
|
|
0ad2529e1d | ||
|
|
437946f7f3 | ||
|
|
b5edd7b8b2 | ||
|
|
52ccef83d3 | ||
|
|
6b324459ee | ||
|
|
33e9d3a125 | ||
|
|
6020525ad2 | ||
|
|
b3a147bb89 | ||
|
|
03bea5cfb4 | ||
|
|
3b3e212517 | ||
|
|
bf2f7059d1 | ||
|
|
803641b5ef | ||
|
|
cb0f2b789f | ||
|
|
696575a925 | ||
|
|
c96037ff3f | ||
|
|
76f4f6d90b | ||
|
|
76799e6d2a | ||
|
|
685c09df15 | ||
|
|
e8e8216f35 | ||
|
|
5c9a238abf | ||
|
|
54dde87b47 | ||
|
|
92c579228e | ||
|
|
e080c27251 | ||
|
|
f3e720c129 | ||
|
|
b9e6dd787e | ||
|
|
d00a1db48e | ||
|
|
500bd26e56 | ||
|
|
73bc0a596a | ||
|
|
02e6c71099 | ||
|
|
1445bbd4a9 | ||
|
|
c0e2a0498b | ||
|
|
c493761abc | ||
|
|
4c07e02372 | ||
|
|
354665f069 | ||
|
|
43b4fff014 | ||
|
|
c14505fb28 | ||
|
|
7f4291e460 | ||
|
|
f8a367a1c8 | ||
|
|
c1bcd61d5a | ||
|
|
9a9aca0ae0 | ||
|
|
fad3fc4580 | ||
|
|
2c36419fd7 | ||
|
|
812b488515 | ||
|
|
bd3a98905f | ||
|
|
3a226bac77 | ||
|
|
29f812aaaf | ||
|
|
7d3dd41f59 | ||
|
|
422bda7983 | ||
|
|
e7f12e3df4 | ||
|
|
28eb1260d5 | ||
|
|
9dc22085ee | ||
|
|
3d8457d5df | ||
|
|
c41d08a4fe | ||
|
|
0e737a1aa8 | ||
|
|
7bb0d7b232 | ||
|
|
29a6c8b996 | ||
|
|
0f4438f581 | ||
|
|
1c5211c47c | ||
|
|
b0b67d51dd | ||
|
|
1c5942ad96 | ||
|
|
c635b65d75 | ||
|
|
a15a2f0f89 | ||
|
|
1a80387c54 | ||
|
|
bea74662db | ||
|
|
fcfe309839 | ||
|
|
918c27f1fd | ||
|
|
8f6706e1b4 | ||
|
|
ab0f7cab07 | ||
|
|
4d16d6b5bb | ||
|
|
080520c272 | ||
|
|
3d1d7b1287 | ||
|
|
92bf42fc66 | ||
|
|
38e75af977 | ||
|
|
978d7f0520 | ||
|
|
10ca108e3e | ||
|
|
c6238c8a36 | ||
|
|
8bb5ff94c8 | ||
|
|
fec5d9b436 | ||
|
|
6f97fcc1b4 | ||
|
|
7c5116b1cb | ||
|
|
fbd6f853f2 | ||
|
|
31127430b1 | ||
|
|
b6849aa02d | ||
|
|
ffe501d0dc | ||
|
|
9bc7938f97 | ||
|
|
61874d3b39 | ||
|
|
fb6e291605 | ||
|
|
a73cef8b2f | ||
|
|
bd1f3c3ac6 | ||
|
|
012ed970ba | ||
|
|
1dce831baf | ||
|
|
c9a11ad2a3 | ||
|
|
1c88d96cc5 | ||
|
|
c3bfea5f59 | ||
|
|
008e2f7b03 | ||
|
|
62d54535fb | ||
|
|
08b5f4bb35 | ||
|
|
d705685298 | ||
|
|
d1ac8c42ee | ||
|
|
d5ba02861e | ||
|
|
d982853a2e | ||
|
|
fb6d42d137 | ||
|
|
067b24e63c | ||
|
|
aa0a39cd64 | ||
|
|
f1671ec6d8 | ||
|
|
778b255877 | ||
|
|
ed67d22986 | ||
|
|
390c852c39 | ||
|
|
13de75de47 | ||
|
|
a0a8897378 | ||
|
|
380ec72221 | ||
|
|
9b4a4b954f | ||
|
|
326c9dd81b | ||
|
|
d2e6437909 | ||
|
|
9349388777 | ||
|
|
5747efba6b | ||
|
|
c4db612a9d | ||
|
|
7df2f7befd | ||
|
|
13ea94f9b5 | ||
|
|
48b2e9b0e1 | ||
|
|
8e38047d13 | ||
|
|
1c2d8da629 | ||
|
|
6b805f730d | ||
|
|
a0999bd081 | ||
|
|
06f5d659d5 | ||
|
|
9a52be8470 | ||
|
|
35140e77df | ||
|
|
69915ed0dd | ||
|
|
6e2105337d | ||
|
|
956429f1ad | ||
|
|
14d1506df8 | ||
|
|
562c3c741c | ||
|
|
17318fe08b | ||
|
|
49627a90ba | ||
|
|
578d69a225 | ||
|
|
3e57401ce2 | ||
|
|
5c1c55ae80 | ||
|
|
48f3ee95c8 | ||
|
|
bac49870cb | ||
|
|
6c55058ddb | ||
|
|
19785fe226 | ||
|
|
18077c9d67 | ||
|
|
492c353fc2 | ||
|
|
515171c79d | ||
|
|
3f40e8029b | ||
|
|
76023ce723 | ||
|
|
93726208ff |
@@ -0,0 +1,32 @@
|
||||
name: 🐛 Bug Report
|
||||
description: Report a bug in the ion-icon component. Incorrect icons should use the "Incorrect Icon" template instead.
|
||||
labels: ['triage']
|
||||
title: 'bug: '
|
||||
body:
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Current Behavior
|
||||
description: A clear description of what the bug is and how it manifests.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
description: A clear description of what you expected to happen.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Steps to Reproduce
|
||||
description: Please explain the steps required to duplicate this issue.
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: Code Reproduction URL
|
||||
description: Please provide an application with the minimum code required to reproduce the issue. This is the best way to ensure this issue is triaged quickly. Issues without a code reproduction may be closed if the Ionic Team cannot reproduce the issue you are reporting.
|
||||
placeholder: https://github.com/...
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional Information
|
||||
description: List any other information that is relevant to your issue. Stack traces, related issues, suggestions on how to fix, Stack Overflow links, forum links, etc.
|
||||
@@ -0,0 +1,23 @@
|
||||
name: 💡 Feature Request
|
||||
description: Suggest a new feature for the ion-icon component. Icon requests should use the "Icon Request" template instead.
|
||||
labels: ['triage']
|
||||
title: 'feat: '
|
||||
body:
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Describe Problem
|
||||
description: A clear and concise description of what the problem is. Ex. I am always frustrated when [...]
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Describe Preferred Solution
|
||||
description: A clear and concise description of what you want to happen.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Describe Alternatives
|
||||
description: A clear and concise description of any alternative solutions or features you have considered.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional Information
|
||||
description: Add any other context or screenshots about the feature request here.
|
||||
@@ -0,0 +1,19 @@
|
||||
name: 🚀 Icon Request
|
||||
description: Request a new icon
|
||||
labels: ['triage']
|
||||
title: 'icon request: '
|
||||
body:
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Describe the Icon
|
||||
description: A clear and concise description of the icon you would like added.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Links to Examples
|
||||
description: Add links to any examples of the icon in other libraries that you like.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional Information
|
||||
description: Add any other context about the icon request here.
|
||||
@@ -0,0 +1,17 @@
|
||||
name: 😒 Incorrect Icon
|
||||
description: Report an incorrect icon
|
||||
labels: ['triage']
|
||||
title: 'incorrect icon: '
|
||||
body:
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Describe the Issue
|
||||
description: A clear description of what is wrong with the icon. Please include any relevant screenshots.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
description: A clear description of what the icon should look like. Please include any relevant screenshots.
|
||||
validations:
|
||||
required: true
|
||||
@@ -0,0 +1,105 @@
|
||||
triage:
|
||||
label: triage
|
||||
dryRun: false
|
||||
|
||||
closeAndLock:
|
||||
labels:
|
||||
- label: 'ionitron: support'
|
||||
message: >
|
||||
Thanks for the issue! This issue appears to be a support request. We use this issue tracker exclusively for
|
||||
bug reports and feature requests. Please use our [forum](https://forum.ionicframework.com/) for help or
|
||||
questions about Ionicons.
|
||||
|
||||
|
||||
Thank you for using Ionicons!
|
||||
- label: 'ionitron: missing template'
|
||||
message: >
|
||||
Thanks for the issue! It appears that you have not filled out the provided issue template. We use this issue
|
||||
template in order to gather more information and further assist you. Please create a new issue and ensure the
|
||||
template is fully filled out.
|
||||
|
||||
|
||||
Thank you for using Ionicons!
|
||||
close: true
|
||||
lock: true
|
||||
dryRun: false
|
||||
|
||||
comment:
|
||||
labels:
|
||||
- label: 'help wanted'
|
||||
message: >
|
||||
This issue has been labeled as `help wanted`. This label is added to issues
|
||||
that we believe would be good for contributors.
|
||||
|
||||
|
||||
If you'd like to work on this issue, please comment here letting us know that
|
||||
you would like to submit a pull request for it. This helps us to keep track of
|
||||
the pull request and make sure there isn't duplicated effort.
|
||||
|
||||
|
||||
For a guide on how to create a pull request and test this project locally to see
|
||||
your changes, see our [contributing documentation](https://github.com/ionic-team/ionicons/blob/main/.github/CONTRIBUTING.md#creating-a-pull-request).
|
||||
|
||||
|
||||
Thank you!
|
||||
- label: 'ionitron: needs reproduction'
|
||||
message: >
|
||||
Thanks for the issue! This issue has been labeled as `needs reproduction`. This label is added to issues that
|
||||
need a code reproduction.
|
||||
|
||||
|
||||
Please reproduce this issue and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a
|
||||
reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.
|
||||
|
||||
|
||||
If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was
|
||||
not enough for our team to reproduce the issue.
|
||||
- label: 'community feedback wanted'
|
||||
message: >
|
||||
This issue has been labeled as `community feedback wanted`. This label is added to issues that we would like to hear from the community on before moving forward with any final decision on the feature request.
|
||||
|
||||
|
||||
If the requested feature is something you would find useful for your applications, please react to the original post with 👍 (`+1`). If you would like to provide an additional use case for the feature, please post a comment.
|
||||
|
||||
|
||||
The team will review this feedback and make a final decision. Any decision will be posted on this thread, but please note that we may ultimately decide not to pursue this feature.
|
||||
|
||||
|
||||
Thank you!
|
||||
dryRun: false
|
||||
|
||||
noReply:
|
||||
days: 14
|
||||
maxIssuesPerRun: 100
|
||||
label: 'needs: reply'
|
||||
responseLabel: triage
|
||||
exemptProjects: true
|
||||
exemptMilestones: true
|
||||
message: >
|
||||
Thanks for the issue! This issue is being closed due to the lack of a reply. If this is still
|
||||
an issue with the latest version of Ionicons, please create a new issue and ensure the
|
||||
template is fully filled out.
|
||||
|
||||
|
||||
Thank you for using Ionicons!
|
||||
close: true
|
||||
lock: true
|
||||
dryRun: false
|
||||
|
||||
noReproduction:
|
||||
days: 14
|
||||
maxIssuesPerRun: 100
|
||||
label: 'ionitron: needs reproduction'
|
||||
responseLabel: triage
|
||||
exemptProjects: true
|
||||
exemptMilestones: true
|
||||
message: >
|
||||
Thanks for the issue! This issue is being closed due to the lack of a code reproduction. If this is still
|
||||
an issue with the latest version of Ionicons, please create a new issue and ensure the
|
||||
template is fully filled out.
|
||||
|
||||
|
||||
Thank you for using Ionicons!
|
||||
close: true
|
||||
lock: true
|
||||
dryRun: false
|
||||
@@ -0,0 +1,34 @@
|
||||
name: 'Build Ionicons'
|
||||
description: 'Build Ionicons'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
# Checkout the latest commit in this branch
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- uses: actions/setup-node@v4
|
||||
|
||||
- name: Cache Node Modules
|
||||
uses: actions/cache@v4
|
||||
env:
|
||||
cache-name: node-modules
|
||||
with:
|
||||
path: ./node_modules
|
||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./package-lock.json') }}-v1
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
shell: bash
|
||||
- name: Build
|
||||
run: npm run build
|
||||
shell: bash
|
||||
- uses: ./.github/workflows/actions/upload-archive
|
||||
with:
|
||||
name: ionicons-build
|
||||
output: IoniconsBuild.zip
|
||||
paths: dist components icons www
|
||||
- uses: ./.github/workflows/actions/upload-archive
|
||||
with:
|
||||
name: ionicons-src
|
||||
output: IoniconsSrc.zip
|
||||
paths: src
|
||||
@@ -0,0 +1,19 @@
|
||||
name: 'Archive Download'
|
||||
description: 'Downloads and decompresses an archive from a previous job'
|
||||
inputs:
|
||||
path:
|
||||
description: 'Input archive name'
|
||||
filename:
|
||||
description: 'Input file name'
|
||||
name:
|
||||
description: 'Archive name'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ${{ inputs.name }}
|
||||
path: ${{ inputs.path }}
|
||||
- name: Exract Archive
|
||||
run: unzip -q -o ${{ inputs.path }}/${{ inputs.filename }}
|
||||
shell: bash
|
||||
@@ -0,0 +1,63 @@
|
||||
name: 'Release'
|
||||
description: 'Releases a package'
|
||||
inputs:
|
||||
version:
|
||||
description: 'The type of version to release.'
|
||||
tag:
|
||||
description: 'The tag to publish to on NPM.'
|
||||
working-directory:
|
||||
description: 'The directory of the package.'
|
||||
folder:
|
||||
default: './'
|
||||
description: 'A folder containing a package.json file.'
|
||||
createRelease:
|
||||
description: 'Create a release on GitHub.'
|
||||
default: 'false'
|
||||
ghToken:
|
||||
description: 'The GitHub authentication token required to create a release.'
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22.x
|
||||
- name: Install latest npm
|
||||
run: npm install -g npm@latest
|
||||
shell: bash
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
shell: bash
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
- name: Set Git User
|
||||
run: |
|
||||
git config user.name ionitron
|
||||
git config user.email hi@ionicframework.com
|
||||
shell: bash
|
||||
- name: Update Version
|
||||
id: update_version
|
||||
run: |
|
||||
npm version ${{ inputs.version }}
|
||||
echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
- name: Run Build
|
||||
run: npm run build
|
||||
shell: bash
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
- name: Publish to NPM
|
||||
run: npm publish ${{ inputs.folder }} --tag ${{ inputs.tag }} --provenance
|
||||
shell: bash
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
|
||||
- name: Create Release
|
||||
if: ${{ inputs.createRelease == 'true' }}
|
||||
run: |
|
||||
git remote set-url origin https://${GH_TOKEN}:x-oauth-basic@github.com/ionic-team/ionicons.git
|
||||
git remote -v
|
||||
git push origin main --tags
|
||||
gh release create "v$VERSION" --title "v$VERSION" --generate-notes
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ inputs.ghToken }}
|
||||
VERSION: ${{ env.VERSION }}
|
||||
@@ -0,0 +1,84 @@
|
||||
name: 'Test E2E'
|
||||
description: 'Test E2E'
|
||||
inputs:
|
||||
shard:
|
||||
description: 'Playwright Test Shard (ex: 2)'
|
||||
totalShards:
|
||||
description: 'Playwright total number of test shards (ex: 4)'
|
||||
update:
|
||||
description: 'Whether or not to update the reference snapshots'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
|
||||
- name: Cache Node Modules
|
||||
uses: actions/cache@v4
|
||||
env:
|
||||
cache-name: node-modules
|
||||
with:
|
||||
path: ./node_modules
|
||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./package-lock.json') }}-v1
|
||||
- uses: ./.github/workflows/actions/download-archive
|
||||
with:
|
||||
name: ionicons-build
|
||||
path: .
|
||||
filename: IoniconsBuild.zip
|
||||
- uses: ./.github/workflows/actions/download-archive
|
||||
with:
|
||||
name: ionicons-src
|
||||
path: .
|
||||
filename: IoniconsSrc.zip
|
||||
- name: Install Playwright Dependencies
|
||||
run: npx playwright install && npx playwright install-deps
|
||||
shell: bash
|
||||
- name: Test
|
||||
if: inputs.update != 'true'
|
||||
run: npx playwright test --shard=${{ inputs.shard }}/${{ inputs.totalShards }}
|
||||
shell: bash
|
||||
- name: Test and Update
|
||||
id: test-and-update
|
||||
if: inputs.update == 'true'
|
||||
# Keep track of the files that were
|
||||
# changed so they can be correctly restored
|
||||
# in the combine step.
|
||||
# To do this, we move only the changed files
|
||||
# to a separate directory, while preserving the
|
||||
# directory structure of the source.
|
||||
# When, we create and archive of these results
|
||||
# so that the combine step can simply
|
||||
# unzip and move the changed files into place.
|
||||
# We have extra logic added so that job runners
|
||||
# that do not have any new screenshots do not create
|
||||
# an unnecessary .zip.
|
||||
run: |
|
||||
npx playwright test --shard=${{ inputs.shard }}/${{ inputs.totalShards }} --update-snapshots
|
||||
git add src/\*.png --force
|
||||
mkdir updated-screenshots
|
||||
rsync -R --progress $(git diff --name-only --cached) updated-screenshots
|
||||
if [ "$(ls -A updated-screenshots)" ]; then
|
||||
echo "hasUpdatedScreenshots=$(echo 'true')" >> $GITHUB_OUTPUT
|
||||
cd updated-screenshots
|
||||
ls
|
||||
zip -q -r ../UpdatedScreenshots-${{ inputs.shard }}-${{ inputs.totalShards }}.zip ./
|
||||
fi
|
||||
shell: bash
|
||||
- name: Archive Updated Screenshots
|
||||
if: inputs.update == 'true' && steps.test-and-update.outputs.hasUpdatedScreenshots == 'true'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: updated-screenshots-${{ inputs.shard }}-${{ inputs.totalShards }}
|
||||
path: UpdatedScreenshots-${{ inputs.shard }}-${{ inputs.totalShards }}.zip
|
||||
- name: Archive Test Results
|
||||
# The always() ensures that this step
|
||||
# runs even if the previous step fails.
|
||||
# We want the test results to be archived
|
||||
# even if the test fails in the previous
|
||||
# step, otherwise there would be no way
|
||||
# to debug these tests.
|
||||
if: always()
|
||||
uses: ./.github/workflows/actions/upload-archive
|
||||
with:
|
||||
name: test-results-${{ inputs.shard }}-${{ inputs.totalShards }}
|
||||
output: TestResults-${{ inputs.shard }}-${{ inputs.totalShards }}.zip
|
||||
paths: playwright-report
|
||||
@@ -0,0 +1,22 @@
|
||||
name: 'Test Spec'
|
||||
description: 'Test Spec'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
|
||||
- name: Cache Node Modules
|
||||
uses: actions/cache@v4
|
||||
env:
|
||||
cache-name: node-modules
|
||||
with:
|
||||
path: ./node_modules
|
||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./package-lock.json') }}-v1
|
||||
- uses: ./.github/workflows/actions/download-archive
|
||||
with:
|
||||
name: ionicons-build
|
||||
path: .
|
||||
filename: IoniconsBuild.zip
|
||||
- name: Test
|
||||
run: npm run test.spec -- --ci
|
||||
shell: bash
|
||||
@@ -0,0 +1,38 @@
|
||||
name: 'Update Reference Screenshots'
|
||||
description: 'Update Reference Screenshots'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: ./artifacts
|
||||
- name: Extract Archives
|
||||
# This finds all .zip files in the ./artifacts
|
||||
# directory, including nested directories.
|
||||
# It then unzips every .zip to the root directory
|
||||
run: |
|
||||
find . -type f -name 'UpdatedScreenshots-*.zip' -exec unzip -q -o -d ../ {} \;
|
||||
shell: bash
|
||||
working-directory: ./artifacts
|
||||
- name: Push Screenshots
|
||||
# Configure user as Ionitron
|
||||
# and push only the changed .png snapshots
|
||||
# to the remote branch.
|
||||
# Screenshots are in .gitignore
|
||||
# to prevent local screenshots from getting
|
||||
# pushed to Git. As a result, we need --force
|
||||
# here so that CI generated screenshots can
|
||||
# get added to git. Screenshot ground truths
|
||||
# should only be added via this CI process.
|
||||
run: |
|
||||
git config user.name ionitron
|
||||
git config user.email hi@ionicframework.com
|
||||
git add src/\*.png --force
|
||||
git commit -m "chore(): add updated snapshots"
|
||||
git push
|
||||
shell: bash
|
||||
@@ -0,0 +1,19 @@
|
||||
name: 'Archive Upload'
|
||||
description: 'Compresses and uploads an archive to be reused across jobs'
|
||||
inputs:
|
||||
paths:
|
||||
description: 'Paths to files or directories to archive'
|
||||
output:
|
||||
description: 'Output file name'
|
||||
name:
|
||||
description: 'Archive name'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Create Archive
|
||||
run: zip -q -r ${{ inputs.output }} ${{ inputs.paths }}
|
||||
shell: bash
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ inputs.name }}
|
||||
path: ${{ inputs.output }}
|
||||
@@ -0,0 +1,43 @@
|
||||
name: 'Dev Release'
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
create-dev-hash:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
dev-hash: ${{ steps.create-dev-hash.outputs.DEV_HASH }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Dependencies
|
||||
run: npm ci --no-package-lock
|
||||
shell: bash
|
||||
- id: create-dev-hash
|
||||
name: Create Dev Hash
|
||||
run: |
|
||||
echo "DEV_HASH=$(node ./scripts/bump-version.js)-dev.1$(date +%s).1$(git log -1 --format=%H | cut -c 1-7)" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
|
||||
release-ionicons:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [create-dev-hash]
|
||||
permissions:
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Publish to NPM
|
||||
uses: ./.github/workflows/actions/publish-npm
|
||||
with:
|
||||
tag: dev
|
||||
version: ${{ needs.create-dev-hash.outputs.dev-hash }}
|
||||
working-directory: './'
|
||||
createRelease: 'false'
|
||||
|
||||
get-build:
|
||||
name: Get your dev build!
|
||||
runs-on: ubuntu-latest
|
||||
needs: [create-dev-hash, release-ionicons]
|
||||
steps:
|
||||
- run: echo ${{ needs.create-dev-hash.outputs.dev-hash }}
|
||||
@@ -0,0 +1,28 @@
|
||||
name: 'Production Release'
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
required: false
|
||||
type: string
|
||||
description: npm version (major, minor, or patch)
|
||||
|
||||
jobs:
|
||||
release-ionicons:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.IONITRON_TOKEN }}
|
||||
- name: Publish to NPM
|
||||
uses: ./.github/workflows/actions/publish-npm
|
||||
with:
|
||||
tag: latest
|
||||
version: ${{ inputs.version }}
|
||||
working-directory: './'
|
||||
createRelease: true
|
||||
ghToken: ${{ secrets.IONITRON_TOKEN }}
|
||||
@@ -0,0 +1,37 @@
|
||||
name: 'Release Orchestrator'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release-type:
|
||||
description: 'Release type'
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- dev
|
||||
- production
|
||||
version:
|
||||
description: 'Version for production releases'
|
||||
required: false
|
||||
type: choice
|
||||
options:
|
||||
- patch
|
||||
- minor
|
||||
- major
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
run-dev:
|
||||
if: ${{ inputs.release-type == 'dev' }}
|
||||
uses: ./.github/workflows/dev-release.yml
|
||||
secrets: inherit
|
||||
|
||||
run-production:
|
||||
if: ${{ inputs.release-type == 'production' }}
|
||||
uses: ./.github/workflows/production-release.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
version: ${{ inputs.version }}
|
||||
@@ -0,0 +1,52 @@
|
||||
name: 'Update Reference Screenshots'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-core:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/workflows/actions/build-core
|
||||
|
||||
test-e2e:
|
||||
strategy:
|
||||
# This ensures that all screenshot shard
|
||||
# failures are reported so the dev can
|
||||
# review everything at once.
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# Divide the tests into n buckets
|
||||
# and run those buckets in parallel.
|
||||
# To increase the number of shards,
|
||||
# add new items to the shard array
|
||||
# and change the value of totalShards
|
||||
# to be the length of the shard array.
|
||||
shard: [1, 2, 3]
|
||||
totalShards: [3]
|
||||
needs: [build-core]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/workflows/actions/test-e2e
|
||||
with:
|
||||
shard: ${{ matrix.shard }}
|
||||
totalShards: ${{ matrix.totalShards }}
|
||||
update: true
|
||||
|
||||
update-reference-screenshots:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [test-e2e]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
# Normally, we could just push with the
|
||||
# default GITHUB_TOKEN, but that will
|
||||
# not cause the build workflow
|
||||
# to re-run. We use Ionitron's
|
||||
# Personal Access Token instead
|
||||
# to allow for this build workflow
|
||||
# to run when the screenshots are pushed.
|
||||
with:
|
||||
token: ${{ secrets.IONITRON_TOKEN }}
|
||||
- uses: ./.github/workflows/actions/update-reference-screenshots
|
||||
@@ -0,0 +1,73 @@
|
||||
name: 'Validation'
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: ['**']
|
||||
push:
|
||||
branches: ['main']
|
||||
|
||||
# When pushing a new commit we should
|
||||
# cancel the previous test run to not
|
||||
# consume more runners than we need to.
|
||||
concurrency:
|
||||
group: ${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build-core:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
# Checkout the latest commit in this branch
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- uses: ./.github/workflows/actions/build-core
|
||||
|
||||
test-spec:
|
||||
needs: [build-core]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/workflows/actions/test-spec
|
||||
|
||||
test-e2e:
|
||||
strategy:
|
||||
# This ensures that all screenshot shard
|
||||
# failures are reported so the dev can
|
||||
# review everything at once.
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# Divide the tests into n buckets
|
||||
# and run those buckets in parallel.
|
||||
# To increase the number of shards,
|
||||
# add new items to the shard array
|
||||
# and change the value of totalShards
|
||||
# to be the length of the shard array.
|
||||
shard: [1, 2, 3]
|
||||
totalShards: [3]
|
||||
needs: [build-core]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/workflows/actions/test-e2e
|
||||
with:
|
||||
shard: ${{ matrix.shard }}
|
||||
totalShards: ${{ matrix.totalShards }}
|
||||
|
||||
# Screenshots are required to pass
|
||||
# in order for the branch to be merge
|
||||
# eligible. However, the screenshot tests
|
||||
# are run on n runners where n can change
|
||||
# over time. The verify-screenshots step allows
|
||||
# us to have a required status check for screenshot
|
||||
# results without having to manually add each
|
||||
# matrix run in the branch protection rules
|
||||
# Source: https://github.community/t/status-check-for-a-matrix-jobs/127354
|
||||
verify-e2e:
|
||||
if: ${{ always() }}
|
||||
needs: test-e2e
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check build matrix status
|
||||
if: ${{ needs.test-e2e.result != 'success' }}
|
||||
run: exit 1
|
||||
@@ -8,11 +8,20 @@ log.txt
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
.idea/
|
||||
.sass-cache/
|
||||
.versions/
|
||||
.vscode/
|
||||
/components/
|
||||
node_modules/
|
||||
tmp/
|
||||
.DS_Store
|
||||
dist/
|
||||
docs/
|
||||
icons/
|
||||
.DS_Store
|
||||
scripts/*.js
|
||||
!scripts/install-loader.js
|
||||
|
||||
www/
|
||||
/test-results/
|
||||
/playwright-report/
|
||||
/playwright/.cache/
|
||||
/src/**/*-snapshots
|
||||
*.tgz
|
||||
@@ -0,0 +1 @@
|
||||
src/components.d.ts
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"arrowParens": "always",
|
||||
"bracketSpacing": true,
|
||||
"jsxBracketSameLine": false,
|
||||
"jsxSingleQuote": false,
|
||||
"quoteProps": "consistent",
|
||||
"printWidth": 120,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "all",
|
||||
"useTabs": false
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Change Log
|
||||
|
||||
Please see https://github.com/ionic-team/ionicons/releases
|
||||
@@ -0,0 +1,11 @@
|
||||
# Contributor Code of Conduct
|
||||
|
||||
As contributors and maintainers of the Ionicons project, we pledge to respect everyone who contributes by posting issues, updating documentation, submitting pull requests, providing feedback in comments, and any other activities.
|
||||
|
||||
Communication through any of Ionic's channels (GitHub, Slack, Forum, IRC, mailing lists, Twitter, etc.) must be constructive and never resort to personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
||||
|
||||
We promise to extend courtesy and respect to everyone involved in this project regardless of gender, gender identity, sexual orientation, disability, age, race, ethnicity, religion, or level of experience. We expect anyone contributing to the Ionicons project to do the same.
|
||||
|
||||
If any member of the community violates this code of conduct, the maintainers of the Ionicons project may take action, removing issues, comments, and PRs or blocking accounts as deemed appropriate.
|
||||
|
||||
If you are subject to or witness unacceptable behavior, or have any other concerns, please email us at [hi@ionicframework.com](mailto:hi@ionicframework.com).
|
||||
@@ -0,0 +1,196 @@
|
||||
# Contributing to Ionicons
|
||||
|
||||
Thank you for your interest in contributing to Ionicons! :tada:
|
||||
|
||||
This document outlines the guidelines and processes for contributing to this project.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Code of Conduct](#code-of-conduct)
|
||||
- [Getting Started](#getting-started)
|
||||
* [Prerequisites](#prerequisites)
|
||||
* [Environment Setup](#environment-setup)
|
||||
- [Development Workflow](#development-workflow)
|
||||
* [Branch Strategy](#branch-strategy)
|
||||
* [Component Modifications](#component-modifications)
|
||||
* [Testing](#testing)
|
||||
* [Code Style](#code-style)
|
||||
* [Building](#building)
|
||||
- [Submitting Issues](#submitting-issues)
|
||||
- [Submitting Pull Requests](#submitting-pull-requests)
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
Please read our [Contributor Code of Conduct](./CODE_OF_CONDUCT.md) for information on our rules of conduct. By contributing to Ionicons, you agree to abide by its terms.
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- [Node.js](https://nodejs.org/) (LTS version recommended)
|
||||
- [npm](https://www.npmjs.com/) (comes with Node.js)
|
||||
- Git
|
||||
|
||||
### Environment Setup
|
||||
|
||||
1. We recommend using [nvm](https://github.com/nvm-sh/nvm) (Node Version Manager) to manage Node.js versions:
|
||||
- For macOS/Linux: `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash`
|
||||
- For Windows: Use [nvm-windows](https://github.com/coreybutler/nvm-windows)
|
||||
- Install and use the LTS version: `nvm install --lts && nvm use --lts`
|
||||
|
||||
Alternatively, you can [download the installer](https://nodejs.org/) for the LTS version of Node.js directly.
|
||||
|
||||
2. Fork the repository on GitHub
|
||||
3. Clone your fork locally:
|
||||
```bash
|
||||
git clone https://github.com/YOUR-USERNAME/ionicons.git
|
||||
cd ionicons
|
||||
```
|
||||
4. Add the original repository as an upstream remote:
|
||||
```bash
|
||||
git remote add upstream https://github.com/ionic-team/ionicons.git
|
||||
```
|
||||
5. Create a new branch from `main` for your change:
|
||||
```bash
|
||||
git checkout -b your-feature-branch
|
||||
```
|
||||
6. Install dependencies:
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
7. Run the initial build:
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
8. If desired, [modify the Icon Component](#component-modifications)
|
||||
9. Or, modify and preview the site
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### Branch Strategy
|
||||
|
||||
- Always create a new branch from `main` for your changes:
|
||||
```bash
|
||||
git checkout main
|
||||
git pull upstream main
|
||||
git checkout -b your-feature-branch
|
||||
```
|
||||
|
||||
### Component Modifications
|
||||
|
||||
If you're modifying the `ion-icon` component:
|
||||
|
||||
1. Navigate to `src/components/` directory and open the `icon` component to modify
|
||||
2. Make your changes to the component code
|
||||
3. Test your changes locally with `npm start`
|
||||
4. Run the full test suite: `npm run test.spec` for unit tests and `npm run test.e2e` for E2E tests
|
||||
5. All PRs that change component behavior must include tests covering the changes
|
||||
|
||||
### Testing
|
||||
|
||||
Tests are crucial for maintaining confidence in changes. All PRs that modify component behavior must include tests covering those changes.
|
||||
|
||||
#### Local Development & Previewing
|
||||
|
||||
To preview component changes during development:
|
||||
|
||||
```bash
|
||||
npm start
|
||||
```
|
||||
|
||||
This starts the dev server with live-reloading. The test landing page displays all available test pages.
|
||||
|
||||
Test pages are organized in `src/components/icon/test/` with individual folders for each test scenario.
|
||||
|
||||
#### Unit Tests
|
||||
|
||||
Run Jest tests for component logic:
|
||||
|
||||
```bash
|
||||
npm run test.spec
|
||||
```
|
||||
|
||||
#### E2E Tests
|
||||
|
||||
Run Playwright tests to generate visual regression snapshots and verify component behavior:
|
||||
|
||||
```bash
|
||||
npm run test.e2e
|
||||
```
|
||||
|
||||
View the HTML report after tests complete:
|
||||
|
||||
```bash
|
||||
npx playwright show-report
|
||||
```
|
||||
|
||||
> [!IMPORTANT]
|
||||
> All E2E test navigation URLs must include a trailing slash (e.g., `/icon/test/basic/` not `/icon/test/basic`). The trailing slash ensures proper directory routing, correct timing for script initialization, and consistent page loading across browsers.
|
||||
|
||||
##### Updating Snapshots
|
||||
|
||||
To update visual regression snapshots with new baselines:
|
||||
|
||||
```bash
|
||||
npm run test.e2e -- --update-snapshots
|
||||
```
|
||||
|
||||
Or for a specific test:
|
||||
|
||||
```bash
|
||||
npm run test.e2e -- src/components/icon/test/basic/icon.e2e.ts --update-snapshots
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> Updating snapshots locally updates your gitignored screenshot files for local testing. To update the official repository snapshots, run the "Update Reference Screenshots" GitHub action with your development branch selected.
|
||||
|
||||
### Code Style
|
||||
|
||||
- This project uses Prettier for code formatting
|
||||
- Run `npm run prettier` to format your code before submitting
|
||||
|
||||
### Building
|
||||
|
||||
- Run `npm run build` to build the complete package
|
||||
- Run `npm run build.files` to rebuild only the SVG icon files
|
||||
|
||||
## Submitting Issues
|
||||
|
||||
Please submit issues for:
|
||||
- Bug reports
|
||||
- Feature requests
|
||||
- General questions about the project
|
||||
|
||||
When creating issues:
|
||||
|
||||
1. If you have a question about using Ionicons, please ask on the [Ionic Forum](http://forum.ionicframework.com/) or in the [Ionic Discord](https://ionic.link/discord).
|
||||
|
||||
2. It is required that you clearly describe the steps necessary to reproduce the issue you are running into. Although we would love to help our users as much as possible, diagnosing issues without clear reproduction steps is extremely time-consuming and simply not sustainable.
|
||||
|
||||
3. The issue list of this repository is exclusively for bug reports and feature requests. Non-conforming issues will be closed immediately.
|
||||
|
||||
4. Check if a similar issue already exists by searching through [existing issues](https://github.com/ionic-team/ionicons/issues?utf8=%E2%9C%93&q=is%3Aissue). You can search through existing issues to see if there is a similar one reported. Include closed issues as it may have been closed with a solution.
|
||||
|
||||
5. Use the provided issue templates and clearly describe:
|
||||
- Expected behavior
|
||||
- Actual behavior
|
||||
- Steps to reproduce (for bugs)
|
||||
- Browser/device information when relevant
|
||||
|
||||
6. [Create a new issue](https://github.com/ionic-team/ionicons/issues/new/choose) that thoroughly explains the problem.
|
||||
|
||||
## Submitting Pull Requests
|
||||
|
||||
1. Before submitting a Pull Request (PR), please:
|
||||
- Create an issue first to discuss the proposed changes
|
||||
- Comment on an existing issue mentioning you'd like to work on it
|
||||
- Look for issues labeled with [`help wanted`](https://github.com/ionic-team/ionicons/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) if you're new to the project
|
||||
|
||||
2. Creating the PR:
|
||||
- Update your fork to the latest upstream main
|
||||
- Make your changes in a new git branch
|
||||
- Follow the code style of the project
|
||||
- Include relevant tests
|
||||
- Make sure all tests pass: `npm test`
|
||||
- Update documentation if needed
|
||||
- [Create a new pull request](https://github.com/ionic-team/ionicons/compare) with the `main` branch as the base.
|
||||
@@ -0,0 +1,20 @@
|
||||
import path from 'path';
|
||||
import url from 'url';
|
||||
|
||||
import { createJestStencilPreset } from 'jest-stencil-runner';
|
||||
|
||||
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
||||
|
||||
export default createJestStencilPreset({
|
||||
rootDir: __dirname,
|
||||
// Add any additional Jest configuration here
|
||||
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
|
||||
collectCoverageFrom: [
|
||||
'src/**/*.{ts,tsx}',
|
||||
'!src/**/*.d.ts',
|
||||
],
|
||||
testMatch: [
|
||||
'**/__tests__/**/*.(ts|tsx|js)',
|
||||
'**/*.(test|spec).(ts|tsx|js)'
|
||||
]
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
const Stencil = require('@stencil/core');
|
||||
Stencil.Build.isBrowser = true;
|
||||
@@ -1,48 +1,97 @@
|
||||
{
|
||||
"name": "ionicons",
|
||||
"version": "4.0.0-15",
|
||||
"version": "8.1.1",
|
||||
"description": "Premium icons for Ionic.",
|
||||
"files": [
|
||||
"dist/"
|
||||
"components/",
|
||||
"dist/",
|
||||
"icons/"
|
||||
],
|
||||
"main": "dist/ionicons.js",
|
||||
"main": "./dist/index.cjs.js",
|
||||
"module": "./dist/index.js",
|
||||
"types": "dist/types/index.d.ts",
|
||||
"unpkg": "dist/ionicons/ionicons.esm.js",
|
||||
"jsdelivr": "dist/ionicons/ionicons.esm.js",
|
||||
"collection": "dist/collection/collection-manifest.json",
|
||||
"collection:main": "dist/collection/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/types/index.d.ts",
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs.js"
|
||||
},
|
||||
"./loader": {
|
||||
"types": "./dist/loader/index.d.ts",
|
||||
"import": "./dist/loader/index.js",
|
||||
"require": "./dist/loader/index.cjs.js"
|
||||
},
|
||||
"./components": {
|
||||
"types": "./components/index.d.ts",
|
||||
"import": "./components/index.js"
|
||||
},
|
||||
"./components/ion-icon.js": {
|
||||
"types": "./components/ion-icon.d.ts",
|
||||
"import": "./components/ion-icon.js"
|
||||
},
|
||||
"./icons": {
|
||||
"types": "./icons/index.d.ts",
|
||||
"import": "./icons/index.mjs",
|
||||
"require": "./icons/index.js"
|
||||
},
|
||||
"./dist/ionicons.json": {
|
||||
"default": "./dist/ionicons.json"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build.icon && npm run generate && npm run svg-to-js && npm run png && npm run build.data && npm run build.css && npm run build.docs && npm run icon-copy",
|
||||
"build.icon": "stencil build",
|
||||
"build.docs": "stencil build --config src/docs/stencil.config.js",
|
||||
"build.data": "node scripts/data.js",
|
||||
"build.css": "node scripts/build-css.js",
|
||||
"icon-copy": "node scripts/copy-svg-to-dist.js",
|
||||
"mode.comparison": "node scripts/mode-comparison.js",
|
||||
"dev": "npm run build && sd concurrent \"stencil build --dev --config src/docs/stencil.config.js --watch\" \"stencil-dev-server\" ",
|
||||
"generate": "python scripts/generate.py",
|
||||
"svg-to-js": "node scripts/svg-to-js.js",
|
||||
"png": "node scripts/png.js",
|
||||
"deploy": "npm run build && np --any-branch"
|
||||
"build": "run-s clean build.*",
|
||||
"build.files": "tsx scripts/build.ts",
|
||||
"build.component": "stencil build",
|
||||
"build.collection": "tsx scripts/collection-copy.ts",
|
||||
"clean": "rimraf dist components icons www",
|
||||
"lint": "npm run prettier -- --write",
|
||||
"prettier": "prettier \"./src/**/*.{html,ts,tsx,js,jsx,scss}\"",
|
||||
"prettier.dry-run": "npm run prettier -- --list-different",
|
||||
"start": "run-s build.files && stencil build --dev --watch --serve",
|
||||
"test": "run-s test.spec test.e2e",
|
||||
"test.spec": "jest",
|
||||
"test.e2e": "playwright test",
|
||||
"test.e2e.install": "playwright install && playwright install-deps"
|
||||
},
|
||||
"dependencies": {
|
||||
"@stencil/core": "^4.43.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ionic/jpml": "latest",
|
||||
"@stencil/core": "0.6.6",
|
||||
"@stencil/dev-server": "latest",
|
||||
"@stencil/utils": "latest",
|
||||
"fs-extra": "4.0.2",
|
||||
"node-sass": "4.7.2",
|
||||
"np": "2.17.0",
|
||||
"svg2png": "4.1.1",
|
||||
"svgo": "1.0.3"
|
||||
"@axe-core/playwright": "^4.12.1",
|
||||
"@playwright/test": "^1.61.1",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/node": "^22.15.3",
|
||||
"@types/svgo": "^3.0.0",
|
||||
"fs-extra": "^11.3.0",
|
||||
"jest": "^30.0.4",
|
||||
"jest-cli": "^30.0.4",
|
||||
"jest-stencil-runner": "^0.0.20",
|
||||
"npm-run-all2": "^8.0.4",
|
||||
"prettier": "^3.6.2",
|
||||
"puppeteer": "^24.12.0",
|
||||
"rimraf": "^6.0.1",
|
||||
"semver": "^7.7.2",
|
||||
"serve": "^14.2.4",
|
||||
"svgo": "4.0.0",
|
||||
"tsx": "^4.20.3",
|
||||
"typescript": "^5.8.3"
|
||||
},
|
||||
"keywords": [
|
||||
"ionicons",
|
||||
"icon pack",
|
||||
"ionic",
|
||||
"icon",
|
||||
"svg",
|
||||
"font",
|
||||
"mobile",
|
||||
"web component",
|
||||
"component",
|
||||
"custom element"
|
||||
"custom element",
|
||||
"material design",
|
||||
"ios"
|
||||
],
|
||||
"homepage": "http://ionicons.com/",
|
||||
"author": {
|
||||
@@ -62,5 +111,9 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/ionic-team/ionicons/issues"
|
||||
},
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"sideEffects": [
|
||||
"icons/imports/"
|
||||
],
|
||||
"web-types": "dist/ionic.web-types.json"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
import type { PlaywrightTestConfig } from '@playwright/test';
|
||||
import { devices, expect } from '@playwright/test';
|
||||
|
||||
const projects: PlaywrightTestConfig['projects'] = [
|
||||
{
|
||||
/**
|
||||
* This is really just desktop Firefox
|
||||
* but with a mobile viewport.
|
||||
*/
|
||||
name: 'Mobile Firefox',
|
||||
use: {
|
||||
browserName: 'firefox',
|
||||
/**
|
||||
* This is the Pixel 5 configuration.
|
||||
* We can't use devices['Pixel 5']
|
||||
* because the "isMobile" option is
|
||||
* not supported on Firefox.
|
||||
*/
|
||||
viewport: {
|
||||
width: 393,
|
||||
height: 727
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Mobile Chrome',
|
||||
use: {
|
||||
browserName: 'chromium',
|
||||
...devices['Pixel 5']
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Mobile Safari',
|
||||
use: {
|
||||
browserName: 'webkit',
|
||||
...devices['iPhone 12']
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/
|
||||
const config: PlaywrightTestConfig = {
|
||||
testMatch: '*.e2e.ts',
|
||||
expect: {
|
||||
/**
|
||||
* Maximum time expect() should wait for the condition to be met.
|
||||
* For example in `await expect(locator).toHaveText();`
|
||||
*/
|
||||
timeout: 5000,
|
||||
|
||||
/**
|
||||
* Configure screenshot comparison settings
|
||||
* to be more tolerant of minor visual differences
|
||||
*/
|
||||
toHaveScreenshot: {
|
||||
// Increase the threshold to allow for small font rendering differences
|
||||
// This sets the maximum allowed ratio of pixels that can be different
|
||||
maxDiffPixelRatio: 0.02, // Allow up to 2% of pixels to be different
|
||||
|
||||
// Alternatively, you can use absolute pixel count
|
||||
// maxDiffPixels: 100, // Allow up to 100 pixels to be different
|
||||
|
||||
// Add a threshold for per-pixel difference to handle anti-aliasing
|
||||
threshold: 0.2, // Default is 0.1
|
||||
}
|
||||
},
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
forbidOnly: !!process.env.CI,
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
/* Opt out of parallel tests on CI. */
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
reporter: 'html',
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
|
||||
actionTimeout: 0,
|
||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||
// baseURL: 'http://localhost:3000',
|
||||
|
||||
/**
|
||||
* All failed tests should create
|
||||
* a trace file for easier debugging.
|
||||
*
|
||||
* See https://playwright.dev/docs/trace-viewer
|
||||
*/
|
||||
trace: 'retain-on-failure',
|
||||
baseURL: 'http://localhost:3333',
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
projects,
|
||||
webServer: {
|
||||
command: 'serve www -p 3333',
|
||||
port: 3333,
|
||||
reuseExistingServer: !process.env.CI
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -1,15 +1,150 @@
|
||||
# Ionicons
|
||||
|
||||
[Ionicons](http://ionicons.com/) is a completely open-source icon set with 1,300 icons crafted for web, iOS, Android, and desktop apps. Ionicons was built for [Ionic Framework](https://ionicframework.com/), so icons have both Material Design and iOS versions.
|
||||
|
||||
Premium icons for [Ionic](http://ionicframework.com/). Designed by [@benjsperry](https://twitter.com/benjsperry).
|
||||
|
||||
Note: All brand icons are trademarks of their respective owners. The use of these trademarks does not indicate endorsement of the trademark holder by Drifty, nor vice versa.
|
||||
|
||||
Visit [ionicons.com](http://ionicons.com) and check out the search feature, which has keywords identifying common icon names and styles. For example, if you search for “arrow” we call up every icon that could possibly be used as an arrow.
|
||||
Note: All brand icons are trademarks of their respective owners. The use of these trademarks does not indicate endorsement of the trademark holder by Ionic, nor vice versa.
|
||||
|
||||
We intend for this icon pack to be used with [Ionic](http://ionicframework.com/), but it’s by no means limited to it. Use them wherever you see fit, personal or commercial. They are free to use and licensed under [MIT](http://opensource.org/licenses/MIT).
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
Thanks for your interest in contributing! Read up on our guidelines for
|
||||
[contributing](https://github.com/ionic-team/ionicons/blob/main/CONTRIBUTING.md)
|
||||
and then look through our issues with a [help wanted](https://github.com/ionic-team/ionicons/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)
|
||||
label.
|
||||
|
||||
|
||||
## Using the Web Component
|
||||
|
||||
The Ionicons Web Component is an easy and performant way to use Ionicons in your app. The component will dynamically load an SVG for each icon, so your app is only requesting the icons that you need.
|
||||
|
||||
Also note that only visible icons are loaded, and icons that are "below the fold" and hidden from the user's view do not make fetch requests for the svg resource.
|
||||
|
||||
### Installation
|
||||
|
||||
If you're using [Ionic Framework](https://ionicframework.com/), Ionicons is packaged by default, so no installation is necessary. Want to use Ionicons without Ionic Framework? Place the following `<script>` near the end of your page, right before the closing `</body>` tag, to enable them.
|
||||
|
||||
```html
|
||||
<script type="module" src="https://esm.sh/ionicons@latest/loader"></script>
|
||||
<script nomodule src="https://esm.sh/ionicons@latest/loader"></script>
|
||||
```
|
||||
|
||||
you can replace `latest` to pick any version of Ionicon, e.g.:
|
||||
|
||||
```html
|
||||
<script type="module" src="https://esm.sh/ionicons@8.0.0/loader"></script>
|
||||
<script nomodule src="https://esm.sh/ionicons@8.0.0/loader"></script>
|
||||
```
|
||||
|
||||
### Basic usage
|
||||
|
||||
To use a built-in icon from the Ionicons package, populate the `name` attribute on the ion-icon component:
|
||||
|
||||
```html
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
```
|
||||
|
||||
### Custom icons
|
||||
|
||||
To use a custom SVG, provide its url in the `src` attribute to request the external SVG file. The `src` attribute works the same as `<img src="...">` in that the url must be accessible from the webpage that's making a request for the image. Additionally, the external file can only be a valid svg and does not allow scripts or events within the svg element.
|
||||
|
||||
```html
|
||||
<ion-icon src="/path/to/external/file.svg"></ion-icon>
|
||||
```
|
||||
|
||||
#### Custom Asset Path
|
||||
|
||||
If you have a different set of icons you would like to load or if the Ionicon icons are hosted on a different page or path, you can set the asset url from which Ionicons pulls the icons via:
|
||||
|
||||
```ts
|
||||
import { setAssetPath, addIcons } from 'ionicons';
|
||||
import { add, logoIonic, save } from 'ionicons/icons';
|
||||
|
||||
// set root path for loading icons to "<root>/public/svg"
|
||||
setAssetPath(`${window.location.origin}/public/svg/`);
|
||||
|
||||
// only load specific icons
|
||||
addIcons({ add, logoIonic, save });
|
||||
```
|
||||
|
||||
This allows the use of named icons like this:
|
||||
|
||||
```html
|
||||
<!-- now pulls the svg from "<root>/public/svg/heart.svg" -->
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
```
|
||||
|
||||
## Variants
|
||||
Each app icon in Ionicons has a `filled`, `outline` and `sharp` variant. These different variants are provided to make your app feel native to a variety of platforms. The filled variant uses the default name without a suffix. Note: Logo icons do not have outline or sharp variants.
|
||||
|
||||
```html
|
||||
<ion-icon name="heart"></ion-icon> <!--filled-->
|
||||
<ion-icon name="heart-outline"></ion-icon> <!--outline-->
|
||||
<ion-icon name="heart-sharp"></ion-icon> <!--sharp-->
|
||||
```
|
||||
|
||||
### Platform specificity
|
||||
When using icons in Ionic Framework you can specify different icons per platform. Use the `md` and `ios` attributes and provide the platform-specific icon/variant name.
|
||||
|
||||
```html
|
||||
<ion-icon ios="heart-outline" md="heart-sharp"></ion-icon>
|
||||
```
|
||||
|
||||
## Size
|
||||
|
||||
To specify the icon size, you can use the size attribute for our pre-defined font sizes.
|
||||
|
||||
```html
|
||||
<ion-icon size="small"></ion-icon>
|
||||
<ion-icon size="large"></ion-icon>
|
||||
```
|
||||
|
||||
Or you can set a specific size by applying the `font-size` CSS property on the `ion-icon` component. It's recommended to use pixel sizes that are a multiple of 8 (8, 16, 32, 64, etc.)
|
||||
|
||||
```css
|
||||
ion-icon {
|
||||
font-size: 64px;
|
||||
}
|
||||
```
|
||||
|
||||
## Color
|
||||
|
||||
Specify the icon color by applying the `color` CSS property on the `ion-icon` component.
|
||||
|
||||
```css
|
||||
ion-icon {
|
||||
color: blue;
|
||||
}
|
||||
```
|
||||
|
||||
## Stroke width
|
||||
When using an `outline` icon variant it is possible to adjust the stroke width, for improved visual balance relative to the icon's size or relative to the width of adjacent text. You can set a specific size by applying the `--ionicon-stroke-width` CSS custom property to the `ion-icon` component. The default value is 32px.
|
||||
|
||||
```html
|
||||
<ion-icon name="heart-outline"></ion-icon>
|
||||
```
|
||||
|
||||
```css
|
||||
ion-icon {
|
||||
--ionicon-stroke-width: 16px;
|
||||
}
|
||||
```
|
||||
|
||||
## Migrating from v4
|
||||
|
||||
See the [5.0 release notes](https://github.com/ionic-team/ionicons/releases/tag/5.0.0) for a list of icon deletions/renames.
|
||||
|
||||
## License
|
||||
|
||||
Ionicons is licensed under the [MIT license](http://opensource.org/licenses/MIT).
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
* [Ionicons Homepage](http://ionicons.com/)
|
||||
* [Ionic Framework](https://ionicframework.com/)
|
||||
* [Ionic Discord](https://ionic.link/discord)
|
||||
* [Ionic Forum](https://forum.ionicframework.com/)
|
||||
* [Stencil](https://stenciljs.com/)
|
||||
* [Capacitor](https://capacitorjs.com/)
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
var sass = require('node-sass');
|
||||
var fs = require('fs-extra');
|
||||
var path = require('path');
|
||||
|
||||
var distScssDir = path.join(__dirname, '..', 'dist', 'scss');
|
||||
var distCssDir = path.join(__dirname, '..', 'dist', 'css');
|
||||
|
||||
fs.emptyDirSync(distCssDir);
|
||||
|
||||
generateCss('ionicons');
|
||||
generateCss('ionicons-core');
|
||||
|
||||
|
||||
function generateCss(fileName) {
|
||||
var input = path.join(distScssDir, fileName + '.scss');
|
||||
var output = path.join(distCssDir, fileName + '.css');
|
||||
var outputMin = path.join(distCssDir, fileName + '.min.css');
|
||||
|
||||
var opts = {
|
||||
file: input,
|
||||
outputStyle: 'expanded'
|
||||
};
|
||||
|
||||
sass.render(opts, (err, result) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
fs.writeFile(output, result.css.toString(), { encoding: 'utf-8' }, (err) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
var optsMin = {
|
||||
file: input,
|
||||
outputStyle: 'compressed'
|
||||
};
|
||||
|
||||
sass.render(optsMin, (err, result) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
fs.writeFile(outputMin, result.css.toString(), { encoding: 'utf-8' }, (err) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,421 @@
|
||||
import path from 'node:path';
|
||||
|
||||
import fs from 'fs-extra';
|
||||
import { optimize } from 'svgo';
|
||||
|
||||
import { webComponentPassPlugins, sourcePassPlugins } from './plugins';
|
||||
import { reservedKeywords } from './constants';
|
||||
import pkgData from '../package.json' with { type: 'json' };
|
||||
import type { SvgData } from './types';
|
||||
|
||||
async function build(rootDir: string) {
|
||||
try {
|
||||
const srcDir = path.join(rootDir, 'src');
|
||||
const srcSvgDir = path.join(srcDir, 'svg');
|
||||
const iconDir = path.join(rootDir, 'icons');
|
||||
const distDir = path.join(rootDir, 'dist');
|
||||
const distIoniconsDir = path.join(distDir, 'ionicons');
|
||||
const distSvgDir = path.join(distDir, 'svg');
|
||||
const optimizedSvgDir = path.join(distIoniconsDir, 'svg');
|
||||
|
||||
/**
|
||||
* Create the directories first, then empty them
|
||||
* This ensures they exist before we try to write files to them
|
||||
*/
|
||||
await Promise.all([
|
||||
fs.ensureDir(iconDir),
|
||||
fs.ensureDir(distDir),
|
||||
fs.ensureDir(distSvgDir),
|
||||
fs.ensureDir(optimizedSvgDir),
|
||||
fs.ensureDir(distIoniconsDir),
|
||||
]);
|
||||
|
||||
/**
|
||||
* Empty the directories
|
||||
*/
|
||||
await Promise.all([
|
||||
fs.emptyDir(iconDir),
|
||||
fs.emptyDir(distDir),
|
||||
fs.emptyDir(distSvgDir),
|
||||
fs.emptyDir(optimizedSvgDir),
|
||||
fs.emptyDir(distIoniconsDir),
|
||||
]);
|
||||
|
||||
const version = pkgData.version as string;
|
||||
const srcSvgData = await getSvgs(srcSvgDir, distSvgDir, optimizedSvgDir);
|
||||
await optimizeSvgs(srcSvgData);
|
||||
await Promise.all([
|
||||
createDataJson(version, srcDir, distDir, srcSvgData),
|
||||
createIconPackage(version, iconDir, srcSvgData),
|
||||
]);
|
||||
|
||||
const svgSymbolsContent = await createSvgSymbols(version, distDir, srcSvgData);
|
||||
|
||||
await createCheatsheet(version, rootDir, distDir, svgSymbolsContent, srcSvgData);
|
||||
await createWebTypes(version, rootDir, distDir, srcSvgData);
|
||||
await copyToTesting(rootDir, distDir, srcSvgData);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
async function optimizeSvgs(srcSvgData: SvgData[]) {
|
||||
await Promise.all(
|
||||
srcSvgData.map(async (svgData) => {
|
||||
return optimizeSvg(svgData);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
async function optimizeSvg(svgData: SvgData) {
|
||||
const srcSvgContent = await fs.readFile(svgData.srcFilePath, 'utf8');
|
||||
|
||||
const optimizedSvg = await optimize(srcSvgContent, { path: svgData.srcFilePath });
|
||||
const webComponentSvg = await optimize(optimizedSvg.data, {
|
||||
path: svgData.srcFilePath,
|
||||
plugins: webComponentPassPlugins,
|
||||
});
|
||||
const sourceSvg = await optimize(optimizedSvg.data, {
|
||||
path: svgData.srcFilePath,
|
||||
plugins: sourcePassPlugins,
|
||||
});
|
||||
|
||||
// Ensure directories exist before writing files
|
||||
await Promise.all([
|
||||
fs.ensureDir(path.dirname(svgData.optimizedFilePath)),
|
||||
fs.ensureDir(path.dirname(svgData.distSvgFilePath)),
|
||||
]);
|
||||
|
||||
svgData.optimizedSvgContent = webComponentSvg.data;
|
||||
await Promise.all([
|
||||
fs.writeFile(svgData.optimizedFilePath, svgData.optimizedSvgContent),
|
||||
fs.writeFile(svgData.distSvgFilePath, sourceSvg.data),
|
||||
]);
|
||||
}
|
||||
|
||||
async function copyToTesting(rootDir: string, distDir: string, srcSvgData: SvgData[]) {
|
||||
const testDir = path.join(rootDir, 'www');
|
||||
const testBuildDir = path.join(testDir, 'build');
|
||||
const testSvgDir = path.join(testBuildDir, 'svg');
|
||||
const cheatsheetDir = path.join(testDir, 'icon', 'test', 'cheatsheet');
|
||||
const version = (await fs.readJson(path.join(rootDir, 'package.json'))).version;
|
||||
|
||||
// Ensure all directories exist
|
||||
await Promise.all([
|
||||
fs.ensureDir(testDir),
|
||||
fs.ensureDir(testBuildDir),
|
||||
fs.ensureDir(testSvgDir),
|
||||
fs.ensureDir(cheatsheetDir),
|
||||
]);
|
||||
|
||||
await Promise.all(
|
||||
srcSvgData
|
||||
.filter((svgData): svgData is SvgData & { optimizedSvgContent: string } => Boolean(svgData.optimizedSvgContent))
|
||||
.map(async (svgData) => {
|
||||
const testSvgFilePath = path.join(testSvgDir, svgData.fileName);
|
||||
await fs.writeFile(testSvgFilePath, svgData.optimizedSvgContent);
|
||||
}),
|
||||
);
|
||||
|
||||
const wwwCheatsheetFilePath = path.join(cheatsheetDir, 'index.html');
|
||||
const srcIndexFilePath = path.join(rootDir, 'src', 'components', 'icon', 'test', 'index.html');
|
||||
const testIndexFilePath = path.join(testDir, 'index.html');
|
||||
|
||||
await fs.copyFile(srcIndexFilePath, testIndexFilePath);
|
||||
|
||||
// Generate the cheatsheet with placeholders filled in
|
||||
const svgSymbolsContent = await fs.readFile(path.join(distDir, 'ionicons.symbols.svg'), 'utf8');
|
||||
const c = srcSvgData.map(
|
||||
(svgData) =>
|
||||
`<a href="/svg/${svgData.fileName}"><svg><use href="#${svgData.iconName}" xlink:href="#${svgData.iconName}"/></svg></a>`,
|
||||
);
|
||||
c.push(svgSymbolsContent);
|
||||
|
||||
const cheatsheetTemplate = await fs.readFile(path.join(rootDir, 'scripts', 'cheatsheet-template.html'), 'utf8');
|
||||
const cheatsheetHtml = cheatsheetTemplate
|
||||
.replace(/{{version}}/g, version)
|
||||
.replace(/{{count}}/g, srcSvgData.length.toString())
|
||||
.replace(/{{content}}/g, c.join('\n'));
|
||||
|
||||
await fs.writeFile(wwwCheatsheetFilePath, cheatsheetHtml);
|
||||
}
|
||||
|
||||
async function createSvgSymbols(version: string, distDir: string, srcSvgData: SvgData[]) {
|
||||
srcSvgData = srcSvgData.sort((a, b) => {
|
||||
if (a.iconName < b.iconName) return -1;
|
||||
if (a.iconName > b.iconName) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
const symbolsSvgFilePath = path.join(distDir, 'ionicons.symbols.svg');
|
||||
|
||||
const lines = [
|
||||
`<svg data-ionicons="${version}" style="display:none">`,
|
||||
`<style>`,
|
||||
`.ionicon {`,
|
||||
` fill: currentColor;`,
|
||||
` stroke: currentColor;`,
|
||||
`}`,
|
||||
`.ionicon-fill-none {`,
|
||||
` fill: none;`,
|
||||
`}`,
|
||||
`.ionicon-stroke-width {`,
|
||||
` stroke-width: 32px;`,
|
||||
`}`,
|
||||
`</style>`,
|
||||
];
|
||||
|
||||
srcSvgData
|
||||
.filter((svgData): svgData is SvgData & { optimizedSvgContent: string } => Boolean(svgData.optimizedSvgContent))
|
||||
.forEach((svgData) => {
|
||||
const svg = svgData.optimizedSvgContent
|
||||
.replace(`<svg xmlns="http://www.w3.org/2000/svg"`, `<symbol id="${svgData.iconName}"`)
|
||||
.replace(`</svg>`, `</symbol>`);
|
||||
lines.push(svg);
|
||||
});
|
||||
|
||||
lines.push(`</svg>`, ``);
|
||||
|
||||
const content = lines.join('\n');
|
||||
await fs.writeFile(symbolsSvgFilePath, content);
|
||||
return content;
|
||||
}
|
||||
|
||||
async function createCheatsheet(
|
||||
version: string,
|
||||
rootDir: string,
|
||||
distDir: string,
|
||||
svgSymbolsContent: string,
|
||||
srcSvgData: SvgData[],
|
||||
) {
|
||||
const CheatsheetTmpFilePath = path.join(rootDir, 'scripts', 'cheatsheet-template.html');
|
||||
const distCheatsheetFilePath = path.join(distDir, 'cheatsheet.html');
|
||||
|
||||
const c = srcSvgData.map(
|
||||
(svgData) =>
|
||||
`<a href="/svg/${svgData.fileName}"><svg><use href="#${svgData.iconName}" xlink:href="#${svgData.iconName}"/></svg></a>`,
|
||||
);
|
||||
|
||||
c.push(svgSymbolsContent);
|
||||
|
||||
const html = (await fs.readFile(CheatsheetTmpFilePath, 'utf8'))
|
||||
.replace(/{{version}}/g, version)
|
||||
.replace(/{{count}}/g, srcSvgData.length.toString())
|
||||
.replace(/{{content}}/g, c.join('\n'));
|
||||
|
||||
await fs.writeFile(distCheatsheetFilePath, html);
|
||||
}
|
||||
|
||||
async function createWebTypes(version: string, rootDir: string, distDir: string, srcSvgData: SvgData[]) {
|
||||
const srcWebTypeFilePath = path.join(rootDir, 'src/ionicons.web-types.json');
|
||||
const distWebTypesFilePath = path.join(distDir, 'ionicons.web-types.json');
|
||||
const webTypes = JSON.parse(await fs.readFile(srcWebTypeFilePath, 'utf8'));
|
||||
|
||||
webTypes.version = version;
|
||||
|
||||
const icons = webTypes.contributions.html.ionicons;
|
||||
for (let data of srcSvgData) {
|
||||
icons.push({
|
||||
name: data.iconName,
|
||||
icon: 'dist/svg/' + data.fileName,
|
||||
});
|
||||
}
|
||||
|
||||
const jsonStr = JSON.stringify(webTypes, null, 2) + '\n';
|
||||
await fs.writeFile(distWebTypesFilePath, jsonStr);
|
||||
}
|
||||
|
||||
async function getSvgs(srcSvgDir: string, distSvgDir: string, optimizedSvgDir: string): Promise<SvgData[]> {
|
||||
const svgFiles = (await fs.readdir(srcSvgDir)).filter((fileName) => {
|
||||
return !fileName.startsWith('.') && fileName.endsWith('.svg');
|
||||
});
|
||||
|
||||
const svgData = await Promise.all(
|
||||
svgFiles.map(async (fileName) => {
|
||||
// fileName: airplane-outline.svg
|
||||
|
||||
if (fileName.toLowerCase() !== fileName) {
|
||||
throw new Error(`svg filename "${fileName}" must be all lowercase`);
|
||||
}
|
||||
|
||||
// srcFilePath: /src/svg/airplane-outline.svg
|
||||
const srcFilePath = path.join(srcSvgDir, fileName);
|
||||
|
||||
// srcFilePath: /src/svg/airplane-outline.svg
|
||||
const distSvgFilePath = path.join(distSvgDir, fileName);
|
||||
|
||||
// optimizedFilePath: /dist/ionicons/svg/airplane-outline.svg
|
||||
const optimizedFilePath = path.join(optimizedSvgDir, fileName);
|
||||
|
||||
const dotSplit = fileName.split('.');
|
||||
if (dotSplit.length > 2) {
|
||||
throw new Error(`svg filename "${fileName}" cannot contain more than one period`);
|
||||
}
|
||||
|
||||
// iconName: airplane-outline
|
||||
const iconName = dotSplit[0];
|
||||
|
||||
if (reservedKeywords.has(iconName)) {
|
||||
throw new Error(`svg icon name "${iconName}" is a reserved JavaScript keyword`);
|
||||
}
|
||||
|
||||
// fileNameMjs: airplane-outline.mjs
|
||||
const fileNameMjs = iconName + '.mjs';
|
||||
|
||||
// fileNameCjs: airplane-outline.mjs
|
||||
const fileNameCjs = iconName + '.js';
|
||||
|
||||
// exportName: airplaneOutline
|
||||
const exportName = camelize(iconName);
|
||||
|
||||
const title = toTitleCase(
|
||||
fileName.replace('.svg', '').replace('-outline', '').replace('-sharp', '').replace(/-/g, ' '),
|
||||
);
|
||||
|
||||
return {
|
||||
fileName,
|
||||
title,
|
||||
srcFilePath,
|
||||
distSvgFilePath,
|
||||
srcSvgContent: await fs.readFile(srcFilePath, 'utf8'),
|
||||
optimizedFilePath,
|
||||
iconName,
|
||||
fileNameMjs,
|
||||
fileNameCjs,
|
||||
exportName,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return svgData.sort((a, b) => {
|
||||
if (a.exportName < b.exportName) return -1;
|
||||
if (a.exportName > b.exportName) return 1;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
async function createIconPackage(version: string, iconDir: string, srcSvgData: SvgData[]) {
|
||||
await Promise.all([
|
||||
createEsmIcons(version, iconDir, srcSvgData),
|
||||
createCjsIcons(version, iconDir, srcSvgData),
|
||||
createDtsIcons(version, iconDir, srcSvgData),
|
||||
]);
|
||||
}
|
||||
|
||||
async function createEsmIcons(version: string, iconDir: string, srcSvgData: SvgData[]) {
|
||||
const iconEsmFilePath = path.join(iconDir, 'index.mjs');
|
||||
|
||||
const o = [`/* Ionicons v${version}, ES Modules */`, ``];
|
||||
|
||||
srcSvgData.forEach((svgData) => {
|
||||
o.push(`export const ${svgData.exportName} = ${getDataUrl(svgData)}`);
|
||||
});
|
||||
|
||||
await fs.writeFile(iconEsmFilePath, o.join('\n') + '\n');
|
||||
}
|
||||
|
||||
async function createCjsIcons(version: string, iconDir: string, srcSvgData: SvgData[]) {
|
||||
const iconCjsFilePath = path.join(iconDir, 'index.js');
|
||||
|
||||
const o = [`/* Ionicons v${version}, CommonJS */`, ``];
|
||||
|
||||
srcSvgData.forEach((svgData) => {
|
||||
o.push(`exports.${svgData.exportName} = ${getDataUrl(svgData)}`);
|
||||
});
|
||||
|
||||
await fs.writeFile(iconCjsFilePath, o.join('\n') + '\n');
|
||||
}
|
||||
|
||||
async function createDtsIcons(version: string, iconDir: string, srcSvgData: SvgData[]) {
|
||||
const iconDtsFilePath = path.join(iconDir, 'index.d.ts');
|
||||
|
||||
const o = [`/* Ionicons v${version}, Types */`, ``];
|
||||
|
||||
srcSvgData.forEach((svgData) => {
|
||||
o.push(`export declare var ${svgData.exportName}: string;`);
|
||||
});
|
||||
|
||||
await fs.writeFile(iconDtsFilePath, o.join('\n') + '\n');
|
||||
}
|
||||
|
||||
function getDataUrl(svgData: SvgData) {
|
||||
let svg = svgData.optimizedSvgContent;
|
||||
|
||||
if (!svg) {
|
||||
throw new Error(`oh no! no optimized SVG content! ${svgData.fileName}`);
|
||||
}
|
||||
|
||||
if (svg.includes(`'`)) {
|
||||
throw new Error(`oh no! no single quotes allowed! ${svgData.fileName}`);
|
||||
}
|
||||
if (svg.includes(`\n`) || svg.includes(`\r`)) {
|
||||
throw new Error(`oh no! no new lines allowed! ${svgData.fileName}`);
|
||||
}
|
||||
svg = svg.replace(/"/g, "'");
|
||||
return `"data:image/svg+xml;utf8,${svg}"`;
|
||||
}
|
||||
|
||||
async function createDataJson(version: string, srcDir: string, distDir: string, srcSvgData: SvgData[]) {
|
||||
const srcDataJsonPath = path.join(srcDir, 'data.json');
|
||||
const distDataJsonPath = path.join(distDir, 'ionicons.json');
|
||||
|
||||
const data = await fs.readJson(srcDataJsonPath).catch(() => ({}));
|
||||
data.icons = data.icons || [];
|
||||
|
||||
// add new icons
|
||||
srcSvgData.forEach((svgData) => {
|
||||
if (!data.icons.some((i) => i.name === svgData.iconName)) {
|
||||
data.icons.push({
|
||||
name: svgData.iconName,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// remove dead icons
|
||||
data.icons = data.icons.filter((dataIcon) => {
|
||||
return srcSvgData.some((svgData) => dataIcon.name === svgData.iconName);
|
||||
});
|
||||
|
||||
// sort
|
||||
data.icons = data.icons.sort((a, b) => {
|
||||
if (a.name < b.name) return -1;
|
||||
if (a.name > b.name) return 1;
|
||||
return 0;
|
||||
});
|
||||
data.icons.forEach((icon) => {
|
||||
icon.tags = icon.tags || icon.name.split('-');
|
||||
icon.tags = icon.tags.sort();
|
||||
});
|
||||
|
||||
const srcJsonStr = JSON.stringify(data, null, 2) + '\n';
|
||||
await fs.writeFile(srcDataJsonPath, srcJsonStr);
|
||||
|
||||
const distJsonData = {
|
||||
name: 'ionicons',
|
||||
version,
|
||||
icons: data.icons,
|
||||
};
|
||||
const distJsonStr = JSON.stringify(distJsonData, null, 2) + '\n';
|
||||
await fs.writeFile(distDataJsonPath, distJsonStr);
|
||||
}
|
||||
|
||||
function camelize(text: string) {
|
||||
let words = text.split(/[-_]/g); // ok one simple regexp.
|
||||
return words[0].toLowerCase() + words.slice(1).map(upFirst).join('');
|
||||
}
|
||||
|
||||
function upFirst(word: string) {
|
||||
return word[0].toUpperCase() + word.toLowerCase().slice(1);
|
||||
}
|
||||
|
||||
function toTitleCase(str: string) {
|
||||
const s = str.trim().toLowerCase().split(' ');
|
||||
for (var i = 0; i < s.length; i++) {
|
||||
s[i] = s[i].charAt(0).toUpperCase() + s[i].slice(1);
|
||||
}
|
||||
return s.join(' ');
|
||||
}
|
||||
|
||||
// let's do this
|
||||
build(path.join(__dirname, '..'));
|
||||
@@ -0,0 +1,10 @@
|
||||
const semver = require('semver');
|
||||
|
||||
const getDevVersion = () => {
|
||||
const originalVersion = require('../package.json').version;
|
||||
const baseVersion = semver.inc(originalVersion, 'patch');
|
||||
|
||||
return baseVersion;
|
||||
}
|
||||
|
||||
console.log(getDevVersion());
|
||||
@@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html dir="ltr" lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
|
||||
<title>Ionicons {{version}} Cheatsheet</title>
|
||||
<script type="module" src="/build/ionicons.esm.js"></script>
|
||||
<script nomodule src="/build/ionicons.js"></script>
|
||||
<link rel="stylesheet" href="../styles.css" />
|
||||
<script src="../header.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<test-header></test-header>
|
||||
|
||||
<main>
|
||||
<h1>Ionicons {{version}} Cheatsheet</h1>
|
||||
<h3>{{count}} icons</h3>
|
||||
|
||||
{{content}}
|
||||
</main>
|
||||
</body>
|
||||
|
||||
<style>
|
||||
svg {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
</html>
|
||||
@@ -0,0 +1,44 @@
|
||||
import fs from 'fs-extra';
|
||||
import { join } from 'path';
|
||||
|
||||
async function collectionCopy(rootDir: string) {
|
||||
// move optimized svgs to correct collection location
|
||||
const optimizedSrc = join(rootDir, 'dist', 'ionicons', 'svg');
|
||||
const collectionDest = join(rootDir, 'dist', 'collection', 'components', 'icon', 'svg');
|
||||
await fs.copy(optimizedSrc, collectionDest);
|
||||
|
||||
// we don't to copy the src svgs to collection
|
||||
await fs.remove(join(rootDir, 'dist', 'collection', 'svg'));
|
||||
// We don't want to copy the test svg assets to collection
|
||||
await fs.remove(join(rootDir, 'dist', 'collection', 'components', 'test'));
|
||||
|
||||
const cePackageDir = join(rootDir, 'components');
|
||||
const cePackageJsonPath = join(cePackageDir, 'package.json');
|
||||
const ceCjsPath = join(cePackageDir, 'index.cjs.js');
|
||||
|
||||
const emptyCjs = `/*empty cjs*/`;
|
||||
await fs.writeFile(ceCjsPath, emptyCjs);
|
||||
|
||||
const cePackageJson = {
|
||||
name: 'ionicons/components',
|
||||
description: 'Ionicons custom element.',
|
||||
main: './index.cjs.js',
|
||||
module: './index.js',
|
||||
types: './index.d.ts',
|
||||
private: true,
|
||||
};
|
||||
await fs.writeFile(cePackageJsonPath, JSON.stringify(cePackageJson, null, 2));
|
||||
|
||||
// this is temporary!!!!
|
||||
// removing the `type` from the d.ts export
|
||||
// to make it easier for users migrating between
|
||||
// of older versions of angular and typescript
|
||||
// to the newer verisons, where the `type` keyword
|
||||
// is used. This is a megahack, no doubt.
|
||||
const typesDist = join(rootDir, 'dist', 'types', 'index.d.ts');
|
||||
let types = await fs.readFile(typesDist, 'utf8');
|
||||
types = types.replace('export type', 'export');
|
||||
await fs.writeFile(typesDist, types);
|
||||
}
|
||||
|
||||
collectionCopy(join(__dirname, '..'));
|
||||
@@ -0,0 +1,52 @@
|
||||
// https://mathiasbynens.be/notes/reserved-keywords
|
||||
export const reservedKeywords = new Set([
|
||||
'do',
|
||||
'if',
|
||||
'in',
|
||||
'for',
|
||||
'let',
|
||||
'new',
|
||||
'try',
|
||||
'var',
|
||||
'case',
|
||||
'else',
|
||||
'enum',
|
||||
'eval',
|
||||
'null',
|
||||
'this',
|
||||
'true',
|
||||
'void',
|
||||
'with',
|
||||
'await',
|
||||
'break',
|
||||
'catch',
|
||||
'class',
|
||||
'const',
|
||||
'false',
|
||||
'super',
|
||||
'throw',
|
||||
'while',
|
||||
'yield',
|
||||
'delete',
|
||||
'export',
|
||||
'import',
|
||||
'public',
|
||||
'return',
|
||||
'static',
|
||||
'switch',
|
||||
'typeof',
|
||||
'default',
|
||||
'extends',
|
||||
'finally',
|
||||
'package',
|
||||
'private',
|
||||
'continue',
|
||||
'debugger',
|
||||
'function',
|
||||
'arguments',
|
||||
'interface',
|
||||
'protected',
|
||||
'implements',
|
||||
'instanceof',
|
||||
'constructor',
|
||||
]);
|
||||
@@ -1,11 +0,0 @@
|
||||
console.log('Copy optimized svg files to dist/ionicons/svg');
|
||||
|
||||
var fs = require('fs-extra');
|
||||
var path = require('path');
|
||||
|
||||
var optimizedSvgsDir = path.join(__dirname, '..', 'dist', 'collection', 'icon', 'svg');
|
||||
var componentSvgDir = path.join(__dirname, '..', 'dist', 'ionicons', 'svg');
|
||||
|
||||
fs.emptyDirSync(componentSvgDir);
|
||||
|
||||
fs.copy(optimizedSvgsDir, componentSvgDir);
|
||||
@@ -1,43 +0,0 @@
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
|
||||
const ROOT_DIR = path.join(__dirname, '..');
|
||||
const SRC_DIR = path.join(ROOT_DIR, 'src');
|
||||
const SRC_SVG_DIR = path.join(SRC_DIR, 'svg');
|
||||
const SRC_JSON = path.join(SRC_DIR, 'data.json');
|
||||
const DST_DIR = path.join(ROOT_DIR, 'dist');
|
||||
const DST_JSON = path.join(DST_DIR, 'ionicons/data.json');
|
||||
|
||||
|
||||
console.log('checking icon data: ' + SRC_JSON);
|
||||
|
||||
let srcData = fs.readJsonSync(SRC_JSON);
|
||||
let svgFiles = fs.readdirSync(SRC_SVG_DIR);
|
||||
|
||||
svgFiles.filter(f => f.indexOf('.svg') > -1).forEach(svgFile => {
|
||||
let iconName = svgFile.split('.')[0];
|
||||
|
||||
let icon = srcData.icons.find(i => i.icons.indexOf(iconName) > -1);
|
||||
if (!icon) {
|
||||
console.log('icon data missing for: ' + svgFile);
|
||||
}
|
||||
});
|
||||
|
||||
srcData.icons.forEach(i => {
|
||||
if (i.tags.length === 0) {
|
||||
console.log('icon data missing search tags for: ' + i.icons);
|
||||
}
|
||||
|
||||
i.icons.forEach(iconName => {
|
||||
let svgFile = iconName + '.svg';
|
||||
|
||||
let f = svgFiles.find(f => f === svgFile);
|
||||
if (!f) {
|
||||
console.log('icon data contains "' + iconName + '", but the file "' + path.join(SRC_SVG_DIR, svgFile) + '" doesn\'t exist');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
let content = JSON.stringify(srcData);
|
||||
fs.writeFileSync(DST_JSON, content);
|
||||
@@ -1,466 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is font utility code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Mozilla Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2009
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# John Daggett <jdaggett@mozilla.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
# eotlitetool.py - create EOT version of OpenType font for use with IE
|
||||
#
|
||||
# Usage: eotlitetool.py [-o output-filename] font1 [font2 ...]
|
||||
#
|
||||
|
||||
# OpenType file structure
|
||||
# http://www.microsoft.com/typography/otspec/otff.htm
|
||||
#
|
||||
# Types:
|
||||
#
|
||||
# BYTE 8-bit unsigned integer.
|
||||
# CHAR 8-bit signed integer.
|
||||
# USHORT 16-bit unsigned integer.
|
||||
# SHORT 16-bit signed integer.
|
||||
# ULONG 32-bit unsigned integer.
|
||||
# Fixed 32-bit signed fixed-point number (16.16)
|
||||
# LONGDATETIME Date represented in number of seconds since 12:00 midnight, January 1, 1904. The value is represented as a signed 64-bit integer.
|
||||
#
|
||||
# SFNT Header
|
||||
#
|
||||
# Fixed sfnt version // 0x00010000 for version 1.0.
|
||||
# USHORT numTables // Number of tables.
|
||||
# USHORT searchRange // (Maximum power of 2 <= numTables) x 16.
|
||||
# USHORT entrySelector // Log2(maximum power of 2 <= numTables).
|
||||
# USHORT rangeShift // NumTables x 16-searchRange.
|
||||
#
|
||||
# Table Directory
|
||||
#
|
||||
# ULONG tag // 4-byte identifier.
|
||||
# ULONG checkSum // CheckSum for this table.
|
||||
# ULONG offset // Offset from beginning of TrueType font file.
|
||||
# ULONG length // Length of this table.
|
||||
#
|
||||
# OS/2 Table (Version 4)
|
||||
#
|
||||
# USHORT version // 0x0004
|
||||
# SHORT xAvgCharWidth
|
||||
# USHORT usWeightClass
|
||||
# USHORT usWidthClass
|
||||
# USHORT fsType
|
||||
# SHORT ySubscriptXSize
|
||||
# SHORT ySubscriptYSize
|
||||
# SHORT ySubscriptXOffset
|
||||
# SHORT ySubscriptYOffset
|
||||
# SHORT ySuperscriptXSize
|
||||
# SHORT ySuperscriptYSize
|
||||
# SHORT ySuperscriptXOffset
|
||||
# SHORT ySuperscriptYOffset
|
||||
# SHORT yStrikeoutSize
|
||||
# SHORT yStrikeoutPosition
|
||||
# SHORT sFamilyClass
|
||||
# BYTE panose[10]
|
||||
# ULONG ulUnicodeRange1 // Bits 0-31
|
||||
# ULONG ulUnicodeRange2 // Bits 32-63
|
||||
# ULONG ulUnicodeRange3 // Bits 64-95
|
||||
# ULONG ulUnicodeRange4 // Bits 96-127
|
||||
# CHAR achVendID[4]
|
||||
# USHORT fsSelection
|
||||
# USHORT usFirstCharIndex
|
||||
# USHORT usLastCharIndex
|
||||
# SHORT sTypoAscender
|
||||
# SHORT sTypoDescender
|
||||
# SHORT sTypoLineGap
|
||||
# USHORT usWinAscent
|
||||
# USHORT usWinDescent
|
||||
# ULONG ulCodePageRange1 // Bits 0-31
|
||||
# ULONG ulCodePageRange2 // Bits 32-63
|
||||
# SHORT sxHeight
|
||||
# SHORT sCapHeight
|
||||
# USHORT usDefaultChar
|
||||
# USHORT usBreakChar
|
||||
# USHORT usMaxContext
|
||||
#
|
||||
#
|
||||
# The Naming Table is organized as follows:
|
||||
#
|
||||
# [name table header]
|
||||
# [name records]
|
||||
# [string data]
|
||||
#
|
||||
# Name Table Header
|
||||
#
|
||||
# USHORT format // Format selector (=0).
|
||||
# USHORT count // Number of name records.
|
||||
# USHORT stringOffset // Offset to start of string storage (from start of table).
|
||||
#
|
||||
# Name Record
|
||||
#
|
||||
# USHORT platformID // Platform ID.
|
||||
# USHORT encodingID // Platform-specific encoding ID.
|
||||
# USHORT languageID // Language ID.
|
||||
# USHORT nameID // Name ID.
|
||||
# USHORT length // String length (in bytes).
|
||||
# USHORT offset // String offset from start of storage area (in bytes).
|
||||
#
|
||||
# head Table
|
||||
#
|
||||
# Fixed tableVersion // Table version number 0x00010000 for version 1.0.
|
||||
# Fixed fontRevision // Set by font manufacturer.
|
||||
# ULONG checkSumAdjustment // To compute: set it to 0, sum the entire font as ULONG, then store 0xB1B0AFBA - sum.
|
||||
# ULONG magicNumber // Set to 0x5F0F3CF5.
|
||||
# USHORT flags
|
||||
# USHORT unitsPerEm // Valid range is from 16 to 16384. This value should be a power of 2 for fonts that have TrueType outlines.
|
||||
# LONGDATETIME created // Number of seconds since 12:00 midnight, January 1, 1904. 64-bit integer
|
||||
# LONGDATETIME modified // Number of seconds since 12:00 midnight, January 1, 1904. 64-bit integer
|
||||
# SHORT xMin // For all glyph bounding boxes.
|
||||
# SHORT yMin
|
||||
# SHORT xMax
|
||||
# SHORT yMax
|
||||
# USHORT macStyle
|
||||
# USHORT lowestRecPPEM // Smallest readable size in pixels.
|
||||
# SHORT fontDirectionHint
|
||||
# SHORT indexToLocFormat // 0 for short offsets, 1 for long.
|
||||
# SHORT glyphDataFormat // 0 for current format.
|
||||
#
|
||||
#
|
||||
#
|
||||
# Embedded OpenType (EOT) file format
|
||||
# http://www.w3.org/Submission/EOT/
|
||||
#
|
||||
# EOT version 0x00020001
|
||||
#
|
||||
# An EOT font consists of a header with the original OpenType font
|
||||
# appended at the end. Most of the data in the EOT header is simply a
|
||||
# copy of data from specific tables within the font data. The exceptions
|
||||
# are the 'Flags' field and the root string name field. The root string
|
||||
# is a set of names indicating domains for which the font data can be
|
||||
# used. A null root string implies the font data can be used anywhere.
|
||||
# The EOT header is in little-endian byte order but the font data remains
|
||||
# in big-endian order as specified by the OpenType spec.
|
||||
#
|
||||
# Overall structure:
|
||||
#
|
||||
# [EOT header]
|
||||
# [EOT name records]
|
||||
# [font data]
|
||||
#
|
||||
# EOT header
|
||||
#
|
||||
# ULONG eotSize // Total structure length in bytes (including string and font data)
|
||||
# ULONG fontDataSize // Length of the OpenType font (FontData) in bytes
|
||||
# ULONG version // Version number of this format - 0x00020001
|
||||
# ULONG flags // Processing Flags (0 == no special processing)
|
||||
# BYTE fontPANOSE[10] // OS/2 Table panose
|
||||
# BYTE charset // DEFAULT_CHARSET (0x01)
|
||||
# BYTE italic // 0x01 if ITALIC in OS/2 Table fsSelection is set, 0 otherwise
|
||||
# ULONG weight // OS/2 Table usWeightClass
|
||||
# USHORT fsType // OS/2 Table fsType (specifies embedding permission flags)
|
||||
# USHORT magicNumber // Magic number for EOT file - 0x504C.
|
||||
# ULONG unicodeRange1 // OS/2 Table ulUnicodeRange1
|
||||
# ULONG unicodeRange2 // OS/2 Table ulUnicodeRange2
|
||||
# ULONG unicodeRange3 // OS/2 Table ulUnicodeRange3
|
||||
# ULONG unicodeRange4 // OS/2 Table ulUnicodeRange4
|
||||
# ULONG codePageRange1 // OS/2 Table ulCodePageRange1
|
||||
# ULONG codePageRange2 // OS/2 Table ulCodePageRange2
|
||||
# ULONG checkSumAdjustment // head Table CheckSumAdjustment
|
||||
# ULONG reserved[4] // Reserved - must be 0
|
||||
# USHORT padding1 // Padding - must be 0
|
||||
#
|
||||
# EOT name records
|
||||
#
|
||||
# USHORT FamilyNameSize // Font family name size in bytes
|
||||
# BYTE FamilyName[FamilyNameSize] // Font family name (name ID = 1), little-endian UTF-16
|
||||
# USHORT Padding2 // Padding - must be 0
|
||||
#
|
||||
# USHORT StyleNameSize // Style name size in bytes
|
||||
# BYTE StyleName[StyleNameSize] // Style name (name ID = 2), little-endian UTF-16
|
||||
# USHORT Padding3 // Padding - must be 0
|
||||
#
|
||||
# USHORT VersionNameSize // Version name size in bytes
|
||||
# bytes VersionName[VersionNameSize] // Version name (name ID = 5), little-endian UTF-16
|
||||
# USHORT Padding4 // Padding - must be 0
|
||||
#
|
||||
# USHORT FullNameSize // Full name size in bytes
|
||||
# BYTE FullName[FullNameSize] // Full name (name ID = 4), little-endian UTF-16
|
||||
# USHORT Padding5 // Padding - must be 0
|
||||
#
|
||||
# USHORT RootStringSize // Root string size in bytes
|
||||
# BYTE RootString[RootStringSize] // Root string, little-endian UTF-16
|
||||
|
||||
|
||||
|
||||
import optparse
|
||||
import struct
|
||||
|
||||
class FontError(Exception):
|
||||
"""Error related to font handling"""
|
||||
pass
|
||||
|
||||
def multichar(str):
|
||||
vals = struct.unpack('4B', str[:4])
|
||||
return (vals[0] << 24) + (vals[1] << 16) + (vals[2] << 8) + vals[3]
|
||||
|
||||
def multicharval(v):
|
||||
return struct.pack('4B', (v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF)
|
||||
|
||||
class EOT:
|
||||
EOT_VERSION = 0x00020001
|
||||
EOT_MAGIC_NUMBER = 0x504c
|
||||
EOT_DEFAULT_CHARSET = 0x01
|
||||
EOT_FAMILY_NAME_INDEX = 0 # order of names in variable portion of EOT header
|
||||
EOT_STYLE_NAME_INDEX = 1
|
||||
EOT_VERSION_NAME_INDEX = 2
|
||||
EOT_FULL_NAME_INDEX = 3
|
||||
EOT_NUM_NAMES = 4
|
||||
|
||||
EOT_HEADER_PACK = '<4L10B2BL2H7L18x'
|
||||
|
||||
class OpenType:
|
||||
SFNT_CFF = multichar('OTTO') # Postscript CFF SFNT version
|
||||
SFNT_TRUE = 0x10000 # Standard TrueType version
|
||||
SFNT_APPLE = multichar('true') # Apple TrueType version
|
||||
|
||||
SFNT_UNPACK = '>I4H'
|
||||
TABLE_DIR_UNPACK = '>4I'
|
||||
|
||||
TABLE_HEAD = multichar('head') # TrueType table tags
|
||||
TABLE_NAME = multichar('name')
|
||||
TABLE_OS2 = multichar('OS/2')
|
||||
TABLE_GLYF = multichar('glyf')
|
||||
TABLE_CFF = multichar('CFF ')
|
||||
|
||||
OS2_FSSELECTION_ITALIC = 0x1
|
||||
OS2_UNPACK = '>4xH2xH22x10B4L4xH14x2L'
|
||||
|
||||
HEAD_UNPACK = '>8xL'
|
||||
|
||||
NAME_RECORD_UNPACK = '>6H'
|
||||
NAME_ID_FAMILY = 1
|
||||
NAME_ID_STYLE = 2
|
||||
NAME_ID_UNIQUE = 3
|
||||
NAME_ID_FULL = 4
|
||||
NAME_ID_VERSION = 5
|
||||
NAME_ID_POSTSCRIPT = 6
|
||||
PLATFORM_ID_UNICODE = 0 # Mac OS uses this typically
|
||||
PLATFORM_ID_MICROSOFT = 3
|
||||
ENCODING_ID_MICROSOFT_UNICODEBMP = 1 # with Microsoft platformID BMP-only Unicode encoding
|
||||
LANG_ID_MICROSOFT_EN_US = 0x0409 # with Microsoft platformID EN US lang code
|
||||
|
||||
def eotname(ttf):
|
||||
i = ttf.rfind('.')
|
||||
if i != -1:
|
||||
ttf = ttf[:i]
|
||||
return ttf + '.eotlite'
|
||||
|
||||
def readfont(f):
|
||||
data = open(f, 'rb').read()
|
||||
return data
|
||||
|
||||
def get_table_directory(data):
|
||||
"""read the SFNT header and table directory"""
|
||||
datalen = len(data)
|
||||
sfntsize = struct.calcsize(OpenType.SFNT_UNPACK)
|
||||
if sfntsize > datalen:
|
||||
raise FontError, 'truncated font data'
|
||||
sfntvers, numTables = struct.unpack(OpenType.SFNT_UNPACK, data[:sfntsize])[:2]
|
||||
if sfntvers != OpenType.SFNT_CFF and sfntvers != OpenType.SFNT_TRUE:
|
||||
raise FontError, 'invalid font type';
|
||||
|
||||
font = {}
|
||||
font['version'] = sfntvers
|
||||
font['numTables'] = numTables
|
||||
|
||||
# create set of offsets, lengths for tables
|
||||
table_dir_size = struct.calcsize(OpenType.TABLE_DIR_UNPACK)
|
||||
if sfntsize + table_dir_size * numTables > datalen:
|
||||
raise FontError, 'truncated font data, table directory extends past end of data'
|
||||
table_dir = {}
|
||||
for i in range(0, numTables):
|
||||
start = sfntsize + i * table_dir_size
|
||||
end = start + table_dir_size
|
||||
tag, check, bongo, dirlen = struct.unpack(OpenType.TABLE_DIR_UNPACK, data[start:end])
|
||||
table_dir[tag] = {'offset': bongo, 'length': dirlen, 'checksum': check}
|
||||
|
||||
font['tableDir'] = table_dir
|
||||
|
||||
return font
|
||||
|
||||
def get_name_records(nametable):
|
||||
"""reads through the name records within name table"""
|
||||
name = {}
|
||||
# read the header
|
||||
headersize = 6
|
||||
count, strOffset = struct.unpack('>2H', nametable[2:6])
|
||||
namerecsize = struct.calcsize(OpenType.NAME_RECORD_UNPACK)
|
||||
if count * namerecsize + headersize > len(nametable):
|
||||
raise FontError, 'names exceed size of name table'
|
||||
name['count'] = count
|
||||
name['strOffset'] = strOffset
|
||||
|
||||
# read through the name records
|
||||
namerecs = {}
|
||||
for i in range(0, count):
|
||||
start = headersize + i * namerecsize
|
||||
end = start + namerecsize
|
||||
platformID, encodingID, languageID, nameID, namelen, offset = struct.unpack(OpenType.NAME_RECORD_UNPACK, nametable[start:end])
|
||||
if platformID != OpenType.PLATFORM_ID_MICROSOFT or \
|
||||
encodingID != OpenType.ENCODING_ID_MICROSOFT_UNICODEBMP or \
|
||||
languageID != OpenType.LANG_ID_MICROSOFT_EN_US:
|
||||
continue
|
||||
namerecs[nameID] = {'offset': offset, 'length': namelen}
|
||||
|
||||
name['namerecords'] = namerecs
|
||||
return name
|
||||
|
||||
def make_eot_name_headers(fontdata, nameTableDir):
|
||||
"""extracts names from the name table and generates the names header portion of the EOT header"""
|
||||
nameoffset = nameTableDir['offset']
|
||||
namelen = nameTableDir['length']
|
||||
name = get_name_records(fontdata[nameoffset : nameoffset + namelen])
|
||||
namestroffset = name['strOffset']
|
||||
namerecs = name['namerecords']
|
||||
|
||||
eotnames = (OpenType.NAME_ID_FAMILY, OpenType.NAME_ID_STYLE, OpenType.NAME_ID_VERSION, OpenType.NAME_ID_FULL)
|
||||
nameheaders = []
|
||||
for nameid in eotnames:
|
||||
if nameid in namerecs:
|
||||
namerecord = namerecs[nameid]
|
||||
noffset = namerecord['offset']
|
||||
nlen = namerecord['length']
|
||||
nformat = '%dH' % (nlen / 2) # length is in number of bytes
|
||||
start = nameoffset + namestroffset + noffset
|
||||
end = start + nlen
|
||||
nstr = struct.unpack('>' + nformat, fontdata[start:end])
|
||||
nameheaders.append(struct.pack('<H' + nformat + '2x', nlen, *nstr))
|
||||
else:
|
||||
nameheaders.append(struct.pack('4x')) # len = 0, padding = 0
|
||||
|
||||
return ''.join(nameheaders)
|
||||
|
||||
# just return a null-string (len = 0)
|
||||
def make_root_string():
|
||||
return struct.pack('2x')
|
||||
|
||||
def make_eot_header(fontdata):
|
||||
"""given ttf font data produce an EOT header"""
|
||||
fontDataSize = len(fontdata)
|
||||
font = get_table_directory(fontdata)
|
||||
|
||||
# toss out .otf fonts, t2embed library doesn't support these
|
||||
tableDir = font['tableDir']
|
||||
|
||||
# check for required tables
|
||||
required = (OpenType.TABLE_HEAD, OpenType.TABLE_NAME, OpenType.TABLE_OS2)
|
||||
for table in required:
|
||||
if not (table in tableDir):
|
||||
raise FontError, 'missing required table ' + multicharval(table)
|
||||
|
||||
# read name strings
|
||||
|
||||
# pull out data from individual tables to construct fixed header portion
|
||||
# need to calculate eotSize before packing
|
||||
version = EOT.EOT_VERSION
|
||||
flags = 0
|
||||
charset = EOT.EOT_DEFAULT_CHARSET
|
||||
magicNumber = EOT.EOT_MAGIC_NUMBER
|
||||
|
||||
# read values from OS/2 table
|
||||
os2Dir = tableDir[OpenType.TABLE_OS2]
|
||||
os2offset = os2Dir['offset']
|
||||
os2size = struct.calcsize(OpenType.OS2_UNPACK)
|
||||
|
||||
if os2size > os2Dir['length']:
|
||||
raise FontError, 'OS/2 table invalid length'
|
||||
|
||||
os2fields = struct.unpack(OpenType.OS2_UNPACK, fontdata[os2offset : os2offset + os2size])
|
||||
|
||||
panose = []
|
||||
urange = []
|
||||
codepage = []
|
||||
|
||||
weight, fsType = os2fields[:2]
|
||||
panose[:10] = os2fields[2:12]
|
||||
urange[:4] = os2fields[12:16]
|
||||
fsSelection = os2fields[16]
|
||||
codepage[:2] = os2fields[17:19]
|
||||
|
||||
italic = fsSelection & OpenType.OS2_FSSELECTION_ITALIC
|
||||
|
||||
# read in values from head table
|
||||
headDir = tableDir[OpenType.TABLE_HEAD]
|
||||
headoffset = headDir['offset']
|
||||
headsize = struct.calcsize(OpenType.HEAD_UNPACK)
|
||||
|
||||
if headsize > headDir['length']:
|
||||
raise FontError, 'head table invalid length'
|
||||
|
||||
headfields = struct.unpack(OpenType.HEAD_UNPACK, fontdata[headoffset : headoffset + headsize])
|
||||
checkSumAdjustment = headfields[0]
|
||||
|
||||
# make name headers
|
||||
nameheaders = make_eot_name_headers(fontdata, tableDir[OpenType.TABLE_NAME])
|
||||
rootstring = make_root_string()
|
||||
|
||||
# calculate the total eot size
|
||||
eotSize = struct.calcsize(EOT.EOT_HEADER_PACK) + len(nameheaders) + len(rootstring) + fontDataSize
|
||||
fixed = struct.pack(EOT.EOT_HEADER_PACK,
|
||||
*([eotSize, fontDataSize, version, flags] + panose + [charset, italic] +
|
||||
[weight, fsType, magicNumber] + urange + codepage + [checkSumAdjustment]))
|
||||
|
||||
return ''.join((fixed, nameheaders, rootstring))
|
||||
|
||||
|
||||
def write_eot_font(eot, header, data):
|
||||
open(eot,'wb').write(''.join((header, data)))
|
||||
return
|
||||
|
||||
def main():
|
||||
|
||||
# deal with options
|
||||
p = optparse.OptionParser()
|
||||
p.add_option('--output', '-o', default="world")
|
||||
options, args = p.parse_args()
|
||||
|
||||
# iterate over font files
|
||||
for f in args:
|
||||
data = readfont(f)
|
||||
if len(data) == 0:
|
||||
print 'Error reading %s' % f
|
||||
else:
|
||||
eot = eotname(f)
|
||||
header = make_eot_header(data)
|
||||
write_eot_font(eot, header, data)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
# Font generation script from FontCustom
|
||||
# https://github.com/FontCustom/fontcustom/
|
||||
# http://fontcustom.com/
|
||||
|
||||
import fontforge
|
||||
import os, errno
|
||||
import md5
|
||||
import subprocess
|
||||
import tempfile
|
||||
import json
|
||||
import copy
|
||||
|
||||
SCRIPTS_FONT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
INPUT_SVG_DIR = os.path.join(SCRIPTS_FONT_DIR, '..', '..', 'src', 'svg')
|
||||
OUTPUT_FONT_DIR = os.path.join(SCRIPTS_FONT_DIR, '..', '..', 'dist', 'fonts')
|
||||
OUTPUT_IONICONS_FONT_DIR = os.path.join(OUTPUT_FONT_DIR, 'ionicons')
|
||||
MANIFEST_PATH = os.path.join(SCRIPTS_FONT_DIR, '..', 'manifest.json')
|
||||
AUTO_WIDTH = True
|
||||
KERNING = 15
|
||||
|
||||
cp = 0xf100
|
||||
m = md5.new()
|
||||
|
||||
f = fontforge.font()
|
||||
f.encoding = 'UnicodeFull'
|
||||
f.design_size = 16
|
||||
f.em = 512
|
||||
f.ascent = 448
|
||||
f.descent = 64
|
||||
|
||||
manifest_file = open(MANIFEST_PATH, 'r')
|
||||
manifest_data = json.loads(manifest_file.read())
|
||||
manifest_file.close()
|
||||
print "Load Manifest, Icons: %s" % ( len(manifest_data['icons']) )
|
||||
|
||||
try:
|
||||
os.makedirs(OUTPUT_FONT_DIR)
|
||||
except OSError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
try:
|
||||
os.makedirs(OUTPUT_IONICONS_FONT_DIR)
|
||||
except OSError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
# ensure each icon is actually used in the manifest
|
||||
clean_manifest_data = copy.deepcopy(manifest_data)
|
||||
clean_manifest_data['icons'] = []
|
||||
for ionicon in manifest_data['icons']:
|
||||
svg_path = os.path.join(INPUT_SVG_DIR, '%s.svg' % (ionicon['name']))
|
||||
if os.path.isfile(svg_path):
|
||||
clean_manifest_data['icons'].append({
|
||||
"code": ionicon['code'],
|
||||
"name": ionicon['name']
|
||||
})
|
||||
else:
|
||||
print 'removed from manifest: %s' % (ionicon['name'])
|
||||
|
||||
manifest_data = copy.deepcopy(clean_manifest_data)
|
||||
|
||||
font_name = manifest_data['name']
|
||||
m.update(font_name + ';')
|
||||
m.update(manifest_data['prefix'] + ';')
|
||||
|
||||
for dirname, dirnames, filenames in os.walk(INPUT_SVG_DIR):
|
||||
for filename in filenames:
|
||||
name, ext = os.path.splitext(filename)
|
||||
filePath = os.path.join(dirname, filename)
|
||||
size = os.path.getsize(filePath)
|
||||
|
||||
if ext in ['.svg', '.eps']:
|
||||
|
||||
# see if this file is already in the manifest
|
||||
chr_code = None
|
||||
for ionicon in manifest_data['icons']:
|
||||
if ionicon['name'] == name:
|
||||
chr_code = ionicon['code']
|
||||
break
|
||||
|
||||
if chr_code is None:
|
||||
# this is a new src icon
|
||||
print 'New Icon: \n - %s' % (name)
|
||||
|
||||
while True:
|
||||
chr_code = '0x%x' % (cp)
|
||||
already_exists = False
|
||||
for ionicon in manifest_data['icons']:
|
||||
if ionicon.get('code') == chr_code:
|
||||
already_exists = True
|
||||
cp += 1
|
||||
chr_code = '0x%x' % (cp)
|
||||
continue
|
||||
if not already_exists:
|
||||
break
|
||||
|
||||
print ' - %s' % chr_code
|
||||
manifest_data['icons'].append({
|
||||
'name': name,
|
||||
'code': chr_code
|
||||
})
|
||||
|
||||
if ext in ['.svg']:
|
||||
# hack removal of <switch> </switch> tags
|
||||
svgfile = open(filePath, 'r+')
|
||||
tmpsvgfile = tempfile.NamedTemporaryFile(suffix=ext, delete=False)
|
||||
svgtext = svgfile.read()
|
||||
svgfile.seek(0)
|
||||
|
||||
# replace the <switch> </switch> tags with 'nothing'
|
||||
svgtext = svgtext.replace('<switch>', '')
|
||||
svgtext = svgtext.replace('</switch>', '')
|
||||
|
||||
tmpsvgfile.file.write(svgtext)
|
||||
|
||||
svgfile.close()
|
||||
tmpsvgfile.file.close()
|
||||
|
||||
filePath = tmpsvgfile.name
|
||||
# end hack
|
||||
|
||||
m.update(name + str(size) + ';')
|
||||
glyph = f.createChar( int(chr_code, 16) )
|
||||
glyph.importOutlines(filePath)
|
||||
|
||||
# if we created a temporary file, let's clean it up
|
||||
if tmpsvgfile:
|
||||
os.unlink(tmpsvgfile.name)
|
||||
|
||||
# set glyph size explicitly or automatically depending on autowidth
|
||||
if AUTO_WIDTH:
|
||||
glyph.left_side_bearing = glyph.right_side_bearing = 0
|
||||
glyph.round()
|
||||
|
||||
# resize glyphs if autowidth is enabled
|
||||
if AUTO_WIDTH:
|
||||
f.autoWidth(0, 0, 512)
|
||||
|
||||
fontfile = '%s/ionicons' % (OUTPUT_FONT_DIR)
|
||||
|
||||
f.fontname = font_name
|
||||
f.familyname = font_name
|
||||
f.fullname = font_name
|
||||
|
||||
print 'Generate TTF Font File'
|
||||
f.generate(fontfile + '.ttf')
|
||||
|
||||
print 'Generate SVG Font File'
|
||||
f.generate(fontfile + '.svg')
|
||||
|
||||
# Fix SVG header for webkit
|
||||
# from: https://github.com/fontello/font-builder/blob/master/bin/fontconvert.py
|
||||
svgfile = open(fontfile + '.svg', 'r+')
|
||||
svgtext = svgfile.read()
|
||||
svgfile.seek(0)
|
||||
svgfile.write(svgtext.replace('''<svg>''', '''<svg xmlns="http://www.w3.org/2000/svg">'''))
|
||||
svgfile.close()
|
||||
|
||||
scriptPath = os.path.dirname(os.path.realpath(__file__))
|
||||
try:
|
||||
subprocess.Popen([scriptPath + '/sfnt2woff', fontfile + '.ttf'], stdout=subprocess.PIPE)
|
||||
except OSError:
|
||||
# If the local version of sfnt2woff fails (i.e., on Linux), try to use the
|
||||
# global version. This allows us to avoid forcing OS X users to compile
|
||||
# sfnt2woff from source, simplifying install.
|
||||
subprocess.call(['sfnt2woff', fontfile + '.ttf'])
|
||||
|
||||
# eotlitetool.py script to generate IE7-compatible .eot fonts
|
||||
print 'Generate EOT Font File'
|
||||
subprocess.call('python ' + scriptPath + '/eotlitetool.py ' + fontfile + '.ttf -o ' + fontfile + '.eot', shell=True)
|
||||
subprocess.call('mv ' + fontfile + '.eotlite ' + fontfile + '.eot', shell=True)
|
||||
|
||||
print 'Hint TTF file'
|
||||
subprocess.call('ttfautohint -s -f -n ' + fontfile + '.ttf ' + fontfile + '-hinted.ttf > /dev/null 2>&1 && mv ' + fontfile + '-hinted.ttf ' + fontfile + '.ttf', shell=True)
|
||||
|
||||
print 'Generate WOFF2 Font File'
|
||||
subprocess.call('woff2_compress ' + fontfile + '.ttf', shell=True)
|
||||
|
||||
manifest_data['icons'] = sorted(manifest_data['icons'], key=lambda k: k['name'])
|
||||
|
||||
print "Save Manifest, Icons: %s" % ( len(manifest_data['icons']) )
|
||||
f = open(MANIFEST_PATH, 'w')
|
||||
f.write( json.dumps(manifest_data, indent=2, separators=(',', ': ')) )
|
||||
f.close()
|
||||
@@ -1,279 +0,0 @@
|
||||
from subprocess import call
|
||||
import os, errno
|
||||
import shutil
|
||||
import subprocess
|
||||
import json
|
||||
import codecs
|
||||
from collections import OrderedDict
|
||||
import hashlib
|
||||
|
||||
|
||||
SCRIPTS_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||
ROOT_PATH = os.path.join(SCRIPTS_PATH, '..')
|
||||
SRC_PATH = os.path.join(ROOT_PATH, 'src')
|
||||
DIST_PATH = os.path.join(ROOT_PATH, 'dist')
|
||||
INPUT_SVG_DIR = os.path.join(SRC_PATH, 'svg')
|
||||
OUTPUT_SVG_DIR = os.path.join(DIST_PATH, 'svg')
|
||||
DATA_PATH = os.path.join(DIST_PATH, 'data')
|
||||
FONTS_FOLDER_PATH = os.path.join(DIST_PATH, 'fonts')
|
||||
CSS_FOLDER_PATH = os.path.join(DIST_PATH, 'css')
|
||||
INPUT_SCSS_FOLDER_PATH = os.path.join(SRC_PATH, 'scss')
|
||||
OUTPUT_SCSS_FOLDER_PATH = os.path.join(DIST_PATH, 'scss')
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
os.makedirs(DIST_PATH)
|
||||
except OSError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
try:
|
||||
os.makedirs(OUTPUT_SVG_DIR)
|
||||
except OSError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
if requires_update():
|
||||
generate_font_files()
|
||||
|
||||
data = get_build_data()
|
||||
|
||||
rename_svg_glyph_names(data)
|
||||
generate_scss(data)
|
||||
generate_svg_files()
|
||||
generate_cheatsheet(data)
|
||||
|
||||
|
||||
def requires_update():
|
||||
m = hashlib.sha256()
|
||||
|
||||
for filename in os.listdir(INPUT_SVG_DIR):
|
||||
filename = os.path.join(INPUT_SVG_DIR, filename)
|
||||
with open(filename, 'rb') as inputfile:
|
||||
data = inputfile.read()
|
||||
m.update(data)
|
||||
|
||||
current_hash = m.hexdigest()
|
||||
|
||||
manifest_path = os.path.join(SCRIPTS_PATH, 'manifest.json')
|
||||
|
||||
f = codecs.open(manifest_path, 'r', 'utf-8')
|
||||
data = json.loads(f.read())
|
||||
last_hash = data.get('hash')
|
||||
f.close()
|
||||
|
||||
if last_hash != current_hash or not os.path.exists(FONTS_FOLDER_PATH):
|
||||
print "Generating fonts..."
|
||||
data['hash'] = current_hash
|
||||
|
||||
with open(manifest_path, 'w') as outfile:
|
||||
json.dump(data, outfile)
|
||||
|
||||
return True
|
||||
|
||||
print "SVGs unchanged, skip generating fonts"
|
||||
return False
|
||||
|
||||
|
||||
def generate_font_files():
|
||||
print "Generate Fonts"
|
||||
cmd = "fontforge -script %s/font/generate_font.py" % (SCRIPTS_PATH)
|
||||
call(cmd, shell=True)
|
||||
|
||||
|
||||
def generate_svg_files():
|
||||
print "Generate SVG Files"
|
||||
shutil.rmtree(OUTPUT_SVG_DIR)
|
||||
if not os.path.exists(OUTPUT_SVG_DIR):
|
||||
os.makedirs(OUTPUT_SVG_DIR)
|
||||
|
||||
cmd = 'svgo -f %s -o %s' % (INPUT_SVG_DIR, OUTPUT_SVG_DIR)
|
||||
cwd = os.path.join(os.path.dirname(__file__), '../node_modules/svgo/bin')
|
||||
subprocess.call([cmd], shell=True, cwd=cwd)
|
||||
|
||||
for filename in os.listdir(OUTPUT_SVG_DIR):
|
||||
svg_path = os.path.join(OUTPUT_SVG_DIR, filename)
|
||||
svg_read_file = open(svg_path, 'r')
|
||||
svg_text = svg_read_file.read()
|
||||
|
||||
svg_text = svg_text.replace(' width="512px"', '')
|
||||
svg_text = svg_text.replace(' width="512"', '')
|
||||
svg_text = svg_text.replace(' height="512px"', '')
|
||||
svg_text = svg_text.replace(' height="512"', '')
|
||||
|
||||
if 'viewBox="0 0 512 512"' not in svg_text:
|
||||
svg_text = svg_text.replace('xmlns="http://www.w3.org/2000/svg"', 'xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"')
|
||||
|
||||
svg_write_file = open(svg_path, 'w')
|
||||
svg_write_file.write(svg_text)
|
||||
svg_write_file.close()
|
||||
|
||||
|
||||
def rename_svg_glyph_names(data):
|
||||
# hacky and slow (but safe) way to rename glyph-name attributes
|
||||
svg_path = os.path.join(FONTS_FOLDER_PATH, 'ionicons.svg')
|
||||
svg_file = codecs.open(svg_path, 'r+', 'utf-8')
|
||||
svg_text = svg_file.read()
|
||||
svg_file.seek(0)
|
||||
|
||||
for ionicon in data['icons']:
|
||||
# uniF2CA
|
||||
org_name = 'uni%s' % (ionicon['code'].replace('0x', '').upper())
|
||||
ion_name = 'ion-%s' % (ionicon['name'])
|
||||
svg_text = svg_text.replace(org_name, ion_name)
|
||||
|
||||
svg_file.write(svg_text)
|
||||
svg_file.close()
|
||||
|
||||
|
||||
def generate_scss(data):
|
||||
try:
|
||||
os.makedirs(OUTPUT_SCSS_FOLDER_PATH)
|
||||
except OSError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
print "Generate SCSS"
|
||||
font_name = data['name']
|
||||
font_version = data['version']
|
||||
css_prefix = data['prefix']
|
||||
|
||||
ionicons_core_file_path_input = os.path.join(INPUT_SCSS_FOLDER_PATH, 'ionicons-core.scss')
|
||||
ionicons_core_file_path_output = os.path.join(OUTPUT_SCSS_FOLDER_PATH, 'ionicons-core.scss')
|
||||
shutil.copyfile(ionicons_core_file_path_input, ionicons_core_file_path_output)
|
||||
|
||||
ionicons_scc_file_path_input = os.path.join(INPUT_SCSS_FOLDER_PATH, 'ionicons.scss')
|
||||
ionicons_scc_file_path_output = os.path.join(OUTPUT_SCSS_FOLDER_PATH, 'ionicons.scss')
|
||||
shutil.copyfile(ionicons_scc_file_path_input, ionicons_scc_file_path_output)
|
||||
|
||||
variables_file_path_input = os.path.join(INPUT_SCSS_FOLDER_PATH, 'ionicons-variables.scss')
|
||||
variables_file_path = os.path.join(OUTPUT_SCSS_FOLDER_PATH, 'ionicons-variables.scss')
|
||||
shutil.copyfile(variables_file_path_input, variables_file_path)
|
||||
|
||||
common_file_path = os.path.join(OUTPUT_SCSS_FOLDER_PATH, 'ionicons-common.scss')
|
||||
icons_file_path = os.path.join(OUTPUT_SCSS_FOLDER_PATH, 'ionicons-icons.scss')
|
||||
|
||||
|
||||
d = []
|
||||
d.append('@charset "UTF-8";')
|
||||
d.append('// Ionicons Variables')
|
||||
d.append('// --------------------------\n')
|
||||
d.append('$ionicons-font-path: "../fonts" !default;')
|
||||
d.append('$ionicons-font-family: "%s" !default;' % (font_name) )
|
||||
d.append('$ionicons-version: "%s" !default;' % (font_version) )
|
||||
|
||||
f = codecs.open(variables_file_path, 'w', 'utf-8')
|
||||
f.write( u'\n'.join(d) )
|
||||
f.close()
|
||||
|
||||
d = []
|
||||
d.append('@charset "UTF-8";')
|
||||
d.append('// Ionicons Common CSS')
|
||||
d.append('// --------------------------\n')
|
||||
|
||||
group = [ '.%s' % (data['name'].lower()) ]
|
||||
for ionicon in data['icons']:
|
||||
group.append('.%s%s:before' % (css_prefix, ionicon['name']) )
|
||||
|
||||
d.append( ',\n'.join(group) )
|
||||
|
||||
d.append('{')
|
||||
d.append(' @extend .ion;')
|
||||
d.append('}')
|
||||
|
||||
f = codecs.open(common_file_path, 'w', 'utf-8')
|
||||
f.write( '\n'.join(d) )
|
||||
f.close()
|
||||
|
||||
d = []
|
||||
d.append('@charset "UTF-8";')
|
||||
d.append('// Ionicons Icon Font CSS')
|
||||
d.append('// --------------------------\n')
|
||||
|
||||
for ionicon in data['icons']:
|
||||
chr_code = ionicon['code'].replace('0x', '\\')
|
||||
d.append('.%s%s:before { content: "%s"; }' % (css_prefix, ionicon['name'], chr_code) )
|
||||
|
||||
f = codecs.open(icons_file_path, 'w', 'utf-8')
|
||||
f.write( '\n'.join(d) )
|
||||
f.close()
|
||||
|
||||
|
||||
def generate_cheatsheet(data):
|
||||
print "Generate Cheatsheet"
|
||||
|
||||
cheatsheet_file_path = os.path.join(DIST_PATH, 'cheatsheet.html')
|
||||
template_path = os.path.join(SRC_PATH, 'cheatsheet', 'template.html')
|
||||
icon_row_path = os.path.join(SRC_PATH, 'cheatsheet', 'icon-row.html')
|
||||
|
||||
f = codecs.open(template_path, 'r', 'utf-8')
|
||||
template_html = f.read()
|
||||
f.close()
|
||||
|
||||
f = codecs.open(icon_row_path, 'r', 'utf-8')
|
||||
icon_row_template = f.read()
|
||||
f.close()
|
||||
|
||||
content = []
|
||||
icon_names = []
|
||||
|
||||
for ionicon in data['icons']:
|
||||
name = ""
|
||||
if ionicon['name'].startswith('ios-'):
|
||||
name = ionicon['name'][4:]
|
||||
|
||||
elif ionicon['name'].startswith('md-'):
|
||||
name = ionicon['name'][3:]
|
||||
|
||||
if name not in icon_names:
|
||||
icon_names.append(name)
|
||||
|
||||
icon_names.sort()
|
||||
|
||||
for icon_name in icon_names:
|
||||
if icon_name != "":
|
||||
item_row = icon_row_template.replace('{{name}}', icon_name)
|
||||
item_row = item_row.replace('{{prefix}}', data['prefix'])
|
||||
|
||||
content.append(item_row)
|
||||
|
||||
template_html = template_html.replace("{{title}}", 'Cheatsheet')
|
||||
template_html = template_html.replace("{{font_name}}", data["name"])
|
||||
template_html = template_html.replace("{{font_version}}", data["version"])
|
||||
template_html = template_html.replace("{{icon_count}}", str(len(icon_names)) )
|
||||
template_html = template_html.replace("{{content}}", '\n'.join(content) )
|
||||
|
||||
f = codecs.open(cheatsheet_file_path, 'w', 'utf-8')
|
||||
f.write(template_html)
|
||||
f.close()
|
||||
|
||||
|
||||
def get_build_data():
|
||||
manifest_path = os.path.join(SCRIPTS_PATH, 'manifest.json')
|
||||
|
||||
f = codecs.open(manifest_path, 'r', 'utf-8')
|
||||
data = json.loads(f.read())
|
||||
f.close()
|
||||
|
||||
package_json_path = os.path.join(ROOT_PATH, 'package.json')
|
||||
f = codecs.open(package_json_path, 'r', 'utf-8')
|
||||
package_data = json.loads(f.read())
|
||||
f.close()
|
||||
|
||||
data['version'] = package_data['version']
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def get_tag_data():
|
||||
tag_data_path = os.path.join(SCRIPTS_PATH, 'tags.json')
|
||||
|
||||
f = codecs.open(tag_data_path, 'r', 'utf-8')
|
||||
data = json.loads(f.read())
|
||||
f.close()
|
||||
return data
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,87 @@
|
||||
import { PluginConfig } from 'svgo';
|
||||
|
||||
const setRootIoniconClass: PluginConfig = {
|
||||
name: 'addClassesToSVGElement',
|
||||
params: {
|
||||
className: 'ionicon',
|
||||
},
|
||||
};
|
||||
|
||||
const addFillNoneCss: PluginConfig = {
|
||||
name: 'addFillNoneCss',
|
||||
fn: () => ({
|
||||
element: {
|
||||
enter: (element) => {
|
||||
if (element.attributes.fill) {
|
||||
if (element.attributes.fill === 'none') {
|
||||
element.attributes.class = [...(element.attributes.class?.split(' ') || []), 'ionicon-fill-none'].join(' ');
|
||||
}
|
||||
delete element.attributes.fill;
|
||||
}
|
||||
if (element.attributes.stroke) {
|
||||
delete element.attributes.stroke;
|
||||
}
|
||||
if (
|
||||
element.attributes['stroke-width'] &&
|
||||
(element.attributes['stroke-width'] === '32px' || element.attributes['stroke-width'] === '32')
|
||||
) {
|
||||
delete element.attributes['stroke-width'];
|
||||
element.attributes.class = [...(element.attributes.class?.split(' ') || []), 'ionicon-stroke-width'].join(
|
||||
' ',
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
const forceCurrentColor: PluginConfig = {
|
||||
name: 'forceCurrentColor',
|
||||
fn: () => ({
|
||||
element: {
|
||||
enter: (element) => {
|
||||
const attr = element.attributes.stroke || element.attributes.fill;
|
||||
const attrName = element.attributes.stroke ? 'stroke' : element.attributes.fill ? 'fill' : undefined;
|
||||
|
||||
if (attrName) {
|
||||
if (attr === '#000' || attr === 'currentColor') {
|
||||
element.attributes[attrName] = 'currentColor';
|
||||
} else if (attr !== 'none') {
|
||||
throw new Error(`invalid "${attrName}" value: ${element.attributes[attrName]}`);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
const validatePlugin: PluginConfig = {
|
||||
name: 'validate',
|
||||
fn: () => ({
|
||||
element: {
|
||||
enter: (element) => {
|
||||
if (element.attributes.style) {
|
||||
console.warn(
|
||||
`Inline style attributed detected: <${element.name} style="${element.attributes.style}">...</${element.name}>`,
|
||||
);
|
||||
}
|
||||
if (element.name === 'style') {
|
||||
console.warn('Inline style element detected');
|
||||
}
|
||||
},
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
const basePlugins: PluginConfig[] = [
|
||||
'removeStyleElement',
|
||||
'convertStyleToAttrs',
|
||||
'removeScripts',
|
||||
'removeDimensions',
|
||||
setRootIoniconClass,
|
||||
validatePlugin,
|
||||
];
|
||||
|
||||
export const webComponentPassPlugins: PluginConfig[] = [...basePlugins, addFillNoneCss];
|
||||
|
||||
export const sourcePassPlugins: PluginConfig[] = [...basePlugins, forceCurrentColor];
|
||||
@@ -1,61 +0,0 @@
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const svg2png = require('svg2png');
|
||||
const crypto = require('crypto');
|
||||
|
||||
const ROOT_DIR = path.join(__dirname, '..');
|
||||
const SRC_DIR = path.join(ROOT_DIR, 'src');
|
||||
const TMP_DIR = path.join(ROOT_DIR, 'tmp');
|
||||
const DIST_DIR = path.join(ROOT_DIR, 'dist');
|
||||
const SVG_SRC_DIR = path.join(SRC_DIR, 'svg');
|
||||
const PNG_DIST_DIR = path.join(DIST_DIR, 'png');
|
||||
|
||||
const SIZES = [64];
|
||||
|
||||
fs.ensureDirSync(DIST_DIR);
|
||||
fs.ensureDirSync(TMP_DIR);
|
||||
fs.emptyDirSync(PNG_DIST_DIR);
|
||||
|
||||
SIZES.forEach(size => {
|
||||
const pngDir = path.join(PNG_DIST_DIR, size.toString());
|
||||
fs.emptyDirSync(pngDir);
|
||||
});
|
||||
|
||||
var svgFileNames = fs.readdirSync(SVG_SRC_DIR).filter(f => {
|
||||
return f.split('.').pop() === 'svg';
|
||||
});
|
||||
|
||||
svgFileNames.forEach(svgFileName => {
|
||||
const svgFilePath = path.join(SVG_SRC_DIR, svgFileName);
|
||||
const pngFileName = svgFileName.replace('.svg', '.png');
|
||||
|
||||
const sourceBuffer = fs.readFileSync(svgFilePath);
|
||||
|
||||
const hash = crypto.createHash('sha1')
|
||||
.update(sourceBuffer.toString())
|
||||
.digest('base64')
|
||||
.replace(/\W/g, '');
|
||||
|
||||
SIZES.forEach(size => {
|
||||
generatePng(pngFileName, sourceBuffer, hash, size);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function generatePng(pngFileName, sourceBuffer, hash, size) {
|
||||
const cachedFilePath = path.join(TMP_DIR, hash + '.' + size + '.png');
|
||||
const pngFilePath = path.join(PNG_DIST_DIR, size.toString(), pngFileName);
|
||||
|
||||
try {
|
||||
const cachedFileContent = fs.readFileSync(cachedFilePath);
|
||||
fs.writeFileSync(pngFilePath, cachedFileContent);
|
||||
|
||||
} catch (e) {
|
||||
const outputBuffer = svg2png.sync(sourceBuffer, { width: size, height: size });
|
||||
|
||||
fs.writeFileSync(pngFilePath, outputBuffer);
|
||||
fs.writeFileSync(cachedFilePath, outputBuffer);
|
||||
|
||||
console.log('converted to png', size, pngFileName);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,38 @@
|
||||
# Build
|
||||
# Development and Build Scripts
|
||||
|
||||
npm run build
|
||||
## Updating Icons
|
||||
|
||||
The `src/svg` directory is the single source of truth for svgs. They should not already be optimized and can be the original svg export straight out of an svg editor. A build step before releasing will optimize the source svgs (remove comments, reduce the size, etc) and ensure they'll work within `ion-icon`.
|
||||
|
||||
# Data
|
||||
## Build Locally
|
||||
|
||||
Update the src/data.json file with each icon and search tags.
|
||||
After an svg has been updated, added or deleted from the `src/svg` directory, run:
|
||||
|
||||
```sh
|
||||
npm run build
|
||||
```
|
||||
|
||||
# Cheatsheet
|
||||
The build command will optimize all of the icons and generate the files to be distributed. After the build command, all of the optimized svgs are saved in `dist/ionicons/svg`. Additionally the `dist` directory contains the distribution files for the `ion-icon` web component.
|
||||
|
||||
docs/cheatsheet.html
|
||||
## Svg Symbols Cheatsheet
|
||||
|
||||
After a build, a new `www/cheatsheet.html` file will be created. This version uses svg symbols rather than `ion-icon`.
|
||||
|
||||
## Install
|
||||
## ion-icon Component Preview
|
||||
|
||||
This repo already comes with all the files built and ready to go, but can also build the fonts from the source. Requires Python, FontForge, WOFF2, SVGO and Sass:
|
||||
To see the `ion-icon` component in action, run:
|
||||
|
||||
1) Install FontForge, which is the program that creates the font files from the SVG files:
|
||||
```sh
|
||||
npm start
|
||||
```
|
||||
|
||||
$ brew install fontforge ttfautohint
|
||||
## Release Steps
|
||||
|
||||
2) Install Google's WOFF2 font compressor
|
||||
Releases are automated via GitHub Actions. To trigger a release:
|
||||
|
||||
https://github.com/google/woff2
|
||||
|
||||
3) Add or subtract files from the `src/` folder you'd like to be apart of the build.
|
||||
|
||||
4) Modify any settings in the `scripts/manifest.json` file. You can change the name of the font-family and CSS classname prefix.
|
||||
|
||||
5) Run the build command:
|
||||
|
||||
npm run build
|
||||
1. Go to the [Release Orchestrator](https://github.com/ionic-team/ionicons/actions/workflows/release-orchestrator.yml) workflow
|
||||
2. Click "Run workflow"
|
||||
3. Select the release type:
|
||||
- **dev** — Creates a pre-release with a timestamp-based version (e.g., `8.0.14-dev.11784821417.1c794397`)
|
||||
- **production** — Creates a semver release; select `patch`, `minor`, or `major`
|
||||
4. The workflow will build, publish to NPM, and create a GitHub release (for production releases)
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
console.log('Build JPML files');
|
||||
|
||||
var jpml = require('@ionic/jpml');
|
||||
var fs = require('fs-extra');
|
||||
var path = require('path');
|
||||
|
||||
const OUT_DIR = [
|
||||
path.join(__dirname, '..', 'dist', 'collection', 'icon', 'svg')
|
||||
];
|
||||
|
||||
OUT_DIR.forEach(outDir => {
|
||||
fs.emptyDirSync(outDir);
|
||||
});
|
||||
|
||||
jpml.generate({
|
||||
include: ['dist/svg/'],
|
||||
outDir: OUT_DIR,
|
||||
filter: function(path) {
|
||||
return path.toLowerCase().split('.').pop() === 'svg';
|
||||
},
|
||||
fileName: function(path) {
|
||||
return path.replace('.svg', '.js');
|
||||
},
|
||||
key: function(path) {
|
||||
return path.replace('.svg', '');
|
||||
},
|
||||
wrapper: function(content, key) {
|
||||
return "loadIonicon('" + content.replace(/'/g, "\\\'") + "','" + key + "');"
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,53 @@
|
||||
import { PluginConfig } from 'svgo';
|
||||
|
||||
export interface SvgData {
|
||||
/**
|
||||
* airplane-outline.svg
|
||||
*/
|
||||
fileName: string;
|
||||
|
||||
/**
|
||||
* airplane
|
||||
*/
|
||||
title: string;
|
||||
|
||||
/**
|
||||
* /src/svg/airplane-outline.svg
|
||||
*/
|
||||
srcFilePath: string;
|
||||
|
||||
/**
|
||||
* /dist/ionicons/svg/airplane-outline.svg
|
||||
*/
|
||||
optimizedFilePath: string;
|
||||
|
||||
/**
|
||||
* /dist/svg/airplane-outline.svg
|
||||
*/
|
||||
distSvgFilePath: string;
|
||||
|
||||
/**
|
||||
* optimized svg content
|
||||
*/
|
||||
optimizedSvgContent?: string;
|
||||
|
||||
/**
|
||||
* airplane-outline
|
||||
*/
|
||||
iconName: string;
|
||||
|
||||
/**
|
||||
* airplane-outline.mjs
|
||||
*/
|
||||
fileNameMjs: string;
|
||||
|
||||
/**
|
||||
* airplane-outline.js
|
||||
*/
|
||||
fileNameCjs: string;
|
||||
|
||||
/**
|
||||
* airplaneOutline
|
||||
*/
|
||||
exportName: string;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<tr class="mode-row">
|
||||
<td>
|
||||
{{name}}
|
||||
</td>
|
||||
<td class="align-center">
|
||||
<ion-icon name="ios-{{name}}"></ion-icon>
|
||||
</div>
|
||||
<td class="align-center">
|
||||
<ion-icon name="md-{{name}}"></ion-icon>
|
||||
</div>
|
||||
</tr>
|
||||
@@ -1,126 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{{font_name}} {{title}}</title>
|
||||
<style>
|
||||
* {
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #fff;
|
||||
color: #444;
|
||||
font: 16px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
a, a:visited {
|
||||
color: #888;
|
||||
text-decoration: underline;
|
||||
}
|
||||
a:hover, a:focus { color: #000; }
|
||||
|
||||
header {
|
||||
overflow: hidden;
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #888;
|
||||
float: left;
|
||||
font-size: 24px;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
main {
|
||||
margin: 0 auto;
|
||||
padding: 0 20px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
tr {
|
||||
padding: 0 0 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
padding: 4px;
|
||||
width: 33%;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #ddd;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
th:first-child,
|
||||
td:first-child {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
ion-icon {
|
||||
display: block;
|
||||
min-height: 38px;
|
||||
}
|
||||
|
||||
ion-icon svg {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
footer {
|
||||
color: #888;
|
||||
font-size: 12px;
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
.heart {
|
||||
display: inline-block;
|
||||
|
||||
}
|
||||
|
||||
.heart svg {
|
||||
display: inline-block;
|
||||
padding-top: 4px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
fill: red;
|
||||
}
|
||||
</style>
|
||||
<script src="ionicons.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main>
|
||||
<header>
|
||||
<h1>{{font_name}} {{title}}, {{icon_count}} icons</h1>
|
||||
</header>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Icon Name
|
||||
</th>
|
||||
<th>
|
||||
iOS
|
||||
</th>
|
||||
<th>
|
||||
Material Design
|
||||
</th>
|
||||
</tr>
|
||||
{{content}}
|
||||
</table>
|
||||
<footer>
|
||||
Made with <ion-icon class="heart" name="md-heart"></ion-icon> by the <a href="http://ionicframework.com/">Ionic Team</a>
|
||||
</footer>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,146 @@
|
||||
/* eslint-disable */
|
||||
/* tslint:disable */
|
||||
/**
|
||||
* This is an autogenerated file created by the Stencil compiler.
|
||||
* It contains typing information for all components that exist in this project.
|
||||
*/
|
||||
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
|
||||
export namespace Components {
|
||||
interface IonIcon {
|
||||
/**
|
||||
* The color to use for the background of the item.
|
||||
*/
|
||||
"color"?: string;
|
||||
/**
|
||||
* Specifies whether the icon should horizontally flip when `dir` is `"rtl"`.
|
||||
*/
|
||||
"flipRtl"?: boolean;
|
||||
/**
|
||||
* A combination of both `name` and `src`. If a `src` url is detected it will set the `src` property. Otherwise it assumes it's a built-in named SVG and set the `name` property.
|
||||
*/
|
||||
"icon"?: any;
|
||||
/**
|
||||
* Specifies which icon to use on `ios` mode.
|
||||
*/
|
||||
"ios"?: string;
|
||||
/**
|
||||
* If enabled, ion-icon will be loaded lazily when it's visible in the viewport. Default, `false`.
|
||||
* @default false
|
||||
*/
|
||||
"lazy": boolean;
|
||||
/**
|
||||
* Specifies which icon to use on `md` mode.
|
||||
*/
|
||||
"md"?: string;
|
||||
/**
|
||||
* The mode determines which platform styles to use.
|
||||
* @default getIonMode()
|
||||
*/
|
||||
"mode": string;
|
||||
/**
|
||||
* Specifies which icon to use from the built-in set of icons.
|
||||
*/
|
||||
"name"?: string;
|
||||
/**
|
||||
* When `true`, SVG content, including SVG `data:` URLs, is checked before it renders. SVGs with `<script>` elements, attributes that start with `on` (like `onclick`), `javascript:` URLs, or non-SVG elements aren't rendered, and `<foreignObject>` elements are removed. Only set this to `false` for SVG content from a trusted source.
|
||||
* @default true
|
||||
*/
|
||||
"sanitize": boolean;
|
||||
/**
|
||||
* The size of the icon. Available options are: `"small"` and `"large"`.
|
||||
*/
|
||||
"size"?: string;
|
||||
/**
|
||||
* Specifies the exact `src` of an SVG file to use.
|
||||
*/
|
||||
"src"?: string;
|
||||
}
|
||||
}
|
||||
declare global {
|
||||
interface HTMLIonIconElement extends Components.IonIcon, HTMLStencilElement {
|
||||
}
|
||||
var HTMLIonIconElement: {
|
||||
prototype: HTMLIonIconElement;
|
||||
new (): HTMLIonIconElement;
|
||||
};
|
||||
interface HTMLElementTagNameMap {
|
||||
"ion-icon": HTMLIonIconElement;
|
||||
}
|
||||
}
|
||||
declare namespace LocalJSX {
|
||||
interface IonIcon {
|
||||
/**
|
||||
* The color to use for the background of the item.
|
||||
*/
|
||||
"color"?: string;
|
||||
/**
|
||||
* Specifies whether the icon should horizontally flip when `dir` is `"rtl"`.
|
||||
*/
|
||||
"flipRtl"?: boolean;
|
||||
/**
|
||||
* A combination of both `name` and `src`. If a `src` url is detected it will set the `src` property. Otherwise it assumes it's a built-in named SVG and set the `name` property.
|
||||
*/
|
||||
"icon"?: any;
|
||||
/**
|
||||
* Specifies which icon to use on `ios` mode.
|
||||
*/
|
||||
"ios"?: string;
|
||||
/**
|
||||
* If enabled, ion-icon will be loaded lazily when it's visible in the viewport. Default, `false`.
|
||||
* @default false
|
||||
*/
|
||||
"lazy"?: boolean;
|
||||
/**
|
||||
* Specifies which icon to use on `md` mode.
|
||||
*/
|
||||
"md"?: string;
|
||||
/**
|
||||
* The mode determines which platform styles to use.
|
||||
* @default getIonMode()
|
||||
*/
|
||||
"mode"?: string;
|
||||
/**
|
||||
* Specifies which icon to use from the built-in set of icons.
|
||||
*/
|
||||
"name"?: string;
|
||||
/**
|
||||
* When `true`, SVG content, including SVG `data:` URLs, is checked before it renders. SVGs with `<script>` elements, attributes that start with `on` (like `onclick`), `javascript:` URLs, or non-SVG elements aren't rendered, and `<foreignObject>` elements are removed. Only set this to `false` for SVG content from a trusted source.
|
||||
* @default true
|
||||
*/
|
||||
"sanitize"?: boolean;
|
||||
/**
|
||||
* The size of the icon. Available options are: `"small"` and `"large"`.
|
||||
*/
|
||||
"size"?: string;
|
||||
/**
|
||||
* Specifies the exact `src` of an SVG file to use.
|
||||
*/
|
||||
"src"?: string;
|
||||
}
|
||||
|
||||
interface IonIconAttributes {
|
||||
"mode": string;
|
||||
"color": string;
|
||||
"ios": string;
|
||||
"md": string;
|
||||
"flipRtl": boolean;
|
||||
"name": string;
|
||||
"src": string;
|
||||
"icon": string;
|
||||
"size": string;
|
||||
"lazy": boolean;
|
||||
"sanitize": boolean;
|
||||
}
|
||||
|
||||
interface IntrinsicElements {
|
||||
"ion-icon": Omit<IonIcon, keyof IonIconAttributes> & { [K in keyof IonIcon & keyof IonIconAttributes]?: IonIcon[K] } & { [K in keyof IonIcon & keyof IonIconAttributes as `attr:${K}`]?: IonIconAttributes[K] } & { [K in keyof IonIcon & keyof IonIconAttributes as `prop:${K}`]?: IonIcon[K] };
|
||||
}
|
||||
}
|
||||
export { LocalJSX as JSX };
|
||||
declare module "@stencil/core" {
|
||||
export namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
"ion-icon": LocalJSX.IntrinsicElements["ion-icon"] & JSXBase.HTMLAttributes<HTMLIonIconElement>;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* This is an autogenerated file created by the Stencil build process.
|
||||
* It contains typing information for all components that exist in this project
|
||||
* and imports for stencil collections that might be configured in your stencil.config.js file
|
||||
*/
|
||||
|
||||
|
||||
declare global {
|
||||
interface HTMLStencilElement extends HTMLElement {
|
||||
componentOnReady(): Promise<this>;
|
||||
componentOnReady(done: (ele?: this) => void): void;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
import {
|
||||
Icon as IonIcon
|
||||
} from './icon/icon';
|
||||
|
||||
declare global {
|
||||
interface HTMLIonIconElement extends IonIcon, HTMLStencilElement {
|
||||
}
|
||||
var HTMLIonIconElement: {
|
||||
prototype: HTMLIonIconElement;
|
||||
new (): HTMLIonIconElement;
|
||||
};
|
||||
interface HTMLElementTagNameMap {
|
||||
"ion-icon": HTMLIonIconElement;
|
||||
}
|
||||
interface ElementTagNameMap {
|
||||
"ion-icon": HTMLIonIconElement;
|
||||
}
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
"ion-icon": JSXElements.IonIconAttributes;
|
||||
}
|
||||
}
|
||||
namespace JSXElements {
|
||||
export interface IonIconAttributes extends HTMLAttributes {
|
||||
ariaLabel?: string;
|
||||
color?: string;
|
||||
ios?: string;
|
||||
md?: string;
|
||||
name?: string;
|
||||
size?: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare global { namespace JSX { interface StencilJSX {} } }
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"/></svg>
|
||||
|
After Width: | Height: | Size: 512 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"/></svg>
|
||||
|
After Width: | Height: | Size: 227 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M12 4H5C3.34 4 2 5.34 2 7v8c0 1.66 1.34 3 3 3l-1 1v1h1l2-2.03L9 18v-5H4V5.98L13 6v2h2V7c0-1.66-1.34-3-3-3zM5 14c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm15.57-4.34c-.14-.4-.52-.66-.97-.66h-7.19c-.46 0-.83.26-.98.66L10 13.77l.01 5.51c0 .38.31.72.69.72h.62c.38 0 .68-.38.68-.76V18h8v1.24c0 .38.31.76.69.76h.61c.38 0 .69-.34.69-.72l.01-1.37v-4.14l-1.43-4.11zm-8.16.34h7.19l1.03 3h-9.25l1.03-3zM12 16c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm8 0c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"/><path fill="none" d="M0 0h24v24H0z"/></svg>
|
||||
|
After Width: | Height: | Size: 641 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24"><defs><path id="a" d="M24 0v24H0V0h24z"/></defs><clipPath id="b"><use xlink:href="#a" overflow="visible"/></clipPath><path d="M10.08 10.86c.05-.33.16-.62.3-.87s.34-.46.59-.62c.24-.15.54-.22.91-.23.23.01.44.05.63.13.2.09.38.21.52.36s.25.33.34.53.13.42.14.64h1.79c-.02-.47-.11-.9-.28-1.29s-.4-.73-.7-1.01-.66-.5-1.08-.66-.88-.23-1.39-.23c-.65 0-1.22.11-1.7.34s-.88.53-1.2.92-.56.84-.71 1.36S8 11.29 8 11.87v.27c0 .58.08 1.12.23 1.64s.39.97.71 1.35.72.69 1.2.91 1.05.34 1.7.34c.47 0 .91-.08 1.32-.23s.77-.36 1.08-.63.56-.58.74-.94.29-.74.3-1.15h-1.79c-.01.21-.06.4-.15.58s-.21.33-.36.46-.32.23-.52.3c-.19.07-.39.09-.6.1-.36-.01-.66-.08-.89-.23-.25-.16-.45-.37-.59-.62s-.25-.55-.3-.88-.08-.67-.08-1v-.27c0-.35.03-.68.08-1.01zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z" clip-path="url(#b)"/></svg>
|
||||
|
After Width: | Height: | Size: 1000 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M18 7l-1.41-1.41-6.34 6.34 1.41 1.41L18 7zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12-1.42-1.41zM.41 13.41L6 19l1.41-1.41L1.83 12 .41 13.41z"/></svg>
|
||||
|
After Width: | Height: | Size: 292 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 17c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm6-9h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6h1.9c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm0 12H6V10h12v10z"/></svg>
|
||||
|
After Width: | Height: | Size: 369 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><script>alert('got ya')</script><path d="M0 0h24v24H0z" fill="none"/><path d="M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"/></svg>
|
||||
|
After Width: | Height: | Size: 544 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><script>alert('got ya')</script><path d="M0 0h24v24H0z" fill="none"/><path d="M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8zm-6 8h-4v-2h4v2zm0-4h-4v-2h4v2z"/></svg>
|
||||
|
After Width: | Height: | Size: 544 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M15 4c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"/><path fill="none" d="M0 0h24v24H0V0z"/><path d="M3 12c0-2.61 1.67-4.83 4-5.65V4.26C3.55 5.15 1 8.27 1 12s2.55 6.85 6 7.74v-2.09c-2.33-.82-4-3.04-4-5.65z"/></svg>
|
||||
|
After Width: | Height: | Size: 372 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 4H5c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2zm0 14H5V8h14v10z"/><path fill="none" d="M0 0h24v24H0z"/></svg>
|
||||
|
After Width: | Height: | Size: 233 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill-rule="evenodd" clip-rule="evenodd" d="M14 6V4h-4v2h4zM4 8v11h16V8H4zm16-2c1.11 0 2 .89 2 2v11c0 1.11-.89 2-2 2H4c-1.11 0-2-.89-2-2l.01-11c0-1.11.88-2 1.99-2h4V4c0-1.11.89-2 2-2h4c1.11 0 2 .89 2 2v2h4z"/><path fill="none" d="M0 0h24v24H0z"/></svg>
|
||||
|
After Width: | Height: | Size: 340 B |
@@ -1,119 +1,161 @@
|
||||
ion-icon {
|
||||
:host {
|
||||
display: inline-block;
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
ion-icon .icon-inner {
|
||||
height: 1em;
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
|
||||
font-size: 1em;
|
||||
|
||||
contain: layout style;
|
||||
|
||||
fill: currentColor;
|
||||
|
||||
box-sizing: content-box !important;
|
||||
}
|
||||
|
||||
ion-icon svg {
|
||||
fill: currentColor;
|
||||
:host .ionicon {
|
||||
stroke: currentColor;
|
||||
}
|
||||
|
||||
.icon-small .icon-inner {
|
||||
font-size: 18px;
|
||||
.ionicon-fill-none {
|
||||
fill: none;
|
||||
}
|
||||
|
||||
.icon-large .icon-inner {
|
||||
font-size: 32px;
|
||||
.ionicon-stroke-width {
|
||||
stroke-width: var(--ionicon-stroke-width, 32px);
|
||||
}
|
||||
|
||||
/* Set iOS Icon Colors */
|
||||
/* ------------------- */
|
||||
.icon-inner {
|
||||
display: flex;
|
||||
|
||||
.icon-ios-primary svg {
|
||||
fill: var(--ion-color-ios-primary, var(--ion-color-primary, #3880ff));
|
||||
stroke: var(--ion-color-ios-primary, var(--ion-color-primary, #3880ff));
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.icon-ios-secondary svg {
|
||||
fill: var(--ion-color-ios-secondary, var(--ion-color-secondary, #0cd1e8));
|
||||
stroke: var(--ion-color-ios-secondary, var(--ion-color-secondary, #0cd1e8));
|
||||
.ionicon,
|
||||
svg {
|
||||
display: block;
|
||||
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.icon-ios-tertiary svg {
|
||||
fill: var(--ion-color-ios-tertiary, var(--ion-color-tertiary, #f4a942));
|
||||
stroke: var(--ion-color-ios-tertiary, var(--ion-color-tertiary, #f4a942));
|
||||
/* Slotted Content
|
||||
* -----------------------------------------------------------
|
||||
*/
|
||||
|
||||
::slotted(*) {
|
||||
font-size: inherit !important;
|
||||
}
|
||||
|
||||
.icon-ios-success svg {
|
||||
fill: var(--ion-color-ios-success, var(--ion-color-success, #10dc60));
|
||||
stroke: var(--ion-color-ios-success, var(--ion-color-success, #10dc60));
|
||||
/* Icon RTL
|
||||
* -----------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Safari <16.4 incorrectly reports
|
||||
* that it supports :dir(rtl) when it does not.
|
||||
* This @supports statement lets us target
|
||||
* WebKit browsers to apply the RTL fallback.
|
||||
* -webkit-named-image only exists on WebKit.
|
||||
* For WebKit browsers that do support :dir(rtl)
|
||||
* (i.e. Safari >= 16.4) then the :dir(rtl)
|
||||
* code farther down on the page will take
|
||||
* effect and override this fallback.
|
||||
*/
|
||||
@supports (background: -webkit-named-image(i)) {
|
||||
:host(.icon-rtl) .icon-inner {
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
}
|
||||
|
||||
.icon-ios-warning svg {
|
||||
fill: var(--ion-color-ios-warning, var(--ion-color-warning, #ffce00));
|
||||
stroke: var(--ion-color-ios-warning, var(--ion-color-warning, #ffce00));
|
||||
/**
|
||||
* Fallback for browsers that support
|
||||
* neither :host-context nor :dir.
|
||||
* The icon will not react to dir
|
||||
* changes, but it will at least
|
||||
* respect the dir on component load.
|
||||
*/
|
||||
@supports not selector(:dir(rtl)) and selector(:host-context([dir='rtl'])) {
|
||||
:host(.icon-rtl) .icon-inner {
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
}
|
||||
|
||||
.icon-ios-danger svg {
|
||||
fill: var(--ion-color-ios-danger, var(--ion-color-danger, #f14141));
|
||||
stroke: var(--ion-color-ios-danger, var(--ion-color-danger, #f14141));
|
||||
/* :host-context is supported in chromium; :dir is supported in safari & firefox */
|
||||
:host(.flip-rtl):host-context([dir='rtl']) .icon-inner {
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
|
||||
.icon-ios-light svg {
|
||||
fill: var(--ion-color-ios-light, var(--ion-color-light, #f4f5f8));
|
||||
stroke: var(--ion-color-ios-light, var(--ion-color-light, #f4f5f8));
|
||||
@supports selector(:dir(rtl)) {
|
||||
:host(.flip-rtl:dir(rtl)) .icon-inner {
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
/**
|
||||
* This is needed for WebKit otherwise the fallback
|
||||
* will always cause the icon to be flipped if the document
|
||||
* loads in RTL.
|
||||
*/
|
||||
:host(.flip-rtl:dir(ltr)) .icon-inner {
|
||||
transform: scaleX(1);
|
||||
}
|
||||
}
|
||||
|
||||
.icon-ios-medium svg {
|
||||
fill: var(--ion-color-ios-medium, var(--ion-color-medium, #989aa2));
|
||||
stroke: var(--ion-color-ios-medium, var(--ion-color-medium, #989aa2));
|
||||
/* Icon Sizes
|
||||
* -----------------------------------------------------------
|
||||
*/
|
||||
|
||||
:host(.icon-small) {
|
||||
font-size: 1.125rem !important;
|
||||
}
|
||||
|
||||
.icon-ios-dark svg {
|
||||
fill: var(--ion-color-ios-dark, var(--ion-color-dark, #222428));
|
||||
stroke: var(--ion-color-ios-dark, var(--ion-color-dark, #222428));
|
||||
:host(.icon-large) {
|
||||
font-size: 2rem !important;
|
||||
}
|
||||
|
||||
/* Icon Colors
|
||||
* -----------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* Set Material Design Icon Colors */
|
||||
/* ------------------------------- */
|
||||
|
||||
.icon-md-primary svg {
|
||||
fill: var(--ion-color-md-primary, var(--ion-color-primary, #3880ff));
|
||||
stroke: var(--ion-color-md-primary, var(--ion-color-primary, #3880ff));
|
||||
:host(.ion-color) {
|
||||
color: var(--ion-color-base) !important;
|
||||
}
|
||||
|
||||
.icon-md-secondary svg {
|
||||
fill: var(--ion-color-md-secondary, var(--ion-color-secondary, #0cd1e8));
|
||||
stroke: var(--ion-color-md-secondary, var(--ion-color-secondary, #0cd1e8));
|
||||
:host(.ion-color-primary) {
|
||||
--ion-color-base: var(--ion-color-primary, #3880ff);
|
||||
}
|
||||
|
||||
.icon-md-tertiary svg {
|
||||
fill: var(--ion-color-md-tertiary, var(--ion-color-tertiary, #f4a942));
|
||||
stroke: var(--ion-color-md-tertiary, var(--ion-color-tertiary, #f4a942));
|
||||
:host(.ion-color-secondary) {
|
||||
--ion-color-base: var(--ion-color-secondary, #0cd1e8);
|
||||
}
|
||||
|
||||
.icon-md-success svg {
|
||||
fill: var(--ion-color-md-success, var(--ion-color-success, #10dc60));
|
||||
stroke: var(--ion-color-md-success, var(--ion-color-success, #10dc60));
|
||||
:host(.ion-color-tertiary) {
|
||||
--ion-color-base: var(--ion-color-tertiary, #f4a942);
|
||||
}
|
||||
|
||||
.icon-md-warning svg {
|
||||
fill: var(--ion-color-md-warning, var(--ion-color-warning, #ffce00));
|
||||
stroke: var(--ion-color-md-warning, var(--ion-color-warning, #ffce00));
|
||||
:host(.ion-color-success) {
|
||||
--ion-color-base: var(--ion-color-success, #10dc60);
|
||||
}
|
||||
|
||||
.icon-md-danger svg {
|
||||
fill: var(--ion-color-md-danger, var(--ion-color-danger, #f14141));
|
||||
stroke: var(--ion-color-md-danger, var(--ion-color-danger, #f14141));
|
||||
:host(.ion-color-warning) {
|
||||
--ion-color-base: var(--ion-color-warning, #ffce00);
|
||||
}
|
||||
|
||||
.icon-md-light svg {
|
||||
fill: var(--ion-color-md-light, var(--ion-color-light, #f4f5f8));
|
||||
stroke: var(--ion-color-md-light, var(--ion-color-light, #f4f5f8));
|
||||
:host(.ion-color-danger) {
|
||||
--ion-color-base: var(--ion-color-danger, #f14141);
|
||||
}
|
||||
|
||||
.icon-md-medium svg {
|
||||
fill: var(--ion-color-md-medium, var(--ion-color-medium, #989aa2));
|
||||
stroke: var(--ion-color-md-medium, var(--ion-color-medium, #989aa2));
|
||||
:host(.ion-color-light) {
|
||||
--ion-color-base: var(--ion-color-light, #f4f5f8);
|
||||
}
|
||||
|
||||
.icon-md-dark svg {
|
||||
fill: var(--ion-color-md-dark, var(--ion-color-dark, #222428));
|
||||
stroke: var(--ion-color-md-dark, var(--ion-color-dark, #222428));
|
||||
:host(.ion-color-medium) {
|
||||
--ion-color-base: var(--ion-color-medium, #989aa2);
|
||||
}
|
||||
|
||||
:host(.ion-color-dark) {
|
||||
--ion-color-base: var(--ion-color-dark, #222428);
|
||||
}
|
||||
|
||||
@@ -1,223 +1,255 @@
|
||||
import { Component, Prop, State } from '@stencil/core';
|
||||
|
||||
import { Build, Component, Element, Host, Prop, State, Watch, h } from '@stencil/core';
|
||||
import { getCacheKey, getSvgContent, ioniconContent } from './request';
|
||||
import { getName, getUrl, inheritAttributes, isRTL } from './utils';
|
||||
|
||||
@Component({
|
||||
tag: 'ion-icon',
|
||||
host: {
|
||||
theme: 'icon'
|
||||
},
|
||||
assetsDir: 'svg',
|
||||
styleUrl: 'icon.css'
|
||||
assetsDirs: ['svg'],
|
||||
styleUrl: 'icon.css',
|
||||
shadow: true,
|
||||
})
|
||||
export class Icon {
|
||||
@State() private svgContent: string = null;
|
||||
private io?: IntersectionObserver;
|
||||
private iconName: string | null = null;
|
||||
private inheritedAttributes: { [k: string]: any } = {};
|
||||
private didLoadIcon = false;
|
||||
|
||||
@Prop({ context: 'isServer'}) private isServer: boolean;
|
||||
@Element() el!: HTMLElement;
|
||||
|
||||
@Prop({ context: 'publicPath'}) private publicPath: string;
|
||||
|
||||
@Prop({ context: 'mode' }) mode: string;
|
||||
@State() private svgContent?: string;
|
||||
@State() private isVisible = false;
|
||||
|
||||
/**
|
||||
* The color to use from your Sass `$colors` map.
|
||||
* Default options are: `"primary"`, `"secondary"`, `"danger"`, `"light"`, and `"dark"`.
|
||||
* For more information, see [Theming your App](/docs/theming/theming-your-app).
|
||||
* The mode determines which platform styles to use.
|
||||
*/
|
||||
@Prop() color: string;
|
||||
@Prop({ mutable: true }) mode = getIonMode();
|
||||
|
||||
/**
|
||||
* Specifies the label to use for accessibility. Defaults to the icon name.
|
||||
* The color to use for the background of the item.
|
||||
*/
|
||||
@Prop() ariaLabel = '';
|
||||
@Prop() color?: string;
|
||||
|
||||
/**
|
||||
* Specifies which icon to use on `ios` mode.
|
||||
*/
|
||||
@Prop() ios = '';
|
||||
@Prop() ios?: string;
|
||||
|
||||
/**
|
||||
* Specifies which icon to use on `md` mode.
|
||||
*/
|
||||
@Prop() md = '';
|
||||
@Prop() md?: string;
|
||||
|
||||
/**
|
||||
* Specifies which icon to use. The appropriate icon will be used based on the mode.
|
||||
* For more information, see [Ionicons](/docs/ionicons/).
|
||||
* Specifies whether the icon should horizontally flip when `dir` is `"rtl"`.
|
||||
*/
|
||||
@Prop() name = '';
|
||||
@Prop() flipRtl?: boolean;
|
||||
|
||||
/**
|
||||
* Specifies which icon to use from the built-in set of icons.
|
||||
*/
|
||||
@Prop({ reflect: true }) name?: string;
|
||||
|
||||
/**
|
||||
* Specifies the exact `src` of an SVG file to use.
|
||||
*/
|
||||
@Prop() src?: string;
|
||||
|
||||
/**
|
||||
* A combination of both `name` and `src`. If a `src` url is detected
|
||||
* it will set the `src` property. Otherwise it assumes it's a built-in named
|
||||
* SVG and set the `name` property.
|
||||
*/
|
||||
@Prop() icon?: any;
|
||||
|
||||
/**
|
||||
* The size of the icon.
|
||||
* Available options are: `"small"` and `"large"`.
|
||||
*/
|
||||
@Prop() size: string;
|
||||
@Prop() size?: string;
|
||||
|
||||
/**
|
||||
* If enabled, ion-icon will be loaded lazily when it's visible in the viewport.
|
||||
* Default, `false`.
|
||||
*/
|
||||
@Prop() lazy = false;
|
||||
|
||||
private get iconName() {
|
||||
let iconName = this.name.toLowerCase();
|
||||
/**
|
||||
* When `true`, SVG content, including SVG `data:` URLs, is checked before it
|
||||
* renders. SVGs with `<script>` elements, attributes that start with `on`
|
||||
* (like `onclick`), `javascript:` URLs, or non-SVG elements aren't rendered,
|
||||
* and `<foreignObject>` elements are removed. Only set this to `false` for
|
||||
* SVG content from a trusted source.
|
||||
* @default true
|
||||
*/
|
||||
@Prop() sanitize = true;
|
||||
|
||||
// default to "md" if somehow the mode wasn't set
|
||||
const mode = this.mode || 'md';
|
||||
|
||||
// if an icon was passed in using the ios or md attributes
|
||||
// set the iconName to whatever was passed in
|
||||
if (this.ios && mode === 'ios') {
|
||||
iconName = this.ios.toLowerCase();
|
||||
} else if (this.md && mode === 'md') {
|
||||
iconName = this.md.toLowerCase();
|
||||
// this does not have one of the defaults
|
||||
// so lets auto add in the mode prefix for them
|
||||
} else if (iconName && !(/^md-|^ios-|^logo-/.test(iconName))) {
|
||||
iconName = mode + '-' + iconName;
|
||||
}
|
||||
|
||||
// only allow alpha characters and dash
|
||||
const invalidChars = iconName.replace(/[a-z]|-|\d/g, '');
|
||||
if (invalidChars !== '') {
|
||||
console.error(`invalid characters in ion-icon name: ${invalidChars}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
return iconName;
|
||||
componentWillLoad() {
|
||||
this.inheritedAttributes = inheritAttributes(this.el, ['aria-label']);
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
/**
|
||||
* purposely do not return the promise here because loading
|
||||
* the svg file should not hold up loading the app
|
||||
* only load the svg if it's visible
|
||||
*/
|
||||
this.waitUntilVisible(this.el, '50px', () => {
|
||||
this.isVisible = true;
|
||||
this.loadIcon();
|
||||
});
|
||||
}
|
||||
|
||||
hostData() {
|
||||
const attrs: {[attrName: string]: string} = {
|
||||
'role': 'img'
|
||||
};
|
||||
/**
|
||||
* Loads the icon after the component has finished rendering.
|
||||
*/
|
||||
componentDidLoad() {
|
||||
/**
|
||||
* Addresses an Angular issue where property values are assigned after the 'connectedCallback' but prior to the registration of watchers.
|
||||
* This enhancement ensures the loading of an icon when the component has finished rendering and the icon has yet to apply the SVG data.
|
||||
* This modification pertains to the usage of Angular's binding syntax:
|
||||
* `<ion-icon [name]="myIconName"></ion-icon>`
|
||||
*/
|
||||
if (!this.didLoadIcon) {
|
||||
this.loadIcon();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.ariaLabel) {
|
||||
// user provided label
|
||||
attrs['aria-label'] = this.ariaLabel;
|
||||
/**
|
||||
* Disconnect the IntersectionObserver.
|
||||
*/
|
||||
disconnectedCallback() {
|
||||
if (this.io) {
|
||||
this.io.disconnect();
|
||||
this.io = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// come up with the label based on the icon name
|
||||
const iconName = this.iconName;
|
||||
if (iconName) {
|
||||
attrs['aria-label'] =
|
||||
iconName
|
||||
.replace('ios-', '')
|
||||
.replace('md-', '')
|
||||
.replace('-outline', '')
|
||||
.replace(/\-/g, ' ');
|
||||
/**
|
||||
* Wait until the icon is visible in the viewport.
|
||||
* @param el - The element to observe.
|
||||
* @param rootMargin - The root margin of the observer.
|
||||
* @param cb - The callback to call when the element is visible.
|
||||
*/
|
||||
private waitUntilVisible(el: HTMLElement, rootMargin: string, cb: () => void) {
|
||||
/**
|
||||
* IntersectionObserver is a browser API that allows you to observe
|
||||
* the visibility of an element relative to a root element. It is
|
||||
* supported in all modern browsers, except IE and when server-side
|
||||
* rendering.
|
||||
*/
|
||||
const hasIntersectionObserverSupport = Boolean(
|
||||
Build.isBrowser && this.lazy && typeof window !== 'undefined' && window.IntersectionObserver,
|
||||
);
|
||||
|
||||
/**
|
||||
* browser doesn't support IntersectionObserver
|
||||
* so just fallback to always show it
|
||||
*/
|
||||
if (!hasIntersectionObserverSupport) {
|
||||
return cb();
|
||||
}
|
||||
|
||||
const io = (this.io = new window.IntersectionObserver(
|
||||
(data: IntersectionObserverEntry[]) => {
|
||||
if (data[0].isIntersecting) {
|
||||
io.disconnect();
|
||||
this.io = undefined;
|
||||
cb();
|
||||
}
|
||||
},
|
||||
{ rootMargin },
|
||||
));
|
||||
|
||||
io.observe(el);
|
||||
}
|
||||
|
||||
/**
|
||||
* Watch for changes to the icon name, src, icon, ios, or md properties.
|
||||
* When a change is detected, the icon will be loaded.
|
||||
*/
|
||||
@Watch('name')
|
||||
@Watch('src')
|
||||
@Watch('icon')
|
||||
@Watch('ios')
|
||||
@Watch('md')
|
||||
loadIcon() {
|
||||
if (Build.isBrowser && this.isVisible) {
|
||||
const url = getUrl(this);
|
||||
|
||||
if (url) {
|
||||
const cacheKey = getCacheKey(url, this.sanitize);
|
||||
if (ioniconContent.has(cacheKey)) {
|
||||
// sync if it's already loaded
|
||||
this.svgContent = ioniconContent.get(cacheKey);
|
||||
} else {
|
||||
// async if it hasn't been loaded
|
||||
getSvgContent(url, this.sanitize).then(() => (this.svgContent = ioniconContent.get(cacheKey)));
|
||||
}
|
||||
this.didLoadIcon = true;
|
||||
}
|
||||
}
|
||||
|
||||
const iconClasses = {};
|
||||
if (this.size) {
|
||||
iconClasses[`icon-${this.size}`] = true;
|
||||
}
|
||||
|
||||
return {
|
||||
...attrs,
|
||||
class: iconClasses
|
||||
};
|
||||
this.iconName = getName(this.name, this.icon, this.mode, this.ios, this.md);
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
if (this.isServer) {
|
||||
return <div class="icon-inner">{/* ssr */}</div>;
|
||||
}
|
||||
const { flipRtl, iconName, inheritedAttributes, el } = this;
|
||||
const mode = this.mode || 'md';
|
||||
|
||||
const iconName = this.iconName;
|
||||
if (!iconName) {
|
||||
// we don't have good data
|
||||
return <div class="icon-inner">{/* invalid svg */}</div>;
|
||||
}
|
||||
/**
|
||||
* we have designated that arrows & chevrons should automatically flip (unless flip-rtl
|
||||
* is set to false) because "back" is left in ltr and right in rtl, and "forward" is the opposite
|
||||
*/
|
||||
const shouldAutoFlip = iconName
|
||||
? (iconName.includes('arrow') || iconName.includes('chevron')) && flipRtl !== false
|
||||
: false;
|
||||
|
||||
const svgContent = svgContents[iconName];
|
||||
if (svgContent === this.svgContent) {
|
||||
// we've already loaded up this svg at one point
|
||||
// and the svg content we've loaded and assigned checks out
|
||||
// render this svg!!
|
||||
return <div class="icon-inner" innerHTML={svgContent}></div>;
|
||||
}
|
||||
/**
|
||||
* if shouldBeFlippable is true, the icon should change direction when `dir` changes
|
||||
*/
|
||||
const shouldBeFlippable = flipRtl || shouldAutoFlip;
|
||||
|
||||
// haven't loaded this svg yet
|
||||
// start the request
|
||||
loadSvgContent(iconName, this.publicPath, loadedSvgContent => {
|
||||
// we're finished loading the svg content!
|
||||
// set to this.svgContent so we do another render
|
||||
this.svgContent = loadedSvgContent;
|
||||
});
|
||||
|
||||
// actively requesting the svg, so let's just render a div for now
|
||||
return <div class="icon-inner">{/* loading svg */}</div>;
|
||||
return (
|
||||
<Host
|
||||
role="img"
|
||||
class={{
|
||||
[mode]: true,
|
||||
...createColorClasses(this.color),
|
||||
[`icon-${this.size}`]: !!this.size,
|
||||
'flip-rtl': shouldBeFlippable,
|
||||
'icon-rtl': shouldBeFlippable && isRTL(el),
|
||||
}}
|
||||
{...inheritedAttributes}
|
||||
>
|
||||
{Build.isBrowser && this.svgContent ? (
|
||||
<div class="icon-inner" innerHTML={this.svgContent}></div>
|
||||
) : (
|
||||
<div class="icon-inner">
|
||||
<slot></slot>
|
||||
</div>
|
||||
)}
|
||||
</Host>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mode of the document.
|
||||
* @returns The mode of the document.
|
||||
*/
|
||||
const getIonMode = () =>
|
||||
(Build.isBrowser && typeof document !== 'undefined' && document.documentElement.getAttribute('mode')) || 'md';
|
||||
|
||||
function loadSvgContent(iconName: string, publicPath: string, callback: {(loadedSvgContent: string): void}) {
|
||||
// static since all IonIcons use this same function and pointing at global/shared data
|
||||
// passed in callback will have instance info
|
||||
|
||||
// add to the list of callbacks to fiure when this url is finished loading
|
||||
(loadCallbacks[iconName] = loadCallbacks[iconName] || []).push(callback);
|
||||
|
||||
if (activeRequests[iconName]) {
|
||||
// already requesting this icon, don't bother kicking off another
|
||||
return;
|
||||
}
|
||||
|
||||
// add this icons to our list of active requests
|
||||
activeRequests[iconName] = true;
|
||||
|
||||
|
||||
// kick off the request for the external svg file
|
||||
// create a script element to add to the document.head
|
||||
var scriptElm = document.createElement('script');
|
||||
scriptElm.charset = 'utf-8';
|
||||
scriptElm.async = true;
|
||||
scriptElm.src = `${publicPath}svg/${iconName}.js`;
|
||||
|
||||
// create a fallback timeout if something goes wrong
|
||||
var tmrId = setTimeout(onScriptComplete, 120000);
|
||||
|
||||
function onScriptComplete() {
|
||||
clearTimeout(tmrId);
|
||||
scriptElm.onerror = scriptElm.onload = null;
|
||||
scriptElm.parentNode.removeChild(scriptElm);
|
||||
|
||||
// remove from our list of active requests
|
||||
delete activeRequests[iconName];
|
||||
}
|
||||
|
||||
// add script completed listener to this script element
|
||||
scriptElm.onerror = scriptElm.onload = onScriptComplete;
|
||||
|
||||
// inject a script tag in the head
|
||||
// kick off the actual request
|
||||
document.head.appendChild(scriptElm);
|
||||
}
|
||||
|
||||
|
||||
const activeRequests: {[iconName: string]: boolean} = {};
|
||||
const loadCallbacks: {[iconName: string]: {(loadedSvgContent: string): void}[]} = [] as any;
|
||||
const svgContents: {[iconName: string]: string} = {};
|
||||
|
||||
// add a jsonp handler to the window
|
||||
// as svg jsonp files are requested
|
||||
// once they load they'll call this method
|
||||
(window as any).loadIonicon = function loadIonicon(svgContent: string, iconName: string) {
|
||||
// awesome, we've finished loading the svg file
|
||||
|
||||
// remove this url from the active requests
|
||||
delete activeRequests[iconName];
|
||||
|
||||
svgContents[iconName] = svgContent
|
||||
|
||||
// find any callbacks waiting on this icon
|
||||
const svgLoadCallbacks = loadCallbacks[iconName];
|
||||
if (svgLoadCallbacks) {
|
||||
// loop through all the callbacks that are waiting on the svg content
|
||||
svgLoadCallbacks.forEach(cb => {
|
||||
// fire off this callback which was provided by an instance
|
||||
cb(svgContent);
|
||||
});
|
||||
delete loadCallbacks[iconName];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create color classes for the icon.
|
||||
* @param color - The color of the icon.
|
||||
* @returns The color classes for the icon.
|
||||
*/
|
||||
const createColorClasses = (color: string | undefined) => {
|
||||
return color
|
||||
? {
|
||||
'ion-color': true,
|
||||
[`ion-color-${color}`]: true,
|
||||
}
|
||||
: null;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
# ion-icon
|
||||
|
||||
|
||||
|
||||
<!-- Auto Generated Below -->
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Attribute | Description | Type | Default |
|
||||
| ---------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | -------------- |
|
||||
| `color` | `color` | The color to use for the background of the item. | `string \| undefined` | `undefined` |
|
||||
| `flipRtl` | `flip-rtl` | Specifies whether the icon should horizontally flip when `dir` is `"rtl"`. | `boolean \| undefined` | `undefined` |
|
||||
| `icon` | `icon` | A combination of both `name` and `src`. If a `src` url is detected it will set the `src` property. Otherwise it assumes it's a built-in named SVG and set the `name` property. | `any` | `undefined` |
|
||||
| `ios` | `ios` | Specifies which icon to use on `ios` mode. | `string \| undefined` | `undefined` |
|
||||
| `lazy` | `lazy` | If enabled, ion-icon will be loaded lazily when it's visible in the viewport. Default, `false`. | `boolean` | `false` |
|
||||
| `md` | `md` | Specifies which icon to use on `md` mode. | `string \| undefined` | `undefined` |
|
||||
| `mode` | `mode` | The mode determines which platform styles to use. | `string` | `getIonMode()` |
|
||||
| `name` | `name` | Specifies which icon to use from the built-in set of icons. | `string \| undefined` | `undefined` |
|
||||
| `sanitize` | `sanitize` | When `true`, SVG content, including SVG `data:` URLs, is checked before it renders. SVGs with `<script>` elements, attributes that start with `on` (like `onclick`), `javascript:` URLs, or non-SVG elements aren't rendered, and `<foreignObject>` elements are removed. Only set this to `false` for SVG content from a trusted source. | `boolean` | `true` |
|
||||
| `size` | `size` | The size of the icon. Available options are: `"small"` and `"large"`. | `string \| undefined` | `undefined` |
|
||||
| `src` | `src` | Specifies the exact `src` of an SVG file to use. | `string \| undefined` | `undefined` |
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
|
||||
*Built with [StencilJS](https://stenciljs.com/)*
|
||||
@@ -0,0 +1,111 @@
|
||||
import { isEncodedDataUrl, isSvgDataUrl, validateContent } from './validate';
|
||||
|
||||
export const ioniconContent = new Map<string, string>();
|
||||
const requests = new Map<string, Promise<any>>();
|
||||
|
||||
let parser: DOMParser;
|
||||
|
||||
/**
|
||||
* Unsanitized content gets its own key so it's never served to an icon that
|
||||
* sanitizes.
|
||||
*/
|
||||
export const getCacheKey = (url: string, sanitize: boolean) =>
|
||||
`${sanitize !== false ? 'sanitized' : 'unsanitized'}:${url}`;
|
||||
|
||||
/**
|
||||
* Warns when the whole icon is rejected so it doesn't silently render nothing.
|
||||
*/
|
||||
const sanitizeSvg = (url: string, svgContent: string) =>
|
||||
validateContent(svgContent, () => {
|
||||
const source = url.length > 100 ? `${url.slice(0, 100)}...` : url;
|
||||
console.warn(
|
||||
`[Ionicons Warning]: The SVG from "${source}" was not rendered because it failed sanitization. Only set sanitize="false" for SVG content from a trusted source.`,
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Safely fallback to an empty svg
|
||||
*/
|
||||
function safeFallback(cacheKey: string) {
|
||||
const svg = '';
|
||||
ioniconContent.set(cacheKey, svg);
|
||||
return svg;
|
||||
}
|
||||
|
||||
export const getSvgContent = (url: string, sanitize: boolean): Promise<string> => {
|
||||
const cacheKey = getCacheKey(url, sanitize);
|
||||
/**
|
||||
* See if we already have a request for this url
|
||||
*/
|
||||
const req = requests.get(cacheKey);
|
||||
if (req) {
|
||||
return req;
|
||||
}
|
||||
|
||||
if (typeof fetch !== 'undefined' && typeof document !== 'undefined') {
|
||||
/**
|
||||
* If the url is a data url of an svg, then try to parse it
|
||||
* with the DOMParser. This works with content security policies enabled.
|
||||
*/
|
||||
if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {
|
||||
return Promise.resolve(getSvgByUrl(url, sanitize));
|
||||
}
|
||||
|
||||
return fetchSvg(url, sanitize);
|
||||
}
|
||||
|
||||
return Promise.resolve(safeFallback(cacheKey));
|
||||
};
|
||||
|
||||
function getSvgByUrl(url: string, sanitize: boolean): string {
|
||||
if (!parser) {
|
||||
/**
|
||||
* Create an instance of the DOM parser. This creates a single
|
||||
* parser instance for the entire app, which is more efficient.
|
||||
*/
|
||||
parser = new DOMParser();
|
||||
}
|
||||
const doc = parser.parseFromString(url, 'text/html');
|
||||
const svg = doc.querySelector('svg');
|
||||
if (svg) {
|
||||
const svgContent = sanitize !== false ? sanitizeSvg(url, svg.outerHTML) : svg.outerHTML;
|
||||
ioniconContent.set(getCacheKey(url, sanitize), svgContent);
|
||||
return svgContent;
|
||||
}
|
||||
|
||||
throw new Error(`Could not parse svg from ${url}`);
|
||||
}
|
||||
|
||||
function fetchSvg(url: string, sanitize: boolean): Promise<string> {
|
||||
const cacheKey = getCacheKey(url, sanitize);
|
||||
/**
|
||||
* We don't already have a request
|
||||
*/
|
||||
const req = fetch(url)
|
||||
.then((rsp) => {
|
||||
/**
|
||||
* When fetching from a file:// URL, some browsers return
|
||||
* a 0 status code even when the request succeeds so don't
|
||||
* rely on rsp.ok as the only signal of success.
|
||||
*/
|
||||
return rsp
|
||||
.text()
|
||||
.then((svgContent) => {
|
||||
if (svgContent && sanitize !== false) {
|
||||
svgContent = sanitizeSvg(url, svgContent);
|
||||
}
|
||||
|
||||
const svg = svgContent || '';
|
||||
ioniconContent.set(cacheKey, svg);
|
||||
return svg;
|
||||
})
|
||||
.catch(() => safeFallback(cacheKey));
|
||||
})
|
||||
.catch(() => safeFallback(cacheKey));
|
||||
|
||||
/**
|
||||
* Cache for the same requests
|
||||
*/
|
||||
requests.set(cacheKey, req);
|
||||
return req;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
# this gitignore file is used as a placeholder
|
||||
# for this directory. The directory itself will
|
||||
# contain files generated during a build step.
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,15 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { test } from '@utils/test/playwright';
|
||||
import { AxeBuilder } from '@axe-core/playwright';
|
||||
|
||||
test.describe('icon: a11y', () => {
|
||||
test('should pass accessibility checks', async ({ page }) => {
|
||||
await page.goto(`/icon/test/a11y/`);
|
||||
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
const results = await new AxeBuilder({ page }).analyze();
|
||||
|
||||
expect(results.violations).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
<!doctype html>
|
||||
<html dir="ltr" lang="en" mode="ios">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
|
||||
<title>Icon - Accessibility</title>
|
||||
<script type="module" src="/build/ionicons.esm.js"></script>
|
||||
<script nomodule src="/build/ionicons.js"></script>
|
||||
<link rel="stylesheet" href="../styles.css" />
|
||||
<script src="../header.js"></script>
|
||||
|
||||
<!-- Font Awesome Icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<test-header></test-header>
|
||||
|
||||
<main>
|
||||
<h1>Icon - Accessibility</h1>
|
||||
|
||||
<h2>SVG icon with aria-label</h2>
|
||||
<ion-icon name="cellular" aria-label="Mobile data"></ion-icon>
|
||||
|
||||
<h2>Button with aria-label and SVG icon</h2>
|
||||
<button aria-label="Mobile data">
|
||||
<ion-icon name="cellular" aria-hidden="true"></ion-icon>
|
||||
</button>
|
||||
|
||||
<h2>SVG icon with aria-hidden</h2>
|
||||
<ion-icon name="cellular" aria-hidden="true"></ion-icon>
|
||||
|
||||
<hr />
|
||||
|
||||
<h2>Font icon with aria-label</h2>
|
||||
<ion-icon aria-label="Mobile data">
|
||||
<i class="fa fa-home"></i>
|
||||
</ion-icon>
|
||||
|
||||
<h2>Button with aria-label and font icon</h2>
|
||||
<button aria-label="Mobile data">
|
||||
<ion-icon aria-hidden="true">
|
||||
<i class="fa fa-home"></i>
|
||||
</ion-icon>
|
||||
</button>
|
||||
|
||||
<h2>Font icon with aria-hidden</h2>
|
||||
<ion-icon aria-hidden="true">
|
||||
<i class="fa fa-home"></i>
|
||||
</ion-icon>
|
||||
</main>
|
||||
|
||||
<style>
|
||||
ion-icon {
|
||||
font-size: 32px;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,13 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { test } from '@utils/test/playwright';
|
||||
|
||||
test.describe('icon: basic', () => {
|
||||
test('should not have visual regressions', async ({ page }) => {
|
||||
await page.goto(`/icon/test/basic/`);
|
||||
|
||||
// Wait for all SVGs to be lazily loaded before taking screenshots
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
await expect(page).toHaveScreenshot(`icon-basic.png`, { fullPage: true });
|
||||
});
|
||||
});
|
||||
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 68 KiB |
@@ -0,0 +1,101 @@
|
||||
<!doctype html>
|
||||
<html dir="ltr" lang="en" mode="ios">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
|
||||
<title>Icon - Basic</title>
|
||||
<script type="module" src="/build/ionicons.esm.js"></script>
|
||||
<script nomodule src="/build/ionicons.js"></script>
|
||||
<link rel="stylesheet" href="../styles.css" />
|
||||
<script src="../header.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<test-header></test-header>
|
||||
|
||||
<main>
|
||||
<h1>Icon - Basic</h1>
|
||||
|
||||
<h2>Default</h2>
|
||||
<ion-icon name="cellular"></ion-icon>
|
||||
<ion-icon name="at"></ion-icon>
|
||||
<ion-icon name="call"></ion-icon>
|
||||
<ion-icon name="football"></ion-icon>
|
||||
<ion-icon name="analytics"></ion-icon>
|
||||
<ion-icon name="grid"></ion-icon>
|
||||
<ion-icon name="funnel"></ion-icon>
|
||||
<ion-icon name="watch"></ion-icon>
|
||||
<ion-icon name="add-circle-outline"></ion-icon>
|
||||
|
||||
<h2>Mode from html ios mode attribute</h2>
|
||||
<ion-icon md="logo-android" ios="logo-apple"></ion-icon>
|
||||
<ion-icon md="logo-android" ios="logo-apple"></ion-icon>
|
||||
|
||||
<h2>Mode set on icon</h2>
|
||||
<ion-icon mode="ios" md="logo-android" ios="logo-apple"></ion-icon>
|
||||
<ion-icon mode="md" md="logo-android" ios="logo-apple"></ion-icon>
|
||||
|
||||
<h2>Colors</h2>
|
||||
<ion-icon color="primary" name="cellular"></ion-icon>
|
||||
<ion-icon color="secondary" name="at"></ion-icon>
|
||||
<ion-icon color="tertiary" name="call"></ion-icon>
|
||||
<ion-icon color="success" name="football"></ion-icon>
|
||||
<ion-icon color="warning" name="analytics"></ion-icon>
|
||||
<ion-icon color="danger" name="grid"></ion-icon>
|
||||
<ion-icon color="light" name="funnel"></ion-icon>
|
||||
<ion-icon color="medium" name="watch"></ion-icon>
|
||||
<ion-icon color="dark" name="toggle"></ion-icon>
|
||||
|
||||
<h2>Stroke width</h2>
|
||||
<ion-icon name="heart-outline" style="--ionicon-stroke-width: 8px"></ion-icon>
|
||||
|
||||
<h2>Font size</h2>
|
||||
<ion-icon name="book" style="font-size: 50px"></ion-icon>
|
||||
<ion-icon src="../../assets/bug_report.svg" style="font-size: 50px"></ion-icon>
|
||||
|
||||
<h2>Custom SVGs</h2>
|
||||
<ion-icon src="../../assets/bug_report.svg"></ion-icon>
|
||||
<ion-icon src="../../assets/chat.svg"></ion-icon>
|
||||
<ion-icon src="../../assets/commute.svg"></ion-icon>
|
||||
<ion-icon src="../../assets/copyright.svg"></ion-icon>
|
||||
<ion-icon src="../../assets/done_all.svg"></ion-icon>
|
||||
<ion-icon src="../../assets/lock_open.svg"></ion-icon>
|
||||
<ion-icon src="../../assets/toll.svg"></ion-icon>
|
||||
<ion-icon src="../../assets/web_asset.svg"></ion-icon>
|
||||
<ion-icon src="../../assets/work_outline.svg"></ion-icon>
|
||||
|
||||
<h2>Custom SVGs: colors</h2>
|
||||
<ion-icon color="primary" src="../../assets/bug_report.svg"></ion-icon>
|
||||
<ion-icon color="secondary" src="../../assets/chat.svg"></ion-icon>
|
||||
<ion-icon color="tertiary" src="../../assets/commute.svg"></ion-icon>
|
||||
<ion-icon color="success" src="../../assets/copyright.svg"></ion-icon>
|
||||
<ion-icon color="warning" src="../../assets/done_all.svg"></ion-icon>
|
||||
<ion-icon color="danger" src="../../assets/lock_open.svg"></ion-icon>
|
||||
<ion-icon color="light" src="../../assets/toll.svg"></ion-icon>
|
||||
<ion-icon color="medium" src="../../assets/web_asset.svg"></ion-icon>
|
||||
<ion-icon color="dark" src="../../assets/work_outline.svg"></ion-icon>
|
||||
|
||||
<h2>Custom CSS</h2>
|
||||
<ion-icon class="custom" name="grid"></ion-icon>
|
||||
<ion-icon class="custom" name="funnel"></ion-icon>
|
||||
<ion-icon class="custom" name="watch"></ion-icon>
|
||||
<ion-icon class="custom" name="logo-react"></ion-icon>
|
||||
<ion-icon class="custom" name="logo-javascript"></ion-icon>
|
||||
<ion-icon class="custom" name="logo-angular"></ion-icon>
|
||||
<ion-icon class="custom" src="../../assets/done_all.svg"></ion-icon>
|
||||
<ion-icon class="custom" src="../../assets/web_asset.svg"></ion-icon>
|
||||
<ion-icon class="custom" src="../../assets/work_outline.svg"></ion-icon>
|
||||
</main>
|
||||
|
||||
<style>
|
||||
ion-icon {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.custom {
|
||||
stroke: red;
|
||||
fill: blue;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,13 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { test } from '@utils/test/playwright';
|
||||
|
||||
test.describe('icon: csp', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/icon/test/csp');
|
||||
});
|
||||
|
||||
test('should load svg', async ({ page }) => {
|
||||
const svg = page.locator('ion-icon#icon-usage svg');
|
||||
await expect(svg).toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
<!doctype html>
|
||||
<html dir="ltr" lang="en" mode="ios">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="default-src 'none'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com/*; img-src 'self'; connect-src 'self'; font-src https://fonts.gstatic.com/*'"
|
||||
/>
|
||||
<title>Icon - Content Security Policy</title>
|
||||
<script type="module" src="/build/ionicons.esm.js"></script>
|
||||
<script nomodule src="/build/ionicons.js"></script>
|
||||
<link rel="stylesheet" href="../styles.css" />
|
||||
<script src="../header.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<test-header></test-header>
|
||||
|
||||
<main>
|
||||
<h1>Icon - Content Security Policy</h1>
|
||||
|
||||
<h2>Default</h2>
|
||||
<ion-icon src="/assets/chat.svg"></ion-icon>
|
||||
<ion-icon name="add"></ion-icon>
|
||||
|
||||
<ion-icon
|
||||
id="icon-usage"
|
||||
icon="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><title>Watch</title><rect x='136' y='136' width='240' height='240' rx='8' ry='8'/><path d='M384 96h-48V16H176v80h-48a32 32 0 00-32 32v256a32 32 0 0032 32h48v80h160v-80h48a32 32 0 0032-32V128a32 32 0 00-32-32zm8 272a24 24 0 01-24 24H144a24 24 0 01-24-24V144a24 24 0 0124-24h224a24 24 0 0124 24z'/></svg>"
|
||||
>
|
||||
</ion-icon>
|
||||
|
||||
<ion-icon
|
||||
class="custom"
|
||||
icon="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><title>Watch</title><rect x='136' y='136' width='240' height='240' rx='8' ry='8'/><path d='M384 96h-48V16H176v80h-48a32 32 0 00-32 32v256a32 32 0 0032 32h48v80h160v-80h48a32 32 0 0032-32V128a32 32 0 00-32-32zm8 272a24 24 0 01-24 24H144a24 24 0 01-24-24V144a24 24 0 0124-24h224a24 24 0 0124 24z'/></svg>"
|
||||
>
|
||||
</ion-icon>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
<style>
|
||||
ion-icon {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.custom {
|
||||
stroke: red;
|
||||
fill: goldenrod;
|
||||
color: black;
|
||||
}
|
||||
</style>
|
||||
</html>
|
||||
@@ -0,0 +1,16 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { test } from '@utils/test/playwright';
|
||||
|
||||
test.describe('icon: dynamic type', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto(`/icon/test/dynamic-type/`);
|
||||
});
|
||||
|
||||
test('should scale text on larger font sizes', async ({ page }) => {
|
||||
// Wait for all SVGs to be lazily loaded before taking screenshots
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
const main = page.locator('main');
|
||||
await expect(main).toHaveScreenshot(`icon-dynamic-type.png`);
|
||||
});
|
||||
});
|
||||
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 16 KiB |
@@ -0,0 +1,45 @@
|
||||
<!doctype html>
|
||||
<html dir="ltr" lang="en" mode="ios">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
|
||||
<title>Icon - Dynamic Type</title>
|
||||
<script type="module" src="/build/ionicons.esm.js"></script>
|
||||
<script nomodule src="/build/ionicons.js"></script>
|
||||
<link rel="stylesheet" href="../styles.css" />
|
||||
<script src="../header.js"></script>
|
||||
|
||||
<!-- Font Awesome Icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<test-header></test-header>
|
||||
|
||||
<main>
|
||||
<h1>Icon - Dynamic Type</h1>
|
||||
|
||||
<h2>Default Icons</h2>
|
||||
<ion-icon name="star"></ion-icon>
|
||||
<ion-icon name="star" size="small"></ion-icon>
|
||||
<ion-icon name="star" size="large"></ion-icon>
|
||||
|
||||
<h2>Font Icons</h2>
|
||||
<ion-icon>
|
||||
<i class="fa fa-star"></i>
|
||||
</ion-icon>
|
||||
<ion-icon size="small">
|
||||
<i class="fa fa-star"></i>
|
||||
</ion-icon>
|
||||
<ion-icon size="large">
|
||||
<i class="fa fa-star"></i>
|
||||
</ion-icon>
|
||||
</main>
|
||||
|
||||
<style>
|
||||
html {
|
||||
font-size: 28px;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,14 @@
|
||||
class TestHeader extends HTMLElement {
|
||||
connectedCallback() {
|
||||
const header = document.createElement('header');
|
||||
header.innerHTML = `
|
||||
<a href="/" class="back-button">
|
||||
<ion-icon name="arrow-back" aria-hidden="true"></ion-icon>
|
||||
Back
|
||||
</a>
|
||||
`;
|
||||
this.appendChild(header);
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define('test-header', TestHeader);
|
||||
@@ -0,0 +1,202 @@
|
||||
import { newSpecPage } from 'jest-stencil-runner';
|
||||
import { Icon } from '../icon';
|
||||
|
||||
describe('icon', () => {
|
||||
describe('basic rendering', () => {
|
||||
it('renders', async () => {
|
||||
const { root } = await newSpecPage({
|
||||
components: [Icon],
|
||||
html: '<ion-icon></ion-icon>',
|
||||
});
|
||||
expect(root).toEqualHtml(`
|
||||
<ion-icon class="md" role="img">
|
||||
<mock:shadow-root>
|
||||
<div class="icon-inner">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</mock:shadow-root>
|
||||
</ion-icon>
|
||||
`);
|
||||
});
|
||||
|
||||
it('renders rtl with aria-hidden', async () => {
|
||||
const { root } = await newSpecPage({
|
||||
components: [Icon],
|
||||
direction: 'rtl',
|
||||
html: `<ion-icon name="chevron-forward" aria-hidden="true"></ion-icon>`,
|
||||
});
|
||||
|
||||
expect(root).toEqualHtml(`
|
||||
<ion-icon class="md flip-rtl icon-rtl" name="chevron-forward" role="img" aria-hidden="true">
|
||||
<mock:shadow-root>
|
||||
<div class="icon-inner">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</mock:shadow-root>
|
||||
</ion-icon>
|
||||
`);
|
||||
});
|
||||
|
||||
it('renders custom aria-label', async () => {
|
||||
const { root } = await newSpecPage({
|
||||
components: [Icon],
|
||||
html: `<ion-icon name="star" aria-label="custom label"></ion-icon>`,
|
||||
});
|
||||
|
||||
expect(root).toEqualHtml(`
|
||||
<ion-icon class="md" name="star" role="img" aria-label="custom label">
|
||||
<mock:shadow-root>
|
||||
<div class="icon-inner">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</mock:shadow-root>
|
||||
</ion-icon>
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('dynamic rendering', () => {
|
||||
it('renders custom label after changing source', async () => {
|
||||
const page = await newSpecPage({
|
||||
components: [Icon],
|
||||
html: `<ion-icon name="chevron-forward" aria-label="custom label"></ion-icon>`,
|
||||
});
|
||||
|
||||
const icon = page.root;
|
||||
|
||||
expect(icon).toEqualHtml(`
|
||||
<ion-icon class="flip-rtl md" name="chevron-forward" role="img" aria-label="custom label">
|
||||
<mock:shadow-root>
|
||||
<div class="icon-inner">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</mock:shadow-root>
|
||||
</ion-icon>
|
||||
`);
|
||||
|
||||
if (icon) {
|
||||
icon.name = 'trash';
|
||||
}
|
||||
await page.waitForChanges();
|
||||
|
||||
expect(icon).toEqualHtml(`
|
||||
<ion-icon class="md" name="trash" role="img" aria-label="custom label">
|
||||
<mock:shadow-root>
|
||||
<div class="icon-inner">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</mock:shadow-root>
|
||||
</ion-icon>
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('svg rendering scenarios', () => {
|
||||
it('svgContent=true: renders svg without slot', async () => {
|
||||
const page = await newSpecPage({
|
||||
components: [Icon],
|
||||
html: `<ion-icon aria-hidden="true" part="close-icon" class="close-icon"></ion-icon>`,
|
||||
});
|
||||
|
||||
const icon = page.root as any;
|
||||
const instance = page.rootInstance as any;
|
||||
instance.svgContent = '<svg><circle cx="50" cy="50" r="40"/></svg>';
|
||||
await page.waitForChanges();
|
||||
|
||||
const shadowRoot = icon.shadowRoot;
|
||||
const iconInner = shadowRoot?.querySelector('.icon-inner');
|
||||
|
||||
// Should have no slot
|
||||
const slot = iconInner?.querySelector('slot');
|
||||
expect(slot).toBeNull();
|
||||
|
||||
// SVG should be a direct child of icon-inner,
|
||||
// not nested in another div
|
||||
expect(iconInner?.children.length).toBe(1);
|
||||
const firstChild = iconInner?.children[0];
|
||||
expect((firstChild as any)?.tagName?.toLowerCase()).toBe('svg');
|
||||
expect(firstChild?.querySelector('circle')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('svgContent=false: renders slot for custom content', async () => {
|
||||
const page = await newSpecPage({
|
||||
components: [Icon],
|
||||
html: `<ion-icon aria-hidden="true" part="close-icon" class="close-icon"></ion-icon>`,
|
||||
});
|
||||
|
||||
const icon = page.root as any;
|
||||
const shadowRoot = icon.shadowRoot;
|
||||
const iconInner = shadowRoot?.querySelector('.icon-inner');
|
||||
const slot = iconInner?.querySelector('slot');
|
||||
const svg = iconInner?.querySelector('svg');
|
||||
|
||||
expect(slot).not.toBeNull();
|
||||
expect(svg).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('slotted content', () => {
|
||||
it('renders slotted font icon (Font Awesome)', async () => {
|
||||
const { root } = await newSpecPage({
|
||||
components: [Icon],
|
||||
html: `
|
||||
<ion-icon>
|
||||
<i class="fa fa-home"></i>
|
||||
</ion-icon>
|
||||
`,
|
||||
});
|
||||
expect(root).toEqualHtml(`
|
||||
<ion-icon class="md" role="img">
|
||||
<mock:shadow-root>
|
||||
<div class="icon-inner">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</mock:shadow-root>
|
||||
<i class="fa fa-home"></i>
|
||||
</ion-icon>
|
||||
`);
|
||||
});
|
||||
|
||||
it('renders slotted font icon with color', async () => {
|
||||
const { root } = await newSpecPage({
|
||||
components: [Icon],
|
||||
html: `
|
||||
<ion-icon color="primary">
|
||||
<i class="fa fa-heart"></i>
|
||||
</ion-icon>
|
||||
`,
|
||||
});
|
||||
expect(root).toEqualHtml(`
|
||||
<ion-icon class="md ion-color ion-color-primary" color="primary" role="img">
|
||||
<mock:shadow-root>
|
||||
<div class="icon-inner">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</mock:shadow-root>
|
||||
<i class="fa fa-heart"></i>
|
||||
</ion-icon>
|
||||
`);
|
||||
});
|
||||
|
||||
it('renders slotted font icon with custom style', async () => {
|
||||
const { root } = await newSpecPage({
|
||||
components: [Icon],
|
||||
html: `
|
||||
<ion-icon style="font-size: 48px">
|
||||
<i class="fa fa-star"></i>
|
||||
</ion-icon>
|
||||
`,
|
||||
});
|
||||
expect(root).toEqualHtml(`
|
||||
<ion-icon class="md" role="img" style="font-size: 48px">
|
||||
<mock:shadow-root>
|
||||
<div class="icon-inner">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</mock:shadow-root>
|
||||
<i class="fa fa-star"></i>
|
||||
</ion-icon>
|
||||
`);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
<!doctype html>
|
||||
<html dir="ltr" lang="en" mode="ios">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
|
||||
<title>Icon Tests</title>
|
||||
<script type="module" src="/build/ionicons.esm.js"></script>
|
||||
<script nomodule src="/build/ionicons.js"></script>
|
||||
<link rel="stylesheet" href="./icon/test/styles.css" />
|
||||
<script src="./icon/test/header.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main>
|
||||
<h1>Icon Tests</h1>
|
||||
<p>Select a test category to view the icon component tests.</p>
|
||||
|
||||
<div class="grid">
|
||||
<a href="/icon/test/a11y/" class="card">
|
||||
<h3>Accessibility</h3>
|
||||
<p>ARIA labels and accessible icon patterns</p>
|
||||
</a>
|
||||
|
||||
<a href="/icon/test/basic/" class="card">
|
||||
<h3>Basic</h3>
|
||||
<p>Default SVG icons, modes, colors, sizes, and custom SVGs</p>
|
||||
</a>
|
||||
|
||||
<a href="/icon/test/cheatsheet/" class="card">
|
||||
<h3>Cheatsheet</h3>
|
||||
<p>Visual reference of all available ionicons</p>
|
||||
</a>
|
||||
|
||||
<a href="/icon/test/csp/" class="card">
|
||||
<h3>Content Security Policy</h3>
|
||||
<p>SVG content loading with Content Security Policy</p>
|
||||
</a>
|
||||
|
||||
<a href="/icon/test/dynamic-type/" class="card">
|
||||
<h3>Dynamic Type</h3>
|
||||
<p>Font size scaling and dynamic text sizing behavior</p>
|
||||
</a>
|
||||
|
||||
<a href="/icon/test/rtl/" class="card">
|
||||
<h3>RTL</h3>
|
||||
<p>Right-to-left text direction and icon flipping behavior</p>
|
||||
</a>
|
||||
|
||||
<a href="/icon/test/sanitization/" class="card">
|
||||
<h3>Sanitization</h3>
|
||||
<p>SVG content sanitization and security</p>
|
||||
</a>
|
||||
|
||||
<a href="/icon/test/size/" class="card">
|
||||
<h3>Size</h3>
|
||||
<p>Size prop with small and large variants for native and slotted icons</p>
|
||||
</a>
|
||||
|
||||
<a href="/icon/test/slotted/" class="card">
|
||||
<h3>Slotted Content</h3>
|
||||
<p>Font Awesome, Material, Phosphor, Bootstrap, and custom SVGs</p>
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,60 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { test } from '@utils/test/playwright';
|
||||
|
||||
test.describe('icon: rtl', () => {
|
||||
test('some icons should flip when rtl', async ({ page }) => {
|
||||
await page.goto(`/icon/test/rtl/`);
|
||||
|
||||
const autoflip = page.locator('.auto-flip-chevrons [name=chevron-forward] .icon-inner');
|
||||
const unflip = page.locator('.un-flip-chevrons [name=chevron-forward] .icon-inner');
|
||||
await expect(autoflip).not.toHaveCSS('transform', /matrix\(-1/);
|
||||
await expect(unflip).not.toHaveCSS('transform', /matrix\(-1/);
|
||||
|
||||
await page.evaluate(() => {
|
||||
document.dir = 'rtl';
|
||||
});
|
||||
|
||||
await expect(autoflip).toHaveCSS('transform', /matrix\(-1/);
|
||||
await expect(unflip).not.toHaveCSS('transform', /matrix\(-1/);
|
||||
|
||||
// Wait for all SVGs to be lazily loaded before taking screenshots
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
await expect(page).toHaveScreenshot(`icon-rtl.png`);
|
||||
});
|
||||
|
||||
test('arrows should flip if dir changes on the element', async ({ page }) => {
|
||||
await page.goto(`/icon/test/rtl/`);
|
||||
|
||||
const autoflip = page.locator('.auto-flip-chevrons [name=chevron-forward] .icon-inner');
|
||||
const unflip = page.locator('.un-flip-chevrons [name=chevron-forward] .icon-inner');
|
||||
await expect(autoflip).not.toHaveCSS('transform', /matrix\(-1/);
|
||||
await expect(unflip).not.toHaveCSS('transform', /matrix\(-1/);
|
||||
|
||||
const autoflipEl = await page.$('.auto-flip-chevrons [name=chevron-forward]');
|
||||
const unflipEl = await page.$('.un-flip-chevrons [name=chevron-forward]');
|
||||
await autoflipEl!.evaluate((node) => node.setAttribute('dir', 'rtl'));
|
||||
await unflipEl!.evaluate((node) => node.setAttribute('dir', 'rtl'));
|
||||
|
||||
await expect(autoflip).toHaveCSS('transform', /matrix\(-1/);
|
||||
await expect(unflip).not.toHaveCSS('transform', /matrix\(-1/);
|
||||
});
|
||||
|
||||
test('icon should reassess flipping when name changes', async ({ page }) => {
|
||||
await page.goto(`/icon/test/rtl/`);
|
||||
|
||||
await page.evaluate(() => {
|
||||
document.dir = 'rtl';
|
||||
});
|
||||
|
||||
const iconLoc = page.locator('.auto-flip-chevrons ion-icon:nth-child(2)');
|
||||
await expect(iconLoc).toHaveAttribute('name', 'chevron-forward');
|
||||
await expect(iconLoc).toHaveClass(/flip-rtl/);
|
||||
|
||||
const iconEl = await page.$('.auto-flip-chevrons ion-icon:nth-child(2)');
|
||||
await iconEl!.evaluate((node) => node.setAttribute('name', 'brush'));
|
||||
|
||||
await expect(iconLoc).toHaveAttribute('name', 'brush');
|
||||
await expect(iconLoc).not.toHaveClass(/flip-rtl/);
|
||||
});
|
||||
});
|
||||
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 34 KiB |
@@ -0,0 +1,72 @@
|
||||
<!doctype html>
|
||||
<html dir="ltr" lang="en" mode="ios">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
|
||||
<title>Icon - RTL</title>
|
||||
<script type="module" src="/build/ionicons.esm.js"></script>
|
||||
<script nomodule src="/build/ionicons.js"></script>
|
||||
<link rel="stylesheet" href="../styles.css" />
|
||||
<script src="../header.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<test-header></test-header>
|
||||
|
||||
<main>
|
||||
<h1>Icon - RTL</h1>
|
||||
|
||||
<h2>Default: Non-arrows</h2>
|
||||
<ion-icon name="cut"></ion-icon>
|
||||
<ion-icon name="call"></ion-icon>
|
||||
<ion-icon name="checkbox"></ion-icon>
|
||||
<ion-icon name="brush"></ion-icon>
|
||||
|
||||
<h2>Flip: Non-arrows</h2>
|
||||
<ion-icon name="cut" flip-rtl></ion-icon>
|
||||
<ion-icon name="call" flip-rtl></ion-icon>
|
||||
<ion-icon name="checkbox" flip-rtl></ion-icon>
|
||||
<ion-icon name="brush" flip-rtl></ion-icon>
|
||||
|
||||
<h2>Auto Flip: arrows</h2>
|
||||
<ion-icon name="arrow-up"></ion-icon>
|
||||
<ion-icon name="arrow-forward"></ion-icon>
|
||||
<ion-icon name="arrow-down"></ion-icon>
|
||||
<ion-icon name="arrow-back"></ion-icon>
|
||||
|
||||
<h2>Un-flip: arrows</h2>
|
||||
<ion-icon name="arrow-up" flip-rtl="false"></ion-icon>
|
||||
<ion-icon name="arrow-forward" flip-rtl="false"></ion-icon>
|
||||
<ion-icon name="arrow-down" flip-rtl="false"></ion-icon>
|
||||
<ion-icon name="arrow-back" flip-rtl="false"></ion-icon>
|
||||
|
||||
<h2>Auto Flip: chevrons</h2>
|
||||
<div class="auto-flip-chevrons">
|
||||
<ion-icon name="chevron-up"></ion-icon>
|
||||
<ion-icon name="chevron-forward"></ion-icon>
|
||||
<ion-icon name="chevron-down"></ion-icon>
|
||||
<ion-icon name="chevron-back"></ion-icon>
|
||||
</div>
|
||||
|
||||
<h2>Un-flip: chevrons</h2>
|
||||
<div class="un-flip-chevrons">
|
||||
<ion-icon name="chevron-up" flip-rtl="false"></ion-icon>
|
||||
<ion-icon name="chevron-forward" flip-rtl="false"></ion-icon>
|
||||
<ion-icon name="chevron-down" flip-rtl="false"></ion-icon>
|
||||
<ion-icon name="chevron-back" flip-rtl="false"></ion-icon>
|
||||
</div>
|
||||
|
||||
<h2>Auto Flip, RTL on components</h2>
|
||||
<ion-icon name="arrow-up" dir="rtl" flip-rtl></ion-icon>
|
||||
<ion-icon name="arrow-forward" dir="rtl" flip-rtl></ion-icon>
|
||||
<ion-icon name="arrow-down" dir="rtl" flip-rtl></ion-icon>
|
||||
<ion-icon name="arrow-back" dir="rtl" flip-rtl></ion-icon>
|
||||
</main>
|
||||
|
||||
<style>
|
||||
ion-icon {
|
||||
font-size: 32px;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,284 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import type { E2EPage } from '@utils/test/playwright';
|
||||
import { test } from '@utils/test/playwright';
|
||||
|
||||
/**
|
||||
* An SVG whose handler pushes `label` to `window.xssFired` if it ever runs.
|
||||
*/
|
||||
const imageOnErrorSvg = (label: string) =>
|
||||
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><image href="x" onerror="window.xssFired.push('${label}')"/></svg>`;
|
||||
|
||||
const utf8DataUrl = (svg: string) => `data:image/svg+xml;utf8,${svg}`;
|
||||
|
||||
/**
|
||||
* Sets `sanitize` before `src` so the icon loads with the intended setting.
|
||||
*/
|
||||
const addIcon = (page: E2EPage, id: string, src: string, sanitize?: boolean) =>
|
||||
page.evaluate(
|
||||
([id, src, sanitize]) => {
|
||||
const icon = document.createElement('ion-icon') as any;
|
||||
icon.id = id;
|
||||
if (sanitize !== undefined) {
|
||||
icon.sanitize = sanitize;
|
||||
}
|
||||
icon.src = src;
|
||||
document.body.appendChild(icon);
|
||||
},
|
||||
[id, src, sanitize] as const,
|
||||
);
|
||||
|
||||
/**
|
||||
* Waits for the unsanitized control icon's handler to fire. Any `data:` URL
|
||||
* payload added before it has had at least as long to fire.
|
||||
*/
|
||||
const waitForControl = (page: E2EPage) => page.waitForFunction(() => (window as any).xssFired.includes('control'));
|
||||
|
||||
const getFired = (page: E2EPage) => page.evaluate(() => (window as any).xssFired as string[]);
|
||||
|
||||
test.describe('icon: sanitization', () => {
|
||||
test('should not have visual regressions', async ({ page }) => {
|
||||
await page.goto(`/icon/test/sanitization/`);
|
||||
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
const main = page.locator('main');
|
||||
await expect(main).toHaveScreenshot(`icon-sanitization.png`);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('icon: sanitization: unsafe content', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.setContent(`<script>window.xssFired = [];</script>`);
|
||||
});
|
||||
|
||||
test('should not run handlers from a utf8 svg data url', async ({ page }) => {
|
||||
await addIcon(page, 'attack', utf8DataUrl(imageOnErrorSvg('attack')));
|
||||
await addIcon(page, 'control', utf8DataUrl(imageOnErrorSvg('control')), false);
|
||||
await waitForControl(page);
|
||||
|
||||
expect(await getFired(page)).not.toContain('attack');
|
||||
await expect(page.locator('#attack .icon-inner svg')).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('should render a clean utf8 svg data url', async ({ page }) => {
|
||||
const clean = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0h24v24H0z"/></svg>`;
|
||||
await addIcon(page, 'clean', utf8DataUrl(clean));
|
||||
|
||||
await expect(page.locator('#clean .icon-inner svg path')).toHaveCount(1);
|
||||
});
|
||||
|
||||
test('should warn when an svg is rejected', async ({ page }) => {
|
||||
const warnings: string[] = [];
|
||||
page.on('console', (msg) => {
|
||||
if (msg.type() === 'warning') {
|
||||
warnings.push(msg.text());
|
||||
}
|
||||
});
|
||||
|
||||
await addIcon(page, 'attack', utf8DataUrl(imageOnErrorSvg('attack')));
|
||||
|
||||
await expect.poll(() => warnings.some((warning) => warning.includes('[Ionicons Warning]'))).toBe(true);
|
||||
});
|
||||
|
||||
test('should not warn about sanitizing when the response is not an svg', async ({ page }) => {
|
||||
const warnings: string[] = [];
|
||||
page.on('console', (msg) => {
|
||||
if (msg.type() === 'warning') {
|
||||
warnings.push(msg.text());
|
||||
}
|
||||
});
|
||||
await page.route('**/missing.svg', (route) =>
|
||||
route.fulfill({ status: 404, contentType: 'text/html', body: '<html><body>Not found</body></html>' }),
|
||||
);
|
||||
await page.route('**/rejected.svg', (route) =>
|
||||
route.fulfill({ contentType: 'image/svg+xml', body: imageOnErrorSvg('attack') }),
|
||||
);
|
||||
|
||||
const missingLoaded = page.waitForResponse('**/missing.svg');
|
||||
await addIcon(page, 'missing', '/missing.svg');
|
||||
await missingLoaded;
|
||||
// This takes the same fetch and sanitize steps, so once it warns the 404 has been handled
|
||||
await addIcon(page, 'rejected', '/rejected.svg');
|
||||
await expect.poll(() => warnings.some((warning) => warning.includes('rejected.svg'))).toBe(true);
|
||||
|
||||
expect(warnings.filter((warning) => warning.includes('missing.svg'))).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('should not run handlers from a fetched svg while sanitizing it', async ({ page }) => {
|
||||
await page.route('**/xss/*.svg', (route) => {
|
||||
const label = route.request().url().includes('control') ? 'control' : 'attack';
|
||||
route.fulfill({
|
||||
contentType: 'image/svg+xml',
|
||||
body: `<img src="x" onerror="window.xssFired.push('${label}')">${imageOnErrorSvg(label)}`,
|
||||
});
|
||||
});
|
||||
|
||||
// Fetches resolve independently, so let the attack load before the control starts
|
||||
const attackLoaded = page.waitForResponse('**/xss/attack.svg');
|
||||
await addIcon(page, 'attack', '/xss/attack.svg');
|
||||
await attackLoaded;
|
||||
await addIcon(page, 'control', '/xss/control.svg', false);
|
||||
await waitForControl(page);
|
||||
|
||||
expect(await getFired(page)).not.toContain('attack');
|
||||
await expect(page.locator('#attack .icon-inner svg')).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('should reject a fetched svg with more than one root svg', async ({ page }) => {
|
||||
await page.route('**/xss/*.svg', (route) => {
|
||||
const label = route.request().url().includes('control') ? 'control' : 'attack';
|
||||
route.fulfill({
|
||||
contentType: 'image/svg+xml',
|
||||
body: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0h24v24H0z"/></svg>${imageOnErrorSvg(label)}`,
|
||||
});
|
||||
});
|
||||
|
||||
const attackLoaded = page.waitForResponse('**/xss/attack.svg');
|
||||
await addIcon(page, 'attack', '/xss/attack.svg');
|
||||
await attackLoaded;
|
||||
await addIcon(page, 'control', '/xss/control.svg', false);
|
||||
await waitForControl(page);
|
||||
|
||||
expect(await getFired(page)).not.toContain('attack');
|
||||
await expect(page.locator('#attack .icon-inner svg')).toHaveCount(0);
|
||||
});
|
||||
|
||||
const htmlInSvgPayloads = [
|
||||
{
|
||||
name: 'noscript',
|
||||
inner: `<desc><noscript><p title="</noscript><img src=x onerror=top.xssFired.push('attack')>"></p></noscript></desc>`,
|
||||
},
|
||||
{
|
||||
name: 'template',
|
||||
inner: `<desc><template><img src="x" onerror="top.xssFired.push('attack')"></template></desc>`,
|
||||
},
|
||||
];
|
||||
|
||||
htmlInSvgPayloads.forEach(({ name, inner }) => {
|
||||
test(`should reject an svg containing an html ${name} element`, async ({ page }) => {
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">${inner}<path d="M0 0h24v24H0z"/></svg>`;
|
||||
await addIcon(page, 'attack', utf8DataUrl(svg));
|
||||
await addIcon(page, 'control', utf8DataUrl(imageOnErrorSvg('control')), false);
|
||||
await waitForControl(page);
|
||||
|
||||
expect(await getFired(page)).not.toContain('attack');
|
||||
await expect(page.locator('#attack .icon-inner svg')).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
|
||||
const foreignObjectPayloads = [
|
||||
{
|
||||
name: 'iframe srcdoc',
|
||||
inner: `<iframe xmlns="http://www.w3.org/1999/xhtml" srcdoc="<script>top.xssFired.push('attack')</script>"></iframe>`,
|
||||
},
|
||||
{
|
||||
name: 'iframe javascript: src',
|
||||
inner: `<iframe xmlns="http://www.w3.org/1999/xhtml" src="javascript:top.xssFired.push('attack')"></iframe>`,
|
||||
},
|
||||
];
|
||||
|
||||
foreignObjectPayloads.forEach(({ name, inner }) => {
|
||||
test(`should remove a foreignObject containing an ${name}`, async ({ page }) => {
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><foreignObject width="24" height="24">${inner}</foreignObject><path d="M0 0h24v24H0z"/></svg>`;
|
||||
await addIcon(page, 'attack', utf8DataUrl(svg));
|
||||
await addIcon(page, 'control', utf8DataUrl(imageOnErrorSvg('control')), false);
|
||||
await waitForControl(page);
|
||||
|
||||
expect(await getFired(page)).not.toContain('attack');
|
||||
await expect(page.locator('#attack .icon-inner svg path')).toHaveCount(1);
|
||||
await expect(page.locator('#attack .icon-inner svg > :not(path)')).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
|
||||
test('should render an illustrator export that uses a switch with a foreignObject', async ({ page }) => {
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><switch><foreignObject requiredExtensions="http://ns.adobe.com/AdobeIllustrator/10.0/" x="0" y="0" width="1" height="1"><i:pgfRef xlink:href="#adobe_illustrator_pgf"></i:pgfRef></foreignObject><g i:extraneous="self"><path d="M0 0h24v24H0z"/></g></switch></svg>`;
|
||||
await addIcon(page, 'illustrator', utf8DataUrl(svg));
|
||||
|
||||
await expect(page.locator('#illustrator .icon-inner svg path')).toHaveCount(1);
|
||||
});
|
||||
|
||||
const javascriptUrlPayloads = [
|
||||
{ name: 'an anchor href', inner: `<a href="javascript:top.xssFired.push('attack')"><path d="M0 0h24v24H0z"/></a>` },
|
||||
{
|
||||
name: 'an obfuscated xlink:href',
|
||||
inner: `<a xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href=" JaVa	ScRiPt:top.xssFired.push('attack')"><path d="M0 0h24v24H0z"/></a>`,
|
||||
},
|
||||
{
|
||||
name: 'an animate element',
|
||||
inner: `<a><animate attributeName="href" values="https://ionic.io;javascript:top.xssFired.push('attack')"/><path d="M0 0h24v24H0z"/></a>`,
|
||||
},
|
||||
{
|
||||
name: 'a set element',
|
||||
inner: `<a><set attributeName="href" to="javascript:top.xssFired.push('attack')"/><path d="M0 0h24v24H0z"/></a>`,
|
||||
},
|
||||
];
|
||||
|
||||
javascriptUrlPayloads.forEach(({ name, inner }) => {
|
||||
test(`should reject an svg with a javascript: url in ${name}`, async ({ page }) => {
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">${inner}</svg>`;
|
||||
await addIcon(page, 'attack', utf8DataUrl(svg));
|
||||
await addIcon(page, 'control', utf8DataUrl(imageOnErrorSvg('control')), false);
|
||||
await waitForControl(page);
|
||||
|
||||
await expect(page.locator('#attack .icon-inner svg')).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
|
||||
test('should not reuse unsanitized content cached for the same data url', async ({ page }) => {
|
||||
const shared = utf8DataUrl(imageOnErrorSvg('shared'));
|
||||
|
||||
await addIcon(page, 'unsanitized', shared, false);
|
||||
await page.waitForFunction(() => (window as any).xssFired.includes('shared'));
|
||||
|
||||
await addIcon(page, 'sanitized', shared);
|
||||
await addIcon(page, 'control', utf8DataUrl(imageOnErrorSvg('control')), false);
|
||||
await waitForControl(page);
|
||||
|
||||
await expect(page.locator('#sanitized .icon-inner svg')).toHaveCount(0);
|
||||
expect((await getFired(page)).filter((label) => label === 'shared')).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('should not reuse sanitized content cached for the same data url', async ({ page }) => {
|
||||
const shared = utf8DataUrl(imageOnErrorSvg('shared'));
|
||||
|
||||
await addIcon(page, 'sanitized', shared);
|
||||
await addIcon(page, 'unsanitized', shared, false);
|
||||
|
||||
await expect(page.locator('#unsanitized .icon-inner svg')).toHaveCount(1);
|
||||
});
|
||||
|
||||
test('should not let a src forge the unsanitized cache key', async ({ page }) => {
|
||||
const shared = utf8DataUrl(imageOnErrorSvg('shared'));
|
||||
|
||||
await addIcon(page, 'unsanitized', shared, false);
|
||||
await page.waitForFunction(() => (window as any).xssFired.includes('shared'));
|
||||
|
||||
await addIcon(page, 'sanitized', `unsanitized:${shared}`);
|
||||
await addIcon(page, 'control', utf8DataUrl(imageOnErrorSvg('control')), false);
|
||||
await waitForControl(page);
|
||||
|
||||
await expect(page.locator('#sanitized .icon-inner svg')).toHaveCount(0);
|
||||
expect((await getFired(page)).filter((label) => label === 'shared')).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('should not reuse an unsanitized in-flight fetch for the same url', async ({ page }) => {
|
||||
await page.route('**/xss/*.svg', (route) => {
|
||||
const label = route.request().url().includes('control') ? 'control' : 'shared';
|
||||
// Sanitizing drops the <img> sibling and keeps the clean <svg>
|
||||
route.fulfill({
|
||||
contentType: 'image/svg+xml',
|
||||
body: `<img src="x" onerror="window.xssFired.push('${label}')"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0h24v24H0z"/></svg>`,
|
||||
});
|
||||
});
|
||||
|
||||
await addIcon(page, 'unsanitized', '/xss/shared.svg', false);
|
||||
await addIcon(page, 'sanitized', '/xss/shared.svg');
|
||||
await addIcon(page, 'control', '/xss/control.svg', false);
|
||||
await waitForControl(page);
|
||||
await page.waitForFunction(() => (window as any).xssFired.includes('shared'));
|
||||
|
||||
await expect(page.locator('#sanitized .icon-inner svg path')).toHaveCount(1);
|
||||
await expect(page.locator('#sanitized .icon-inner img')).toHaveCount(0);
|
||||
expect((await getFired(page)).filter((label) => label === 'shared')).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 19 KiB |
@@ -0,0 +1,37 @@
|
||||
<!doctype html>
|
||||
<html dir="ltr" lang="en" mode="ios">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
|
||||
<title>Icon - Sanitization</title>
|
||||
<script type="module" src="/build/ionicons.esm.js"></script>
|
||||
<script nomodule src="/build/ionicons.js"></script>
|
||||
<link rel="stylesheet" href="../styles.css" />
|
||||
<script src="../header.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<test-header></test-header>
|
||||
|
||||
<main>
|
||||
<h1>Icon - Sanitization</h1>
|
||||
|
||||
<h2>Sanitized (shouldn't show)</h2>
|
||||
<ion-icon src="/icon/assets/sanitize.svg"></ion-icon>
|
||||
|
||||
<h2>Not Sanitized (should show)</h2>
|
||||
<ion-icon sanitize="false" src="/icon/assets/no-sanitize.svg"></ion-icon>
|
||||
|
||||
<h2>Base64 URL</h2>
|
||||
<ion-icon
|
||||
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSJub25lIiBkPSJNMCAwaDI0djI0SDBWMHoiLz48cGF0aCBkPSJNMjAgMkg0Yy0xLjEgMC0yIC45LTIgMnYxOGw0LTRoMTRjMS4xIDAgMi0uOSAyLTJWNGMwLTEuMS0uOS0yLTItMnptMCAxNEg2bC0yIDJWNGgxNnYxMnoiLz48L3N2Zz4="
|
||||
></ion-icon>
|
||||
</main>
|
||||
|
||||
<style>
|
||||
ion-icon {
|
||||
font-size: 32px;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,40 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { test } from '@utils/test/playwright';
|
||||
|
||||
test.describe('icon: size', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto(`/icon/test/size/`);
|
||||
});
|
||||
|
||||
test('should scale the icon based on the size property', async ({ page }) => {
|
||||
// Wait for all SVGs to be lazily loaded before taking screenshots
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
const main = page.locator('main');
|
||||
await expect(main).toHaveScreenshot(`icon-size.png`);
|
||||
});
|
||||
|
||||
test('size prop should apply correct font-size to SVG icons', async ({ page }) => {
|
||||
// Wait for all SVGs to be lazily loaded
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
const icons = page.locator('ion-icon[name="heart"]');
|
||||
|
||||
// Default size is 16px, small is 18px, large is 32px
|
||||
expect(await icons.nth(0).evaluate((el) => window.getComputedStyle(el).fontSize)).toBe('16px');
|
||||
expect(await icons.nth(1).evaluate((el) => window.getComputedStyle(el).fontSize)).toBe('18px');
|
||||
expect(await icons.nth(2).evaluate((el) => window.getComputedStyle(el).fontSize)).toBe('32px');
|
||||
});
|
||||
|
||||
test('size prop should apply correct font-size to font icons', async ({ page }) => {
|
||||
// Wait for document fonts to be ready
|
||||
await page.evaluate(() => document.fonts.ready);
|
||||
|
||||
const icons = page.locator('ion-icon:not([name])');
|
||||
|
||||
// Default size is 16px, small is 18px, large is 32px
|
||||
expect(await icons.nth(0).evaluate((el) => window.getComputedStyle(el).fontSize)).toBe('16px');
|
||||
expect(await icons.nth(1).evaluate((el) => window.getComputedStyle(el).fontSize)).toBe('18px');
|
||||
expect(await icons.nth(2).evaluate((el) => window.getComputedStyle(el).fontSize)).toBe('32px');
|
||||
});
|
||||
});
|
||||
|
After Width: | Height: | Size: 9.2 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1,39 @@
|
||||
<!doctype html>
|
||||
<html dir="ltr" lang="en" mode="ios">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
|
||||
<title>Icon - Size</title>
|
||||
<script type="module" src="/build/ionicons.esm.js"></script>
|
||||
<script nomodule src="/build/ionicons.js"></script>
|
||||
<link rel="stylesheet" href="../styles.css" />
|
||||
<script src="../header.js"></script>
|
||||
|
||||
<!-- Font Awesome Icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<test-header></test-header>
|
||||
|
||||
<main>
|
||||
<h1>Icon - Size</h1>
|
||||
|
||||
<h2>Default Icons</h2>
|
||||
<ion-icon name="heart"></ion-icon>
|
||||
<ion-icon name="heart" size="small"></ion-icon>
|
||||
<ion-icon name="heart" size="large"></ion-icon>
|
||||
|
||||
<h2>Font Icons</h2>
|
||||
<ion-icon>
|
||||
<i class="fa fa-heart"></i>
|
||||
</ion-icon>
|
||||
<ion-icon size="small">
|
||||
<i class="fa fa-heart"></i>
|
||||
</ion-icon>
|
||||
<ion-icon size="large">
|
||||
<i class="fa fa-heart"></i>
|
||||
</ion-icon>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||