diff --git a/packages/competition/src/App.tsx b/packages/competition/src/App.tsx index 82d9c3e..bb3be1c 100644 --- a/packages/competition/src/App.tsx +++ b/packages/competition/src/App.tsx @@ -8,7 +8,7 @@ function App() { <>
-
+ {/*
*/}
@@ -16,7 +16,7 @@ function App() { setVisible(false)} - width={400} + width={500} > ); diff --git a/packages/ui/lib/Sheet/Sheet.module.scss b/packages/ui/lib/Sheet/Sheet.module.scss index c56a734..b98d71a 100644 --- a/packages/ui/lib/Sheet/Sheet.module.scss +++ b/packages/ui/lib/Sheet/Sheet.module.scss @@ -1,3 +1,14 @@ +@use '../variables' as *; +$animation-duration: $duration-400; +$padding-left-right-distance: 20px; + +@mixin animation($name) { + animation-name: $name; + animation-duration: $animation-duration; + animation-timing-function: ease-in-out; + animation-fill-mode: forwards; +} + .base { height: 100vh; width: 100vw; @@ -6,14 +17,12 @@ top: 0; z-index: 2; box-sizing: border-box; - background-color: rgb(0, 0, 0, 0.4); + background-color: $background-shadow-color; &.showAnimation { - animation: showShadow 0.4s; - animation-fill-mode: forwards; + @include animation(showShadow); } &.hideAnimation { - animation: hideShadow 0.4s; - animation-fill-mode: forwards; + @include animation(hideShadow); } .sheetContent { top: 0; @@ -24,15 +33,13 @@ box-sizing: border-box; opacity: 1; right: 0; - padding: 20px; + padding: $padding-left-right-distance; opacity: 1; &.showAnimation { - animation: slideSheet 0.4s; - animation-fill-mode: forwards; + @include animation(showSlideSheet); } &.hideAnimation { - animation: hideSlideSheet 0.4s; - animation-fill-mode: forwards; + @include animation(hideSlideSheet); } .sheetMainContent { padding: 10px 0; @@ -40,14 +47,14 @@ display: flex; position: relative; height: calc(100vh - 32px - 60px); - top: 31px; + top: 30px; } .sheetFooter { height: 50px; position: absolute; bottom: 20px; width: -webkit-fill-available; - padding-right: 20px; + padding-right: $padding-left-right-distance; text-align: end; background-color: var(--white-color); } @@ -76,7 +83,7 @@ align-items: center; justify-content: center; svg { - transition: all 0.4s ease-in-out; + transition: all $animation-duration ease-in-out; } &:hover { svg { @@ -90,13 +97,13 @@ } .wrapper { - transition: all 400ms ease-in-out; + transition: all $animation-duration ease-in-out; border-radius: 15px; & > div { - transition: all 0.4s ease-in-out; + transition: all $animation-duration ease-in-out; } &.show { - padding: 10px; + padding: 12px; & > div { border-radius: 15px; } @@ -105,25 +112,25 @@ @keyframes showShadow { from { - background-color: rgb(0, 0, 0, 0); + background-color: rgb(var(--black-color-rgb), 0); } to { - background-color: rgb(0, 0, 0, 0.4); + background-color: $background-shadow-color; } } @keyframes hideShadow { from { - background-color: rgb(0, 0, 0, 0.4); + background-color: $background-shadow-color; } to { - background-color: rgb(0, 0, 0, 0); + background-color: rgb(var(--black-color-rgb), 0); } } -@keyframes slideSheet { +@keyframes showSlideSheet { from { - right: -30vw; + right: -30%; } to { right: 0; @@ -135,6 +142,6 @@ right: 0; } to { - right: -30vw; + right: -30%; } } diff --git a/packages/ui/lib/Sheet/SheetWrapper.tsx b/packages/ui/lib/Sheet/SheetWrapper.tsx index 096a90b..138cf12 100644 --- a/packages/ui/lib/Sheet/SheetWrapper.tsx +++ b/packages/ui/lib/Sheet/SheetWrapper.tsx @@ -1,4 +1,4 @@ -import React, { Children, useEffect } from 'react'; +import React from 'react'; import { useWrapperVisibleStore } from './useWrapperVisibleStore'; import styles from './Sheet.module.scss'; @@ -19,7 +19,7 @@ export const SheetWrapper = React.forwardRef( return ( <> -
+
( ref, ) => { const [visible, setVisble] = useState(true); - const [innerVisible, setInnerVisible] = useState(true); const toastClass = classNames( styles['base'], @@ -58,18 +57,12 @@ export const Toast = React.forwardRef( ); useEffect(() => { - if (!visible && close) { - // A delay is set here, in order to see the animation in its entirety - setTimeout(() => { - setInnerVisible(false); - close(); - }, 300); - } + if (!visible && close) close(); }, [visible, close]); return ( <> - {innerVisible && ( + {
(
- )} + } ); }, diff --git a/packages/ui/lib/Toast/showToast.tsx b/packages/ui/lib/Toast/showToast.tsx index c5c5ba8..d1f3be7 100644 --- a/packages/ui/lib/Toast/showToast.tsx +++ b/packages/ui/lib/Toast/showToast.tsx @@ -41,13 +41,12 @@ export const showToast = (props?: ToastProps) => { const moreTimeClose = (div: HTMLDivElement) => { setTimeout(() => { const ToasthideClass: string = classNames(styles['toastHide']); - div.className = ToasthideClass; - + div.classList.add(ToasthideClass); setTimeout(() => { toastContainer?.removeChild(div); toasts = toasts.filter((toast) => toast !== div); - }, 300); - }, 6000); + }, 400); + }, 5000); }; const moreThreeClose = () => { @@ -62,7 +61,9 @@ const moreThreeClose = () => { }; const closeToast = (div: HTMLDivElement) => { - div.remove(); + setTimeout(() => { + div.remove(); + }, 300); toasts = toasts.filter((toast) => toast !== div); addListener(div); expand(toasts); diff --git a/packages/ui/lib/_variables.scss b/packages/ui/lib/_variables.scss index e9a94e1..6cae35b 100644 --- a/packages/ui/lib/_variables.scss +++ b/packages/ui/lib/_variables.scss @@ -75,3 +75,5 @@ $font-size-14: 14px; opacity: 0.4; } +//background color +$background-shadow-color: rgb(var(--black-color-rgb), 0.6);