mdb-ui-kit/sass/_mixins-shared.scss

156 lines
8.1 KiB
SCSS
Raw Normal View History

@mixin variations-content($material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1) {
#{$material-param-1}: unquote($material-color);
}
@mixin background-variations-content($material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1) {
background-color: $material-color;
@if ($material-color == $btn-default) {
color: $lightbg-text;
} @else {
color: $material-text-color;
}
}
@mixin text-variations-content($material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1) {
color: $material-color;
}
@mixin button-variations-content($material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1) {
background-color: contrast($material-color, darken($material-color, $material-param-1), lighten($material-color, $material-param-1), $contrast-factor);
}
@mixin bg-color-variations-content($material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1) {
background-color: rgba($material-color, $material-param-1);
}
// interpolation of mixin-name is not allowed evidently, so we statically include based on the mixin-name given
@mixin call-variations-content-mixin($mixin-name, $material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1) {
@if $mixin-name == variations-content {
@include variations-content($material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1);
} @else if $mixin-name == background-variations-content {
@include background-variations-content($material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1);
} @else if $mixin-name == text-variations-content {
@include text-variations-content($material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1);
} @else if $mixin-name == button-variations-content {
@include button-variations-content($material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1);
} @else if $mixin-name == bg-color-variations-content {
@include bg-color-variations-content($material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1);
} @else {
@error "Unknown mixin: #{$mixin-name}"
}
}
// @include button-variations(unquote(":not(.btn-link):not(.btn-flat)"), $btn-default, 4%);
@mixin variations($extra, $default, $material-param-1) {
@include generic-variations($extra, $default, "variations-content", $material-param-1);
}
@mixin background-variations($extra, $default) {
@include generic-variations($extra, $default, "background-variations-content", null);
}
@mixin text-variations($extra, $default) {
@include generic-variations($extra, $default, "text-variations-content", null);
}
@mixin button-variations($extra, $default, $material-param-1) {
@include generic-variations($extra, $default, "button-variations-content", $material-param-1);
}
@mixin bg-color-variations($extra, $default, $material-param-1) {
@include generic-variations($extra, $default, "bg-color-variations-content", $material-param-1);
}
//
// To use this mixin you should pass a function as final parameter to define
// the style. In that definition you can use the following variables to define it.
//
// $material-color-name ---> "red", "green", "indigo" ...
// $material-color-full-name ---> "red", "green-50", "indigo-400" ...
// $material-color ---> #f44336, #e8f5e9, #5c6bc0 ...
// $material-text-color ---> rgba(255,255,255,0.84), rgba(0,0,0,0.84), rgba(255,255,255,0.84) ...
//
@mixin generic-variations($extra, $default, $mixin-name, $material-param-1) {
$contrast-factor: 40% !default;
// bootstrap styles
&#{$extra}, &-default#{$extra} {
$material-color-name: "default" !default;
$material-color-full-name: $material-color-name !default;
$material-color: $default !default;
$material-text-color: $darkbg-text !default;
@include call-variations-content-mixin($mixin-name, $material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1);
}
&-black#{$extra} {
$material-color-name: "black" !default;
$material-color-full-name: $material-color-name !default;
$material-color: $black !default;
$material-text-color: $darkbg-text !default;
@include call-variations-content-mixin($mixin-name, $material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1);
}
&-white#{$extra} {
$material-color-name: "white" !default;
$material-color-full-name: $material-color-name !default;
$material-color: $white !default;
$material-text-color: $lightbg-text !default;
@include call-variations-content-mixin($mixin-name, $material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1);
}
&-inverse#{$extra} {
$material-color-name: "inverse" !default;
$material-color-full-name: $material-color-name !default;
$material-color: $inverse !default;
$material-text-color: contrast($inverse, $lightbg-text, $darkbg-text, $contrast-factor) !default;
@include call-variations-content-mixin($mixin-name, $material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1);
}
&-primary#{$extra} {
$material-color-name: "primary" !default;
$material-color-full-name: $material-color-name !default;
$material-color: $primary !default;
$material-text-color: $darkbg-text !default;
@include call-variations-content-mixin($mixin-name, $material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1);
}
&-success#{$extra} {
$material-color-name: "success" !default;
$material-color-full-name: $material-color-name !default;
$material-color: $success !default;
$material-text-color: $darkbg-text !default;
@include call-variations-content-mixin($mixin-name, $material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1);
}
&-info#{$extra} {
$material-color-name: "info" !default;
$material-color-full-name: $material-color-name !default;
$material-color: $info !default;
$material-text-color: $darkbg-text !default;
@include call-variations-content-mixin($mixin-name, $material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1);
}
&-warning#{$extra} {
$material-color-name: "warning" !default;
$material-color-full-name: $material-color-name !default;
$material-color: $warning !default;
$material-text-color: $darkbg-text !default;
@include call-variations-content-mixin($mixin-name, $material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1);
}
&-danger#{$extra} {
$material-color-name: "danger" !default;
$material-color-full-name: $material-color-name !default;
$material-color: $danger !default;
$material-text-color: $darkbg-text !default;
@include call-variations-content-mixin($mixin-name, $material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1);
}
@include generic-variations-colors($mixin-name, $extra, $default, $contrast-factor, $material-param-1)
}
@mixin generic-variations-color($mixin-name, $extra, $default, $contrast-factor, $material-color-name, $material-color-number, $material-param-1) {
& -material-#{$material-color-name}#{unquote($material-color-number)}#{$extra} {
$material-color-full-name: "#{$material-color-name}#{$material-color-number}" !default;
$material-color: $material-color-full-name !default;
$material-text-color: contrast($material-color, $lightbg-text, $darkbg-text, $contrast-factor) !default;
@include call-variations-content-mixin($mixin-name, $material-color-name, $material-color-full-name, $material-color, $material-text-color, $material-param-1);
}
}
$all-variations: unquote("-default, -primary, -info, -success, -warning, -danger") !default;