2025-08-15 14:18:59 +03:00
|
|
|
import { ComponentChild } from "preact";
|
2025-12-15 00:31:36 +02:00
|
|
|
import { CommandNames } from "../../components/app_context";
|
2025-08-15 14:18:59 +03:00
|
|
|
|
|
|
|
|
interface LinkButtonProps {
|
2025-12-15 00:31:36 +02:00
|
|
|
onClick?: () => void;
|
2025-08-15 14:18:59 +03:00
|
|
|
text: ComponentChild;
|
2025-12-15 00:31:36 +02:00
|
|
|
triggerCommand?: CommandNames;
|
2025-08-15 14:18:59 +03:00
|
|
|
}
|
|
|
|
|
|
2025-12-15 00:31:36 +02:00
|
|
|
export default function LinkButton({ onClick, text, triggerCommand }: LinkButtonProps) {
|
2025-08-15 14:18:59 +03:00
|
|
|
return (
|
2025-12-15 01:43:36 +02:00
|
|
|
<a class="tn-link" href="#"
|
2025-12-15 00:31:36 +02:00
|
|
|
data-trigger-command={triggerCommand}
|
2025-12-15 02:23:57 +02:00
|
|
|
role="button"
|
|
|
|
|
onKeyDown={(e)=> {
|
|
|
|
|
if (e.code === "Space") {
|
|
|
|
|
onClick?.();
|
|
|
|
|
}
|
|
|
|
|
}}
|
2025-12-15 00:31:36 +02:00
|
|
|
onClick={(e) => {
|
|
|
|
|
e.preventDefault();
|
2025-12-15 01:43:36 +02:00
|
|
|
onClick?.();
|
2025-12-15 00:31:36 +02:00
|
|
|
}}>
|
2025-08-15 14:18:59 +03:00
|
|
|
{text}
|
|
|
|
|
</a>
|
|
|
|
|
)
|
|
|
|
|
}
|