_mixins.scss 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. //
  2. // General: Mixins
  3. //
  4. // Cards Variant
  5. @mixin cards-variant($name, $color) {
  6. .card-#{$name} {
  7. &:not(.card-outline) {
  8. > .card-header {
  9. background-color: $color;
  10. border-bottom: 0;
  11. &,
  12. a {
  13. color: color-yiq($color);
  14. }
  15. a.active {
  16. color: color-yiq($white);
  17. }
  18. .nav-item {
  19. &:first-child .nav-link {
  20. margin-left: -1px;
  21. }
  22. }
  23. }
  24. }
  25. &.card-outline {
  26. border-top: 3px solid $color;
  27. .nav-item {
  28. border-bottom: 0;
  29. &:first-child .nav-link {
  30. border-left: 0;
  31. margin-left: 0;
  32. }
  33. }
  34. }
  35. &.card-outline-tabs {
  36. border-top: 0;
  37. > .card-header {
  38. .nav-item {
  39. &:first-child .nav-link {
  40. border-left: 0;
  41. margin-left: 0;
  42. }
  43. }
  44. a {
  45. border-top: 3px solid transparent;
  46. &:hover {
  47. border-top: $nav-tabs-border-width solid $nav-tabs-border-color;
  48. margin-top: 2px;
  49. }
  50. &.active {
  51. &:hover {
  52. margin-top: 0;
  53. }
  54. border-top: 3px solid $color;
  55. }
  56. }
  57. }
  58. }
  59. }
  60. .bg-#{$name},
  61. .bg-gradient-#{$name},
  62. .card-#{$name}:not(.card-outline) {
  63. .btn-tool {
  64. color: rgba(color-yiq($color), 0.8);
  65. &:hover {
  66. color: color-yiq($color);
  67. }
  68. }
  69. }
  70. .card.bg-#{$name},
  71. .card.bg-gradient-#{$name} {
  72. .bootstrap-datetimepicker-widget {
  73. .table td,
  74. .table th {
  75. border: none;
  76. }
  77. table thead tr:first-child th:hover,
  78. table td.day:hover,
  79. table td.hour:hover,
  80. table td.minute:hover,
  81. table td.second:hover {
  82. background: darken($color, 8%);
  83. color: color-yiq($color);
  84. }
  85. table td.today::before {
  86. border-bottom-color: color-yiq($color);
  87. }
  88. table td.active,
  89. table td.active:hover {
  90. background: lighten($color, 10%);
  91. color: color-yiq($color);
  92. }
  93. }
  94. }
  95. }
  96. // Sidebar Color
  97. @mixin sidebar-color($color) {
  98. .nav-sidebar > .nav-item {
  99. & > .nav-link.active {
  100. background-color: $color;
  101. color: color-yiq($color);
  102. }
  103. }
  104. }
  105. // Sidebar Mini Breakpoints
  106. @mixin sidebar-mini-breakpoint() {
  107. // A fix for text overflow while transitioning from sidebar mini to full sidebar
  108. .nav-sidebar,
  109. .nav-sidebar > .nav-header,
  110. .nav-sidebar .nav-link {
  111. white-space: nowrap;
  112. overflow: hidden;
  113. }
  114. // When the sidebar is collapsed...
  115. &.sidebar-collapse {
  116. .d-hidden-mini {
  117. display: none;
  118. }
  119. // Apply the new margins to the main content and footer
  120. .content-wrapper,
  121. .main-footer,
  122. .main-header {
  123. margin-left: $sidebar-mini-width !important;
  124. }
  125. // Make the sidebar headers
  126. .nav-sidebar .nav-header {
  127. display: none;
  128. }
  129. .nav-sidebar .nav-link p {
  130. width: 0;
  131. }
  132. .sidebar .user-panel > .info,
  133. .nav-sidebar .nav-link p,
  134. .brand-text {
  135. margin-left: -10px;
  136. opacity: 0;
  137. visibility: hidden;
  138. }
  139. .logo-xl {
  140. opacity: 0;
  141. visibility: hidden;
  142. }
  143. .logo-xs {
  144. display: inline-block;
  145. opacity: 1;
  146. visibility: visible;
  147. }
  148. // Modify the sidebar to shrink instead of disappearing
  149. .main-sidebar {
  150. overflow-x: hidden;
  151. &,
  152. &::before {
  153. // Don't go away! Just shrink
  154. margin-left: 0;
  155. width: $sidebar-mini-width;
  156. }
  157. .user-panel {
  158. .image {
  159. float: none;
  160. }
  161. }
  162. &:hover,
  163. &.sidebar-focused {
  164. width: $sidebar-width;
  165. .nav-sidebar.nav-child-indent .nav-treeview {
  166. padding-left: 1rem;
  167. }
  168. .brand-link {
  169. width: $sidebar-width;
  170. }
  171. .user-panel {
  172. text-align: left;
  173. .image {
  174. float: left;
  175. }
  176. }
  177. .user-panel > .info,
  178. .nav-sidebar .nav-link p,
  179. .brand-text,
  180. .logo-xl {
  181. display: inline-block;
  182. margin-left: 0;
  183. opacity: 1;
  184. visibility: visible;
  185. }
  186. .nav-flat {
  187. .nav-icon {
  188. margin-left: 0;
  189. }
  190. .nav-treeview {
  191. .nav-icon {
  192. margin-left: -.2rem;
  193. }
  194. }
  195. }
  196. .logo-xs {
  197. opacity: 0;
  198. visibility: hidden;
  199. }
  200. .brand-image {
  201. margin-right: .5rem;
  202. }
  203. // Make the sidebar links, menus, labels, badges
  204. // and angle icons disappear
  205. .sidebar-form,
  206. .user-panel > .info {
  207. display: block !important;
  208. -webkit-transform: translateZ(0);
  209. }
  210. .nav-sidebar > .nav-item > .nav-link > span {
  211. display: inline-block !important;
  212. }
  213. }
  214. }
  215. // Make an element visible only when sidebar mini is active
  216. .visible-sidebar-mini {
  217. display: block !important;
  218. }
  219. &.layout-fixed {
  220. .main-sidebar:hover {
  221. .brand-link {
  222. width: $sidebar-width;
  223. }
  224. }
  225. .brand-link {
  226. width: $sidebar-mini-width;
  227. }
  228. }
  229. }
  230. }
  231. // Navbar Variant
  232. @mixin navbar-variant($color, $font-color: rgba(255, 255, 255, 0.8), $hover-color: #f6f6f6, $hover-bg: rgba(0, 0, 0, 0.1)) {
  233. background-color: $color;
  234. .nav > li > a {
  235. color: $font-color;
  236. }
  237. .nav > li > a:hover,
  238. .nav > li > a:active,
  239. .nav > li > a:focus,
  240. .nav .open > a,
  241. .nav .open > a:hover,
  242. .nav .open > a:focus,
  243. .nav > .active > a {
  244. background: $hover-bg;
  245. color: $hover-color;
  246. }
  247. // Add color to the sidebar toggle button
  248. .sidebar-toggle {
  249. color: $font-color;
  250. &:hover,
  251. &:focus {
  252. background: $hover-bg;
  253. color: $hover-color;
  254. }
  255. }
  256. }
  257. // Logo color Variant
  258. @mixin logo-variant($bg-color, $color: #fff, $border-bottom-color: transparent, $border-bottom-width: 0) {
  259. background-color: $bg-color;
  260. border-bottom: $border-bottom-width solid $border-bottom-color;
  261. color: $color;
  262. &:hover,
  263. &:focus {
  264. background-color: darken($bg-color, 1%);
  265. }
  266. }
  267. // Direct Chat Variant
  268. @mixin direct-chat-variant($bg-color, $color: #fff) {
  269. .right > .direct-chat-text {
  270. background: $bg-color;
  271. border-color: $bg-color;
  272. color: color-yiq($bg-color);
  273. &::after,
  274. &::before {
  275. border-left-color: $bg-color;
  276. }
  277. }
  278. @each $name, $color in $theme-colors {
  279. &.bg-#{$name},
  280. &.bg-gradient-#{$name} {
  281. .direct-chat-timestamp {
  282. @if (color-yiq($color) == $yiq-text-dark) {
  283. color: lighten(color-yiq($color), 10%);
  284. } @else {
  285. color: darken(color-yiq($color), 20%);
  286. }
  287. }
  288. }
  289. }
  290. @each $name, $color in $colors {
  291. &.bg-#{$name},
  292. &.bg-gradient-#{$name} {
  293. .direct-chat-timestamp {
  294. @if (color-yiq($color) == $yiq-text-dark) {
  295. color: lighten(color-yiq($color), 10%);
  296. } @else {
  297. color: darken(color-yiq($color), 20%);
  298. }
  299. }
  300. }
  301. }
  302. }
  303. // Background Variant
  304. @mixin background-variant($name, $color) {
  305. .bg-#{$name} {
  306. background-color: #{$color} !important;
  307. &,
  308. > a {
  309. color: color-yiq($color) !important;
  310. }
  311. &.btn {
  312. &:hover {
  313. border-color: darken($color, 10%);
  314. color: darken(color-yiq($color), 7.5%);
  315. }
  316. &:not(:disabled):not(.disabled):active,
  317. &:not(:disabled):not(.disabled).active,
  318. &:active,
  319. &.active {
  320. background-color: darken($color, 10%) !important;
  321. border-color: darken($color, 12.5%);
  322. color: color-yiq(darken($color, 10%));
  323. }
  324. }
  325. }
  326. }
  327. // Background Gradient Variant
  328. @mixin background-gradient-variant($name, $color) {
  329. .bg-gradient-#{$name} {
  330. @include bg-gradient-variant('&', $color);
  331. color: color-yiq($color);
  332. &.btn {
  333. &.disabled,
  334. &:disabled,
  335. &:not(:disabled):not(.disabled):active,
  336. &:not(:disabled):not(.disabled).active,
  337. .show > &.dropdown-toggle {
  338. background-image: none !important;
  339. }
  340. &:hover {
  341. @include bg-gradient-variant('&', darken($color, 7.5%));
  342. border-color: darken($color, 10%);
  343. color: darken(color-yiq($color), 7.5%);
  344. }
  345. &:not(:disabled):not(.disabled):active,
  346. &:not(:disabled):not(.disabled).active,
  347. &:active,
  348. &.active {
  349. @include bg-gradient-variant('&', darken($color, 10%));
  350. border-color: darken($color, 12.5%);
  351. color: color-yiq(darken($color, 10%));
  352. }
  353. }
  354. }
  355. }
  356. // Custom Switch Variant
  357. @mixin custom-switch-variant($name, $color) {
  358. &.custom-switch-off-#{$name} {
  359. & .custom-control-input ~ .custom-control-label::before {
  360. background: #{$color};
  361. border-color: darken($color, 20%);
  362. }
  363. & .custom-control-input:focus ~ .custom-control-label::before {
  364. box-shadow: 0 0 0 1px $body-bg, 0 0 0 2px rgba($color, .25);
  365. }
  366. & .custom-control-input ~ .custom-control-label::after {
  367. background: darken($color, 25%);
  368. }
  369. }
  370. &.custom-switch-on-#{$name} {
  371. & .custom-control-input:checked ~ .custom-control-label::before {
  372. background: #{$color};
  373. border-color: darken($color, 20%);
  374. }
  375. & .custom-control-input:checked:focus ~ .custom-control-label::before {
  376. box-shadow: 0 0 0 1px $body-bg, 0 0 0 2px rgba($color, .25);
  377. }
  378. & .custom-control-input:checked ~ .custom-control-label::after {
  379. background: lighten($color, 30%);
  380. }
  381. }
  382. }
  383. // Custom Range Variant
  384. @mixin custom-range-variant($name, $color) {
  385. &.custom-range-#{$name} {
  386. &:focus {
  387. outline: none;
  388. &::-webkit-slider-thumb {
  389. box-shadow: 0 0 0 1px $body-bg, 0 0 0 2px rgba($color, .25);
  390. }
  391. &::-moz-range-thumb {
  392. box-shadow: 0 0 0 1px $body-bg, 0 0 0 2px rgba($color, .25);
  393. }
  394. &::-ms-thumb {
  395. box-shadow: 0 0 0 1px $body-bg, 0 0 0 2px rgba($color, .25);
  396. }
  397. }
  398. &::-webkit-slider-thumb {
  399. background-color: $color;
  400. &:active {
  401. background-color: lighten($color, 35%);
  402. }
  403. }
  404. &::-moz-range-thumb {
  405. background-color: $color;
  406. &:active {
  407. background-color: lighten($color, 35%);
  408. }
  409. }
  410. &::-ms-thumb {
  411. background-color: $color;
  412. &:active {
  413. background-color: lighten($color, 35%);
  414. }
  415. }
  416. }
  417. }
  418. // Toast Variant
  419. @mixin toast-variant($name, $color) {
  420. &.bg-#{$name} {
  421. background: rgba($color, .9) !important;
  422. @if (color-yiq($color) == $yiq-text-light) {
  423. .close {
  424. color: color-yiq($color);
  425. text-shadow: 0 1px 0 #000;
  426. }
  427. }
  428. .toast-header {
  429. background: rgba($color, .85);
  430. color: color-yiq($color);
  431. }
  432. }
  433. }
  434. // Accent Variant
  435. @mixin accent-variant($name, $color) {
  436. .accent-#{$name} {
  437. $link-color: $color;
  438. $link-hover-color: darken($color, 15%);
  439. $pagination-active-bg: $color;
  440. $pagination-active-border-color: $color;
  441. a {
  442. color: $link-color;
  443. @include hover {
  444. color: $link-hover-color;
  445. }
  446. }
  447. .page-item {
  448. &.active .page-link {
  449. background-color: $pagination-active-bg;
  450. border-color: $pagination-active-border-color;
  451. }
  452. &.disabled .page-link {
  453. background-color: $pagination-disabled-bg;
  454. border-color: $pagination-disabled-border-color;
  455. }
  456. }
  457. }
  458. }
  459. // ETC
  460. @mixin translate($x, $y) {
  461. transform: translate($x, $y);
  462. }
  463. // Different radius each side
  464. @mixin border-radius-sides($top-left, $top-right, $bottom-left, $bottom-right) {
  465. border-radius: $top-left $top-right $bottom-left $bottom-right;
  466. }
  467. @mixin calc($property, $expression) {
  468. #{$property}: calc(#{$expression});
  469. }
  470. @mixin rotate($value) {
  471. transform: rotate($value);
  472. }
  473. @mixin animation($animation) {
  474. animation: $animation;
  475. }
  476. // Gradient background
  477. @mixin gradient($color: #F5F5F5, $start: #EEE, $stop: #FFF) {
  478. background: $color;
  479. background: -webkit-gradient(linear, left bottom, left top, color-stop(0, $start), color-stop(1, $stop));
  480. background: -ms-linear-gradient(bottom, $start, $stop);
  481. background: -moz-linear-gradient(center bottom, $start 0%, $stop 100%);
  482. background: -o-linear-gradient($stop, $start);
  483. }