amis2/scss/_mixins.scss

416 lines
8.0 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) {
2020-10-26 17:31:13 +08:00
a.bg-#{'' + $name}:hover {
2019-12-06 09:58:08 +08:00
background-color: darken($bg-color, 5%);
}
2020-10-26 17:31:13 +08:00
a.text-#{'' + $name}:hover {
2019-12-06 09:58:08 +08:00
color: darken($bg-color, 5%);
}
2020-10-26 17:31:13 +08:00
.text-#{'' + $name} {
2019-12-06 09:58:08 +08:00
color: $bg-color;
}
2020-10-26 17:31:13 +08:00
.text-#{'' + $name}-lt {
2019-12-06 09:58:08 +08:00
color: darken($bg-color, 5%);
}
2020-10-26 17:31:13 +08:00
.text-#{'' + $name}-lter {
2019-12-06 09:58:08 +08:00
color: darken($bg-color, 10%);
}
2020-10-26 17:31:13 +08:00
.text-#{'' + $name}-dk {
2019-12-06 09:58:08 +08:00
color: darken($bg-color, 5%);
}
2020-10-26 17:31:13 +08:00
.text-#{'' + $name}-dker {
2019-12-06 09:58:08 +08:00
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
}
2020-04-08 11:04:37 +08:00
@mixin focus {
2019-12-06 09:58:08 +08:00
&:focus {
@content;
}
2019-04-30 11:11:25 +08:00
}
2020-04-08 11:04:37 +08:00
@mixin hover-focus {
&: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),
2020-06-08 18:46:28 +08:00
> svg.icon:not(:last-child):not(.pull-right),
2019-12-06 09:58:08 +08:00
> .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;
2020-04-08 11:04:37 +08:00
@include hover {
color: $hover-color;
background-color: $hover-background;
border-color: $hover-border;
}
@include focus {
color: $color;
background-color: $background;
border-color: $border;
box-shadow: $Button-boxShadow;
}
2019-12-06 09:58:08 +08:00
@include hover-focus {
color: $hover-color;
background-color: $hover-background;
border-color: $hover-border;
2020-04-08 11:04:37 +08:00
box-shadow: $Button-boxShadow;
2019-12-06 09:58:08 +08:00
}
&.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;
}
}
2020-05-14 20:47:05 +08:00
@mixin input-clear {
padding: px2rem(3px);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
svg {
fill: $Form-input-iconColor;
top: 0;
width: px2rem(10px);
height: px2rem(10px);
}
&:hover svg {
fill: darken($color: $Form-input-iconColor, $amount: 20%);
}
}
@mixin input-input {
display: flex;
background-color: $Form-input-bg;
border: $Form-input-borderWidth solid $Form-input-borderColor;
border-radius: $Form-input-borderRadius;
// height: $Form-input-height;
line-height: $Form-input-lineHeight;
padding: $Form-input-paddingY $Form-input-paddingX;
font-size: $Form-input-fontSize;
flex-wrap: wrap;
2020-08-14 17:45:59 +08:00
justify-content: space-between;
2020-05-14 20:47:05 +08:00
input {
flex-basis: px2rem(80px);
flex-grow: 1;
outline: none;
background: transparent;
border: none;
color: $Form-input-color;
width: 100%;
height: $Form-input-lineHeight * $Form-input-fontSize;
&::placeholder {
color: $Form-input-placeholderColor;
user-select: none;
}
}
}
@mixin input-text {
position: relative;
2020-08-04 16:45:49 +08:00
max-width: 100%;
2020-05-14 20:47:05 +08:00
&.is-inline {
display: inline-block;
2020-08-04 16:45:49 +08:00
width: $Form-control-widthBase;
2020-05-14 20:47:05 +08:00
}
&-input {
@include input-input();
}
&.is-error > &-input {
border-color: $Form-input-onError-borderColor;
background-color: $Form-input-onError-bg;
}
&.is-focused > &-input {
border-color: $Form-input-onFocused-borderColor;
box-shadow: $Form-input-boxShadow;
@if $Form-input-onFocused-bg !=$Form-input-bg {
background-color: $Form-input-onFocused-bg;
}
}
&.is-error.is-focused > &-input {
border-color: $Form-input-onError-borderColor;
}
&.is-disabled > &-input {
color: $text--muted-color;
background: $Form-input-onDisabled-bg;
border-color: $Form-input-onDisabled-borderColor;
}
&-spinner {
line-height: $Form-input-lineHeight * $Form-input-fontSize;
}
&-clear {
@include input-clear();
}
// 需要能撑开
@include media-breakpoint-up(sm) {
&.#{$ns}Form-control--sizeXs > &-input,
&.#{$ns}Form-control--sizeSm > &-input,
&.#{$ns}Form-control--sizeMd > &-input,
&.#{$ns}Form-control--sizeLg > &-input {
min-width: 100%;
display: inline-flex;
}
}
}
2020-05-27 20:09:39 +08:00
@mixin checkboxes-placeholder {
height: $Form-input-height;
line-height: $Form-input-lineHeight;
font-size: $Form-input-fontSize;
padding: ($Form-input-height - $Form-input-lineHeight * $Form-input-fontSize)/2
$gap-sm;
color: $text--muted-color;
}
2020-07-04 22:56:58 +08:00
@mixin label-variant($color) {
background-color: $color;
&[href] {
&:hover,
&:focus {
background-color: darken($color, 10%);
}
}
}
2020-08-14 17:45:59 +08:00
@mixin icon-color {
color: $icon-color;
&:hover {
color: $icon-onHover-color;
}
}