functions.scss 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. * @see core/src/icons.js
  24. */
  25. @function match-color-string($color) {
  26. @if $color == #000 {
  27. @return "dark";
  28. }
  29. @if $color == #fff {
  30. @return 'white';
  31. }
  32. @if $color == #FC0 {
  33. @return 'yellow';
  34. }
  35. @if $color == #e9322d {
  36. @return 'red';
  37. }
  38. @if $color == #eca700 {
  39. @return 'orange';
  40. }
  41. @if $color == #46ba61 {
  42. @return 'green';
  43. }
  44. @if $color == #969696 {
  45. @return 'grey';
  46. }
  47. @return $color;
  48. }
  49. /**
  50. * SVG COLOR API
  51. *
  52. * @param string $icon the icon filename
  53. * @param string $dir the icon folder within /core/img if $core or app name
  54. * @param string $color the desired color in hexadecimal
  55. * @param int $version the version of the file
  56. * @param bool [$core] search icon in core
  57. *
  58. * @returns A background image with the url to the set to the requested icon.
  59. */
  60. @mixin icon-color($icon, $dir, $color, $version: 1, $core: false) {
  61. $color: match-color-string($color);
  62. /* $dir is the app name, so we add this to the icon var to avoid conflicts between apps */
  63. $varName: "--icon-#{$icon}-#{$color}";
  64. background-image: var(#{$varName});
  65. }