diff --git a/app/components/Guide.tsx b/app/components/Guide.tsx index bbc55b51b0..5505fbe6bf 100644 --- a/app/components/Guide.tsx +++ b/app/components/Guide.tsx @@ -1,9 +1,14 @@ import * as React from "react"; -import { Dialog, DialogBackdrop, useDialogState } from "reakit/Dialog"; +import * as Dialog from "@radix-ui/react-dialog"; import styled from "styled-components"; import { depths, s } from "@shared/styles"; import Scrollable from "~/components/Scrollable"; -import usePrevious from "~/hooks/usePrevious"; +import { + fadeIn, + fadeOut, + fadeInAndSlideLeft, + fadeOutAndSlideRight, +} from "~/styles/animations"; type Props = { children?: React.ReactNode; @@ -18,55 +23,33 @@ const Guide: React.FC = ({ title = "Untitled", onRequestClose, ...rest -}: Props) => { - const dialog = useDialogState({ - animated: 250, - }); - const wasOpen = usePrevious(isOpen); +}: Props) => ( + !open && onRequestClose()}> + + + + + {title &&
{title}
} + {children} +
+
+
+
+
+); - React.useEffect(() => { - if (!wasOpen && isOpen) { - dialog.show(); - } - - if (wasOpen && !isOpen) { - dialog.hide(); - } - }, [dialog, wasOpen, isOpen]); - - return ( - - {(backdropProps) => ( - - - {(dialogProps) => ( - - - {title &&
{title}
} - {children} -
-
- )} -
-
- )} -
- ); -}; - -const Header = styled.h1` +const Header = styled(Dialog.Title)` font-size: 18px; margin-top: 0; margin-bottom: 1em; `; -const Backdrop = styled.div` +const StyledOverlay = styled(Dialog.Overlay)` position: fixed; top: 0; left: 0; @@ -74,37 +57,37 @@ const Backdrop = styled.div` bottom: 0; background-color: ${s("backdrop")} !important; z-index: ${depths.overlay}; - transition: opacity 200ms ease-in-out; - opacity: 0; - &[data-enter] { - opacity: 1; + &[data-state="open"] { + animation: ${fadeIn} 200ms ease; + } + + &[data-state="closed"] { + animation: ${fadeOut} 200ms ease; } `; -const Scene = styled.div` +const Scene = styled(Dialog.Content)` position: absolute; top: 0; right: 0; bottom: 0; margin: 12px; - z-index: ${depths.modal}; display: flex; + z-index: ${depths.modal}; justify-content: center; align-items: flex-start; width: 350px; background: ${s("background")}; border-radius: 8px; outline: none; - opacity: 0; - transform: translateX(16px); - transition: - transform 250ms ease, - opacity 250ms ease; - &[data-enter] { - opacity: 1; - transform: translateX(0px); + &[data-state="open"] { + animation: ${fadeInAndSlideLeft} 200ms ease; + } + + &[data-state="closed"] { + animation: ${fadeOutAndSlideRight} 200ms ease; } `; diff --git a/app/styles/animations.ts b/app/styles/animations.ts index c00c085c3b..107ac5cad9 100644 --- a/app/styles/animations.ts +++ b/app/styles/animations.ts @@ -5,6 +5,11 @@ export const fadeIn = keyframes` to { opacity: 1; } `; +export const fadeOut = keyframes` + from { opacity: 1; } + to { opacity: 0; } +`; + export const fadeOutCursor = keyframes` 0% { opacity: 1; } 90% { opacity: 1; } @@ -47,6 +52,30 @@ export const fadeAndSlideUp = keyframes` } `; +export const fadeInAndSlideLeft = keyframes` + from { + opacity: 0; + transform: translateX(10px); + } + + to { + opacity: 1; + transform: translateX(0px); + } +`; + +export const fadeOutAndSlideRight = keyframes` + from { + opacity: 1; + transform: translateX(0); + } + + to { + opacity: 0; + transform: translateX(10px); + } +`; + export const mobileContextMenu = keyframes` from { opacity: 0;