import Link from 'next/link' import styles from './item.module.css' import UpVote from './upvote' import { useEffect, useRef, useState } from 'react' import { NOFOLLOW_LIMIT } from '../lib/constants' import Pin from '../svgs/pushpin-fill.svg' import reactStringReplace from 'react-string-replace' import PollIcon from '../svgs/bar-chart-horizontal-fill.svg' import BountyIcon from '../svgs/bounty-bag.svg' import ActionTooltip from './action-tooltip' import Flag from '../svgs/flag-fill.svg' import { abbrNum } from '../lib/format' import ItemInfo from './item-info' export function SearchTitle ({ title }) { return reactStringReplace(title, /:high\[([^\]]+)\]/g, (match, i) => { return {match} }) } export default function Item ({ item, rank, belowTitle, right, children }) { const [wrap, setWrap] = useState(false) const titleRef = useRef() useEffect(() => { setWrap( Math.ceil(parseFloat(window.getComputedStyle(titleRef.current).lineHeight)) < titleRef.current.clientHeight) }, []) return ( <> {rank ? (
{rank}
) :
}
{item.position ? : item.meDontLike ? : } {right}
{children && (
{children}
)} ) } export function ItemSkeleton ({ rank, children }) { return ( <> {rank ? (
{rank}
) :
}
{children && (
{children}
)} ) }