@patreon/studio
Version:
Patreon Studio Design System
73 lines (72 loc) • 2.33 kB
TypeScript
import type { TextLinkDecoration } from '../../styles/classNameForTextLinkStyle';
import type { BaseProps, ChildrenProps, LoggerProps, StylableProps } from '../../types/component';
import type { BodyTextBundle } from '../../types/type-bundles';
import type { IconComponent, IconProps } from '../Icon/types';
export declare type Variant = 'primary' | 'muted' | 'neutral' | 'critical' | 'success';
export interface BasicTextLinkProps extends BodyTextBundle, BaseProps, StylableProps, LoggerProps, ChildrenProps {
/**
* Specifies color of TextLink
*/
variant?: Variant;
/**
* Decoration style of the text
*/
decoration?: TextLinkDecoration;
/**
* The icon to to display alongside text in a button
*/
icon?: IconComponent;
/**
* Applies disabled styling to the button.
*/
disabled?: boolean;
/**
* Adds an Icon on the right. Only a set list of icons are allowed.
*/
disclosureIcon?: IconComponent;
/**
* Where to display the linked URL
*/
target?: string;
/**
* The relationship of the linked URL.
*/
rel?: string;
/**
* Renders the link as an inline component, rather than an inline-flex component.
* Useful when the link is inline with other surrounding text.
*/
inline?: boolean;
/**
* Custom props to send to the icon
*/
iconProps?: IconProps;
/**
* Custom props to send to the icon
*/
disclosureIconProps?: IconProps;
/** element to render (only applies to `href` links) */
as?: 'a' | ((props: Pick<TextLinkProps, 'href' | 'children'>) => React.JSX.Element);
}
export interface TextLinkWithHref extends BasicTextLinkProps {
/**
* Link destination.
*/
href?: string;
/**
* Function to call when the link is clicked.
*/
onClick?: () => void;
}
export interface TextLinkWithOnClick extends BasicTextLinkProps {
/**
* Function to call when the link is clicked. The event object is passed to the function
* when no href is defined.
*/
onClick?: React.MouseEventHandler<HTMLButtonElement>;
/**
* href is not allowed when used with a fully featured onClick function.
*/
href?: never;
}
export declare type TextLinkProps = TextLinkWithHref | TextLinkWithOnClick;