@hypothesis/frontend-shared
Version:
Shared components, styles and utilities for Hypothesis projects
70 lines (69 loc) • 2.42 kB
TypeScript
/**
* Common props used for Button components.
*
* @typedef ButtonCommonProps
* @prop {boolean} [expanded] - Is the element associated with this button
* expanded? (set `aria-expanded`)
* @prop {never} [aria-expanded] - Use `expanded` prop instead
* @prop {boolean} [pressed] - Is this button currently "active?" (set
* `aria-pressed` or `aria-selected` depending on button `role`)
* @prop {never} [aria-pressed] - Use `pressed` prop instead
* @prop {string} [title] - Button title; used for `aria-label` attribute
* @prop {never} [aria-label] - Use `title` prop instead
*
* HTML attributes accepted by button components. This eliminates conflicting
* `icon` and `size` attributes.
*
* @typedef {Omit<import('preact').JSX.HTMLAttributes<HTMLButtonElement>, 'icon'|'size'>} HTMLButtonAttributes
*
*/
/**
* @typedef {import('../../types').BaseProps} BaseProps
*
* Base component for Button components. Applies common attributes.
*
* @param {BaseProps & ButtonCommonProps & HTMLButtonAttributes} props
*/
export default function ButtonBase({ elementRef, children, className, expanded, pressed, title, role, ...htmlAttributes }: BaseProps & ButtonCommonProps & HTMLButtonAttributes): import("preact").JSX.Element;
/**
* Common props used for Button components.
*/
export type ButtonCommonProps = {
/**
* - Is the element associated with this button
* expanded? (set `aria-expanded`)
*/
expanded?: boolean | undefined;
/**
* - Use `expanded` prop instead
*/
"aria-expanded"?: undefined;
/**
* - Is this button currently "active?" (set
* `aria-pressed` or `aria-selected` depending on button `role`)
*/
pressed?: boolean | undefined;
/**
* - Use `pressed` prop instead
*/
"aria-pressed"?: undefined;
/**
* - Button title; used for `aria-label` attribute
*/
title?: string | undefined;
/**
* - Use `title` prop instead
*
* HTML attributes accepted by button components. This eliminates conflicting
* `icon` and `size` attributes.
*/
"aria-label"?: undefined;
};
/**
* Common props used for Button components.
*/
export type HTMLButtonAttributes = Omit<import('preact').JSX.HTMLAttributes<HTMLButtonElement>, 'icon' | 'size'>;
/**
* Base component for Button components. Applies common attributes.
*/
export type BaseProps = import('../../types').BaseProps;