From 167a7c5289c809cde947e309f2e55afce77aa26c Mon Sep 17 00:00:00 2001 From: John SJ Anderson Date: Thu, 24 Oct 2024 16:30:44 -0700 Subject: [PATCH] Convert 'whoami' page to App Router [#134] Note: updates the page to use the default layout with the toolbar and team avatars, in addition to the sponsor logos. --- static-site/app/whoami/page.tsx | 54 +++++++++++++ static-site/app/whoami/styles.module.css | 23 ++++++ static-site/pages/whoami.jsx | 3 - static-site/src/pages/whoami.jsx | 99 ------------------------ 4 files changed, 77 insertions(+), 102 deletions(-) create mode 100644 static-site/app/whoami/page.tsx create mode 100644 static-site/app/whoami/styles.module.css delete mode 100644 static-site/pages/whoami.jsx delete mode 100644 static-site/src/pages/whoami.jsx diff --git a/static-site/app/whoami/page.tsx b/static-site/app/whoami/page.tsx new file mode 100644 index 000000000..da9285945 --- /dev/null +++ b/static-site/app/whoami/page.tsx @@ -0,0 +1,54 @@ +"use client"; + +import React, { useContext } from "react"; + +import { UserContext } from "../../components/user-data-wrapper"; + +import styles from "./styles.module.css"; + +// we don't export a metadata object here because react client +// components aren't allowed to do that, and we need to be a client +// component to get access to the user context + +export default function WhoAmI(): React.ReactElement { + const { user, groupMemberships } = useContext(UserContext); + + return user ? ( +
+ You’re logged in as {user.username}. +

+ You are a member of the following Nextstrain groups, which each contain + a collection of datasets and/or narratives: +

+ Public: + + Private: + + Logout +
+ ) : ( +
+

+ You are not logged in. +
+ Login +

+
+ ); +} diff --git a/static-site/app/whoami/styles.module.css b/static-site/app/whoami/styles.module.css new file mode 100644 index 000000000..1f8b5c99a --- /dev/null +++ b/static-site/app/whoami/styles.module.css @@ -0,0 +1,23 @@ +.userContainer { + font-size: 24px; + font-weight: 300; + line-height: calc(1.4 * var(--niceLineHeight)); + margin: 0 auto; + max-width: 640px; + padding: 130px 0px 80px; + text-align: center; +} + +.userContainer p { + padding-top: 20px; +} + +.subText { + font-size: 18px; + line-height: var(--niceLineHeight); +} + +.userGroupList { + display: table; + margin: 0 auto !important; +} diff --git a/static-site/pages/whoami.jsx b/static-site/pages/whoami.jsx deleted file mode 100644 index 5a866c7c7..000000000 --- a/static-site/pages/whoami.jsx +++ /dev/null @@ -1,3 +0,0 @@ -import dynamic from 'next/dynamic' -const Index = dynamic(() => import("../src/pages/whoami"), {ssr: false}) -export default Index; diff --git a/static-site/src/pages/whoami.jsx b/static-site/src/pages/whoami.jsx deleted file mode 100644 index 8bbd6b8b2..000000000 --- a/static-site/src/pages/whoami.jsx +++ /dev/null @@ -1,99 +0,0 @@ -import React, {Fragment, useContext} from "react"; -import styled from "styled-components"; -import UserDataWrapper, { UserContext } from "../layouts/userDataWrapper"; -import NavBar from '../components/nav-bar'; -import { Logos } from "../components/logos"; -import MainLayout from "../components/layout"; - -const UserPage = () => { - const { user, groupMemberships } = useContext(UserContext); - - const LoggedIn = () => ( - - You're logged in as {user.username}. - - You are a member of the following Nextstrain groups, which each - contain a collection of datasets and/or narratives: - - - Public: - - - {groupMemberships.filter((group) => group.isPublic).map((group) => ( -
  • - {group.name} -
  • - ))} -
    - - Private: - - - {groupMemberships.filter((group) => !group.isPublic).map((group) => ( -
  • - {group.name} -
  • - ))} -
    - Logout -
    - ); - - const LoggedOut = () => ( -

    - You are not logged in.
    - Login -

    - ); - - return ( - - {user - ? LoggedIn() - : LoggedOut() - } - - ); -}; - -const UserContainer = styled.div` - max-width: 640px; - padding: 130px 0px 80px 0px; - margin-top: 0px; - margin-right: auto; - margin-bottom: 0px; - margin-left: auto; - text-align: center; - font-size: 24px; - font-weight: 300; - line-height: ${(props) => 1.4 * props.theme.niceLineHeight}; -`; - -const SubText = styled.p` - line-height: ${(props) => props.theme.niceLineHeight}; - font-size: 18px; -`; - -const UserGroupsList = styled.ul` - display: table; - margin: 0 auto !important; -`; - -const Users = () => { - console.log(""); - return ( - -
    -
    - - - - - -
    -
    -
    - ); -}; - -export default Users;