scss.hbs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // https://github.com/sass/sass/issues/659#issuecomment-64819075
  2. @function char($character-code) {
  3. @if function-exists("selector-append") {
  4. @return unquote("\"\\#{$character-code}\"");
  5. }
  6. @return str-slice("\x", 1, 1) + $character-code;
  7. }
  8. $icon-font-family: {{fontName}};
  9. @font-face {
  10. font-family: $icon-font-family;
  11. src: url(data:application/font-woff;charset=utf-8;base64,BASE64_WOFF_FONT) format('woff');
  12. font-weight: normal;
  13. font-style: normal;
  14. }
  15. // https://sass-lang.com/documentation/values/maps
  16. $icons: (
  17. {{#each codepoints}}
  18. {{@key}}: '{{this}}',
  19. {{/each}}
  20. );
  21. // NOTE: This is as complex as we want to get with SCSS functionality.
  22. //
  23. // Now that we have a map of icons above, we can iterate over that map and create an icon class
  24. // for each icon in that list. The iterator below produces CSS classes like this:
  25. //
  26. // .vjs-icon-play {
  27. // font-family: VideoJS;
  28. // font-weight: normal;
  29. // font-style: normal;
  30. // }
  31. // .vjs-icon-play:before { content: "\f101"; }
  32. //
  33. // We can then use @extend in the codebase when we need to add an icon to a class. @extend builds up
  34. // the selectors for you so you can avoid duplication. This is generally a bad idea, but since each
  35. // icon should only be extended one or two other places, we'll roll with it.
  36. @each $name, $content in $icons {
  37. .vjs-icon-#{$name} {
  38. font-family: $icon-font-family;
  39. font-weight: normal;
  40. font-style: normal;
  41. &:before {
  42. content: char($content);
  43. }
  44. }
  45. }