_mixins-master.scss 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // Rem output with px fallback
  2. @mixin font-size($sizeValue: 1) {
  3. font-size: ($sizeValue * 16) * 1px;
  4. font-size: $sizeValue * 1rem;
  5. }
  6. // Center block
  7. @mixin center-block {
  8. display: block;
  9. margin-left: auto;
  10. margin-right: auto;
  11. }
  12. // Clearfix
  13. @mixin clearfix() {
  14. content: "";
  15. display: table;
  16. table-layout: fixed;
  17. }
  18. // Clear after (not all clearfix need this also)
  19. @mixin clearfix-after() {
  20. clear: both;
  21. }
  22. // Column width with margin
  23. @mixin column-width($numberColumns: 3) {
  24. width: map-get($columns, $numberColumns) - (($columns__margin * ($numberColumns - 1)) / $numberColumns);
  25. }
  26. @mixin filter-duotone {
  27. &:before {
  28. background: $color__link;
  29. mix-blend-mode: screen;
  30. opacity: 0.1;
  31. z-index: 2;
  32. }
  33. &:after {
  34. background: $color__link;
  35. mix-blend-mode: multiply;
  36. opacity: .8;
  37. z-index: 3;
  38. /* Browsers supporting mix-blend-mode don't need opacity < 1 */
  39. @supports (mix-blend-mode: multiply) {
  40. opacity: 1;
  41. }
  42. }
  43. }
  44. @mixin filter-grayscale {
  45. position: relative;
  46. filter: grayscale(100%);
  47. z-index: 1;
  48. &:after {
  49. display: block;
  50. width: 100%;
  51. height: 100%;
  52. z-index: 10;
  53. }
  54. }
  55. @mixin post-section-dash {
  56. &:before {
  57. background: $color__text-light;
  58. content: "\020";
  59. display: block;
  60. height: 2px;
  61. margin: $size__spacing-unit 0;
  62. width: 1em;
  63. }
  64. }
  65. /* If we add the border using a regular CSS border, it won't look good on non-retina devices,
  66. * since its edges can look jagged due to lack of antialiasing. In this case, we are several
  67. * layers of box-shadow to add the border visually, which will render the border smoother. */
  68. @mixin box-shadow( $size ) {
  69. box-shadow:
  70. 0 0 0 $size $color__text-light inset, // Original border.
  71. 0 0 0 ($size + 1px) $color__text-light inset, // Antialiasing, inner edge.
  72. 0 0 1px 0 rgba( $color__text-light, 0.7 ); // Antialiasing, outer edge.
  73. }
  74. /* Calculates maximum width for post content */
  75. @mixin postContentMaxWidth() {
  76. @include media(tablet) {
  77. max-width: $size__site-tablet-content;
  78. }
  79. @include media(desktop) {
  80. max-width: $size__site-desktop-content;
  81. }
  82. }
  83. /* Nested sub-menu padding: 10 levels deep */
  84. @mixin nestedSubMenuPadding() {
  85. ul {
  86. counter-reset: submenu;
  87. }
  88. ul > li > a::before {
  89. font-family: $font__body;
  90. font-weight: normal;
  91. content: "\2013\00a0" counters(submenu, "\2013\00a0", none);
  92. counter-increment: submenu
  93. }
  94. }
  95. /* Ensure all font family declarations come with non-latin fallbacks */
  96. @mixin font-family( $font_family: $font__body ) {
  97. font-family: $font_family;
  98. }