_functions.scss 2.1 KB

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