Blog-style website for karathan using the self-made Stellar Theme powered by HTML5Up http://blog.karathan.at

_functions.scss 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /// Removes a specific item from a list.
  2. /// @author Hugo Giraudel
  3. /// @param {list} $list List.
  4. /// @param {integer} $index Index.
  5. /// @return {list} Updated list.
  6. @function remove-nth($list, $index) {
  7. $result: null;
  8. @if type-of($index) != number {
  9. @warn "$index: #{quote($index)} is not a number for `remove-nth`.";
  10. }
  11. @else if $index == 0 {
  12. @warn "List index 0 must be a non-zero integer for `remove-nth`.";
  13. }
  14. @else if abs($index) > length($list) {
  15. @warn "List index is #{$index} but list is only #{length($list)} item long for `remove-nth`.";
  16. }
  17. @else {
  18. $result: ();
  19. $index: if($index < 0, length($list) + $index + 1, $index);
  20. @for $i from 1 through length($list) {
  21. @if $i != $index {
  22. $result: append($result, nth($list, $i));
  23. }
  24. }
  25. }
  26. @return $result;
  27. }
  28. /// Gets a value from a map.
  29. /// @author Hugo Giraudel
  30. /// @param {map} $map Map.
  31. /// @param {string} $keys Key(s).
  32. /// @return {string} Value.
  33. @function val($map, $keys...) {
  34. @if nth($keys, 1) == null {
  35. $keys: remove-nth($keys, 1);
  36. }
  37. @each $key in $keys {
  38. $map: map-get($map, $key);
  39. }
  40. @return $map;
  41. }
  42. /// Gets a duration value.
  43. /// @param {string} $keys Key(s).
  44. /// @return {string} Value.
  45. @function _duration($keys...) {
  46. @return val($duration, $keys...);
  47. }
  48. /// Gets a font value.
  49. /// @param {string} $keys Key(s).
  50. /// @return {string} Value.
  51. @function _font($keys...) {
  52. @return val($font, $keys...);
  53. }
  54. /// Gets a misc value.
  55. /// @param {string} $keys Key(s).
  56. /// @return {string} Value.
  57. @function _misc($keys...) {
  58. @return val($misc, $keys...);
  59. }
  60. /// Gets a palette value.
  61. /// @param {string} $keys Key(s).
  62. /// @return {string} Value.
  63. @function _palette($keys...) {
  64. @return val($palette, $keys...);
  65. }
  66. /// Gets a size value.
  67. /// @param {string} $keys Key(s).
  68. /// @return {string} Value.
  69. @function _size($keys...) {
  70. @return val($size, $keys...);
  71. }