Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | 31x 20x 20x 20x 20x 20x 31x 20x 20x | import * as React from 'react';
import { Button as ReakitButton } from 'reakit';
import { useClassName, createComponent, createElement, createHook } from '../utils';
import { Icon, IconProps } from '../Icon';
import { VisuallyHidden } from '../VisuallyHidden';
import { Button, ButtonProps } from './Button';
import * as styles from './styles';
export type LocalButtonCloseProps = {
iconProps?: Omit<IconProps, 'icon'>;
/** Accessible label for the button. Default: `"Close"` */
label?: string;
};
export type ButtonCloseProps = ButtonProps & LocalButtonCloseProps;
const useProps = createHook<ButtonCloseProps>(
(props, { themeKey, themeKeyOverride }) => {
const { iconProps, label, ...restProps } = props;
const buttonProps = Button.useProps(restProps);
const className = useClassName({
style: styles.ButtonClose,
styleProps: props,
themeKey,
themeKeyOverride,
prevClassName: buttonProps.className
});
const children = (
<React.Fragment>
<Icon fontSize="300" icon="close" {...iconProps} />
<VisuallyHidden>{label}</VisuallyHidden>
</React.Fragment>
);
return { ...buttonProps, className, children };
},
{ defaultProps: { label: 'Close', kind: 'ghost' }, themeKey: 'Button.Close' }
);
export const ButtonClose = createComponent<ButtonCloseProps>(
props => {
const buttonCloseProps = useProps(props);
return createElement({
children: props.children,
component: ReakitButton,
use: props.use,
htmlProps: buttonCloseProps
});
},
{
attach: {
useProps
},
themeKey: 'Button.Close'
}
);
|