The second half of the button sweep: the remaining hand-rolled buttons in
feature components, the design lab and the components/ui composites now
stand on Button, IconButton, Pressable, Chip or DragHandle.
- Chip + DismissibleChip (filter / token / tag / suggest / ghost, 24px
floor, 44 on touch) replace five chip geometries; FilterChipGroup
renders Chips; overflow lanes measure a mirror painted by chipClass.
- The Plex control row is IconButton's player rung (36, 20px glyph,
round, overlay; 44 on touch); the YT modal bar is on the sm rung with
pressed cycle toggles and names that survive a folded label.
- New variants: IconButton ghost-accent, danger-soft; Button warn on a
new state-warn utility. The .btn-{tone} recipes and btnCls are gone.
- Fixed on the way: membership rows (collection editor, Plex playlist
add) announce checked/mixed; a one-letter tag chip was 21px wide;
descriptionLinks moved out of lib/ (it renders components).
- local/button-primitive: a raw <button>/<FocusSafeButton> outside the
control-primitive files is a lint error (contract-tested, seen red).
73 lines
2.5 KiB
TypeScript
73 lines
2.5 KiB
TypeScript
import { useTranslation } from "react-i18next";
|
|
import { ExternalLink } from "lucide-react";
|
|
import Avatar from "./ui/Avatar";
|
|
import Tooltip from "./ui/Tooltip";
|
|
import { channelYouTubeUrl } from "../lib/format";
|
|
import { Pressable } from "./ui/Pressable";
|
|
|
|
// Avatar + channel name + "open on YouTube" link, shared by the Channel manager and the
|
|
// discovery list (and anywhere else that lists a channel). When `onView` is given the name
|
|
// is a button that opens the in-app channel view, with middle-click opening YouTube in a new
|
|
// tab; without it the name is plain text.
|
|
export default function ChannelLink({
|
|
id,
|
|
title,
|
|
handle,
|
|
thumbnailUrl,
|
|
onView,
|
|
}: {
|
|
id: string;
|
|
title: string | null;
|
|
handle?: string | null;
|
|
thumbnailUrl: string | null;
|
|
onView?: () => void;
|
|
}) {
|
|
const { t } = useTranslation();
|
|
const ytUrl = channelYouTubeUrl(id, handle);
|
|
const name = title ?? id;
|
|
return (
|
|
<div className="flex items-center gap-2 min-w-0">
|
|
<Avatar src={thumbnailUrl} fallback={title ?? ""} className="w-8 h-8 rounded-full shrink-0" />
|
|
{onView ? (
|
|
<Pressable
|
|
onClick={onView}
|
|
// The channel's "open" element: in a keyboard-walkable list (lib/listNav) Enter on the row or
|
|
// card clicks this.
|
|
data-nav-open=""
|
|
onAuxClick={(e) => {
|
|
// Middle-click opens the channel's YouTube page in a new tab; left-click keeps
|
|
// opening the in-app channel detail.
|
|
if (e.button === 1) {
|
|
e.preventDefault();
|
|
window.open(ytUrl, "_blank", "noopener,noreferrer");
|
|
}
|
|
}}
|
|
onMouseDown={(e) => {
|
|
if (e.button === 1) e.preventDefault(); // suppress middle-click autoscroll
|
|
}}
|
|
// title = the full name, so a truncated fluid-column name is still readable on hover.
|
|
title={name}
|
|
className="text-sm font-medium truncate hover:text-accent min-w-0"
|
|
>
|
|
{name}
|
|
</Pressable>
|
|
) : (
|
|
<span title={name} className="text-sm font-medium truncate min-w-0">
|
|
{name}
|
|
</span>
|
|
)}
|
|
<Tooltip hint={t("channels.row.openOnYouTube")}>
|
|
<a
|
|
href={ytUrl}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="text-muted hover:text-accent shrink-0"
|
|
aria-label={t("channels.row.openOnYouTube")}
|
|
>
|
|
<ExternalLink className="w-3.5 h-3.5" />
|
|
</a>
|
|
</Tooltip>
|
|
</div>
|
|
);
|
|
}
|