Merge pull request #431 from omnivore-app/fix/grid-labels

Re-enable labels on the grid cards
This commit is contained in:
Jackson Harper 2022-04-14 21:50:04 -07:00 committed by GitHub
commit 40cdd0f9e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View file

@ -1,6 +1,6 @@
import Link from 'next/link'
import { useRouter } from 'next/router'
import { Button } from './Button'
import { SpanBox } from './LayoutPrimitives'
import { StyledText } from './StyledText'
type LabelChipProps = {
text: string
@ -8,6 +8,7 @@ type LabelChipProps = {
}
export function LabelChip(props: LabelChipProps): JSX.Element {
const router = useRouter()
const hexToRgb = (hex: string) => {
const bigint = parseInt(hex.substring(1), 16)
const r = (bigint >> 16) & 255
@ -17,8 +18,12 @@ export function LabelChip(props: LabelChipProps): JSX.Element {
return [r, g, b]
}
const color = hexToRgb(props.color)
return (
<Link href={`/home?q=label:"${props.text}"`}>
<Button style="plainIcon" onClick={(e) => {
router.push(`/home?q=label:"${props.text}"`)
e.stopPropagation()
}}>
<SpanBox
css={{
display: 'inline-table',
@ -27,7 +32,7 @@ export function LabelChip(props: LabelChipProps): JSX.Element {
color: props.color,
fontSize: '12px',
fontWeight: 'bold',
padding: '4px 8px 4px 8px',
padding: '2px 5px 2px 5px',
whiteSpace: 'nowrap',
cursor: 'pointer',
backgroundClip: 'padding-box',
@ -37,6 +42,6 @@ export function LabelChip(props: LabelChipProps): JSX.Element {
>
{props.text}
</SpanBox>
</Link>
</Button>
)
}

View file

@ -154,11 +154,11 @@ export function GridLinkedItemCard(props: LinkedItemCardProps): JSX.Element {
/>
)}
</HStack>
{/* <HStack css={{ mt: '8px' }}>
<Box css={{ display: 'block', mt: '8px' }}>
{props.item.labels?.map(({ name, color }, index) => (
<LabelChip key={index} text={name || ''} color={color} />
))}
</HStack> */}
</Box>
</VStack>
)
}