functions.scss 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv@protonmail.com)
  3. *
  4. * @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  5. *
  6. * @license GNU AGPL version 3 or any later version
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * SVG COLOR API
  24. *
  25. * @param string $icon the icon filename
  26. * @param string $dir the icon folder within /core/img if $core or app name
  27. * @param string $color the desired color in hexadecimal
  28. * @param int $version the version of the file
  29. * @param bool [$core] search icon in core
  30. *
  31. * @returns string the url to the svg api endpoint
  32. */
  33. @mixin icon-color($icon, $dir, $color, $version: 1, $core: false) {
  34. // remove # from color
  35. // inspect cast int to string
  36. $index: str-index(inspect($color), '#');
  37. @if $index {
  38. $color: str-slice(inspect($color), 2);
  39. }
  40. $varName: "--icon-#{$icon}-#{$color}";
  41. @if $core {
  42. #{$varName}: url('#{$webroot}/svg/core/#{$dir}/#{$icon}/#{$color}?v=#{$version}');
  43. } @else {
  44. #{$varName}: url('#{$webroot}/svg/#{$dir}/#{$icon}/#{$color}?v=#{$version}');
  45. }
  46. background-image: var(#{$varName});
  47. }
  48. /**
  49. * Create black and white icons
  50. * This will add a default black version of and an additional white version when .icon-white is applied
  51. */
  52. @mixin icon-black-white($icon, $dir, $version, $core: false) {
  53. .icon-#{$icon} {
  54. @include icon-color($icon, $dir, $color-black, $version, $core);
  55. }
  56. .icon-#{$icon}-white,
  57. .icon-#{$icon}.icon-white {
  58. @include icon-color($icon, $dir, $color-white, $version, $core);
  59. }
  60. }
  61. @mixin position($value) {
  62. @if $value == 'sticky' {
  63. position: -webkit-sticky; // Safari support
  64. position: sticky;
  65. } @else {
  66. position: $value;
  67. }
  68. }