_mixins-ui.scss 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /*--------------------------------------------------------------*/
  2. /* !## UI Mixins */
  3. /*--------------------------------------------------------------*/
  4. // Center block
  5. @mixin center-block {
  6. display: block;
  7. margin-left: auto;
  8. margin-right: auto;
  9. }
  10. @mixin vertical-align( $position: relative ) {
  11. position: $position;
  12. left: 50%;
  13. top: 50%;
  14. -webkit-transform: translateY(-50%);
  15. -ms-transform: translateY(-50%);
  16. transform: translateY(-50%);
  17. }
  18. @mixin center-align( $position: relative ) {
  19. position: $position;
  20. top: 50%;
  21. left: 50%;
  22. -webkit-transform: translate( -50%, -50% );
  23. -ms-transform: translate( -50%, -50% );
  24. transform: translate( -50%, -50% );
  25. }
  26. // Clearfix
  27. @mixin clearfix() {
  28. content: "";
  29. display: table;
  30. table-layout: fixed;
  31. }
  32. // Clear after (not all clearfix need this also)
  33. @mixin clearfix-after() {
  34. clear: both;
  35. }
  36. @mixin gutter-width( $width: $size_content, $gutter-width: $gutter ) {
  37. padding-left: ($gutter-width * .5);
  38. padding-right: ($gutter-width * .5);
  39. width: calc(#{$width});
  40. }
  41. // Button
  42. @mixin button($color: $color__link, $round: 30px) {
  43. @include list-item();
  44. @include rounded($round);
  45. background: $color__background-body;
  46. border: 1px solid;
  47. border-color: $color__border-transparent;
  48. box-shadow: 2px 4px 5px rgba(0, 0, 0, 0.25);
  49. color: $color__text-main;
  50. line-height: 1;
  51. outline: none;
  52. padding: 1em $gutter;
  53. -webkit-transition: all 0.3s ease;
  54. -moz-transition: all 0.3s ease;
  55. -o-transform: all 0.3s ease;
  56. -ms-transform: all 0.3s ease;
  57. transition: all 0.3s ease;
  58. &:hover {
  59. @include animation('bounce-reveal 0.3s cubic-bezier(0.645, 0.045, 0.355, 1)');
  60. background: $color;
  61. border-color: $color;
  62. color: $color__background-body;
  63. }
  64. &:active,
  65. &:focus {
  66. border-color: $color__border-button-focus;
  67. box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.125);
  68. -webkit-transform: scale(.925);
  69. -moz-transform: scale(.925);
  70. -o-transform: scale(.925);
  71. -ms-transform: scale(.925);
  72. transform: scale(.925);
  73. }
  74. }
  75. /**
  76. * Non obstructive border
  77. * - Src: http://stackoverflow.com/questions/11765642/sass-optimize-borders-into-one-line-of-code
  78. * - Usage: @include non-border(2px solid shade($ccblue, 10%), bottom, right);
  79. */
  80. @mixin non-border ($style, $sides...) {
  81. @if ( $style != "" ) {
  82. position: relative;
  83. &:before {
  84. content: "";
  85. position: absolute;
  86. z-index: 2;
  87. @if ($sides == "") {
  88. border: $style;
  89. } @else {
  90. @each $side in $sides {
  91. @if ($side == 'none') {
  92. border: none;
  93. }
  94. @if ($side == 'top' or
  95. $side == 'right' or
  96. $side == 'bottom' or
  97. $side == 'left') {
  98. border-#{$side}: $style;
  99. }
  100. @if ($side == 'top') {
  101. height: 0;
  102. top: 0;
  103. left: 0;
  104. width: 100%;
  105. }
  106. @if ($side == 'right') {
  107. height: 100%;
  108. top: 0;
  109. right: 0;
  110. left: inherit;
  111. width: 0;
  112. }
  113. @if ($side == 'bottom') {
  114. bottom: 0;
  115. height: 0;
  116. left: 0;
  117. width: 100%;
  118. }
  119. @if ($side == 'left') {
  120. height: 100%;
  121. left: 0;
  122. top: 0;
  123. right: inherit;
  124. width: 0;
  125. }
  126. }
  127. }
  128. }
  129. }
  130. }
  131. // Rounded Corners
  132. @mixin rounded($radius: 0.5em) {
  133. -webkit-border-radius: $radius;
  134. -moz-border-radius: $radius;
  135. border-radius: $radius;
  136. }
  137. // Rounded Bottom Corners
  138. @mixin rounded-bottom($radius: 0.5em) {
  139. -webkit-border-bottom-left-radius: $radius;
  140. -moz-border-bottom-left-radius: $radius;
  141. border-bottom-left-radius: $radius;
  142. -webkit-border-bottom-right-radius: $radius;
  143. -moz-border-bottom-right-radius: $radius;
  144. border-bottom-right-radius: $radius;
  145. }
  146. // Rounded Bottom Corners
  147. @mixin rounded-top($radius: 0.5em) {
  148. -webkit-border-top-left-radius: $radius;
  149. -moz-border-top-left-radius: $radius;
  150. border-top-left-radius: $radius;
  151. -webkit-border-top-right-radius: $radius;
  152. -moz-border-top-right-radius: $radius;
  153. border-top-right-radius: $radius;
  154. }
  155. // Rounded Paper
  156. @mixin paper($color: $color__border-button, $background: $color__background-body) {
  157. background: $background;
  158. border: 1px solid $color;
  159. @include rounded();
  160. overflow: hidden;
  161. }
  162. // Rounded Bottom Paper
  163. @mixin paperbottom($color: $color__border-button, $background: $color__background-body) {
  164. background: $background;
  165. border: 1px solid $color;
  166. @include rounded-bottom();
  167. overflow: hidden;
  168. }
  169. // Rounded Top Paper
  170. @mixin papertop($color: $color__border-button, $background: $color__background-body) {
  171. background: $background;
  172. border: 1px solid $color;
  173. @include rounded-top();
  174. overflow: hidden;
  175. }
  176. // Flat Paper
  177. @mixin paperflat($color: $color__border-button, $background: $color__background-body) {
  178. background: $background;
  179. border: 1px solid $color;
  180. overflow: hidden;
  181. }
  182. @mixin show-screen-reader-text() {
  183. clip: inherit;
  184. position: inherit !important;
  185. height: inherit;
  186. left: inherit;
  187. overflow: visible;
  188. width: inherit;
  189. }
  190. @mixin hide-this() {
  191. clip: rect(1px, 1px, 1px, 1px);
  192. position: absolute !important;
  193. height: 1px;
  194. width: 1px;
  195. overflow: hidden;
  196. &:focus {
  197. background-color: $color__background-screen;
  198. border-radius: 3px;
  199. box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
  200. clip: auto !important;
  201. color: $color__text-screen;
  202. display: block;
  203. @include font-size(0.875);
  204. font-weight: bold;
  205. height: auto;
  206. left: 5px;
  207. line-height: normal;
  208. padding: 15px 23px 14px;
  209. text-decoration: none;
  210. top: 5px;
  211. width: auto;
  212. z-index: 100000; /* Above WP toolbar. */
  213. }
  214. }
  215. @mixin linear-gradient( $top_color: rgba( 255, 255, 255, 0 ), $bottom_color: rgba( 0, 0, 0, .125 ) ) {
  216. /* Safari 4-5, Chrome 1-9 */
  217. background: -webkit-gradient( linear, 0% 0%, 0% 100%, from( #{ $bottom_color } ), to( #{ $top_color } ) );
  218. /* Safari 5.1, Chrome 10+ */
  219. background: -webkit-linear-gradient( top, $top_color, $bottom_color );
  220. /* Firefox 3.6+ */
  221. background: -moz-linear-gradient( top, $top_color, $bottom_color );
  222. /* IE 10 */
  223. background: -ms-linear-gradient( top, $top_color, $bottom_color );
  224. /* Opera 11.10+ */
  225. background: -o-linear-gradient( top, $top_color, $bottom_color );
  226. }