groups: only change layout if sidebar chat, smaller leave button

This commit is contained in:
mantikoros 2022-07-18 12:55:31 -05:00
parent 39c38a669e
commit 65e4f24531
2 changed files with 20 additions and 18 deletions

View File

@ -135,7 +135,7 @@ export function JoinOrLeaveGroupButton(props: {
return ( return (
<button <button
className={clsx( className={clsx(
'btn btn-outline btn-sm', 'btn btn-outline btn-xs',
small && smallStyle, small && smallStyle,
className className
)} )}

View File

@ -165,7 +165,9 @@ export default function GroupPage(props: {
}, [user, creator, group, router]) }, [user, creator, group, router])
const { width } = useWindowSize() const { width } = useWindowSize()
const showChatSidebar = (width ?? 1280) >= 1280 const chatDisabled = !group || group.chatDisabled
const showChatSidebar = !chatDisabled && (width ?? 1280) >= 1280
const showChatTab = !chatDisabled && !showChatSidebar
if (group === null || !groupSubpages.includes(page) || slugs[2]) { if (group === null || !groupSubpages.includes(page) || slugs[2]) {
return <Custom404 /> return <Custom404 />
@ -199,9 +201,7 @@ export default function GroupPage(props: {
</Col> </Col>
) )
const chatTab = group.chatDisabled ? ( const chatTab = (
<></>
) : (
<Col className=""> <Col className="">
{messages ? ( {messages ? (
<GroupChat messages={messages} user={user} group={group} tips={tips} /> <GroupChat messages={messages} user={user} group={group} tips={tips} />
@ -211,8 +211,19 @@ export default function GroupPage(props: {
</Col> </Col>
) )
const questionsTab = (
<ContractSearch
querySortOptions={{
shouldLoadFromStorage: true,
defaultSort: getSavedSort() ?? 'newest',
defaultFilter: 'open',
}}
additionalFilter={{ groupSlug: group.slug }}
/>
)
const tabs = [ const tabs = [
...(group.chatDisabled || showChatSidebar ...(!showChatTab
? [] ? []
: [ : [
{ {
@ -223,16 +234,7 @@ export default function GroupPage(props: {
]), ]),
{ {
title: 'Questions', title: 'Questions',
content: ( content: questionsTab,
<ContractSearch
querySortOptions={{
shouldLoadFromStorage: true,
defaultSort: getSavedSort() ?? 'newest',
defaultFilter: 'open',
}}
additionalFilter={{ groupSlug: group.slug }}
/>
),
href: groupPath(group.slug, 'questions'), href: groupPath(group.slug, 'questions'),
}, },
{ {
@ -251,8 +253,8 @@ export default function GroupPage(props: {
return ( return (
<Page <Page
rightSidebar={showChatSidebar ? chatTab : undefined} rightSidebar={showChatSidebar ? chatTab : undefined}
rightSidebarClassName="!top-0" rightSidebarClassName={showChatSidebar ? '!top-0' : ''}
className="!max-w-none !pb-0" className={showChatSidebar ? '!max-w-none !pb-0' : ''}
> >
<SEO <SEO
title={group.name} title={group.name}