mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-20 11:12:31 +02:00
basic functionality
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
"use client";
|
||||
|
||||
import { cn } from "@app/lib/cn";
|
||||
import type { LauncherResource } from "@server/routers/launcher/types";
|
||||
import { LauncherLabelsRow } from "./LauncherLabelsRow";
|
||||
import { LauncherResourceAccess } from "./LauncherResourceAccess";
|
||||
import { LauncherResourceIcon } from "./LauncherResourceIcon";
|
||||
import {
|
||||
getLauncherResourceClickProps,
|
||||
useLauncherResourceAction
|
||||
} from "./useLauncherResourceAction";
|
||||
|
||||
type LauncherResourceCardProps = {
|
||||
resource: LauncherResource;
|
||||
showLabels: boolean;
|
||||
};
|
||||
|
||||
export function LauncherResourceCard({
|
||||
resource,
|
||||
showLabels
|
||||
}: LauncherResourceCardProps) {
|
||||
const hasIcon = Boolean(resource.iconUrl);
|
||||
const { handleAction, isClickable } = useLauncherResourceAction({
|
||||
accessUrl: resource.accessUrl,
|
||||
accessCopyValue: resource.accessCopyValue
|
||||
});
|
||||
const clickProps = getLauncherResourceClickProps(handleAction, isClickable);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"flex min-w-0 flex-col gap-2.5 overflow-hidden rounded-xl border border-border bg-background p-4 transition-colors",
|
||||
isClickable && "hover:bg-accent/40",
|
||||
clickProps.className
|
||||
)}
|
||||
onClick={clickProps.onClick}
|
||||
onKeyDown={clickProps.onKeyDown}
|
||||
role={clickProps.role}
|
||||
tabIndex={clickProps.tabIndex}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"flex w-full items-center",
|
||||
hasIcon ? "gap-5" : "gap-0"
|
||||
)}
|
||||
>
|
||||
{hasIcon ? (
|
||||
<LauncherResourceIcon
|
||||
iconUrl={resource.iconUrl}
|
||||
name={resource.name}
|
||||
variant="grid"
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
|
||||
<div className="truncate text-sm font-semibold text-foreground">
|
||||
{resource.name}
|
||||
</div>
|
||||
<LauncherResourceAccess
|
||||
accessDisplay={resource.accessDisplay}
|
||||
accessCopyValue={resource.accessCopyValue}
|
||||
accessUrl={resource.accessUrl}
|
||||
variant="grid"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{showLabels && resource.labels.length > 0 ? (
|
||||
<LauncherLabelsRow labels={resource.labels} />
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user