_mixins.scss 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. @mixin breakpoint($point) {
  2. @if $point == 2x {
  3. @media (min-width:$size-2x) {
  4. @content;
  5. }
  6. } @else if $point == xl {
  7. @media (max-width: $size-xl) {
  8. @content;
  9. }
  10. } @else if $point == lg {
  11. @media (max-width: $size-lg) {
  12. @content;
  13. }
  14. } @else if $point == md {
  15. @media (max-width: $size-md) {
  16. @content;
  17. }
  18. } @else if $point == sm {
  19. @media (max-width: $size-sm) {
  20. @content;
  21. }
  22. } @else if $point == xs {
  23. @media (max-width: $size-xs) {
  24. @content;
  25. }
  26. } @else {
  27. @warn "Breakpoint mixin supports: xs, sm, md, lg, xl, 2x";
  28. }
  29. }
  30. @mixin vertical-align($position: relative) {
  31. position: $position;
  32. top: 50%;
  33. transform: translateY(-50%);
  34. }
  35. @mixin button-primary() {
  36. background: $primary-color;
  37. border-color: $primary-color-dark;
  38. color: $light-color;
  39. &:focus,
  40. &:hover {
  41. background: darken($primary-color-dark, 2%);
  42. border-color: darken($primary-color-dark, 5%);
  43. color: $light-color;
  44. }
  45. &:active,
  46. &.active {
  47. background: darken($primary-color-dark, 4%);
  48. border-color: darken($primary-color-dark, 7%);
  49. color: $light-color;
  50. }
  51. }
  52. @function strip-unit($value) {
  53. @return $value / ($value * 0 + 1);
  54. }
  55. @mixin fluid-type($min-vw, $max-vw, $min-font-size, $max-font-size) {
  56. $u1: unit($min-vw);
  57. $u2: unit($max-vw);
  58. $u3: unit($min-font-size);
  59. $u4: unit($max-font-size);
  60. @if $u1 == $u2 and $u1 == $u3 and $u1 == $u4 {
  61. & {
  62. font-size: $min-font-size;
  63. @media screen and (min-width: $min-vw) {
  64. font-size: calc(#{$min-font-size} + #{strip-unit($max-font-size - $min-font-size)} * ((100vw - #{$min-vw}) / #{strip-unit($max-vw - $min-vw)}));
  65. }
  66. @media screen and (min-width: $max-vw) {
  67. font-size: $max-font-size;
  68. }
  69. }
  70. }
  71. }