-
Notifications
You must be signed in to change notification settings - Fork 80
Description
In similar spirit to videojs/video.js#1880.
@each $name, $content in $icons {
.vjs-icon-#{$name} {
font-family: $icon-font-family;
font-weight: normal;
font-style: normal;
&:before {
content: char($content);
}
}
}https://github.com/videojs/font/blob/master/scss/_icons.scss#L74
The code above specifies the font-family for every icon—making overriding difficult. My recommendation would be to separate that out and have a mixin be created to include the font-family and associated props only when needed.
For controls such as play/pause or volume-0/volume-1/volume-2/volume-3, it really only requires the inclusion of the font-family on the control button. However, due to specificity rules I need to override everyone of them.
/// @name VideoJS Volume
:global(.vjs-volume-menu-button)
{
:global(.video-js) &
{
@include icon-font;
&::before
{
content: $icon-volume-3;
}
&:global(.vjs-vol-0)
{
@include icon-font;
&::before
{
content: $icon-volume-off;
}
}
&:global(.vjs-vol-1)
{
@include icon-font;
&::before
{
content: $icon-volume-1;
}
}
&:global(.vjs-vol-2)
{
@include icon-font;
&::before
{
content: $icon-volume-2;
}
}
}
}Definitely not a 1:1 translation, but this is the way I manage custom icons.
/// Icon Font: <%= font_name %>
/// Font-face styles
@mixin icon-font-face {
<%= font_face(path: @font_path_alt) %>
}
/// Font styles
@mixin icon-font {
<%= glyph_properties %>
}
/// Font glyph
@mixin icon-glyph {
<%= glyphs %>
}
/// Font variables
<% @glyphs.each do |name, value| %>
$icon-<%= name.to_s %>: "\<%= value[:codepoint].to_s(16) %>";<% end %>I then have the flexibility to only include icon-font when necessary. Additionally, I need to add the appropriate content: $icon-{name}.