-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Font Loading Strategy * default the loaded fonts (in case we load multiple instances) check for “not true” instead of “false” (default or un-instanced states can be true, false, null, default or a string). I specifically want to check for the absence of a “true” boolean setting) add a case for when we are passing this mixin a straight string or variable. Separate internal functions into stand-alone files (shea, we may need some discussion if a component contains variables, strings and functions, maybe we can instance this inside a parent folder that has it’s own structure? flatten out the list
- Loading branch information
1 parent
31277b4
commit 6a4d951
Showing
44 changed files
with
2,071 additions
and
2,320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@charset "UTF-8"; | ||
|
||
/// @access private | ||
/// Checks the global variable for loaded fonts | ||
@function _check-loaded-font($url) { | ||
$_value: index($loaded-fonts, $url); | ||
@if type-of($_value) == number { | ||
@return true; | ||
} | ||
@return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@charset "UTF-8"; | ||
|
||
/// @access private | ||
/// Internal function to keep track of loaded fonts | ||
/// so we don't duplicate calls. | ||
@function _log-loaded-font($url) { | ||
$loaded-fonts: append($loaded-fonts, $url, comma) !global; | ||
@return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,5 @@ | |
, 'material-shadow' | ||
, 'font-size' | ||
, 'on-event' | ||
, 'load-fonts' | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
@charset 'UTF-8'; | ||
|
||
//// | ||
/// Font loading function. | ||
/// @group functions | ||
//// | ||
|
||
/// Global default fonts. | ||
$fonts: () !default; | ||
|
||
/// Keeps track of already loaded fonts. | ||
$loaded-fonts: () !default; | ||
|
||
/// Load a collection of @font-face fonts | ||
/// | ||
@mixin load-fonts($load: $fonts) { | ||
|
||
// String | ||
@if type-of($load) == string { | ||
// Cast the item to a string to be sure we don't pass | ||
// strange variables to the loader. | ||
$_item_string: '#{$load}'; | ||
@if (_is-loaded_font($_item_string) != true) { | ||
$_tmp: _log-loaded-font($_item_string); | ||
$_item_string: quote($_item_string); | ||
@import url($_item_string); | ||
} | ||
@else { | ||
@debug "Font: #{$_item_string} already loaded."; | ||
} | ||
// List | ||
} @else if type-of($load) == list { | ||
// Loop through each item in the passed in list. | ||
@each $_item in $load { | ||
// Cast the item to a string to be sure we don't pass | ||
// strange variables to the loader. | ||
$_item_string: '#{$_item}'; | ||
@if (_is-loaded_font($_item_string) != true) { | ||
$_tmp: _log-loaded-font($_item_string); | ||
$_item_string: quote($_item_string); | ||
@import url($_item_string); | ||
} | ||
@else { | ||
@debug "Font: #{$_item_string} already loaded."; | ||
} | ||
} | ||
// Map | ||
} @else if type-of($load) == map { | ||
// Loop through each item in the passed in map. | ||
@each $_index, $_item in $load { | ||
@each $_font in $_item { | ||
// Cast the item to a string to be sure we don't pass | ||
// strange variables to the loader. | ||
$_item_string: '#{$_font}'; | ||
@if (_is-loaded_font($_item_string) != true) { | ||
$_tmp: _log-loaded-font($_item_string); | ||
$_item_string: quote($_item_string); | ||
@import url($_item_string); | ||
} | ||
@else { | ||
@debug "Font: #{$_item_string} already loaded."; | ||
} | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.