amis-rpc-design/libs/amis/packages/amis-ui/scss/components/_drawer.scss

390 lines
8.8 KiB
SCSS
Raw Permalink Normal View History

2023-10-07 19:42:30 +08:00
.#{$ns}Drawer {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: $zindex-modal;
overflow: hidden;
outline: 0;
&-content {
position: absolute;
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
pointer-events: auto;
background: var(--Drawer-bg);
background-clip: padding-box;
outline: 0;
z-index: 2;
border-radius: var(--Drawer-content-borderRadius);
transition: transform ease-in-out var(--animation-duration);
}
&-overlay {
transition: ease-out opacity var(--animation-duration);
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1;
background: var(--Drawer-overlay-bg);
opacity: 0;
&.in {
opacity: 1;
}
}
&-header {
padding: var(--Drawer-header-padding);
background: var(--Drawer-header-bg);
@include clearfix();
border-bottom: var(--Drawer-content-borderWidth) solid
var(--Drawer-header-borderColor);
border-top-left-radius: var(--Drawer-content-borderRadius);
border-top-right-radius: var(--Drawer-content-borderRadius);
}
&-title {
font-size: var(--drawer-header-fontSize);
font-weight: var(--drawer-header-fontWeight);
color: var(--drawer-header-color);
height: var(--drawer-header-height);
}
&-close {
position: absolute;
color: var(--Drawer-close-color);
line-height: 1;
text-decoration: none;
svg {
margin-top: px2rem(2px);
width: var(--drawer-header-icon-size);
height: var(--drawer-header-icon-size);
fill: var(--Drawer-close-color);
color: var(--drawer-header-icon-color);
}
.Drawer-close {
content: var(--drawer-header-icon-icon);
}
&:not(.is-disabled) {
cursor: pointer;
&:hover {
text-decoration: none;
color: var(--Drawer-close-onHover-color);
svg {
fill: var(--Drawer-close-onHover-color);
}
}
}
}
&-body {
padding: 0 var(--drawer-content-paddingRight)
var(--drawer-content-paddingBottom) var(--drawer-content-paddingLeft);
flex-basis: 0;
flex-grow: 1;
overflow: auto;
// 因为如果成员里面有 position:sticky 的内容
// 用 padding 会导致位置不正确
// 所以改成这种写法
&:before {
content: '';
display: block;
height: var(--drawer-content-paddingTop);
}
}
&-footer {
display: flex;
align-items: flex-end;
height: var(--drawer-footer-height);
justify-content: flex-end;
padding: var(--Drawer-footer-padding);
border-top: var(--Drawer-content-borderWidth) solid
var(--Drawer-footer-borderColor);
border-bottom-left-radius: var(--Drawer-content-borderRadius);
border-bottom-right-radius: var(--Drawer-content-borderRadius);
.#{$ns}Button {
margin-left: var(--gap-xs);
}
.#{$ns}Drawer-info {
flex-basis: 0;
flex-grow: 1;
text-align: left;
align-self: center;
}
.#{$ns}Drawer-error {
color: var(--danger);
white-space: pre-wrap;
}
}
&.#{$ns}Drawer--noOverlay {
pointer-events: none;
}
.#{$ns}Drawer-resizeCtrl {
position: absolute;
border: var(--borderWidth) solid var(--borderColor);
background: var(--white);
border-radius: var(--borderRadius);
font-size: var(--fontSizeSm);
line-height: px2rem(10px);
text-align: center;
user-select: none;
}
}
// size
@include media-breakpoint-up(sm) {
.#{$ns}Drawer .#{$ns}Drawer-content {
width: var(--Drawer-widthBase);
height: var(--Drawer-widthBase);
}
.#{$ns}Drawer--xs .#{$ns}Drawer-content {
width: var(--drawer-size-xs-width);
height: var(--Drawer-widthXs);
}
.#{$ns}Drawer--sm .#{$ns}Drawer-content {
width: var(--drawer-size-sm-width);
height: var(--Drawer-widthSm);
}
.#{$ns}Drawer--md .#{$ns}Drawer-content {
width: var(--drawer-size-md-width);
height: var(--Drawer-widthMd);
}
.#{$ns}Drawer--lg .#{$ns}Drawer-content {
width: var(--drawer-size-lg-width);
height: var(--Drawer-widthLg);
}
.#{$ns}Drawer--xl .#{$ns}Drawer-content {
width: var(--drawer-size-xl-width);
height: var(--Drawer-widthXl);
}
// 从第二层弹框开始左右弹框的每层宽度或高度递减
@for $i from 2 through 6 {
$space-diff: 20;
.#{$ns}Drawer--right.#{$ns}Modal--#{$i}th,
.#{$ns}Drawer--left.#{$ns}Modal--#{$i}th {
&.#{$ns}Drawer .#{$ns}Drawer-content {
width: calc(var(--Drawer-widthBase) - #{($i - 1) * $space-diff}px);
}
&.#{$ns}Drawer--xs .#{$ns}Drawer-content {
width: calc(var(--Drawer-widthXs) - #{($i - 1) * $space-diff}px);
}
&.#{$ns}Drawer--sm .#{$ns}Drawer-content {
width: calc(var(--Drawer-widthSm) - #{($i - 1) * $space-diff}px);
}
&.#{$ns}Drawer--md .#{$ns}Drawer-content {
width: calc(var(--Drawer-widthMd) - #{($i - 1) * $space-diff}px);
}
&.#{$ns}Drawer--lg .#{$ns}Drawer-content {
width: calc(var(--Drawer-widthLg) - #{($i - 1) * $space-diff}px);
}
&.#{$ns}Drawer--xl .#{$ns}Drawer-content {
width: calc(var(--Drawer-widthXl) - #{($i - 1) * $space-diff}px);
}
}
.#{$ns}Drawer--top.#{$ns}Modal--#{$i}th,
.#{$ns}Drawer--bottom.#{$ns}Modal--#{$i}th {
&.#{$ns}Drawer .#{$ns}Drawer-content {
height: calc(var(--Drawer-widthBase) - #{($i - 1) * $space-diff}px);
}
&.#{$ns}Drawer--xs .#{$ns}Drawer-content {
height: calc(var(--Drawer-widthXs) - #{($i - 1) * $space-diff}px);
}
&.#{$ns}Drawer--sm .#{$ns}Drawer-content {
height: calc(var(--Drawer-widthSm) - #{($i - 1) * $space-diff}px);
}
&.#{$ns}Drawer--md .#{$ns}Drawer-content {
height: calc(var(--Drawer-widthMd) - #{($i - 1) * $space-diff}px);
}
&.#{$ns}Drawer--lg .#{$ns}Drawer-content {
height: calc(var(--Drawer-widthLg) - #{($i - 1) * $space-diff}px);
}
&.#{$ns}Drawer--xl .#{$ns}Drawer-content {
height: calc(var(--Drawer-widthXl) - #{($i - 1) * $space-diff}px);
}
}
}
}
// positons
.#{$ns}Drawer--top .#{$ns}Drawer-content.in,
.#{$ns}Drawer--right .#{$ns}Drawer-content.in,
.#{$ns}Drawer--bottom .#{$ns}Drawer-content.in,
.#{$ns}Drawer--left .#{$ns}Drawer-content.in {
transform: translate3d(0, 0, 0);
}
.#{$ns}Drawer--top {
.#{$ns}Drawer-close {
top: var(--gap-base);
right: var(--gap-base);
left: auto;
margin-top: 0;
z-index: 10;
}
.#{$ns}Drawer-content {
top: 0;
bottom: auto;
left: 0;
right: 0;
width: 100%;
transform: translate3d(0, -100%, 0);
box-shadow: 0 10px 10px -10px rgba(0, 0, 0, 0.2);
min-height: 120px;
}
.#{$ns}Drawer-resizeCtrl {
bottom: px2rem(-6px);
left: 50%;
cursor: ns-resize;
width: px2rem(24px);
height: px2rem(12px);
}
}
.#{$ns}Drawer--right {
.#{$ns}Drawer-close {
top: var(--gap-md);
right: var(--gap-md);
margin-right: 0;
z-index: 10;
}
.#{$ns}Drawer-content {
top: 0;
bottom: 0;
left: auto;
right: 0;
height: 100%;
transform: translate3d(100%, 0, 0);
box-shadow: -10px 0 10px -10px rgba(0, 0, 0, 0.2);
min-width: 120px;
}
.#{$ns}Drawer-footer {
justify-content: flex-end;
.#{$ns}Button {
margin-left: var(--drawer-footer-margin-left);
margin-right: var(--gap-xs);
}
.#{$ns}Drawer-info {
flex-basis: 0;
flex-grow: 1;
align-self: center;
}
.#{$ns}Drawer-error {
color: var(--danger);
}
}
.#{$ns}Drawer-resizeCtrl {
left: px2rem(-6px);
top: 50%;
cursor: ew-resize;
writing-mode: vertical-lr;
width: px2rem(12px);
height: px2rem(24px);
}
}
.#{$ns}Drawer--bottom {
.#{$ns}Drawer-close {
top: var(--gap-base);
right: var(--gap-base);
left: auto;
margin-bottom: 0;
z-index: 10;
}
.#{$ns}Drawer-content {
top: auto;
bottom: 0;
left: 0;
right: 0;
width: 100%;
transform: translate3d(0, 100%, 0);
box-shadow: 0 -10px 10px -10px rgba(0, 0, 0, 0.2);
min-height: 120px;
}
.#{$ns}Drawer-resizeCtrl {
top: px2rem(-6px);
left: 50%;
cursor: ns-resize;
width: px2rem(24px);
height: px2rem(12px);
}
}
.#{$ns}Drawer--left {
.#{$ns}Drawer-close {
left: auto;
right: var(--gap-base);
top: var(--gap-base);
z-index: 10;
}
.#{$ns}Drawer-content {
top: 0;
bottom: 0;
right: auto;
left: 0;
height: 100%;
transform: translate3d(-100%, 0, 0);
box-shadow: 10px 0 10px -10px rgba(0, 0, 0, 0.2);
border-width: 0 var(--Drawer-content-borderWidth) 0 0;
min-width: 120px;
}
.#{$ns}Drawer-resizeCtrl {
right: px2rem(-6px);
top: 50%;
cursor: ew-resize;
writing-mode: vertical-lr;
width: px2rem(12px);
height: px2rem(24px);
}
.#{$ns}Button {
margin-left: var(--Drawer-footer-margin);
}
}