import {CheckBadgeIcon, ShieldCheckIcon} from '@heroicons/react/24/outline' import {SparklesIcon} from '@heroicons/react/24/solid' import clsx from 'clsx' import {MOD_USERNAMES, VERIFIED_USERNAMES} from 'common/envs/constants' import {DAY_MS} from 'common/util/time' import Link from 'next/link' import {Row} from '../layout/row' import {Avatar} from './avatar' import {linkClass} from './site-link' import {Tooltip} from './tooltip' export const isFresh = (createdTime: number) => createdTime > Date.now() - DAY_MS * 14 export function shortenName(name: string) { const firstName = name.split(' ')[0] const maxLength = 10 return firstName.length >= 3 && name.length > maxLength ? firstName.length < maxLength ? firstName : firstName.substring(0, maxLength - 3) + '...' : name.length > maxLength ? name.substring(0, maxLength - 3) + '...' : name } export function UserAvatarAndBadge(props: { user: {id: string; name: string; username: string; avatarUrl?: string} noLink?: boolean className?: string }) { const {user, noLink, className} = props const {username, avatarUrl} = user return ( ) } export function UserLink(props: { user: {id: string; name: string; username: string} className?: string short?: boolean noLink?: boolean createdTime?: number hideBadge?: boolean }) { const { user: {id, name, username}, className, short, noLink, createdTime, hideBadge, } = props const fresh = createdTime ? isFresh(createdTime) : false const shortName = short ? shortenName(name) : name const children = ( <> {shortName} {!hideBadge && } ) if (noLink) { return (
{children}
) } return ( ) => e.stopPropagation()} > {children} ) } // function BotBadge() { // return ( // // Bot // // ) // } export function BannedBadge() { return ( Banned ) } export function UserBadge(props: {userId: string; username: string; fresh?: boolean}) { const {username, fresh} = props const badges = [] if (MOD_USERNAMES.includes(username)) { badges.push() } else if (VERIFIED_USERNAMES.includes(username)) { badges.push() } if (fresh) { badges.push() } return <>{badges} } // Show a normal checkmark next to our mods function ModBadge() { return ( ) } // Show a normal checkmark next to our verified users function VerifiedBadge() { return ( ) } // Show a fresh badge next to new users function FreshBadge() { return ( ) } // export const StackedUserNames = (props: { // user: { // id: string // name: string // username: string // createdTime: number // is_banned_from_posting?: boolean // } // followsYou?: boolean // className?: string // usernameClassName?: string // }) => { // const {user, followsYou, usernameClassName, className} = props // return ( // //
// {user.name} // { // // } // {user.is_banned_from_posting && } //
// // // @{user.username}{' '} // // {followsYou && ( // // Follows you // // )} // // // ) // }