// Copyright (c) Meta Platforms, Inc. and affiliates.
'use client';
import {useInteractiveRole} from '@astryxdesign/core/hooks';
import {Link} from '@astryxdesign/core/Link';
import {Popover} from '@astryxdesign/core/Popover';
import {Card} from '@astryxdesign/core/Card';
import {Text} from '@astryxdesign/core/Text';
import {VStack} from '@astryxdesign/core/Layout';
// A polymorphic Tile: the hook alone decides what it renders as — href wins,
// then onClick, then a trigger context (Popover), then inert.
function Tile({
href,
onClick,
children,
}: {
href?: string;
onClick?: () => void;
children: React.ReactNode;
}) {
const role = useInteractiveRole({href, onClick});
const body = (
{children}
);
switch (role) {
case 'link':
return {body};
case 'button':
return ;
default:
return body;
}
}
export default function UseInteractiveRoleHookUsage() {
return (
Renders as a link {}}>Renders as a buttonOpened through the tile's context role
}>
Trigger via contextPlain content
);
}