site

personal website, served at mordaunt.dev/site
Log | Files | Refs

_functions.scss (2115B)


      1 // functions
      2 // --------------------------
      3 
      4 // fa-content: convenience function used to set content property
      5 @function fa-content($fa-var) {
      6   @return unquote("\"#{ $fa-var }\"");
      7 }
      8 
      9 // fa-divide: Originally obtained from the Bootstrap https://github.com/twbs/bootstrap
     10 //
     11 // Licensed under: The MIT License (MIT)
     12 //
     13 // Copyright (c) 2011-2021 Twitter, Inc.
     14 // Copyright (c) 2011-2021 The Bootstrap Authors
     15 //
     16 // Permission is hereby granted, free of charge, to any person obtaining a copy
     17 // of this software and associated documentation files (the "Software"), to deal
     18 // in the Software without restriction, including without limitation the rights
     19 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     20 // copies of the Software, and to permit persons to whom the Software is
     21 // furnished to do so, subject to the following conditions:
     22 //
     23 // The above copyright notice and this permission notice shall be included in
     24 // all copies or substantial portions of the Software.
     25 //
     26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     27 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     28 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     29 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     30 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     31 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     32 // THE SOFTWARE.
     33 
     34 @function fa-divide($dividend, $divisor, $precision: 10) {
     35   $sign: if($dividend > 0 and $divisor > 0, 1, -1);
     36   $dividend: abs($dividend);
     37   $divisor: abs($divisor);
     38   $quotient: 0;
     39   $remainder: $dividend;
     40   @if $dividend == 0 {
     41     @return 0;
     42   }
     43   @if $divisor == 0 {
     44     @error "Cannot divide by 0";
     45   }
     46   @if $divisor == 1 {
     47     @return $dividend;
     48   }
     49   @while $remainder >= $divisor {
     50     $quotient: $quotient + 1;
     51     $remainder: $remainder - $divisor;
     52   }
     53   @if $remainder > 0 and $precision > 0 {
     54     $remainder: fa-divide($remainder * 10, $divisor, $precision - 1) * .1;
     55   }
     56   @return ($quotient + $remainder) * $sign;
     57 }