Size group chat window & nav bar list of groups precisely. Update Page margin/padding.
This commit is contained in:
parent
24fac1fc0b
commit
b8d7c2ee17
|
@ -22,6 +22,7 @@ import { CommentTipMap, CommentTips } from 'web/hooks/use-tip-txns'
|
||||||
import { Tipper } from 'web/components/tipper'
|
import { Tipper } from 'web/components/tipper'
|
||||||
import { sum } from 'lodash'
|
import { sum } from 'lodash'
|
||||||
import { formatMoney } from 'common/util/format'
|
import { formatMoney } from 'common/util/format'
|
||||||
|
import { useWindowSize } from 'web/hooks/use-window-size'
|
||||||
|
|
||||||
export function GroupChat(props: {
|
export function GroupChat(props: {
|
||||||
messages: Comment[]
|
messages: Comment[]
|
||||||
|
@ -101,11 +102,20 @@ export function GroupChat(props: {
|
||||||
inputRef?.focus()
|
inputRef?.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { width, height } = useWindowSize()
|
||||||
|
const [containerRef, setContainerRef] = useState<HTMLDivElement | null>(null)
|
||||||
|
// Subtract bottom bar when it's showing (less than lg screen)
|
||||||
|
const bottomBarHeight = (width ?? 0) < 1024 ? 58 : 0
|
||||||
|
const remainingHeight =
|
||||||
|
(height ?? window.innerHeight) -
|
||||||
|
(containerRef?.offsetTop ?? 0) -
|
||||||
|
bottomBarHeight
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Col className={'mt-2 flex-1'}>
|
<Col ref={setContainerRef} style={{ height: remainingHeight }}>
|
||||||
<Col
|
<Col
|
||||||
className={
|
className={
|
||||||
'max-h-[65vh] min-h-[65vh] w-full space-y-2 overflow-x-hidden overflow-y-scroll'
|
'w-full flex-1 space-y-2 overflow-x-hidden overflow-y-scroll pt-2'
|
||||||
}
|
}
|
||||||
ref={setScrollToBottomRef}
|
ref={setScrollToBottomRef}
|
||||||
>
|
>
|
||||||
|
@ -138,7 +148,7 @@ export function GroupChat(props: {
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
{user && group.memberIds.includes(user.id) && (
|
{user && group.memberIds.includes(user.id) && (
|
||||||
<div className=" flex w-full justify-start gap-2 p-2">
|
<div className="flex w-full justify-start gap-2 p-2">
|
||||||
<div className="mt-1">
|
<div className="mt-1">
|
||||||
<Avatar
|
<Avatar
|
||||||
username={user?.username}
|
username={user?.username}
|
||||||
|
|
|
@ -170,7 +170,7 @@ export function MobileSidebar(props: {
|
||||||
leaveFrom="translate-x-0"
|
leaveFrom="translate-x-0"
|
||||||
leaveTo="-translate-x-full"
|
leaveTo="-translate-x-full"
|
||||||
>
|
>
|
||||||
<div className="relative flex w-full max-w-xs flex-1 flex-col bg-white pt-5 pb-4">
|
<div className="relative flex w-full max-w-xs flex-1 flex-col bg-white">
|
||||||
<Transition.Child
|
<Transition.Child
|
||||||
as={Fragment}
|
as={Fragment}
|
||||||
enter="ease-in-out duration-300"
|
enter="ease-in-out duration-300"
|
||||||
|
@ -191,7 +191,7 @@ export function MobileSidebar(props: {
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</Transition.Child>
|
</Transition.Child>
|
||||||
<div className="mx-2 mt-5 h-0 flex-1 overflow-y-auto">
|
<div className="mx-2 h-0 flex-1 overflow-y-auto">
|
||||||
<Sidebar className="pl-2" />
|
<Sidebar className="pl-2" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { ManifoldLogo } from './manifold-logo'
|
||||||
import { MenuButton } from './menu'
|
import { MenuButton } from './menu'
|
||||||
import { ProfileSummary } from './profile-menu'
|
import { ProfileSummary } from './profile-menu'
|
||||||
import NotificationsIcon from 'web/components/notifications-icon'
|
import NotificationsIcon from 'web/components/notifications-icon'
|
||||||
import React, { useEffect } from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
import { IS_PRIVATE_MANIFOLD } from 'common/envs/constants'
|
import { IS_PRIVATE_MANIFOLD } from 'common/envs/constants'
|
||||||
import { CreateQuestionButton } from 'web/components/create-question-button'
|
import { CreateQuestionButton } from 'web/components/create-question-button'
|
||||||
import { useMemberGroups } from 'web/hooks/use-group'
|
import { useMemberGroups } from 'web/hooks/use-group'
|
||||||
|
@ -29,6 +29,7 @@ import { Spacer } from '../layout/spacer'
|
||||||
import { useUnseenPreferredNotifications } from 'web/hooks/use-notifications'
|
import { useUnseenPreferredNotifications } from 'web/hooks/use-notifications'
|
||||||
import { setNotificationsAsSeen } from 'web/pages/notifications'
|
import { setNotificationsAsSeen } from 'web/pages/notifications'
|
||||||
import { PrivateUser } from 'common/user'
|
import { PrivateUser } from 'common/user'
|
||||||
|
import { useWindowSize } from 'web/hooks/use-window-size'
|
||||||
|
|
||||||
function getNavigation() {
|
function getNavigation() {
|
||||||
return [
|
return [
|
||||||
|
@ -199,7 +200,7 @@ export default function Sidebar(props: { className?: string }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav aria-label="Sidebar" className={className}>
|
<nav aria-label="Sidebar" className={className}>
|
||||||
<ManifoldLogo className="pb-6" twoLine />
|
<ManifoldLogo className="py-6" twoLine />
|
||||||
|
|
||||||
<CreateQuestionButton user={user} />
|
<CreateQuestionButton user={user} />
|
||||||
<Spacer h={4} />
|
<Spacer h={4} />
|
||||||
|
@ -282,6 +283,11 @@ function GroupsList(props: {
|
||||||
})
|
})
|
||||||
}, [currentPage, preferredNotifications])
|
}, [currentPage, preferredNotifications])
|
||||||
|
|
||||||
|
const { height } = useWindowSize()
|
||||||
|
const [containerRef, setContainerRef] = useState<HTMLDivElement | null>(null)
|
||||||
|
const remainingHeight =
|
||||||
|
(height ?? window.innerHeight) - (containerRef?.offsetTop ?? 0)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SidebarItem
|
<SidebarItem
|
||||||
|
@ -289,7 +295,11 @@ function GroupsList(props: {
|
||||||
currentPage={currentPage}
|
currentPage={currentPage}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="mt-1 space-y-0.5">
|
<div
|
||||||
|
className="flex-1 space-y-0.5 overflow-y-scroll"
|
||||||
|
style={{ height: remainingHeight }}
|
||||||
|
ref={setContainerRef}
|
||||||
|
>
|
||||||
{memberItems.map((item) => (
|
{memberItems.map((item) => (
|
||||||
<a
|
<a
|
||||||
key={item.href}
|
key={item.href}
|
||||||
|
|
|
@ -7,28 +7,34 @@ import { Toaster } from 'react-hot-toast'
|
||||||
export function Page(props: {
|
export function Page(props: {
|
||||||
rightSidebar?: ReactNode
|
rightSidebar?: ReactNode
|
||||||
suspend?: boolean
|
suspend?: boolean
|
||||||
|
className?: string
|
||||||
children?: ReactNode
|
children?: ReactNode
|
||||||
}) {
|
}) {
|
||||||
const { children, rightSidebar, suspend } = props
|
const { children, rightSidebar, suspend, className } = props
|
||||||
|
|
||||||
|
const bottomBarPadding = 'pb-[58px] lg:pb-0 '
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
className="mx-auto w-full pb-14 lg:grid lg:grid-cols-12 lg:gap-2 lg:pt-6 xl:max-w-7xl xl:gap-8"
|
className={clsx(
|
||||||
|
className,
|
||||||
|
bottomBarPadding,
|
||||||
|
'mx-auto w-full lg:grid lg:grid-cols-12 lg:gap-x-2 xl:max-w-7xl xl:gap-x-8'
|
||||||
|
)}
|
||||||
style={suspend ? visuallyHiddenStyle : undefined}
|
style={suspend ? visuallyHiddenStyle : undefined}
|
||||||
>
|
>
|
||||||
<Toaster />
|
<Toaster />
|
||||||
<Sidebar className="sticky top-4 hidden divide-gray-300 self-start pl-2 lg:col-span-2 lg:block" />
|
<Sidebar className="sticky top-0 hidden divide-gray-300 self-start pl-2 lg:col-span-2 lg:block" />
|
||||||
<main
|
<main
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'lg:col-span-8',
|
'pt-6 lg:col-span-8',
|
||||||
rightSidebar ? 'xl:col-span-7' : 'xl:col-span-8'
|
rightSidebar ? 'xl:col-span-7' : 'xl:col-span-8'
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|
||||||
{/* If right sidebar is hidden, place its content at the bottom of the page. */}
|
{/* If right sidebar is hidden, place its content at the bottom of the page. */}
|
||||||
<div className="mt-4 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="sticky top-4 space-y-4">{rightSidebar}</div>
|
||||||
|
|
|
@ -215,14 +215,14 @@ export default function GroupPage(props: {
|
||||||
</Col>
|
</Col>
|
||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
<Page rightSidebar={rightSidebar}>
|
<Page rightSidebar={rightSidebar} className="!pb-0">
|
||||||
<SEO
|
<SEO
|
||||||
title={group.name}
|
title={group.name}
|
||||||
description={`Created by ${creator.name}. ${group.about}`}
|
description={`Created by ${creator.name}. ${group.about}`}
|
||||||
url={groupPath(group.slug)}
|
url={groupPath(group.slug)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Col className="px-3 lg:px-1">
|
<Col className="px-3">
|
||||||
<Row className={'items-center justify-between gap-4'}>
|
<Row className={'items-center justify-between gap-4'}>
|
||||||
<div className={'sm:mb-1'}>
|
<div className={'sm:mb-1'}>
|
||||||
<div
|
<div
|
||||||
|
@ -251,7 +251,7 @@ export default function GroupPage(props: {
|
||||||
|
|
||||||
<Tabs
|
<Tabs
|
||||||
currentPageForAnalytics={groupPath(group.slug)}
|
currentPageForAnalytics={groupPath(group.slug)}
|
||||||
className={'mb-0 sm:mb-2'}
|
className={'mx-3 mb-0'}
|
||||||
defaultIndex={
|
defaultIndex={
|
||||||
page === 'rankings'
|
page === 'rankings'
|
||||||
? 2
|
? 2
|
||||||
|
|
|
@ -47,7 +47,7 @@ export default function Notifications() {
|
||||||
if (!user) return <Custom404 />
|
if (!user) return <Custom404 />
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<div className={'p-2 sm:p-4'}>
|
<div className={'px-2 sm:px-4'}>
|
||||||
<Title text={'Notifications'} className={'hidden md:block'} />
|
<Title text={'Notifications'} className={'hidden md:block'} />
|
||||||
<div>
|
<div>
|
||||||
<Tabs
|
<Tabs
|
||||||
|
|
Loading…
Reference in New Issue
Block a user