Skip to content

Feature: Icon Mixins#4031

Open
crhallberg wants to merge 42 commits intovufind-org:devfrom
crhallberg:icon-mixins
Open

Feature: Icon Mixins#4031
crhallberg wants to merge 42 commits intovufind-org:devfrom
crhallberg:icon-mixins

Conversation

@crhallberg
Copy link
Contributor

@crhallberg crhallberg commented Oct 22, 2024

This is a fix for a few Font Awesome 6 icons spun out of control. If this is too much too soon, I can do a smaller version of this for v10.1 but editing bootstrap5/theme.config.php.

Just Before Merge

  • Add vendor files (gitignore)

@crhallberg crhallberg added this to the 11.0 milestone Oct 22, 2024
@crhallberg crhallberg self-assigned this Oct 22, 2024
@crhallberg crhallberg requested a review from EreMaijala October 22, 2024 15:34
Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crhallberg, I see that some tests are failing here -- is that a problem, or do the tests themselves need adjustment?

@crhallberg
Copy link
Contributor Author

Do we want to target this to release-10.1?

@demiankatz
Copy link
Member

Do we want to target this to release-10.1?

We can wait and see what @EreMaijala thinks...

@EreMaijala
Copy link
Contributor

@crhallberg I think it might be better to leave bootstrap3 as is. Otherwise it just adds a bit more maintenance burden for anyone upgrading and still using bootstrap3 as their base theme. It's not a huge deal though, but I'm just thinking that all the theme-related changes already add quite a bit of work.

@demiankatz
Copy link
Member

That's a good point, @EreMaijala -- if we leave this until 11.0, then bootstrap3 will be deleted anyway and it will be less to deal with. :-)

What do you think, @crhallberg? Are there changes here that are actively fixing a problem in the bootstrap5 theme, or is this more preventative?

@crhallberg
Copy link
Contributor Author

@demiankatz This is fixing some errors with the icon, since the classes are different from FA4 to FA6 (which BS5 uses). I used it as an excuse to create these mixins. If I was going to check every icon by hand, I may as well refactor, right? 😅

@demiankatz
Copy link
Member

@demiankatz This is fixing some errors with the icon, since the classes are different from FA4 to FA6 (which BS5 uses). I used it as an excuse to create these mixins. If I was going to check every icon by hand, I may as well refactor, right? 😅

In that case, would the solution be to create a PR that just changes the existing icon configuration in the bootstrap5 theme to incorporate your fixes (which I assume can be copied and pasted from the mixin here) and target that against 10.1? Then we don't have major refactoring at the last minute before the release but we can benefit immediately from your research... and this work can be developed in a more leisurely way as we move toward 11.0. :-)

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crhallberg, a couple of issues here:

1.) Looks like some tests are failing and/or throwing "no assertions" warnings. Is this on your radar?

2.) The very large number of changed/added files in this PR is causing GitHub to struggle, which makes reviewing difficult. Can we adapt the npm-based vendor file loading process from the themes to the mixins and then only copy over the pieces that are essential? I'm hoping that we don't actually need thousands of individual svgs. If this file load is unavoidable, maybe it's an argument for moving the non-default mixins to a separate repo so they can be optionally included without adding so much weight to the project.

@crhallberg crhallberg marked this pull request as ready for review September 8, 2025 16:50
Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @crhallberg! See below for the latest round of comments.

tests/phpcs.cache.json
themes/bootstrap5/scss/vendor/bootstrap
themes/mixin-icons-fontawesome-6/css/vendor
themes/mixin-icons-fontawesome-7/css/vendor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is .gitignore the only way to avoid thousands of files in these vendor directories? If so, this intersects with the discussions on #4591 about our general strategy for JS-adjacent dependencies. If not, can we just commit the smaller subset of needed files and not .gitignore vendor files at this time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove this right before we merge so that all the files are in place.

if (str_contains($icon, ':')) {
$parts = explode(':', $icon, 2);
$icon = $parts[0];
$class = str_replace('.', ' ', $parts[1]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this string replace? Is it worth adding a comment?

@@ -0,0 +1 @@
css/vendor/fontawesome-free-6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need both top-level and mixin-level .gitignore files, if we need .gitignore at all (as discussed above).

<?php
$class = trim('icon icon--text ' . ($this->extra['class'] ?? ''));
?>
<span class="<?=$this->escapeHtmlAttr($class) ?>"<?=$this->attrs ?> role="img" aria-hidden="true"><?=$this->escapeHtmlAttr($this->icon)?></span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using escapeHtmlAttr on the icon when it is outside of an HTML attribute?

$class = trim('icon icon--text icon--unicode ' . ($this->extra['class'] ?? ''));
?>
<span class="<?=$this->escapeHtmlAttr($className) ?>"<?=$this->attrs ?> role="img" aria-hidden="true" data-icon="&#x<?=$this->escapeHtmlAttr($this->icon)?>;"></span>
<span class="<?=$this->escapeHtmlAttr($class) ?>"<?=$this->attrs ?> role="img" aria-hidden="true">&#x<?=$this->escapeHtmlAttr($this->icon)?>;</span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another escapeHtmlAttr outside of an attribute.

@demiankatz
Copy link
Member

I've opened #4789 and reverted some minor changes here to make it easier to do side-by-side comparison of the new icons proposed here vs. the existing icons currently in the dev branch. The only thing that is currently preventing the icon lists from aligning correctly is the introduction of the right-to-left recall icon here; I wonder if we should reconsider that choice for easier comparison (and because I'm not sure if it's the most appropriate icon anyway).

@demiankatz
Copy link
Member

I've also opened #4790 to better display right-to-left icons in the dev tool; this will improve side-by-side comparisons even if we do not revert the recall changes mentioned in my previous comment.

@demiankatz demiankatz modified the milestones: 11.0, 11.1 Nov 4, 2025
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

Successfully merging this pull request may close these issues.

3 participants