From c29d3d8c92921da9f7493b63a6533adccf2fe66b Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Tue, 14 Oct 2025 20:51:06 +0200 Subject: [PATCH] Clean --- web/components/widgets/user-link.tsx | 140 +++++++++++++-------------- 1 file changed, 69 insertions(+), 71 deletions(-) diff --git a/web/components/widgets/user-link.tsx b/web/components/widgets/user-link.tsx index c7689d95..aef3704c 100644 --- a/web/components/widgets/user-link.tsx +++ b/web/components/widgets/user-link.tsx @@ -1,14 +1,13 @@ import Link from 'next/link' import clsx from 'clsx' -import { VERIFIED_USERNAMES, MOD_IDS } from 'common/envs/constants' -import { SparklesIcon } from '@heroicons/react/solid' -import { Tooltip } from './tooltip' -import { BadgeCheckIcon, ShieldCheckIcon } from '@heroicons/react/outline' -import { Row } from '../layout/row' -import { Avatar } from './avatar' -import { DAY_MS } from 'common/util/time' -import { linkClass } from './site-link' -import { Col } from 'web/components/layout/col' +import {MOD_IDS, VERIFIED_USERNAMES} from 'common/envs/constants' +import {SparklesIcon} from '@heroicons/react/solid' +import {Tooltip} from './tooltip' +import {BadgeCheckIcon, ShieldCheckIcon} from '@heroicons/react/outline' +import {Row} from '../layout/row' +import {Avatar} from './avatar' +import {DAY_MS} from 'common/util/time' +import {linkClass} from './site-link' export const isFresh = (createdTime: number) => createdTime > Date.now() - DAY_MS * 14 @@ -16,15 +15,13 @@ export const isFresh = (createdTime: number) => export function shortenName(name: string) { const firstName = name.split(' ')[0] const maxLength = 10 - const shortName = - firstName.length >= 3 && name.length > maxLength - ? firstName.length < maxLength - ? firstName - : firstName.substring(0, maxLength - 3) + '...' - : name.length > maxLength + 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 - return shortName } export function UserAvatarAndBadge(props: { @@ -32,8 +29,8 @@ export function UserAvatarAndBadge(props: { noLink?: boolean className?: string }) { - const { user, noLink, className } = props - const { username, avatarUrl } = user + const {user, noLink, className} = props + const {username, avatarUrl} = user return ( @@ -43,7 +40,7 @@ export function UserAvatarAndBadge(props: { size={'sm'} noLink={noLink} /> - + ) } @@ -57,7 +54,7 @@ export function UserLink(props: { hideBadge?: boolean }) { const { - user: { id, name, username }, + user: {id, name, username}, className, short, noLink, @@ -70,7 +67,7 @@ export function UserLink(props: { <> {shortName} {!hideBadge && ( - + )} ) @@ -112,7 +109,8 @@ export function BannedBadge() { text="Can't create comments, messages, or questions" placement="bottom" > - + Banned @@ -124,17 +122,17 @@ export function UserBadge(props: { username: string fresh?: boolean }) { - const { userId, username, fresh } = props + const {userId, username, fresh} = props const badges = [] if (MOD_IDS.includes(userId)) { - badges.push() + badges.push() } if (VERIFIED_USERNAMES.includes(username)) { - badges.push() + badges.push() } if (fresh) { - badges.push() + badges.push() } return <>{badges} } @@ -155,7 +153,7 @@ function ModBadge() { function VerifiedBadge() { return ( - + ) } @@ -164,51 +162,51 @@ function VerifiedBadge() { function FreshBadge() { return ( - ) } -export const StackedUserNames = (props: { - user: { - id: string - name: string - username: string - createdTime: number - isBannedFromPosting?: boolean - } - followsYou?: boolean - className?: string - usernameClassName?: string -}) => { - const { user, followsYou, usernameClassName, className } = props - return ( - -
- {user.name} - { - - } - {user.isBannedFromPosting && } -
- - - @{user.username}{' '} - - {followsYou && ( - - Follows you - - )} - - - ) -} +// export const StackedUserNames = (props: { +// user: { +// id: string +// name: string +// username: string +// createdTime: number +// isBannedFromPosting?: boolean +// } +// followsYou?: boolean +// className?: string +// usernameClassName?: string +// }) => { +// const {user, followsYou, usernameClassName, className} = props +// return ( +// +//
+// {user.name} +// { +// +// } +// {user.isBannedFromPosting && } +//
+// +// +// @{user.username}{' '} +// +// {followsYou && ( +// +// Follows you +// +// )} +// +// +// ) +// }