_mixins.scss 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. @mixin themify($themes) {
  2. @each $theme, $map in $themes {
  3. .theme__#{$theme} & {
  4. $theme-map: () !global;
  5. @each $key, $submap in $map {
  6. $value: map-get(map-get($themes, $theme), "#{$key}");
  7. $theme-map: map-merge(
  8. $theme-map,
  9. (
  10. $key: $value
  11. )
  12. ) !global;
  13. }
  14. @content;
  15. $theme-map: null !global;
  16. }
  17. }
  18. }
  19. @mixin font-source-sans($size: false, $colour: false, $weight: false, $lh: false) {
  20. font-family: "Source Sans Pro", Helvetica, Arial, sans-serif;
  21. @if $size {
  22. font-size: $size;
  23. }
  24. @if $colour {
  25. color: $colour;
  26. }
  27. @if $weight {
  28. font-weight: $weight;
  29. }
  30. @if $lh {
  31. line-height: $lh;
  32. }
  33. }
  34. @mixin input-placeholder {
  35. &.placeholder {
  36. @content;
  37. }
  38. &:-moz-placeholder {
  39. @content;
  40. }
  41. &::-moz-placeholder {
  42. @content;
  43. }
  44. &:-ms-input-placeholder {
  45. @content;
  46. }
  47. &::-webkit-input-placeholder {
  48. @content;
  49. }
  50. }
  51. @mixin truncate($truncation-boundary) {
  52. white-space: nowrap;
  53. overflow: hidden;
  54. text-overflow: ellipsis;
  55. max-width: $truncation-boundary;
  56. }
  57. @mixin truncate2($truncation-boundary) {
  58. white-space: nowrap;
  59. overflow: hidden;
  60. text-overflow: ellipsis;
  61. width: $truncation-boundary;
  62. }
  63. @mixin box-shadow($top, $left, $blur, $size, $color, $inset: false) {
  64. @if $inset {
  65. -webkit-box-shadow: inset $top $left $blur $size $color;
  66. -moz-box-shadow: inset $top $left $blur $size $color;
  67. box-shadow: inset $top $left $blur $size $color;
  68. } @else {
  69. -webkit-box-shadow: $top $left $blur $size $color;
  70. -moz-box-shadow: $top $left $blur $size $color;
  71. box-shadow: $top $left $blur $size $color;
  72. }
  73. }
  74. @mixin on-event($self: false) {
  75. @if $self {
  76. &,
  77. &:hover,
  78. &:active,
  79. &:focus {
  80. @content;
  81. }
  82. } @else {
  83. &:hover,
  84. &:active,
  85. &:focus {
  86. @content;
  87. }
  88. }
  89. }
  90. @mixin transition($what: all, $time: 0.2s, $how: ease-in-out) {
  91. -webkit-transition: $what $time $how;
  92. -moz-transition: $what $time $how;
  93. -ms-transition: $what $time $how;
  94. -o-transition: $what $time $how;
  95. transition: $what $time $how;
  96. }
  97. // Browser Prefixes
  98. @mixin transform($transforms) {
  99. -webkit-transform: $transforms;
  100. -moz-transform: $transforms;
  101. -ms-transform: $transforms;
  102. transform: $transforms;
  103. }
  104. // Rotate
  105. @mixin rotate($deg) {
  106. @include transform(rotate(#{$deg}deg));
  107. }
  108. // Scale
  109. @mixin scale($scale) {
  110. @include transform(scale($scale));
  111. }
  112. @mixin scaleX($scale) {
  113. @include transform(scaleX($scale));
  114. }
  115. @mixin scaleY($scale) {
  116. @include transform(scaleY($scale));
  117. }
  118. // Translate
  119. @mixin translate($x, $y) {
  120. @include transform(translate($x, $y));
  121. }
  122. @mixin translateX($x) {
  123. @include transform(translateX($x));
  124. }
  125. @mixin translateY($y) {
  126. @include transform(translateY($y));
  127. }
  128. // Skew
  129. @mixin skew($x, $y) {
  130. @include transform(skew(#{$x}deg, #{$y}deg));
  131. }
  132. // Transform Origin
  133. @mixin transform-origin($origin) {
  134. -webkit-transform-origin: $origin;
  135. -moz-transform-origin: $origin;
  136. -ms-transform-origin: $origin;
  137. transform-origin: $origin;
  138. }
  139. @mixin keyframes($animation-name) {
  140. @-webkit-keyframes #{$animation-name} {
  141. @content;
  142. }
  143. @-moz-keyframes #{$animation-name} {
  144. @content;
  145. }
  146. @-ms-keyframes #{$animation-name} {
  147. @content;
  148. }
  149. @-o-keyframes #{$animation-name} {
  150. @content;
  151. }
  152. @keyframes #{$animation-name} {
  153. @content;
  154. }
  155. }
  156. @mixin animation($str) {
  157. -webkit-animation: #{$str};
  158. -moz-animation: #{$str};
  159. -ms-animation: #{$str};
  160. -o-animation: #{$str};
  161. animation: #{$str};
  162. }
  163. @mixin no-select {
  164. -webkit-touch-callout: none;
  165. -webkit-user-select: none;
  166. -khtml-user-select: none;
  167. -moz-user-select: none;
  168. -ms-user-select: none;
  169. user-select: none;
  170. }
  171. @mixin webkit-scrollbars($foreground-color, $background-color) {
  172. &::-webkit-scrollbar {
  173. width: 0.45em;
  174. height: 0.45em;
  175. }
  176. &::-webkit-scrollbar-thumb {
  177. background: $foreground-color;
  178. }
  179. &::-webkit-scrollbar-track {
  180. background: $background-color;
  181. }
  182. }
  183. @mixin webkit-scrollbars2($foreground-color, $background-color) {
  184. ::-webkit-scrollbar {
  185. width: 0.45em;
  186. height: 0.45em;
  187. }
  188. ::-webkit-scrollbar-thumb {
  189. background: $foreground-color;
  190. }
  191. ::-webkit-scrollbar-track {
  192. background: $background-color;
  193. }
  194. }
  195. @mixin moz-scrollbars($foreground-color, $background-color) {
  196. scrollbar-width: thin;
  197. scrollbar-color: $foreground-color $background-color;
  198. }
  199. @mixin clippy() {
  200. background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24pt" height="24pt" viewBox="0 0 24 24" version="1.1">
  201. <path style="stroke:none;fill-rule:nonzero;fill:rgb(100,100,100);fill-opacity:1;" d="M 4 2 C 2.894531 2 2 2.894531 2 4 L 2 17 C 2 17.550781 2.449219 18 3 18 C 3.550781 18 4 17.550781 4 17 L 4 4 L 17 4 C 17.550781 4 18 3.550781 18 3 C 18 2.449219 17.550781 2 17 2 Z M 8 6 C 6.894531 6 6 6.894531 6 8 L 6 20 C 6 21.105469 6.894531 22 8 22 L 20 22 C 21.105469 22 22 21.105469 22 20 L 22 8 C 22 6.894531 21.105469 6 20 6 Z M 8 8 L 20 8 L 20 20 L 8 20 Z M 8 8 "/></svg>');
  202. }