Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix drawer animation #6767

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
349 changes: 143 additions & 206 deletions packages/design-system/src/css/drawer.scss
Original file line number Diff line number Diff line change
@@ -1,219 +1,156 @@
@use 'mixins/mixins';
@use './common/var';

@keyframes el-drawer-fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}

@mixin drawer-animation($direction) {
@keyframes #{$direction}-drawer-in {
0% {
@if $direction == ltr {
transform: translate(-100%, 0px);
}

@if $direction == rtl {
transform: translate(100%, 0px);
}

@if $direction == ttb {
transform: translate(0px, -100%);
}

@if $direction == btt {
transform: translate(0px, 100%);
}
}

100% {
@if $direction == ltr {
transform: translate(0px, 0px);
}

@if $direction == rtl {
transform: translate(0px, 0px);
}

@if $direction == ttb {
transform: translate(0px, 0px);
}

@if $direction == btt {
transform: translate(0px, 0px);
}
}
}

@keyframes #{$direction}-drawer-out {
0% {
@if $direction == ltr {
transform: translate(0px, 0px);
}

@if $direction == rtl {
transform: translate(0px, 0px);
}

@if $direction == ttb {
transform: translate(0px, 0px);
}

@if $direction == btt {
transform: translate(0px, 0);
}
}

100% {
@if $direction == ltr {
transform: translate(-100%, 0px);
}

@if $direction == rtl {
transform: translate(100%, 0px);
}

@if $direction == ttb {
transform: translate(0px, -100%);
}

@if $direction == btt {
transform: translate(0px, 100%);
}
}
}
}

@mixin animation-in($direction) {
.el-drawer__open &.#{$direction} {
animation: #{$direction}-drawer-in 0.3s 1ms;
}
}

@mixin animation-out($direction) {
&.#{$direction} {
animation: #{$direction}-drawer-out 0.3s;
}
}

// @TODO Fix drawer animations
//@include drawer-animation(rtl);
//@include drawer-animation(ltr);
//@include drawer-animation(ttb);
//@include drawer-animation(btt);

$directions: rtl, ltr, ttb, btt;

@include mixins.b(drawer) {
position: absolute;
box-sizing: border-box;
position: absolute;
box-sizing: border-box;
background-color: var.$dialog-background-color;
display: flex;
flex-direction: column;
display: flex;
flex-direction: column;
box-shadow: 0px 6px 16px rgb(68 28 23 / 6%);
overflow: hidden;
outline: 0;

@each $direction in $directions {
@include animation-out($direction);
@include animation-in($direction);
}

&__wrapper {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: hidden;
margin: 0;
}

&__header {
align-items: center;
color: rgb(114, 118, 123);
display: flex;
margin-bottom: 32px;
padding: var.$dialog-padding-primary;
padding-bottom: 0;
& > :first-child {
flex: 1;
}
}

&__title {
margin: 0;
flex: 1;
line-height: inherit;
font-size: 1rem;
}

&__close-btn {
border: none;
cursor: pointer;
font-size: var.$font-size-extra-large;
color: inherit;
background-color: transparent;
}

&__body {
flex: 1;
& > * {
box-sizing: border-box;
}
}

&.ltr,
&.rtl {
height: 100%;
top: 0;
bottom: 0;
}

&.ttb,
&.btt {
width: 100%;
left: 0;
right: 0;
}

&.ltr {
left: 0;
border-right: var(--border-base);
}

&.rtl {
right: 0;
border-left: var(--border-base);
}

&.ttb {
top: 0;
}

&.btt {
bottom: 0;
}
}
overflow: hidden;

.el-drawer__container {
position: relative;
left: 0;
right: 0;
top: 0;
bottom: 0;
height: 100%;
width: 100%;
}
transition: all 0.3s;

.el-drawer-fade-enter-active {
animation: el-drawer-fade-in 0.3s;
@each $direction in $directions {
.#{$direction} {
transform: translate(0, 0);
}
}

&__sr-focus:focus {
outline: none !important;
}

&__header {
align-items: center;
color: rgb(114, 118, 123);
display: flex;
margin-bottom: 32px;
padding: var.$dialog-padding-primary;
padding-bottom: 0;
& > :first-child {
flex: 1;
}
}

&__title {
margin: 0;
flex: 1;
line-height: inherit;
font-size: 1rem;
}

@include mixins.e(footer) {
padding: var.$dialog-padding-primary;
padding-top: 10px;
text-align: right;
}

&__close-btn {
display: inline-flex;
border: none;
cursor: pointer;
font-size: getCssVar('font-size-extra-large');
color: inherit;
background-color: transparent;
outline: none;
&:focus,
&:hover {
i {
color: getCssVar('color-primary');
}
}
}

&__body {
flex: 1;
padding: 0;

overflow: auto;
& > * {
box-sizing: border-box;
}
}

&.ltr,
&.rtl {
height: 100%;
top: 0;
bottom: 0;
}

&.ttb,
&.btt {
width: 100%;
left: 0;
right: 0;
}

&.ltr {
left: 0;
}

&.rtl {
right: 0;
}

&.ttb {
top: 0;
}

&.btt {
bottom: 0;
}
}

.el-drawer-fade-leave-active {
animation: el-drawer-fade-in 0.3s reverse;
.el-drawer-fade {
&-enter-active,
&-leave-active {
transition: all 0.3s;
}

&-enter-from,
&-enter-active,
&-enter-to,
&-leave-from,
&-leave-active,
&-leave-to {
overflow: hidden !important;
}

&-enter-from,
&-leave-to {
opacity: 0;
}

&-enter-to,
&-leave-from {
opacity: 1;
}

&-enter-from,
&-leave-to {
@each $direction in $directions {
.#{$direction} {
@if $direction == ltr {
transform: translateX(-100%);
}

@if $direction == rtl {
transform: translateX(100%);
}

@if $direction == ttb {
transform: translateY(-100%);
}

@if $direction == btt {
transform: translateY(100%);
}
}
}
}
}
Loading