_mixins.scss 9.9 KB

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