From effbd44f48bdf0172de79414c36c527927f17cec Mon Sep 17 00:00:00 2001 From: Peer Richelsen Date: Wed, 6 Oct 2021 15:05:01 +0100 Subject: [PATCH] added add to home screen banner for login in screens on mobile (#865) --- components/AddToHomescreen.tsx | 52 ++++++++++++++++++++++++++++++++++ pages/auth/login.tsx | 3 ++ 2 files changed, 55 insertions(+) create mode 100644 components/AddToHomescreen.tsx diff --git a/components/AddToHomescreen.tsx b/components/AddToHomescreen.tsx new file mode 100644 index 0000000000..e37e3099d3 --- /dev/null +++ b/components/AddToHomescreen.tsx @@ -0,0 +1,52 @@ +import { XIcon } from "@heroicons/react/outline"; +import { useState } from "react"; + +export default function AddToHomescreen() { + const [closeBanner, setCloseBanner] = useState(false); + + if (typeof window !== "undefined") { + if (window.matchMedia("(display-mode: standalone)").matches) { + return null; + } + } + return ( + !closeBanner && ( +
+
+
+
+
+ + + + + + + +

+ + Add this app to your home screen for faster access and improved experience. + +

+
+ +
+ +
+
+
+
+
+ ) + ); +} diff --git a/pages/auth/login.tsx b/pages/auth/login.tsx index fcbe84d2b6..a622b70338 100644 --- a/pages/auth/login.tsx +++ b/pages/auth/login.tsx @@ -5,6 +5,7 @@ import { useState } from "react"; import { ErrorCode, getSession } from "@lib/auth"; +import AddToHomescreen from "@components/AddToHomescreen"; import Loader from "@components/Loader"; import { HeadSeo } from "@components/seo/head-seo"; @@ -179,6 +180,8 @@ export default function Login({ csrfToken }) { + + ); }