Files

42 lines
1.5 KiB
TypeScript
Raw Permalink Normal View History

2026-10-05 18:10:18 -04:00
import type * as React from 'react';
import { Plus, type LucideIcon } from 'lucide-react';
2026-10-12 09:04:03 -04:00
import Button, { RouterLinkButton, type ButtonProps } from '@/components/elements/Button';
2026-10-05 18:10:18 -04:00
import Icon from '@/components/elements/Icon';
2026-10-12 09:04:03 -04:00
import { useSkin } from '@/themes/skins';
2026-10-05 18:10:18 -04:00
interface IconProps {
/** Replaces the Plus for sibling toolbar actions such as Upload. */
icon?: LucideIcon;
}
2026-10-12 09:04:03 -04:00
export type NewButtonProps = ButtonProps & IconProps;
2026-10-05 18:10:18 -04:00
/** The panel's "create" action: a Plus icon and a sentence-case label such as "New node". */
2026-10-12 09:04:03 -04:00
export function NewButton({ icon = Plus, className, children, ...props }: NewButtonProps) {
const ui = useSkin('NewButton', { link: false });
2026-10-05 18:10:18 -04:00
return (
2026-10-12 09:04:03 -04:00
<Button className={ui.classes('root', className)} {...props}>
<span {...ui('content')}>
<Icon icon={icon} aria-hidden {...ui('icon')} />
2026-10-05 18:10:18 -04:00
{children}
</span>
</Button>
);
}
2026-10-12 09:04:03 -04:00
export type NewLinkButtonProps = Omit<React.ComponentProps<typeof RouterLinkButton>, 'children'> &
IconProps & { children: React.ReactNode };
2026-10-05 18:10:18 -04:00
/** `NewButton` for actions that navigate to a create page. */
2026-10-12 09:04:03 -04:00
export function NewLinkButton({ icon = Plus, className, children, ...props }: NewLinkButtonProps) {
const ui = useSkin('NewButton', { link: true });
2026-10-05 18:10:18 -04:00
return (
2026-10-12 09:04:03 -04:00
<RouterLinkButton className={ui.classes('root', className)} {...props}>
<Icon icon={icon} aria-hidden {...ui('icon')} />
2026-10-05 18:10:18 -04:00
{children}
</RouterLinkButton>
);
}