amis/scss/_mixins.scss

263 lines
4.9 KiB
SCSS
Raw Normal View History

2019-04-30 11:11:25 +08:00
// 媒体查询最小阈值
@mixin media-breakpoint-up($name, $breakpoints: $breakpoints) {
2019-12-06 09:58:08 +08:00
$min: breakpoint-min($name, $breakpoints);
2019-12-06 09:58:08 +08:00
@if $min {
@media (min-width: $min) {
@content;
2019-04-30 11:11:25 +08:00
}
2019-12-06 09:58:08 +08:00
} @else {
@content;
}
2019-04-30 11:11:25 +08:00
}
//媒体查询最大阈值
@mixin media-breakpoint-down($name, $breakpoints: $breakpoints) {
2019-12-06 09:58:08 +08:00
$max: breakpoint-max($name, $breakpoints);
2019-12-06 09:58:08 +08:00
@if $max {
@media (max-width: $max) {
@content;
2019-04-30 11:11:25 +08:00
}
2019-12-06 09:58:08 +08:00
} @else {
@content;
}
2019-04-30 11:11:25 +08:00
}
//媒体查询中间阈值
@mixin media-breakpoint-between($min, $max, $breakpoints: $breakpoints) {
2019-12-06 09:58:08 +08:00
$min: breakpoint-min($min, $breakpoints);
$max: breakpoint-max($max, $breakpoints);
2019-12-06 09:58:08 +08:00
@media (min-width: $min) and (max-width: $max) {
@content;
}
2019-04-30 11:11:25 +08:00
}
@mixin clearfix() {
2019-12-06 09:58:08 +08:00
&::before,
&::after {
display: table;
content: '';
}
&::after {
clear: both;
}
2019-04-30 11:11:25 +08:00
}
@mixin color-schema($bg-color: #555, $percent: 15%, $sat-percent: 100%) {
2019-12-06 09:58:08 +08:00
background-color: saturate(darken($bg-color, $percent), $sat-percent);
2019-04-30 11:11:25 +08:00
}
@mixin color-schema-lt($bg-color: #555, $percent: 15%, $sat-percent: 100%) {
2019-12-06 09:58:08 +08:00
background-color: desaturate(lighten($bg-color, $percent), $sat-percent);
2019-04-30 11:11:25 +08:00
}
@mixin color-variant(
2019-12-06 09:58:08 +08:00
$bg-color: #555,
$lt-percent: 10%,
$lter-percent: 15%,
$dk-percent: 10%,
$dker-percent: 15%
) {
2019-12-06 09:58:08 +08:00
background-color: $bg-color;
&.lt,
& .lt {
@include color-schema-lt($bg-color, $lt-percent, 2.5%);
}
&.lter,
& .lter {
@include color-schema-lt($bg-color, $lter-percent, 5%);
}
&.dk,
& .dk {
@include color-schema($bg-color, $dk-percent, 2.5%);
}
&.dker,
& .dker {
@include color-schema($bg-color, $dker-percent, 5%);
}
&.bg,
& .bg {
2019-04-30 11:11:25 +08:00
background-color: $bg-color;
2019-12-06 09:58:08 +08:00
}
2019-04-30 11:11:25 +08:00
}
@mixin font-variant($bg-color) {
2019-12-06 09:58:08 +08:00
$font-color: desaturate(lighten($bg-color, 40%), 10%);
$link-color: desaturate(lighten($bg-color, 50%), 10%);
$hover-color: #fff;
color: $font-color;
2019-12-12 19:30:46 +08:00
& a,
& .#{$ns}Button--link {
2019-12-06 09:58:08 +08:00
color: $link-color;
2019-04-30 11:11:25 +08:00
2019-12-06 09:58:08 +08:00
&:hover {
color: $hover-color;
2019-04-30 11:11:25 +08:00
}
2019-12-06 09:58:08 +08:00
}
2019-04-30 11:11:25 +08:00
2019-12-06 09:58:08 +08:00
& .open > a {
&,
&:hover,
&:focus {
color: $hover-color;
2019-04-30 11:11:25 +08:00
}
2019-12-06 09:58:08 +08:00
}
& .text-muted {
color: darken($font-color, 10%) !important;
}
& .text-lt {
color: lighten($font-color, 25%) !important;
}
2019-12-12 19:30:46 +08:00
// &.auto,
// & .auto {
// & .list-group-item {
// border-color: darken($bg-color, 5%) !important;
// background-color: transparent;
// &:hover,
// &:focus,
// &:active,
// &.active {
// @include color-schema($bg-color, 5%, 2.5% !important);
// }
// }
// }
2019-04-30 11:11:25 +08:00
}
@mixin text-wariant($bg-color, $name) {
2019-12-06 09:58:08 +08:00
a.bg-#{$name}:hover {
background-color: darken($bg-color, 5%);
}
2019-12-06 09:58:08 +08:00
a.text-#{$name}:hover {
color: darken($bg-color, 5%);
}
2019-12-06 09:58:08 +08:00
.text-#{$name} {
color: $bg-color;
}
2019-12-06 09:58:08 +08:00
.text-#{$name}-lt {
color: darken($bg-color, 5%);
}
2019-12-06 09:58:08 +08:00
.text-#{$name}-lter {
color: darken($bg-color, 10%);
}
2019-12-06 09:58:08 +08:00
.text-#{$name}-dk {
color: darken($bg-color, 5%);
}
2019-12-06 09:58:08 +08:00
.text-#{$name}-dker {
color: darken($bg-color, 10%);
}
2019-04-30 11:11:25 +08:00
}
@mixin hover {
2019-12-06 09:58:08 +08:00
&:hover {
@content;
}
2019-04-30 11:11:25 +08:00
}
@mixin hover-focus {
2019-12-06 09:58:08 +08:00
&:hover,
&:focus {
@content;
}
2019-04-30 11:11:25 +08:00
}
@mixin hover-active {
2019-12-06 09:58:08 +08:00
&:hover:active {
@content;
}
2019-04-30 11:11:25 +08:00
}
@mixin button-size(
2019-12-06 09:58:08 +08:00
$padding-y,
$padding-x,
$font-size,
$line-height,
$border-radius,
$height: auto,
$iconWdith: px2rem(20px)
2019-04-30 11:11:25 +08:00
) {
2019-12-06 09:58:08 +08:00
padding: $padding-y $padding-x;
font-size: $font-size;
line-height: $line-height;
border-radius: $border-radius;
height: $height;
.#{$ns}Button-icon:first-child:not(:last-child):not(.pull-right),
> .pull-left {
margin-right: $padding-x;
}
.#{$ns}Button-icon:last-child:not(:first-child):not(.pull-left),
> .pull-right {
margin-left: $padding-x;
}
2019-04-30 11:11:25 +08:00
}
@mixin button-variant(
2019-12-06 09:58:08 +08:00
$background,
$border: $background,
$color: $white,
$hover-background: darken($background, 7.5%),
$hover-border: darken($border, 10%),
$hover-color: $color,
$active-background: darken($background, 10%),
$active-border: darken($border, 12.5%),
$active-color: $color
2019-04-30 11:11:25 +08:00
) {
2019-12-06 09:58:08 +08:00
color: $color;
background-color: $background;
border-color: $border;
box-shadow: $Button-boxShadow;
@include hover-focus {
color: $hover-color;
background-color: $hover-background;
border-color: $hover-border;
}
&.is-disabled,
&:disabled {
@if variable-exists(Button-onDisabled-bg) {
background-color: $Button-onDisabled-bg;
} @else {
background-color: $background;
2019-04-30 11:11:25 +08:00
}
2019-12-06 09:58:08 +08:00
@if variable-exists(Button-onDisabled-color) {
color: $Button-onDisabled-color;
} @else {
color: $color;
2019-04-30 11:11:25 +08:00
}
2019-12-06 09:58:08 +08:00
@if variable-exists(Button-onDisabled-borderColor) {
border-color: $Button-onDisabled-borderColor;
} @else {
border-color: $border;
2019-04-30 11:11:25 +08:00
}
2019-12-06 09:58:08 +08:00
}
&:not(:disabled):not(.is-disabled):active,
&:not(:disabled):not(.is-disabled).is-active {
color: $active-color;
background-color: $active-background;
border-color: $active-border;
}
}