move group chat to sidebar on desktop
This commit is contained in:
parent
b5f0b58898
commit
281b712258
|
@ -8,9 +8,11 @@ export function Page(props: {
|
||||||
rightSidebar?: ReactNode
|
rightSidebar?: ReactNode
|
||||||
suspend?: boolean
|
suspend?: boolean
|
||||||
className?: string
|
className?: string
|
||||||
|
rightSidebarClassName?: string
|
||||||
children?: ReactNode
|
children?: ReactNode
|
||||||
}) {
|
}) {
|
||||||
const { children, rightSidebar, suspend, className } = props
|
const { children, rightSidebar, suspend, className, rightSidebarClassName } =
|
||||||
|
props
|
||||||
|
|
||||||
const bottomBarPadding = 'pb-[58px] lg:pb-0 '
|
const bottomBarPadding = 'pb-[58px] lg:pb-0 '
|
||||||
return (
|
return (
|
||||||
|
@ -37,7 +39,11 @@ export function Page(props: {
|
||||||
<div className="block xl:hidden">{rightSidebar}</div>
|
<div className="block xl:hidden">{rightSidebar}</div>
|
||||||
</main>
|
</main>
|
||||||
<aside className="hidden xl:col-span-3 xl:block">
|
<aside className="hidden xl:col-span-3 xl:block">
|
||||||
<div className="sticky top-4 space-y-4">{rightSidebar}</div>
|
<div
|
||||||
|
className={clsx('sticky top-4 space-y-4', rightSidebarClassName)}
|
||||||
|
>
|
||||||
|
{rightSidebar}
|
||||||
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,8 @@ import { FollowList } from 'web/components/follow-list'
|
||||||
import { SearchIcon } from '@heroicons/react/outline'
|
import { SearchIcon } from '@heroicons/react/outline'
|
||||||
import { useTipTxns } from 'web/hooks/use-tip-txns'
|
import { useTipTxns } from 'web/hooks/use-tip-txns'
|
||||||
import { JoinOrLeaveGroupButton } from 'web/components/groups/groups-button'
|
import { JoinOrLeaveGroupButton } from 'web/components/groups/groups-button'
|
||||||
import { OnlineUserList } from 'web/components/online-user-list'
|
|
||||||
import { searchInAny } from 'common/util/parse'
|
import { searchInAny } from 'common/util/parse'
|
||||||
|
import { useWindowSize } from 'web/hooks/use-window-size'
|
||||||
|
|
||||||
export const getStaticProps = fromPropz(getStaticPropz)
|
export const getStaticProps = fromPropz(getStaticPropz)
|
||||||
export async function getStaticPropz(props: { params: { slugs: string[] } }) {
|
export async function getStaticPropz(props: { params: { slugs: string[] } }) {
|
||||||
|
@ -164,6 +164,9 @@ export default function GroupPage(props: {
|
||||||
writeReferralInfo(creator.username, undefined, referrer, group?.slug)
|
writeReferralInfo(creator.username, undefined, referrer, group?.slug)
|
||||||
}, [user, creator, group, router])
|
}, [user, creator, group, router])
|
||||||
|
|
||||||
|
const { width } = useWindowSize()
|
||||||
|
const showChatSidebar = (width ?? 1280) >= 1280
|
||||||
|
|
||||||
if (group === null || !groupSubpages.includes(page) || slugs[2]) {
|
if (group === null || !groupSubpages.includes(page) || slugs[2]) {
|
||||||
return <Custom404 />
|
return <Custom404 />
|
||||||
}
|
}
|
||||||
|
@ -171,16 +174,6 @@ export default function GroupPage(props: {
|
||||||
const isCreator = user && group && user.id === group.creatorId
|
const isCreator = user && group && user.id === group.creatorId
|
||||||
const isMember = user && memberIds.includes(user.id)
|
const isMember = user && memberIds.includes(user.id)
|
||||||
|
|
||||||
const rightSidebar = (
|
|
||||||
<Col className="mt-6 hidden xl:block">
|
|
||||||
<JoinOrAddQuestionsButtons
|
|
||||||
group={group}
|
|
||||||
user={user}
|
|
||||||
isMember={!!isMember}
|
|
||||||
/>
|
|
||||||
{/* <OnlineUserList users={members} /> */}
|
|
||||||
</Col>
|
|
||||||
)
|
|
||||||
const leaderboard = (
|
const leaderboard = (
|
||||||
<Col>
|
<Col>
|
||||||
<GroupLeaderboards
|
<GroupLeaderboards
|
||||||
|
@ -206,22 +199,25 @@ export default function GroupPage(props: {
|
||||||
</Col>
|
</Col>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const chatTab = group.chatDisabled ? (
|
||||||
|
<></>
|
||||||
|
) : (
|
||||||
|
<Col className="">
|
||||||
|
{messages ? (
|
||||||
|
<GroupChat messages={messages} user={user} group={group} tips={tips} />
|
||||||
|
) : (
|
||||||
|
<LoadingIndicator />
|
||||||
|
)}
|
||||||
|
</Col>
|
||||||
|
)
|
||||||
|
|
||||||
const tabs = [
|
const tabs = [
|
||||||
...(group.chatDisabled
|
...(group.chatDisabled || showChatSidebar
|
||||||
? []
|
? []
|
||||||
: [
|
: [
|
||||||
{
|
{
|
||||||
title: 'Chat',
|
title: 'Chat',
|
||||||
content: messages ? (
|
content: chatTab,
|
||||||
<GroupChat
|
|
||||||
messages={messages}
|
|
||||||
user={user}
|
|
||||||
group={group}
|
|
||||||
tips={tips}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<LoadingIndicator />
|
|
||||||
),
|
|
||||||
href: groupPath(group.slug, GROUP_CHAT_SLUG),
|
href: groupPath(group.slug, GROUP_CHAT_SLUG),
|
||||||
},
|
},
|
||||||
]),
|
]),
|
||||||
|
@ -251,8 +247,13 @@ export default function GroupPage(props: {
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
const tabIndex = tabs.map((t) => t.title).indexOf(page ?? GROUP_CHAT_SLUG)
|
const tabIndex = tabs.map((t) => t.title).indexOf(page ?? GROUP_CHAT_SLUG)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page rightSidebar={rightSidebar} className="!pb-0">
|
<Page
|
||||||
|
rightSidebar={showChatSidebar ? chatTab : undefined}
|
||||||
|
rightSidebarClassName="!top-0"
|
||||||
|
className="!max-w-none !pb-0"
|
||||||
|
>
|
||||||
<SEO
|
<SEO
|
||||||
title={group.name}
|
title={group.name}
|
||||||
description={`Created by ${creator.name}. ${group.about}`}
|
description={`Created by ${creator.name}. ${group.about}`}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user