uniplaces / uniplaces-uniq

5 stars 0 forks source link

Create a conditional import for font faces #71

Open asantos00 opened 7 years ago

asantos00 commented 7 years ago

The main idea is to only import the fonts needed on each project (the same approach we do with the mixins, instead of exporting behaviour we don't need, only use what you want)

The main idea was to keep (like a registry) of the imported fonts

(Pseudo code below, it will have lots of errors and won't be complete)


$base-font-path : "fonts/"
$fonts : ();

@mixin font($name = "IntervalNextSemiBold") {
   $font-already-imported: map-get($fonts, $name);

   @if(!$font-already-imported) {
       $fonts : map-set($fonts, $name, true);
       @include font-face($name, "${$base-font-path}/intervalnext-semibold", null, null, woff2 woff eot);
   }

   @return "font-family: ${name}, sans-serif"   
}
asantos00 commented 7 years ago

http://stackoverflow.com/questions/13879042/import-in-if-statement-in-sass