_mixins.scss 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. // Button Mixins
  2. // --------------------------------------------------
  3. @mixin button-style($bg-color, $border-color, $active-bg-color, $active-border-color, $color) {
  4. border-color: $border-color;
  5. background-color: $bg-color;
  6. color: $color;
  7. // Give desktop users something to play with
  8. &:hover {
  9. color: $color;
  10. text-decoration: none;
  11. }
  12. &.active,
  13. &.activated {
  14. @if $active-border-color != ""{
  15. border-color: $active-border-color;
  16. }
  17. background-color: $active-bg-color;
  18. //box-shadow: inset 0 1px 4px rgba(0,0,0,0.1);
  19. }
  20. }
  21. @mixin button-clear($color, $font-size:"") {
  22. &.button-clear {
  23. border-color: transparent;
  24. background: none;
  25. box-shadow: none;
  26. color: $color;
  27. @if $font-size != "" {
  28. font-size: $font-size;
  29. }
  30. }
  31. &.button-icon {
  32. border-color: transparent;
  33. background: none;
  34. }
  35. }
  36. @mixin button-outline($color, $text-color:"") {
  37. &.button-outline {
  38. border-color: $color;
  39. background: transparent;
  40. @if $text-color == "" {
  41. $text-color: $color;
  42. }
  43. color: $text-color;
  44. &.active,
  45. &.activated {
  46. background-color: $color;
  47. box-shadow: none;
  48. color: #fff;
  49. }
  50. }
  51. }
  52. // Bar Mixins
  53. // --------------------------------------------------
  54. @mixin bar-style($bg-color, $border-color, $color) {
  55. border-color: $border-color;
  56. background-color: $bg-color;
  57. background-image: linear-gradient(0deg, $border-color, $border-color 50%, transparent 50%);
  58. color: $color;
  59. .title {
  60. color: $color;
  61. }
  62. }
  63. // Tab Mixins
  64. // --------------------------------------------------
  65. @mixin tab-style($bg-color, $border-color, $color) {
  66. border-color: $border-color;
  67. background-color: $bg-color;
  68. background-image: linear-gradient(0deg, $border-color, $border-color 50%, transparent 50%);
  69. color: $color;
  70. }
  71. @mixin tab-badge-style($bg-color, $color) {
  72. .tab-item .badge {
  73. background-color: $bg-color;
  74. color: $color;
  75. }
  76. }
  77. // Item Mixins
  78. // --------------------------------------------------
  79. @mixin item-style($bg-color, $border-color, $color) {
  80. border-color: $border-color;
  81. background-color: $bg-color;
  82. color: $color;
  83. }
  84. @mixin item-active-style($active-bg-color, $active-border-color) {
  85. border-color: $active-border-color;
  86. background-color: $active-bg-color;
  87. &.item-complex > .item-content {
  88. border-color: $active-border-color;
  89. background-color: $active-bg-color;
  90. }
  91. }
  92. // Badge Mixins
  93. // --------------------------------------------------
  94. @mixin badge-style($bg-color, $color) {
  95. background-color: $bg-color;
  96. color: $color;
  97. }
  98. // Range Mixins
  99. // --------------------------------------------------
  100. @mixin range-style($track-bg-color) {
  101. &::-webkit-slider-thumb:before {
  102. background: $track-bg-color;
  103. }
  104. &::-ms-fill-lower{
  105. background: $track-bg-color;
  106. }
  107. }
  108. // Checkbox Mixins
  109. // --------------------------------------------------
  110. @mixin checkbox-style($off-border-color, $on-bg-color, $on-border-color) {
  111. & input:before,
  112. & .checkbox-icon:before {
  113. border-color: $off-border-color;
  114. }
  115. // what the background looks like when its checked
  116. & input:checked:before,
  117. & input:checked + .checkbox-icon:before {
  118. background: $on-bg-color;
  119. border-color: $on-border-color;
  120. }
  121. }
  122. // Toggle Mixins
  123. // --------------------------------------------------
  124. @mixin toggle-style($on-border-color, $on-bg-color) {
  125. // the track when the toggle is "on"
  126. & input:checked + .track {
  127. border-color: $on-border-color;
  128. background-color: $on-bg-color;
  129. }
  130. }
  131. @mixin toggle-small-style($on-bg-color) {
  132. // the track when the toggle is "on"
  133. & input:checked + .track {
  134. background-color: rgba($on-bg-color, .5);
  135. }
  136. & input:checked + .track .handle {
  137. background-color: $on-bg-color;
  138. }
  139. }
  140. // Clearfix
  141. // --------------------------------------------------
  142. @mixin clearfix {
  143. *zoom: 1;
  144. &:before,
  145. &:after {
  146. display: table;
  147. content: "";
  148. line-height: 0;
  149. }
  150. &:after {
  151. clear: both;
  152. }
  153. }
  154. // Placeholder text
  155. // --------------------------------------------------
  156. @mixin placeholder($color: $input-color-placeholder, $text-indent: 0) {
  157. &::-moz-placeholder { // Firefox 19+
  158. color: $color;
  159. }
  160. &:-ms-input-placeholder {
  161. color: $color;
  162. }
  163. &::-webkit-input-placeholder {
  164. color: $color;
  165. // Safari placeholder margin issue
  166. text-indent: $text-indent;
  167. }
  168. }
  169. // Text Mixins
  170. // --------------------------------------------------
  171. @mixin text-size-adjust($value: none) {
  172. -webkit-text-size-adjust: $value;
  173. -moz-text-size-adjust: $value;
  174. text-size-adjust: $value;
  175. }
  176. @mixin tap-highlight-transparent() {
  177. -webkit-tap-highlight-color: rgba(0,0,0,0);
  178. -webkit-tap-highlight-color: transparent; // For some Androids
  179. }
  180. @mixin touch-callout($value: none) {
  181. -webkit-touch-callout: $value;
  182. }
  183. // Font Mixins
  184. // --------------------------------------------------
  185. @mixin font-family-serif() {
  186. font-family: $serif-font-family;
  187. }
  188. @mixin font-family-sans-serif() {
  189. font-family: $sans-font-family;
  190. }
  191. @mixin font-family-monospace() {
  192. font-family: $mono-font-family;
  193. }
  194. @mixin font-shorthand($size: $base-font-size, $weight: normal, $line-height: $base-line-height) {
  195. font-weight: $weight;
  196. font-size: $size;
  197. line-height: $line-height;
  198. }
  199. @mixin font-serif($size: $base-font-size, $weight: normal, $line-height: $base-line-height) {
  200. @include font-family-serif();
  201. @include font-shorthand($size, $weight, $line-height);
  202. }
  203. @mixin font-sans-serif($size: $base-font-size, $weight: normal, $line-height: $base-line-height) {
  204. @include font-family-sans-serif();
  205. @include font-shorthand($size, $weight, $line-height);
  206. }
  207. @mixin font-monospace($size: $base-font-size, $weight: normal, $line-height: $base-line-height) {
  208. @include font-family-monospace();
  209. @include font-shorthand($size, $weight, $line-height);
  210. }
  211. @mixin font-smoothing($font-smoothing) {
  212. -webkit-font-smoothing: $font-smoothing;
  213. font-smoothing: $font-smoothing;
  214. }
  215. // Appearance
  216. // --------------------------------------------------
  217. @mixin appearance($val) {
  218. -webkit-appearance: $val;
  219. -moz-appearance: $val;
  220. appearance: $val;
  221. }
  222. // Border Radius Mixins
  223. // --------------------------------------------------
  224. @mixin border-radius($radius) {
  225. -webkit-border-radius: $radius;
  226. border-radius: $radius;
  227. }
  228. // Single Corner Border Radius
  229. @mixin border-top-left-radius($radius) {
  230. -webkit-border-top-left-radius: $radius;
  231. border-top-left-radius: $radius;
  232. }
  233. @mixin border-top-right-radius($radius) {
  234. -webkit-border-top-right-radius: $radius;
  235. border-top-right-radius: $radius;
  236. }
  237. @mixin border-bottom-right-radius($radius) {
  238. -webkit-border-bottom-right-radius: $radius;
  239. border-bottom-right-radius: $radius;
  240. }
  241. @mixin border-bottom-left-radius($radius) {
  242. -webkit-border-bottom-left-radius: $radius;
  243. border-bottom-left-radius: $radius;
  244. }
  245. // Single Side Border Radius
  246. @mixin border-top-radius($radius) {
  247. @include border-top-right-radius($radius);
  248. @include border-top-left-radius($radius);
  249. }
  250. @mixin border-right-radius($radius) {
  251. @include border-top-right-radius($radius);
  252. @include border-bottom-right-radius($radius);
  253. }
  254. @mixin border-bottom-radius($radius) {
  255. @include border-bottom-right-radius($radius);
  256. @include border-bottom-left-radius($radius);
  257. }
  258. @mixin border-left-radius($radius) {
  259. @include border-top-left-radius($radius);
  260. @include border-bottom-left-radius($radius);
  261. }
  262. // Box shadows
  263. // --------------------------------------------------
  264. @mixin box-shadow($shadow...) {
  265. -webkit-box-shadow: $shadow;
  266. box-shadow: $shadow;
  267. }
  268. // Transition Mixins
  269. // --------------------------------------------------
  270. @mixin transition($transition...) {
  271. -webkit-transition: $transition;
  272. transition: $transition;
  273. }
  274. @mixin transition-delay($transition-delay) {
  275. -webkit-transition-delay: $transition-delay;
  276. transition-delay: $transition-delay;
  277. }
  278. @mixin transition-duration($transition-duration) {
  279. -webkit-transition-duration: $transition-duration;
  280. transition-duration: $transition-duration;
  281. }
  282. @mixin transition-timing-function($transition-timing) {
  283. -webkit-transition-timing-function: $transition-timing;
  284. transition-timing-function: $transition-timing;
  285. }
  286. @mixin transition-property($property) {
  287. -webkit-transition-property: $property;
  288. transition-property: $property;
  289. }
  290. @mixin transition-transform($properties...) {
  291. // special case cuz of transform vendor prefixes
  292. -webkit-transition: -webkit-transform $properties;
  293. transition: transform $properties;
  294. }
  295. // Animation Mixins
  296. // --------------------------------------------------
  297. @mixin animation($animation) {
  298. -webkit-animation: $animation;
  299. animation: $animation;
  300. }
  301. @mixin animation-duration($duration) {
  302. -webkit-animation-duration: $duration;
  303. animation-duration: $duration;
  304. }
  305. @mixin animation-direction($direction) {
  306. -webkit-animation-direction: $direction;
  307. animation-direction: $direction;
  308. }
  309. @mixin animation-timing-function($animation-timing) {
  310. -webkit-animation-timing-function: $animation-timing;
  311. animation-timing-function: $animation-timing;
  312. }
  313. @mixin animation-fill-mode($fill-mode) {
  314. -webkit-animation-fill-mode: $fill-mode;
  315. animation-fill-mode: $fill-mode;
  316. }
  317. @mixin animation-name($name...) {
  318. -webkit-animation-name: $name;
  319. animation-name: $name;
  320. }
  321. @mixin animation-iteration-count($count) {
  322. -webkit-animation-iteration-count: $count;
  323. animation-iteration-count: $count;
  324. }
  325. // Transformation Mixins
  326. // --------------------------------------------------
  327. @mixin rotate($degrees) {
  328. @include transform( rotate($degrees) );
  329. }
  330. @mixin scale($ratio) {
  331. @include transform( scale($ratio) );
  332. }
  333. @mixin translate($x, $y) {
  334. @include transform( translate($x, $y) );
  335. }
  336. @mixin skew($x, $y) {
  337. @include transform( skew($x, $y) );
  338. -webkit-backface-visibility: hidden;
  339. }
  340. @mixin translate3d($x, $y, $z) {
  341. @include transform( translate3d($x, $y, $z) );
  342. }
  343. @mixin translateZ($z) {
  344. @include transform( translateZ($z) );
  345. }
  346. @mixin transform($val) {
  347. -webkit-transform: $val;
  348. transform: $val;
  349. }
  350. @mixin transform-origin($left, $top) {
  351. -webkit-transform-origin: $left $top;
  352. transform-origin: $left $top;
  353. }
  354. // Backface visibility
  355. // --------------------------------------------------
  356. // Prevent browsers from flickering when using CSS 3D transforms.
  357. // Default value is `visible`, but can be changed to `hidden
  358. @mixin backface-visibility($visibility){
  359. -webkit-backface-visibility: $visibility;
  360. backface-visibility: $visibility;
  361. }
  362. // Background clipping
  363. // --------------------------------------------------
  364. @mixin background-clip($clip) {
  365. -webkit-background-clip: $clip;
  366. background-clip: $clip;
  367. }
  368. // Background sizing
  369. // --------------------------------------------------
  370. @mixin background-size($size) {
  371. -webkit-background-size: $size;
  372. background-size: $size;
  373. }
  374. // Box sizing
  375. // --------------------------------------------------
  376. @mixin box-sizing($boxmodel) {
  377. -webkit-box-sizing: $boxmodel;
  378. -moz-box-sizing: $boxmodel;
  379. box-sizing: $boxmodel;
  380. }
  381. // User select
  382. // --------------------------------------------------
  383. @mixin user-select($select) {
  384. -webkit-user-select: $select;
  385. -moz-user-select: $select;
  386. -ms-user-select: $select;
  387. user-select: $select;
  388. }
  389. // Content Columns
  390. // --------------------------------------------------
  391. @mixin content-columns($columnCount, $columnGap: $grid-gutter-width) {
  392. -webkit-column-count: $columnCount;
  393. -moz-column-count: $columnCount;
  394. column-count: $columnCount;
  395. -webkit-column-gap: $columnGap;
  396. -moz-column-gap: $columnGap;
  397. column-gap: $columnGap;
  398. }
  399. // Flexbox Mixins
  400. // --------------------------------------------------
  401. // http://philipwalton.github.io/solved-by-flexbox/
  402. // https://github.com/philipwalton/solved-by-flexbox
  403. @mixin display-flex {
  404. display: -webkit-box;
  405. display: -webkit-flex;
  406. display: -moz-box;
  407. display: -moz-flex;
  408. display: -ms-flexbox;
  409. display: flex;
  410. }
  411. @mixin display-inline-flex {
  412. display: -webkit-inline-box;
  413. display: -webkit-inline-flex;
  414. display: -moz-inline-flex;
  415. display: -ms-inline-flexbox;
  416. display: inline-flex;
  417. }
  418. @mixin flex-direction($value: row) {
  419. @if $value == row-reverse {
  420. -webkit-box-direction: reverse;
  421. -webkit-box-orient: horizontal;
  422. } @else if $value == column {
  423. -webkit-box-direction: normal;
  424. -webkit-box-orient: vertical;
  425. } @else if $value == column-reverse {
  426. -webkit-box-direction: reverse;
  427. -webkit-box-orient: vertical;
  428. } @else {
  429. -webkit-box-direction: normal;
  430. -webkit-box-orient: horizontal;
  431. }
  432. -webkit-flex-direction: $value;
  433. -moz-flex-direction: $value;
  434. -ms-flex-direction: $value;
  435. flex-direction: $value;
  436. }
  437. @mixin flex-wrap($value: nowrap) {
  438. // No Webkit Box fallback.
  439. -webkit-flex-wrap: $value;
  440. -moz-flex-wrap: $value;
  441. @if $value == nowrap {
  442. -ms-flex-wrap: none;
  443. } @else {
  444. -ms-flex-wrap: $value;
  445. }
  446. flex-wrap: $value;
  447. }
  448. @mixin flex($fg: 1, $fs: null, $fb: null) {
  449. -webkit-box-flex: $fg;
  450. -webkit-flex: $fg $fs $fb;
  451. -moz-box-flex: $fg;
  452. -moz-flex: $fg $fs $fb;
  453. -ms-flex: $fg $fs $fb;
  454. flex: $fg $fs $fb;
  455. }
  456. @mixin flex-flow($values: (row nowrap)) {
  457. // No Webkit Box fallback.
  458. -webkit-flex-flow: $values;
  459. -moz-flex-flow: $values;
  460. -ms-flex-flow: $values;
  461. flex-flow: $values;
  462. }
  463. @mixin align-items($value: stretch) {
  464. @if $value == flex-start {
  465. -webkit-box-align: start;
  466. -ms-flex-align: start;
  467. } @else if $value == flex-end {
  468. -webkit-box-align: end;
  469. -ms-flex-align: end;
  470. } @else {
  471. -webkit-box-align: $value;
  472. -ms-flex-align: $value;
  473. }
  474. -webkit-align-items: $value;
  475. -moz-align-items: $value;
  476. align-items: $value;
  477. }
  478. @mixin align-self($value: auto) {
  479. -webkit-align-self: $value;
  480. -moz-align-self: $value;
  481. @if $value == flex-start {
  482. -ms-flex-item-align: start;
  483. } @else if $value == flex-end {
  484. -ms-flex-item-align: end;
  485. } @else {
  486. -ms-flex-item-align: $value;
  487. }
  488. align-self: $value;
  489. }
  490. @mixin align-content($value: stretch) {
  491. -webkit-align-content: $value;
  492. -moz-align-content: $value;
  493. @if $value == flex-start {
  494. -ms-flex-line-pack: start;
  495. } @else if $value == flex-end {
  496. -ms-flex-line-pack: end;
  497. } @else {
  498. -ms-flex-line-pack: $value;
  499. }
  500. align-content: $value;
  501. }
  502. @mixin justify-content($value: stretch) {
  503. @if $value == flex-start {
  504. -webkit-box-pack: start;
  505. -ms-flex-pack: start;
  506. } @else if $value == flex-end {
  507. -webkit-box-pack: end;
  508. -ms-flex-pack: end;
  509. } @else if $value == space-between {
  510. -webkit-box-pack: justify;
  511. -ms-flex-pack: justify;
  512. } @else {
  513. -webkit-box-pack: $value;
  514. -ms-flex-pack: $value;
  515. }
  516. -webkit-justify-content: $value;
  517. -moz-justify-content: $value;
  518. justify-content: $value;
  519. }
  520. @mixin flex-order($n) {
  521. -webkit-order: $n;
  522. -ms-flex-order: $n;
  523. order: $n;
  524. -webkit-box-ordinal-group: $n;
  525. }
  526. @mixin responsive-grid-break($selector, $max-width) {
  527. @media (max-width: $max-width) {
  528. #{$selector} {
  529. -webkit-box-direction: normal;
  530. -moz-box-direction: normal;
  531. -webkit-box-orient: vertical;
  532. -moz-box-orient: vertical;
  533. -webkit-flex-direction: column;
  534. -ms-flex-direction: column;
  535. flex-direction: column;
  536. .col, .col-10, .col-20, .col-25, .col-33, .col-34, .col-50, .col-66, .col-67, .col-75, .col-80, .col-90 {
  537. @include flex(1);
  538. margin-bottom: ($grid-padding-width * 3) / 2;
  539. margin-left: 0;
  540. max-width: 100%;
  541. width: 100%;
  542. }
  543. }
  544. }
  545. }