_mixins.scss 5.0 KB

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