1 import classNames from "classnames";
2 import { Component } from "inferno";
3 import { Link } from "inferno-router";
4 import { Person } from "lemmy-js-client";
5 import { hostname, isCakeDay, relTags, showAvatars } from "../../utils";
6 import { PictrsImage } from "../common/pictrs-image";
7 import { CakeDay } from "./cake-day";
9 interface PersonListingProps {
12 useApubName?: boolean;
15 showApubName?: boolean;
18 export class PersonListing extends Component<PersonListingProps, any> {
19 constructor(props: any, context: any) {
20 super(props, context);
24 const person = this.props.person;
25 const local = person.local;
26 let apubName: string, link: string;
29 apubName = `@${person.name}`;
30 link = `/u/${person.name}`;
32 const domain = hostname(person.actor_id);
33 apubName = `@${person.name}@${domain}`;
34 link = !this.props.realLink
35 ? `/u/${person.name}@${domain}`
39 let displayName = this.props.useApubName
41 : person.display_name ?? apubName;
43 if (this.props.showApubName && !local && person.display_name) {
44 displayName = `${displayName} (${apubName})`;
49 {!this.props.realLink ? (
52 className={classNames("d-inline-flex align-items-baseline", {
53 "text-muted": this.props.muted,
54 "text-info": !this.props.muted,
58 {this.avatarAndName(displayName)}
63 className={`d-inline-flex align-items-baseline ${
64 this.props.muted ? "text-muted" : "text-info"
69 {this.avatarAndName(displayName)}
73 {isCakeDay(person.published) && <CakeDay creatorName={apubName} />}
78 avatarAndName(displayName: string) {
79 const avatar = this.props.person.avatar;
82 {!this.props.hideAvatar &&
83 !this.props.person.banned &&
86 src={avatar ?? "/static/assets/icons/icon-96x96.png"}
90 <span>{displayName}</span>