AdminLTE/build/scss/_mixins.scss

575 lines
12 KiB
SCSS
Raw Normal View History

//
// General: Mixins
//
2015-10-31 21:00:16 +00:00
// Cards Variant
@mixin cards-variant($name, $color) {
.card-#{$name} {
&:not(.card-outline) {
> .card-header {
background-color: $color;
border-bottom: 0;
&,
a {
color: color-yiq($color);
}
a.active {
color: color-yiq($white);
}
}
}
&.card-outline {
border-top: 3px solid $color;
.nav-item {
border-bottom: 0;
&:first-child .nav-link {
margin-left: -1px;
border-left: 0;
}
}
}
&.card-outline-tabs {
border-top: 0;
> .card-header {
.nav-item {
&:first-child .nav-link {
margin-left: -1px;
border-left: 0;
}
}
a {
border-top: 3px solid transparent;
&:hover {
border-top: $nav-tabs-border-width solid $nav-tabs-border-color;
margin-top: 2px;
}
&.active {
&:hover {
margin-top: 0;
}
border-top: 3px solid $color;
}
}
}
}
}
.bg-#{$name},
.bg-gradient-#{$name},
.card-#{$name}:not(.card-outline) {
.btn-tool {
color: rgba(color-yiq($color), 0.8);
&:hover {
color: color-yiq($color);
}
}
}
.card.bg-#{$name},
.card.bg-gradient-#{$name} {
.bootstrap-datetimepicker-widget {
.table td,
.table th {
border: none;
}
table thead tr:first-child th:hover,
table td.day:hover,
table td.hour:hover,
table td.minute:hover,
table td.second:hover {
background: darken($color, 8%);
color: color-yiq($color);
}
table td.today::before {
border-bottom-color: color-yiq($color);
}
table td.active,
table td.active:hover {
background: lighten($color, 10%);
color: color-yiq($color);
}
}
}
}
// Sidebar Color
@mixin sidebar-color($color) {
.nav-sidebar > .nav-item {
& > .nav-link.active {
background-color: $color;
color: color-yiq($color);
}
}
}
// Sidebar Mini Breakpoints
@mixin sidebar-mini-breakpoint() {
// A fix for text overflow while transitioning from sidebar mini to full sidebar
.nav-sidebar,
.nav-sidebar > .nav-header,
.nav-sidebar .nav-link {
white-space: nowrap;
overflow: hidden;
}
// When the sidebar is collapsed...
&.sidebar-collapse {
.d-hidden-mini {
display: none;
}
// Apply the new margins to the main content and footer
.content-wrapper,
.main-footer,
.main-header {
margin-left: $sidebar-mini-width !important;
}
// Make the sidebar headers
.nav-sidebar .nav-header {
display: none;
}
.nav-sidebar .nav-link p {
width: 0;
}
.sidebar .user-panel > .info,
.nav-sidebar .nav-link p,
.brand-text {
margin-left: -10px;
opacity: 0;
visibility: hidden;
}
.logo-xl {
opacity: 0;
visibility: hidden;
}
.logo-xs {
display: inline-block;
opacity: 1;
visibility: visible;
}
// Modify the sidebar to shrink instead of disappearing
.main-sidebar {
overflow-x: hidden;
&,
&::before {
// Don't go away! Just shrink
margin-left: 0;
width: $sidebar-mini-width;
}
.user-panel {
.image {
float: none;
}
}
&:hover,
&.sidebar-focused {
width: $sidebar-width;
.nav-sidebar.nav-child-indent .nav-treeview {
padding-left: 1rem;
}
.brand-link {
width: $sidebar-width;
}
.user-panel {
text-align: left;
.image {
float: left;
}
}
.user-panel > .info,
.nav-sidebar .nav-link p,
.brand-text,
.logo-xl {
display: inline-block;
margin-left: 0;
opacity: 1;
visibility: visible;
}
2019-09-16 11:07:25 +00:00
.nav-flat {
.nav-icon {
margin-left: 0;
}
.nav-treeview {
.nav-icon {
margin-left: -.2rem;
}
}
}
.logo-xs {
opacity: 0;
visibility: hidden;
}
.brand-image {
margin-right: .5rem;
}
// Make the sidebar links, menus, labels, badges
// and angle icons disappear
.sidebar-form,
.user-panel > .info {
display: block !important;
-webkit-transform: translateZ(0);
}
.nav-sidebar > .nav-item > .nav-link > span {
display: inline-block !important;
}
}
}
// Make an element visible only when sidebar mini is active
.visible-sidebar-mini {
display: block !important;
}
&.layout-fixed {
.main-sidebar:hover {
.brand-link {
width: $sidebar-width;
}
}
.brand-link {
width: $sidebar-mini-width;
}
}
}
}
// Navbar Variant
2015-10-31 21:00:16 +00:00
@mixin navbar-variant($color, $font-color: rgba(255, 255, 255, 0.8), $hover-color: #f6f6f6, $hover-bg: rgba(0, 0, 0, 0.1)) {
background-color: $color;
2015-10-31 21:00:16 +00:00
.nav > li > a {
color: $font-color;
}
.nav > li > a:hover,
.nav > li > a:active,
.nav > li > a:focus,
.nav .open > a,
.nav .open > a:hover,
.nav .open > a:focus,
.nav > .active > a {
background: $hover-bg;
color: $hover-color;
}
2016-01-16 16:27:23 +00:00
// Add color to the sidebar toggle button
2015-10-31 21:00:16 +00:00
.sidebar-toggle {
color: $font-color;
&:hover,
&:focus {
2015-10-31 21:00:16 +00:00
background: $hover-bg;
color: $hover-color;
2015-10-31 21:00:16 +00:00
}
}
}
// Logo color Variant
2015-10-31 21:00:16 +00:00
@mixin logo-variant($bg-color, $color: #fff, $border-bottom-color: transparent, $border-bottom-width: 0) {
background-color: $bg-color;
border-bottom: $border-bottom-width solid $border-bottom-color;
color: $color;
2015-10-31 21:00:16 +00:00
&:hover,
&:focus {
2015-10-31 21:00:16 +00:00
background-color: darken($bg-color, 1%);
}
}
2016-01-16 16:27:23 +00:00
// Direct Chat Variant
2015-10-31 21:00:16 +00:00
@mixin direct-chat-variant($bg-color, $color: #fff) {
.right > .direct-chat-text {
background: $bg-color;
border-color: $bg-color;
2018-03-17 17:07:55 +00:00
color: color-yiq($bg-color);
&::after,
&::before {
2015-10-31 21:00:16 +00:00
border-left-color: $bg-color;
}
}
2019-08-19 11:00:46 +00:00
@each $name, $color in $theme-colors {
&.bg-#{$name},
&.bg-gradient-#{$name} {
.direct-chat-timestamp {
@if (color-yiq($color) == $yiq-text-dark) {
color: lighten(color-yiq($color), 10%);
} @else {
color: darken(color-yiq($color), 20%);
}
}
}
}
@each $name, $color in $colors {
&.bg-#{$name},
&.bg-gradient-#{$name} {
.direct-chat-timestamp {
@if (color-yiq($color) == $yiq-text-dark) {
color: lighten(color-yiq($color), 10%);
} @else {
color: darken(color-yiq($color), 20%);
}
}
}
}
2015-10-31 21:00:16 +00:00
}
// Background Variant
@mixin background-variant($name, $color) {
.bg-#{$name} {
background-color: #{$color} !important;
&,
> a {
color: color-yiq($color) !important;
}
&.btn {
&:hover {
border-color: darken($color, 10%);
2019-08-19 11:00:46 +00:00
color: darken(color-yiq($color), 7.5%);
}
&:not(:disabled):not(.disabled):active,
&:not(:disabled):not(.disabled).active,
&:active,
&.active {
background-color: darken($color, 10%) !important;
border-color: darken($color, 12.5%);
color: color-yiq(darken($color, 10%));
}
}
}
}
// Background Gradient Variant
@mixin background-gradient-variant($name, $color) {
.bg-gradient-#{$name} {
@include bg-gradient-variant('&', $color);
color: color-yiq($color);
&.btn {
&.disabled,
&:disabled,
&:not(:disabled):not(.disabled):active,
&:not(:disabled):not(.disabled).active,
.show > &.dropdown-toggle {
background-image: none !important;
}
&:hover {
@include bg-gradient-variant('&', darken($color, 7.5%));
border-color: darken($color, 10%);
2019-08-19 11:00:46 +00:00
color: darken(color-yiq($color), 7.5%);
}
&:not(:disabled):not(.disabled):active,
&:not(:disabled):not(.disabled).active,
&:active,
&.active {
@include bg-gradient-variant('&', darken($color, 10%));
border-color: darken($color, 12.5%);
color: color-yiq(darken($color, 10%));
}
}
}
}
// Custom Switch Variant
@mixin custom-switch-variant($name, $color) {
&.custom-switch-off-#{$name} {
& .custom-control-input ~ .custom-control-label::before {
background: #{$color};
border-color: darken($color, 20%);
}
& .custom-control-input:focus ~ .custom-control-label::before {
box-shadow: 0 0 0 1px $body-bg, 0 0 0 2px rgba($color, .25);
}
& .custom-control-input ~ .custom-control-label::after {
background: darken($color, 25%);
}
}
&.custom-switch-on-#{$name} {
& .custom-control-input:checked ~ .custom-control-label::before {
background: #{$color};
border-color: darken($color, 20%);
}
& .custom-control-input:checked:focus ~ .custom-control-label::before {
box-shadow: 0 0 0 1px $body-bg, 0 0 0 2px rgba($color, .25);
}
& .custom-control-input:checked ~ .custom-control-label::after {
background: lighten($color, 30%);
}
}
}
// Custom Range Variant
@mixin custom-range-variant($name, $color) {
&.custom-range-#{$name} {
&:focus {
outline: none;
&::-webkit-slider-thumb {
box-shadow: 0 0 0 1px $body-bg, 0 0 0 2px rgba($color, .25);
}
&::-moz-range-thumb {
box-shadow: 0 0 0 1px $body-bg, 0 0 0 2px rgba($color, .25);
}
&::-ms-thumb {
box-shadow: 0 0 0 1px $body-bg, 0 0 0 2px rgba($color, .25);
}
}
&::-webkit-slider-thumb {
background-color: $color;
&:active {
background-color: lighten($color, 35%);
}
}
&::-moz-range-thumb {
background-color: $color;
&:active {
background-color: lighten($color, 35%);
}
}
&::-ms-thumb {
background-color: $color;
&:active {
background-color: lighten($color, 35%);
}
}
}
}
// Toast Variant
@mixin toast-variant($name, $color) {
&.bg-#{$name} {
background: rgba($color, .9) !important;
@if (color-yiq($color) == $yiq-text-light) {
.close {
color: color-yiq($color);
text-shadow: 0 1px 0 #000;
}
}
.toast-header {
background: rgba($color, .85);
color: color-yiq($color);
}
}
}
// Accent Variant
@mixin accent-variant($name, $color) {
&.accent-#{$name} {
$link-color: $color;
$link-hover-color: darken($color, 15%);
$pagination-active-bg: $color;
$pagination-active-border-color: $color;
a {
color: $link-color;
@include hover {
color: $link-hover-color;
}
}
.page-item {
&.active .page-link {
background-color: $pagination-active-bg;
border-color: $pagination-active-border-color;
}
&.disabled .page-link {
background-color: $pagination-disabled-bg;
border-color: $pagination-disabled-border-color;
}
}
}
}
// ETC
2015-10-31 21:00:16 +00:00
@mixin translate($x, $y) {
transform: translate($x, $y);
}
2016-01-16 16:27:23 +00:00
// Different radius each side
2016-10-15 17:20:09 +00:00
@mixin border-radius-sides($top-left, $top-right, $bottom-left, $bottom-right) {
2015-10-31 21:00:16 +00:00
border-radius: $top-left $top-right $bottom-left $bottom-right;
}
2016-01-16 16:27:23 +00:00
@mixin calc($property, $expression) {
#{$property}: calc(#{$expression});
}
2015-10-31 21:00:16 +00:00
@mixin rotate($value) {
transform: rotate($value);
}
@mixin animation($animation) {
animation: $animation;
}
2016-01-16 16:27:23 +00:00
// Gradient background
2015-10-31 21:00:16 +00:00
@mixin gradient($color: #F5F5F5, $start: #EEE, $stop: #FFF) {
background: $color;
background: -webkit-gradient(linear, left bottom, left top, color-stop(0, $start), color-stop(1, $stop));
background: -ms-linear-gradient(bottom, $start, $stop);
background: -moz-linear-gradient(center bottom, $start 0%, $stop 100%);
background: -o-linear-gradient($stop, $start);
}