Skip to content

Commit ff6e030

Browse files
authored
feat(icon): make fontface import and icons optional separately
This PR allows to create some icon groups on demand by the usual switches in variation.variables and make the font-face loading optional and independent of the icon declarations themselves. It is now possible to move the font-face loading out of fomantic ui in favor of loading the fonts separately via a 3rd party lib such as typekit/webfontloader To keep consistency, the creation of brand and outline icons are now also separated into creating the icons and loading the fontface. Because of this logic the usage of the variable importOutlineIcons and importBrancIcons (and the new importIcons) now only applies for the font-face loading and creation of icons is dependent on the new variationIconBrand and variationIconOutline switches It's a breaking change, but it's a more consistent logic. Related PR for the icon creation script is fomantic/create-fomantic-icons#108
1 parent ef6ccc4 commit ff6e030

File tree

4 files changed

+53
-38
lines changed

4 files changed

+53
-38
lines changed

src/definitions/elements/icon.less

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@
2222
/*******************************
2323
Icon
2424
*******************************/
25-
26-
@font-face {
27-
font-family: 'Icons';
28-
src: @fallbackSRC;
29-
src: @src;
30-
font-style: normal;
31-
font-weight: @normal;
32-
font-variant: normal;
33-
text-decoration: inherit;
34-
text-transform: none;
25+
& when (@importIcons) {
26+
@font-face {
27+
font-family: 'Icons';
28+
src: @fallbackSRC;
29+
src: @src;
30+
font-style: normal;
31+
font-weight: @normal;
32+
font-variant: normal;
33+
text-decoration: inherit;
34+
text-transform: none;
35+
}
3536
}
3637

3738
i.icon {

src/themes/default/elements/icon.overrides

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Icons are order A-Z in their group, Solid, Outline, Thin (Pro only) and Brand
3131
/*******************************
3232
Icons
3333
*******************************/
34-
34+
& when(@variationIconDeprecated) {
3535
/* Deprecated *In/Out Naming Conflict) */
3636
i.icon.linkedin.in:before { content: "\f0e1"; }
3737
i.icon.zoom.in:before { content: "\f00e"; }
@@ -40,8 +40,9 @@ i.icon.sign.in:before { content: "\f2f6"; }
4040
i.icon.in.cart:before { content: "\f218"; }
4141
i.icon.log.out:before { content: "\f2f5"; }
4242
i.icon.sign.out:before { content: "\f2f5"; }
43+
}
4344

44-
45+
& when(@variationIconSolid) {
4546
/*******************************
4647
Solid Icons
4748
*******************************/
@@ -1043,7 +1044,9 @@ i.icon.wrench:before { content: "\f0ad"; }
10431044
i.icon.x.ray:before { content: "\f497"; }
10441045
i.icon.yen.sign:before { content: "\f157"; }
10451046
i.icon.yin.yang:before { content: "\f6ad"; }
1047+
}
10461048

1049+
& when(@variationIconAliases) {
10471050
/* Aliases */
10481051
i.icon.add:before { content: "\f067"; }
10491052
i.icon.add.circle:before { content: "\f055"; }
@@ -1335,23 +1338,26 @@ i.icon.zip:before { content: "\f187"; }
13351338
i.icon.zoom:before { content: "\f00e"; }
13361339
i.icon.zoom.in:before { content: "\f00e"; }
13371340
i.icon.zoom.out:before { content: "\f010"; }
1341+
}
13381342

1343+
& when (@variationIconOutline) {
13391344
/*******************************
13401345
Outline Icons
13411346
*******************************/
13421347

13431348
/* Outline Icon */
1344-
.loadOutlineIcons() when (@importOutlineIcons) {
1345-
/* Load & Define Icon Font */
1346-
@font-face {
1347-
font-family: @outlineFontName;
1348-
src: @outlineFallbackSRC;
1349-
src: @outlineSrc;
1350-
font-style: normal;
1351-
font-weight: @normal;
1352-
font-variant: normal;
1353-
text-decoration: inherit;
1354-
text-transform: none;
1349+
& when (@importOutlineIcons) {
1350+
/* Load & Define Icon Font */
1351+
@font-face {
1352+
font-family: @outlineFontName;
1353+
src: @outlineFallbackSRC;
1354+
src: @outlineSrc;
1355+
font-style: normal;
1356+
font-weight: @normal;
1357+
font-variant: normal;
1358+
text-decoration: inherit;
1359+
text-transform: none;
1360+
}
13551361
}
13561362

13571363
i.icon.outline {
@@ -1514,25 +1520,26 @@ i.icon.zoom.out:before { content: "\f010"; }
15141520

15151521

15161522
}
1517-
.loadOutlineIcons();
15181523

15191524

15201525

1526+
& when (@variationIconBrand) {
15211527
/*******************************
15221528
Brand Icons
15231529
*******************************/
15241530

1525-
.loadBrandIcons() when (@importBrandIcons) {
1526-
/* Load & Define Brand Font */
1527-
@font-face {
1528-
font-family: @brandFontName;
1529-
src: @brandFallbackSRC;
1530-
src: @brandSrc;
1531-
font-style: normal;
1532-
font-weight: @normal;
1533-
font-variant: normal;
1534-
text-decoration: inherit;
1535-
text-transform: none;
1531+
& when (@importBrandIcons) {
1532+
/* Load & Define Brand Font */
1533+
@font-face {
1534+
font-family: @brandFontName;
1535+
src: @brandFallbackSRC;
1536+
src: @brandSrc;
1537+
font-style: normal;
1538+
font-weight: @normal;
1539+
font-variant: normal;
1540+
text-decoration: inherit;
1541+
text-transform: none;
1542+
}
15361543
}
15371544

15381545
/* Icons */
@@ -1978,8 +1985,8 @@ i.icon.zoom.out:before { content: "\f010"; }
19781985
i.icon.youtube:before { content: "\f167"; font-family: @brandFontName; }
19791986
i.icon.youtube.square:before { content: "\f431"; font-family: @brandFontName; }
19801987
i.icon.zhihu:before { content: "\f63f"; font-family: @brandFontName; }
1981-
19821988

1989+
& when(@variationIconAliases) {
19831990
/* Aliases */
19841991
i.icon.american.express:before { content: "\f1f3"; font-family: @brandFontName; }
19851992
i.icon.american.express.card:before { content: "\f1f3"; font-family: @brandFontName; }
@@ -2033,6 +2040,6 @@ i.icon.zoom.out:before { content: "\f010"; }
20332040
i.icon.yc:before { content: "\f23b"; font-family: @brandFontName; }
20342041
i.icon.ycombinator:before { content: "\f23b"; font-family: @brandFontName; }
20352042
i.icon.youtube.play:before { content: "\f167"; font-family: @brandFontName; }
2036-
2043+
}
20372044
}
2038-
.loadBrandIcons();
2045+

src/themes/default/elements/icon.variables

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
---------------*/
88

99
/* Solid Icons */
10+
@importIcons: true;
1011
@fontName: 'icons';
1112
@src:
1213
url("@{fontPath}/@{fontName}.eot?#iefix") format('embedded-opentype'),

src/themes/default/globals/variation.variables

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@
6464
@variationHeaderSizes: @variationAllSizes;
6565

6666
/* Icon */
67+
@variationIconDeprecated: true;
68+
@variationIconSolid: true;
69+
@variationIconAliases: true;
70+
@variationIconOutline: true;
71+
@variationIconBrand: true;
72+
@variationIconThin: true; /* Font Awesome Pro only */
6773
@variationIconDisabled: true;
6874
@variationIconInverted: true;
6975
@variationIconLoading: true;

0 commit comments

Comments
 (0)