Make details fit on one line, make group a link

This commit is contained in:
Ian Philips 2022-08-31 08:29:35 -06:00
parent 91e5abe76a
commit 5df594e46a
2 changed files with 30 additions and 23 deletions

View File

@ -5,7 +5,6 @@ import {
TrendingUpIcon, TrendingUpIcon,
UserGroupIcon, UserGroupIcon,
} from '@heroicons/react/outline' } from '@heroicons/react/outline'
import Router from 'next/router'
import clsx from 'clsx' import clsx from 'clsx'
import { Editor } from '@tiptap/react' import { Editor } from '@tiptap/react'
import dayjs from 'dayjs' import dayjs from 'dayjs'
@ -162,13 +161,32 @@ export function ContractDetails(props: {
const { width } = useWindowSize() const { width } = useWindowSize()
const isMobile = (width ?? 0) < 600 const isMobile = (width ?? 0) < 600
const groupInfo = ( const groupInfo = groupToDisplay ? (
<Row> <Row
<UserGroupIcon className="mx-1 inline h-5 w-5 shrink-0" /> className={clsx(
<span className="truncate"> 'items-center pr-2',
{groupToDisplay ? groupToDisplay.name : 'No group'} isMobile ? 'max-w-[140px]' : 'max-w-[250px]'
</span> )}
>
<SiteLink href={groupPath(groupToDisplay.slug)} className={'truncate'}>
<Row>
<UserGroupIcon className="mx-1 inline h-5 w-5 shrink-0" />
<span className="items-center truncate">{groupToDisplay.name}</span>
</Row>
</SiteLink>
</Row> </Row>
) : (
<Button
size={'xs'}
className={'max-w-[200px] pr-2'}
color={'gray-white'}
onClick={() => !groupToDisplay && setOpen(true)}
>
<Row>
<UserGroupIcon className="mx-1 inline h-5 w-5 shrink-0" />
<span className="truncate">No Group</span>
</Row>
</Button>
) )
return ( return (
@ -199,19 +217,8 @@ export function ContractDetails(props: {
<div /> <div />
) : ( ) : (
<Row> <Row>
<Button {groupInfo}
size={'xs'} {user && groupToDisplay && (
className={'max-w-[200px] pr-2'}
color={'gray-white'}
onClick={() =>
groupToDisplay
? Router.push(groupPath(groupToDisplay.slug))
: setOpen(!open)
}
>
{groupInfo}
</Button>
{user && (
<Button <Button
size={'xs'} size={'xs'}
color={'gray-white'} color={'gray-white'}

View File

@ -9,14 +9,14 @@ import { formatMoney } from 'common/util/format'
function shortenName(name: string) { function shortenName(name: string) {
const firstName = name.split(' ')[0] const firstName = name.split(' ')[0]
const maxLength = 10 const maxLength = 11
const shortName = const shortName =
firstName.length >= 4 firstName.length >= 3 && name.length > maxLength
? firstName.length < maxLength ? firstName.length < maxLength
? firstName ? firstName
: firstName.substring(0, maxLength - 3) + '...' : firstName.substring(0, maxLength - 3) + '...'
: name.length > maxLength : name.length > maxLength
? name.substring(0, maxLength) + '...' ? name.substring(0, maxLength - 3) + '...'
: name : name
return shortName return shortName
} }