_mixins.scss 12 KB

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