scss.hbs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. $icon-font-path: '../fonts' !default;
  10. @font-face {
  11. font-family: $icon-font-family;
  12. src: url('#{$icon-font-path}/{{fontName}}.eot?#iefix') format('eot');
  13. }
  14. @font-face {
  15. font-family: $icon-font-family;
  16. src: url(data:application/font-woff;charset=utf-8;base64,BASE64_WOFF_FONT) format('woff'),
  17. url(data:application/x-font-ttf;charset=utf-8;base64,BASE64_TTF_FONT) format('truetype');
  18. font-weight: normal;
  19. font-style: normal;
  20. }
  21. // http://sass-lang.com/documentation/file.SASS_REFERENCE.html#maps
  22. $icons: (
  23. {{#each codepoints}}
  24. {{@key}}: '{{this}}',
  25. {{/each}}
  26. );
  27. // NOTE: This is as complex as we want to get with SCSS functionality.
  28. //
  29. // Now that we have a map of icons above, we can iterate over that map and create an icon class
  30. // for each icon in that list. The iterator below produces CSS classes like this:
  31. //
  32. // .vjs-icon-play {
  33. // font-family: VideoJS;
  34. // font-weight: normal;
  35. // font-style: normal;
  36. // }
  37. // .vjs-icon-play:before { content: "\25b6"; }
  38. //
  39. // We can then use @extend in the codebase when we need to add an icon to a class. @extend builds up
  40. // the selectors for you so you can avoid duplication. This is generally a bad idea, but since each
  41. // icon should only be extended one or two other places, we'll roll with it.
  42. @each $name, $content in $icons {
  43. .vjs-icon-#{$name} {
  44. font-family: $icon-font-family;
  45. font-weight: normal;
  46. font-style: normal;
  47. &:before {
  48. content: char($content);
  49. }
  50. }
  51. }