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.

_mixins.scss 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /**
  2. * Animation mixin.
  3. */
  4. @mixin animation($animate...) {
  5. $max: length($animate);
  6. $animations: '';
  7. @for $i from 1 through $max {
  8. $animations: #{$animations + nth($animate, $i)};
  9. @if $i < $max {
  10. $animations: #{$animations + ", "};
  11. }
  12. }
  13. -webkit-animation: $animations;
  14. -moz-animation: $animations;
  15. -o-animation: $animations;
  16. animation: $animations;
  17. }
  18. @mixin flex() {
  19. display: -webkit-box;
  20. display: -moz-box;
  21. display: -ms-flexbox;
  22. display: -webkit-flex;
  23. display: flex;
  24. }
  25. /**
  26. * Keyframes mixin.
  27. */
  28. @mixin keyframes($animationName) {
  29. @-webkit-keyframes #{$animationName} {
  30. @content;
  31. }
  32. @-moz-keyframes #{$animationName} {
  33. @content;
  34. }
  35. @-o-keyframes #{$animationName} {
  36. @content;
  37. }
  38. @keyframes #{$animationName} {
  39. @content;
  40. }
  41. }
  42. @mixin circle($diameter) {
  43. width: $diameter;
  44. height: $diameter;
  45. border-radius: 50%;
  46. }
  47. /**
  48. * Absolute position the element at the top left corner
  49. **/
  50. @mixin topLeft() {
  51. position: absolute;
  52. top: 0;
  53. left: 0;
  54. }
  55. @mixin absoluteAligning() {
  56. top: 50%;
  57. left: 50%;
  58. position: absolute;
  59. @include transform(translate(-50%, -50%));
  60. }
  61. /**
  62. * Defines the maximum width and height
  63. **/
  64. @mixin maxSize($value) {
  65. max-width: $value;
  66. max-height: $value;
  67. }
  68. @mixin transform($func) {
  69. -moz-transform: $func;
  70. -ms-transform: $func;
  71. -webkit-transform: $func;
  72. -o-transform: $func;
  73. transform: $func;
  74. }
  75. @mixin transition($transition...) {
  76. -moz-transition: $transition;
  77. -o-transition: $transition;
  78. -webkit-transition: $transition;
  79. transition: $transition;
  80. }
  81. /**
  82. * Mixin styling a placeholder.
  83. **/
  84. @mixin placeholder() {
  85. $selectors: (
  86. "::-webkit-input-placeholder",
  87. "::-moz-placeholder",
  88. ":-moz-placeholder",
  89. ":-ms-input-placeholder"
  90. );
  91. @each $selector in $selectors {
  92. #{$selector} {
  93. @content;
  94. }
  95. }
  96. }
  97. /**
  98. * Mixin styling a slider track for different browsers.
  99. **/
  100. @mixin slider() {
  101. $selectors: (
  102. "input[type=range]::-webkit-slider-runnable-track",
  103. "input[type=range]::-moz-range-track",
  104. "input[type=range]::-ms-track"
  105. );
  106. @each $selector in $selectors {
  107. #{$selector} {
  108. @content;
  109. }
  110. }
  111. }
  112. /**
  113. * Mixin styling a slider thumb for different browsers.
  114. **/
  115. @mixin slider-thumb() {
  116. $selectors: (
  117. "input[type=range]::-webkit-slider-thumb",
  118. "input[type=range]::-moz-range-thumb",
  119. "input[type=range]::-ms-thumb"
  120. );
  121. @each $selector in $selectors {
  122. #{$selector} {
  123. @content;
  124. }
  125. }
  126. }
  127. @mixin box-shadow($h, $y, $blur, $color, $inset: false) {
  128. @if $inset {
  129. -webkit-box-shadow: inset $h $y $blur $color;
  130. -moz-box-shadow: inset $h $y $blur $color;
  131. box-shadow: inset $h $y $blur $color;
  132. } @else {
  133. -webkit-box-shadow: $h $y $blur $color;
  134. -moz-box-shadow: $h $y $blur $color;
  135. box-shadow: $h $y $blur $color;
  136. }
  137. }
  138. @mixin no-box-shadow {
  139. -webkit-box-shadow: none;
  140. -moz-box-shadow: none;
  141. box-shadow: none;
  142. }
  143. @mixin box-sizing($box-model) {
  144. -webkit-box-sizing: $box-model; // Safari <= 5
  145. -moz-box-sizing: $box-model; // Firefox <= 19
  146. box-sizing: $box-model;
  147. }
  148. @mixin border-radius($radius) {
  149. -webkit-border-radius: $radius;
  150. border-radius: $radius;
  151. /* stops bg color from leaking outside the border: */
  152. background-clip: padding-box;
  153. }
  154. @mixin opacity($opacity) {
  155. opacity: $opacity;
  156. $opacity-ie: $opacity * 100;
  157. -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=$opacity-ie);
  158. filter: alpha(opacity=$opacity-ie); //IE8
  159. }
  160. @mixin text-truncate {
  161. display: block;
  162. overflow: hidden;
  163. text-overflow: ellipsis;
  164. white-space: nowrap;
  165. }
  166. /**
  167. * Creates a semi-transparent background with the given color and alpha
  168. * (opacity) value.
  169. */
  170. @mixin transparentBg($color, $alpha) {
  171. background-color: rgba(red($color), green($color), blue($color), $alpha);
  172. }
  173. /**
  174. * Avatar status badge mixin
  175. */
  176. @mixin avatarBadge {
  177. border-radius: 50%;
  178. content: '';
  179. display: block;
  180. height: 35%;
  181. position: absolute;
  182. bottom: 0;
  183. width: 35%;
  184. }