From b875ac563d08b060fe731ee16f1ac7f17ac15b7d Mon Sep 17 00:00:00 2001 From: Pico2x Date: Wed, 21 Sep 2022 19:14:05 -0400 Subject: [PATCH] Revert "Bring back tabs in groups (#919)" This reverts commit b4a59cfb212dc99d952800e4c18bd2151aa168d5. --- functions/src/utils.ts | 1 + web/components/nav/group-nav-bar.tsx | 94 +++++++++++++++++++++ web/components/nav/group-sidebar.tsx | 82 ++++++++++++++++++ web/components/nav/sidebar.tsx | 17 +--- web/components/page.tsx | 14 +--- web/pages/group/[...slugs]/index.tsx | 119 +++++++++++++++++++-------- 6 files changed, 267 insertions(+), 60 deletions(-) create mode 100644 web/components/nav/group-nav-bar.tsx create mode 100644 web/components/nav/group-sidebar.tsx diff --git a/functions/src/utils.ts b/functions/src/utils.ts index eb5fa8f8..6bb8349a 100644 --- a/functions/src/utils.ts +++ b/functions/src/utils.ts @@ -1,4 +1,5 @@ import * as admin from 'firebase-admin' +import fetch from 'node-fetch' import { chunk } from 'lodash' import { Contract } from '../../common/contract' diff --git a/web/components/nav/group-nav-bar.tsx b/web/components/nav/group-nav-bar.tsx new file mode 100644 index 00000000..9ea3f5a4 --- /dev/null +++ b/web/components/nav/group-nav-bar.tsx @@ -0,0 +1,94 @@ +import { ClipboardIcon, HomeIcon } from '@heroicons/react/outline' +import { Item } from './sidebar-item' + +import clsx from 'clsx' +import { trackCallback } from 'web/lib/service/analytics' +import TrophyIcon from 'web/lib/icons/trophy-icon' +import { useUser } from 'web/hooks/use-user' +import NotificationsIcon from '../notifications-icon' +import router from 'next/router' +import { userProfileItem } from './bottom-nav-bar' + +const mobileGroupNavigation = [ + { name: 'Markets', key: 'markets', icon: HomeIcon }, + { name: 'Leaderboard', key: 'leaderboards', icon: TrophyIcon }, + { name: 'About', key: 'about', icon: ClipboardIcon }, +] + +const mobileGeneralNavigation = [ + { + name: 'Notifications', + key: 'notifications', + icon: NotificationsIcon, + href: '/notifications', + }, +] + +export function GroupNavBar(props: { + currentPage: string + onClick: (key: string) => void +}) { + const { currentPage } = props + const user = useUser() + + return ( + + ) +} + +function NavBarItem(props: { + item: Item + currentPage: string + onClick: (key: string) => void +}) { + const { item, currentPage } = props + const track = trackCallback( + `group navbar: ${item.trackingEventName ?? item.name}` + ) + + return ( + + ) +} diff --git a/web/components/nav/group-sidebar.tsx b/web/components/nav/group-sidebar.tsx new file mode 100644 index 00000000..a68064e0 --- /dev/null +++ b/web/components/nav/group-sidebar.tsx @@ -0,0 +1,82 @@ +import { ClipboardIcon, HomeIcon } from '@heroicons/react/outline' +import clsx from 'clsx' +import { useUser } from 'web/hooks/use-user' +import { ManifoldLogo } from './manifold-logo' +import { ProfileSummary } from './profile-menu' +import React from 'react' +import TrophyIcon from 'web/lib/icons/trophy-icon' +import { SignInButton } from '../sign-in-button' +import NotificationsIcon from '../notifications-icon' +import { SidebarItem } from './sidebar-item' +import { buildArray } from 'common/util/array' +import { User } from 'common/user' +import { Row } from '../layout/row' +import { Spacer } from '../layout/spacer' + +const groupNavigation = [ + { name: 'Markets', key: 'markets', icon: HomeIcon }, + { name: 'About', key: 'about', icon: ClipboardIcon }, + { name: 'Leaderboard', key: 'leaderboards', icon: TrophyIcon }, +] + +const generalNavigation = (user?: User | null) => + buildArray( + user && { + name: 'Notifications', + href: `/notifications`, + key: 'notifications', + icon: NotificationsIcon, + } + ) + +export function GroupSidebar(props: { + groupName: string + className?: string + onClick: (key: string) => void + joinOrAddQuestionsButton: React.ReactNode + currentKey: string +}) { + const { className, groupName, currentKey } = props + + const user = useUser() + + return ( + + ) +} diff --git a/web/components/nav/sidebar.tsx b/web/components/nav/sidebar.tsx index b0a9862b..45347774 100644 --- a/web/components/nav/sidebar.tsx +++ b/web/components/nav/sidebar.tsx @@ -26,14 +26,9 @@ import TrophyIcon from 'web/lib/icons/trophy-icon' import { SignInButton } from '../sign-in-button' import { SidebarItem } from './sidebar-item' import { MoreButton } from './more-button' -import { Row } from '../layout/row' -import { Spacer } from '../layout/spacer' -export default function Sidebar(props: { - className?: string - logoSubheading?: string -}) { - const { className, logoSubheading } = props +export default function Sidebar(props: { className?: string }) { + const { className } = props const router = useRouter() const currentPage = router.pathname @@ -56,13 +51,7 @@ export default function Sidebar(props: { aria-label="Sidebar" className={clsx('flex max-h-[100vh] flex-col', className)} > - - {logoSubheading && ( - - {logoSubheading} - - )} - + {!user && } diff --git a/web/components/page.tsx b/web/components/page.tsx index f72db80e..9b26e9f8 100644 --- a/web/components/page.tsx +++ b/web/components/page.tsx @@ -9,15 +9,8 @@ export function Page(props: { className?: string rightSidebarClassName?: string children?: ReactNode - logoSubheading?: string }) { - const { - children, - rightSidebar, - className, - rightSidebarClassName, - logoSubheading, - } = props + const { children, rightSidebar, className, rightSidebarClassName } = props const bottomBarPadding = 'pb-[58px] lg:pb-0 ' return ( @@ -30,10 +23,7 @@ export function Page(props: { )} > - +
) - const aboutTab = ( + const aboutPage = ( {(group.aboutPostId != null || isCreator || isAdmin) && ( ) - const questionsTab = ( + const questionsPage = ( <> -
-
-
- -
+ {/* align the divs to the right */} +
+
+
) - const tabs = [ + const sidebarPages = [ { title: 'Markets', - content: questionsTab, + content: questionsPage, + href: groupPath(group.slug, 'markets'), + key: 'markets', }, { title: 'Leaderboards', - content: leaderboardTab, + content: leaderboardPage, + href: groupPath(group.slug, 'leaderboards'), + key: 'leaderboards', }, { title: 'About', - content: aboutTab, + content: aboutPage, + href: groupPath(group.slug, 'about'), + key: 'about', }, ] + const pageContent = sidebarPages[sidebarIndex].content + const onSidebarClick = (key: string) => { + const index = sidebarPages.findIndex((t) => t.key === key) + setSidebarIndex(index) + // Append the page to the URL, e.g. /group/mexifold/markets + router.replace( + { query: { ...router.query, slugs: [group.slug, key] } }, + undefined, + { shallow: true } + ) + } + + const joinOrAddQuestionsButton = ( + + ) + return ( - - + - -
- +
+
+ + + + +
+ {pageContent} +
+
- + ) } -export function TopGroupNavBar(props: { group: Group }) { +export function TopGroupNavBar(props: { + group: Group + currentPage: string + onClick: (key: string) => void +}) { return (
@@ -267,6 +317,7 @@ export function TopGroupNavBar(props: { group: Group }) {
+ ) } @@ -279,7 +330,7 @@ function JoinOrAddQuestionsButtons(props: { }) { const { group, user, isMember } = props return user && isMember ? ( - + ) : group.anyoneCanJoin ? (