garage44.eu/jeroen/midas

logclone: git clone https://garage44.eu/jeroen/midas.git

.. /web/src/components/who.tsx

raw

import m from '@garage44/mithril'

import {nameOf} from '@/lib/names'
import {shortName} from '@/lib/format'

/** A session, by its readable name, linked to its conversation where it has one. */
export function who(owner: string, opts: {sub?: boolean; max?: number} = {}) {
    const n = nameOf(owner)
    const title = shortName(n.title, opts.max ?? 60)
    return (
        <span class="who" title={n.owner}>
            {n.link ? (
                <a href={n.link} target={n.link.startsWith('/') ? undefined : '_blank'} rel="noopener">
                    {title}
                </a>
            ) : (
                <b>{title}</b>
            )}
            {opts.sub && n.sub ? <span class="who__sub">{n.sub}</span> : null}
        </span>
    )
}