Problem/Motivation
The tablesort indicator #2840304: Add tablesort_indicator template to utilize glyphicons issue shows an inflexibility of the CSS classes that should be solved. It would be useful if we are also able to add the icon-after and icon-before classes the the icon span itself.
In the theme the icon-after CSS class is missing from the tablesort link, but if we use thead to add margin-left to every glyphicon of a thead this is wrong as people may use glyphicon as column icons without a title.
Not working code:
<a href="/foo" title="Sort by name" class="active">Name<span title="Sort ascending"><span class="icon glyphicon glyphicon-chevron-up" aria-hidden="true"></span></span></a>
What is much more flexible and easier to implement is adding a class icon-after to the icon itself. This can be done in theme_tablesort_indicator().
<a href="/foo" title="Sort by name" class="active">Name<span title="Sort ascending"><span class="icon icon-after glyphicon glyphicon-chevron-up" aria-hidden="true"></span></span></a>
Aside from this theme_tablesort_indicator() need to be able to add something to attributes of bootstrap_icon() to add titles. So we finally should end up with this clean HTML code:
<a href="/foo" title="Sort by name" class="active">Name<span title="Sort ascending" class="icon icon-after glyphicon glyphicon-chevron-up" aria-hidden="true"></span></a>
Proposed resolution
_bootstrap_icon($name, $default = NULL) is prefixed with underscore. So this is officially not a public API function. I'd like to change this to _bootstrap_icon($variables = array()).
Remaining tasks
Write patch.
User interface changes
None
API changes
None. This is an internal function only.
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 2844885-6.patch | 4.14 KB | markhalliwell |
Comments
Comment #2
hass commentedComment #3
markhalliwellNo.
This would be a major BC break, regardless if it's "internal" or not (all existing implementations would have to change). I'd rather like to avoid that.
Instead, there should just be an additional
$attributesparameter added to the function signature, or better yet.... probably just a single$optionsparameter that could accommodate for any future growth.Comment #4
markhalliwellActually, this isn't needed in 8.x-3.x because Bootstrap::glyphicon returns a render array and one can easily add new attributes using Element::createStandalone, e.g. :
I'll add the extra
$attributesvariable to_bootstrap_iconin 7.x-3.x since we're nearing all feature freezes.Comment #5
markhalliwellBetter title
Comment #6
markhalliwell.