_private.scss 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Checks if a number is even
  2. @function is-even($int) {
  3. @if $int%2 == 0 {
  4. @return true;
  5. }
  6. @return false;
  7. }
  8. // Checks if an element belongs to a list
  9. @function belongs-to($tested-item, $list) {
  10. @each $item in $list {
  11. @if $item == $tested-item {
  12. @return true;
  13. }
  14. }
  15. @return false;
  16. }
  17. // Contains display value
  18. @function contains-display-value($query) {
  19. @if belongs-to(table, $query) or belongs-to(block, $query) or belongs-to(inline-block, $query) or belongs-to(inline, $query) {
  20. @return true;
  21. }
  22. @return false;
  23. }
  24. // Parses the first argument of span-columns()
  25. @function container-span($span: $span) {
  26. @if length($span) == 3 {
  27. $container-columns: nth($span, 3);
  28. @return $container-columns;
  29. }
  30. @else if length($span) == 2 {
  31. $container-columns: nth($span, 2);
  32. @return $container-columns;
  33. }
  34. @else {
  35. @return $grid-columns;
  36. }
  37. }
  38. @function container-shift($shift: $shift) {
  39. $parent-columns: $grid-columns !global !default;
  40. @if length($shift) == 3 {
  41. $container-columns: nth($shift, 3);
  42. @return $container-columns;
  43. }
  44. @else if length($shift) == 2 {
  45. $container-columns: nth($shift, 2);
  46. @return $container-columns;
  47. }
  48. @else {
  49. @return $parent-columns;
  50. }
  51. }
  52. // Generates a striped background
  53. @function gradient-stops($grid-columns, $color: $visual-grid-color) {
  54. $transparent: rgba(0,0,0,0);
  55. $column-width: flex-grid(1, $grid-columns);
  56. $gutter-width: flex-gutter($grid-columns);
  57. $column-offset: $column-width;
  58. $values: ($transparent 0, $color 0);
  59. @for $i from 1 to $grid-columns*2 {
  60. @if is-even($i) {
  61. $values: append($values, $transparent $column-offset, comma);
  62. $values: append($values, $color $column-offset, comma);
  63. $column-offset: $column-offset + $column-width;
  64. }
  65. @else {
  66. $values: append($values, $color $column-offset, comma);
  67. $values: append($values, $transparent $column-offset, comma);
  68. $column-offset: $column-offset + $gutter-width;
  69. }
  70. }
  71. @return $values;
  72. }
  73. // Layout direction
  74. @function get-direction($layout, $default) {
  75. $direction: nil;
  76. @if $layout == LTR or $layout == RTL {
  77. $direction: direction-from-layout($layout);
  78. } @else {
  79. $direction: direction-from-layout($default);
  80. }
  81. @return $direction;
  82. }
  83. @function direction-from-layout($layout) {
  84. $direction: nil;
  85. @if $layout == LTR {
  86. $direction: right;
  87. } @else {
  88. $direction: left;
  89. }
  90. @return $direction;
  91. }
  92. @function get-opposite-direction($direction) {
  93. $opposite-direction: left;
  94. @if $direction == left {
  95. $opposite-direction: right;
  96. }
  97. @return $opposite-direction;
  98. }