Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Converting SCSS icons variables to Map Array #12989

Closed
ghost opened this issue Apr 30, 2018 · 2 comments
Closed

Feature request: Converting SCSS icons variables to Map Array #12989

ghost opened this issue Apr 30, 2018 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 30, 2018

I made a test by switching the hundreds of variables in the icons.scss file to a single variable as a map array and noticed that the SCSS compilation process is a lot faster now. So I think it would be a good thing to update it.

For the information, I use a SCSS compilator on the websites I work on. It auto-compiles the SCSS that has been edited live on the client FTP. It is called scssphp.php.

Since I added the new Font Awesome 5 scss files, I noticed the compilator would take up to 20 seconds to compile my SCSS structure. Now that I use the map array, it compiles it in about 3 seconds.

I discovered this method in the new version of Bootstrap 4, that uses mostly map arrays.

Before

This is the initial code in _variables.scss:

$fa-var-500px: \f26e;
$fa-var-accessible-icon: \f368;
$fa-var-accusoft: \f369;
$fa-var-address-book: \f2b9;
$fa-var-address-card: \f2bb;
$fa-var-adjust: \f042;
[...]

And in the _icons.scss:

.#{$fa-css-prefix}-500px:before { content: fa-content($fa-var-500px); }
.#{$fa-css-prefix}-accessible-icon:before { content: fa-content($fa-var-accessible-icon); }
.#{$fa-css-prefix}-accusoft:before { content: fa-content($fa-var-accusoft); }
.#{$fa-css-prefix}-address-book:before { content: fa-content($fa-var-address-book); }
.#{$fa-css-prefix}-address-card:before { content: fa-content($fa-var-address-card); }
.#{$fa-css-prefix}-adjust:before { content: fa-content($fa-var-adjust); }
[...]

After

This is the new code in _variables.scss:

$fa-icons: () !default;
$fa-icons: map-merge((
'500px': '\f26e',
'accessible-icon': '\f368',
'accusoft': '\f369',
'address-book': '\f2b9',
'address-card': '\f2bb',
'adjust': '\f042',
[...]
), $fa-icons);

And in the _icons.scss:

@each $icon, $value in $fa-icons {
.#{$fa-css-prefix}-#{$icon}:before {content: $value;}
}

@tagliala
Copy link
Member

Hi!

Thanks for being part of the Font Awesome Community.

This request is a duplicate of #12312, please add a 👍 reaction to that PR.

Please make sure you search existing requests before opening new ones

Closing here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@tagliala and others