SCSS Framework (Beta)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.6 KiB

8 months ago
  1. @use 'sass:list';
  2. @use 'sass:math';
  3. @mixin layout($direction, $bpColumns: [], $gap: (0 0)) {
  4. display: flex;
  5. justify-content: space-between;
  6. flex-direction: $direction;
  7. align-items: stretch;
  8. align-content: stretch;
  9. flex-wrap: wrap;
  10. column-gap: list.nth($gap, 1);
  11. row-gap: list.nth($gap, 2);
  12. @if list.length($bpColumns) > 0 {
  13. @for $bpIndex from 1 through list.length($bpColumns) {
  14. $bp: list.nth($bpColumns, $bpIndex);
  15. @include breakpoint('screen', list.nth($bp, 1), list.nth($bp, 2)) {
  16. $columns: list.nth($bp, 3);
  17. @for $i from 1 through list.length($columns) {
  18. $minmax: list.nth($columns, $i);
  19. $min: list.nth($minmax, 1);
  20. $max: list.nth($minmax, 2);
  21. & > *:nth-child(#{$i}) {
  22. @if math.unit($min) == "" and math.unit($max) == "" {
  23. flex: $max $min min-content;
  24. } @else if math.unit($min) == "" {
  25. flex: 1 $min auto;
  26. } @else if math.unit($max) == "" {
  27. flex: $max 0 auto;
  28. } @else {
  29. flex: 1 0 auto;
  30. }
  31. @if math.unit($min) != "" {
  32. @if $direction == 'row' {
  33. min-width: $min;
  34. } @else {
  35. min-height: $min;
  36. }
  37. }
  38. @if math.unit($max) != "" {
  39. @if $direction == 'row' {
  40. max-width: $max;
  41. } @else {
  42. max-height: $max;
  43. }
  44. }
  45. }
  46. }
  47. }
  48. }
  49. } @else {
  50. & > * {
  51. flex: 1 0 auto;
  52. }
  53. }
  54. }