Make add group button same height as group names (#890)

This commit is contained in:
Sinclair Chen 2022-09-16 15:21:07 -07:00 committed by GitHub
parent ab3ed3fbf1
commit 5b8fc12163
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 55 deletions

View File

@ -127,11 +127,7 @@ export function ContractDetails(props: {
{/* GROUPS */} {/* GROUPS */}
{isMobile && ( {isMobile && (
<div className="mt-2"> <div className="mt-2">
<MarketGroups <MarketGroups contract={contract} disabled={disabled} />
contract={contract}
isMobile={isMobile}
disabled={disabled}
/>
</div> </div>
)} )}
</Col> </Col>
@ -182,11 +178,7 @@ export function MarketSubheader(props: {
isCreator={isCreator} isCreator={isCreator}
/> />
{!isMobile && ( {!isMobile && (
<MarketGroups <MarketGroups contract={contract} disabled={disabled} />
contract={contract}
isMobile={isMobile}
disabled={disabled}
/>
)} )}
</Row> </Row>
</Col> </Col>
@ -233,29 +225,24 @@ export function CloseOrResolveTime(props: {
export function MarketGroups(props: { export function MarketGroups(props: {
contract: Contract contract: Contract
isMobile: boolean | undefined disabled?: boolean
disabled: boolean | undefined
}) { }) {
const [open, setOpen] = useState(false) const [open, setOpen] = useState(false)
const user = useUser() const user = useUser()
const { contract, isMobile, disabled } = props const { contract, disabled } = props
const groupToDisplay = getGroupLinkToDisplay(contract) const groupToDisplay = getGroupLinkToDisplay(contract)
return ( return (
<> <>
<Row className="align-middle"> <Row className="items-center gap-1">
<GroupDisplay groupToDisplay={groupToDisplay} isMobile={isMobile} /> <GroupDisplay groupToDisplay={groupToDisplay} />
{!disabled && ( {!disabled && user && (
<Row> <button
{user && ( className="text-greyscale-4 hover:text-greyscale-3"
<button onClick={() => setOpen(true)}
className="text-greyscale-4 hover:text-greyscale-3" >
onClick={() => setOpen(!open)} <PlusCircleIcon className="h-[18px]" />
> </button>
<PlusCircleIcon className="mb-0.5 mr-0.5 inline h-4 w-4 shrink-0" />
</button>
)}
</Row>
)} )}
</Row> </Row>
<Modal open={open} setOpen={setOpen} size={'md'}> <Modal open={open} setOpen={setOpen} size={'md'}>
@ -333,42 +320,21 @@ export function ExtraMobileContractDetails(props: {
) )
} }
export function GroupDisplay(props: { export function GroupDisplay(props: { groupToDisplay?: GroupLink | null }) {
groupToDisplay?: GroupLink | null const { groupToDisplay } = props
isMobile?: boolean
}) {
const { groupToDisplay, isMobile } = props
if (groupToDisplay) { if (groupToDisplay) {
return ( return (
<Link prefetch={false} href={groupPath(groupToDisplay.slug)}> <Link prefetch={false} href={groupPath(groupToDisplay.slug)}>
<a <a className="bg-greyscale-4 hover:bg-greyscale-3 max-w-[140px] truncate rounded-full px-2 text-xs text-white sm:max-w-[250px]">
className={clsx( {groupToDisplay.name}
'flex flex-row items-center truncate pr-1',
isMobile ? 'max-w-[140px]' : 'max-w-[250px]'
)}
>
<div className="bg-greyscale-4 hover:bg-greyscale-3 text-2xs items-center truncate rounded-full px-2 text-white sm:text-xs">
{groupToDisplay.name}
</div>
</a> </a>
</Link> </Link>
) )
} else } else
return ( return (
<Row <div className="bg-greyscale-4 truncate rounded-full px-2 text-xs text-white">
className={clsx( No Group
'cursor-default select-none items-center truncate pr-1', </div>
isMobile ? 'max-w-[140px]' : 'max-w-[250px]'
)}
>
<div
className={clsx(
'bg-greyscale-4 text-2xs items-center truncate rounded-full px-2 text-white sm:text-xs'
)}
>
No Group
</div>
</Row>
) )
} }

View File

@ -1,6 +1,7 @@
import { useWindowSize } from 'web/hooks/use-window-size' import { useWindowSize } from 'web/hooks/use-window-size'
// matches talwind sm breakpoint
export function useIsMobile() { export function useIsMobile() {
const { width } = useWindowSize() const { width } = useWindowSize()
return (width ?? 0) < 600 return (width ?? 0) < 640
} }