diff --git a/src/website/.yarn/install-state.gz b/src/website/.yarn/install-state.gz
index 53da514592..59194fdf9d 100644
Binary files a/src/website/.yarn/install-state.gz and b/src/website/.yarn/install-state.gz differ
diff --git a/src/website/packages/fakeyou.com/src/components/providers/ModalProvider/ModalLayer.scss b/src/website/packages/fakeyou.com/src/components/providers/ModalProvider/ModalLayer.scss
new file mode 100644
index 0000000000..ff56ea7f93
--- /dev/null
+++ b/src/website/packages/fakeyou.com/src/components/providers/ModalProvider/ModalLayer.scss
@@ -0,0 +1,44 @@
+@import "scss/_breakpoint.scss";
+@import "scss/breakpoints.scss";
+@import "scss/colours.scss";
+
+.fy-modal-layer {
+ // position: absolute;
+ position: fixed;
+ background: rgba(#000, 0.5);
+ top: 0;
+ left: 0;
+ height: 100vh;
+ width: 100vw;
+ z-index: 2000;
+
+ display: flex;
+ justify-content: center;
+ align-items: center;
+
+ .fy-modal-body {
+ width: 100%;
+ height: fit-content;
+ background-color: $panel;
+ border-color: lighten($panel, 8%) !important;
+ border: 1px solid;
+ border-radius: 0.5rem;
+ box-shadow: 0px 9px 33px 1px rgba(19, 19, 27, 0.8);
+ -webkit-box-shadow: 0px 9px 33px 1px rgba(19, 19, 27, 0.8);
+ -moz-box-shadow: 0px 9px 33px 1px rgba(19, 19, 27, 0.8);
+
+ padding: 1rem;
+
+ max-width: 1140px;
+
+ @include breakpoint($under1200) {
+ max-width: 800px;
+ }
+
+ @include breakpoint($under992) {
+ max-width: 100%;
+ height: 100%;
+ border-radius: 0;
+ }
+ }
+}
diff --git a/src/website/packages/fakeyou.com/src/components/providers/ModalProvider/ModalLayer.tsx b/src/website/packages/fakeyou.com/src/components/providers/ModalProvider/ModalLayer.tsx
new file mode 100644
index 0000000000..24476f288a
--- /dev/null
+++ b/src/website/packages/fakeyou.com/src/components/providers/ModalProvider/ModalLayer.tsx
@@ -0,0 +1,42 @@
+import React from "react";
+import { a, easings, useTransition } from "@react-spring/web";
+import "./ModalLayer.scss";
+
+interface Props {
+ content?: React.ElementType | null;
+ contentProps?: any;
+ handleClose: () => void;
+ killModal: boolean;
+ modalOpen: boolean;
+ onModalCloseEnd: (x: any) => void;
+}
+
+export default function ModalLayer({
+ content: Content,
+ contentProps,
+ handleClose,
+ modalOpen,
+ onModalCloseEnd,
+}: Props) {
+ const tintTransition = useTransition(modalOpen, {
+ config: {
+ easing: modalOpen ? easings.easeOutQuad : easings.easeInQuad,
+ duration: 175,
+ },
+ from: { opacity: 0 },
+ enter: { opacity: 1 },
+ leave: { opacity: 0 },
+ onRest: onModalCloseEnd,
+ });
+
+ return tintTransition(
+ (tinter, shade) =>
+ shade && (
+
+
+ {Content && }
+
+
+ )
+ );
+}
diff --git a/src/website/packages/fakeyou.com/src/components/providers/ModalProvider/ModalProvider.tsx b/src/website/packages/fakeyou.com/src/components/providers/ModalProvider/ModalProvider.tsx
index 711a329dfa..e0ff9cbe34 100644
--- a/src/website/packages/fakeyou.com/src/components/providers/ModalProvider/ModalProvider.tsx
+++ b/src/website/packages/fakeyou.com/src/components/providers/ModalProvider/ModalProvider.tsx
@@ -1,40 +1,65 @@
-import React, { useState } from "react";
+import React, { useEffect, useState } from "react";
import { ModalContext } from "context";
-import { Modal } from "components/common";
-interface Props {
+import ModalLayer from "./ModalLayer";
+
+interface ModalProviderProps {
children?: any;
}
-interface ModalConfig {
+export interface ModalConfig {
component: React.ElementType;
props?: any;
}
-export default function ModalProvider({ children }: Props) {
+// how this works
+//
+// When modalState is set via open(), modalOpen is set to true to via useEffect
+// this is to separate modal rendering (modalOpen) from its state (modalState) to achieve smooth transitions.
+//
+// When close() is run, modalOpen is set to false triggering a ModalLayer transition,
+// and killModal is set to true to indicate an exiting transition.
+// When the transition is complete onModalCloseEnd() runs, and because killModal is true
+// modalState will be cleared, ensuring the state is cleared only when the modal is no longer rendered.
+
+export default function ModalProvider({ children }: ModalProviderProps) {
const [modalState, modalStateSet] = useState(null);
+ const [modalOpen, modalOpenSet] = useState(false);
+ const [killModal, killModalSet] = useState(false);
const open = (cfg: ModalConfig) => modalStateSet(cfg);
- const close = () => modalStateSet(null);
+ const close = () => {
+ modalOpenSet(false);
+ killModalSet(true);
+ };
+ const onModalCloseEnd = () => {
+ if (killModal && modalState) {
+ killModalSet(false);
+ modalStateSet(null);
+ }
+ };
+
+ useEffect(() => {
+ if (!killModal && modalState && !modalOpen) {
+ modalOpenSet(true);
+ }
+ }, [killModal, modalOpen, modalState]);
return (
-
+
{children}
- {
-
- }
+
);
}
diff --git a/src/website/packages/fakeyou.com/src/context/ModalContext.tsx b/src/website/packages/fakeyou.com/src/context/ModalContext.tsx
index cbae90da8b..2560fb3a44 100644
--- a/src/website/packages/fakeyou.com/src/context/ModalContext.tsx
+++ b/src/website/packages/fakeyou.com/src/context/ModalContext.tsx
@@ -1,20 +1,26 @@
-import { createContext } from 'react';
+import { createContext } from "react";
export enum ModalView {
Closed,
Signup,
- Login
+ Login,
}
interface ModalConfig {
- component: React.ElementType,
- props?: any
+ component: React.ElementType;
+ props?: any;
}
-interface AccountModalContext { close: () => void, modalState: ModalConfig | null, open: (comp: any) => void }
+interface AccountModalContext {
+ close: () => void;
+ modalOpen: boolean;
+ modalState: ModalConfig | null;
+ open: (comp: any) => void;
+}
export default createContext({
- close: () => {},
- open: () => {},
- modalState: null,
-});
\ No newline at end of file
+ close: () => {},
+ open: () => {},
+ modalOpen: false,
+ modalState: null,
+});
diff --git a/src/website/packages/fakeyou.com/src/scss/breakpoints.scss b/src/website/packages/fakeyou.com/src/scss/breakpoints.scss
index 555ac5f722..ea8c57d078 100644
--- a/src/website/packages/fakeyou.com/src/scss/breakpoints.scss
+++ b/src/website/packages/fakeyou.com/src/scss/breakpoints.scss
@@ -1,3 +1,5 @@
$under1280: max-width 1280px;
+$over1200: min-width 1200px;
+$under1200: max-width 1200px;
$under992: max-width 992px;
$over992: min-width 992px;