blob: 1951b4d371a84b76a9e02c4f9edeb6e490782231 (
plain)
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
|
import { forwardRef, type ForwardRefRenderFunction } from 'react';
import { Button, VisuallyHidden, type ButtonProps, Icon } from '../../../atoms';
import styles from './help-button.module.scss';
export type HelpButtonProps = Omit<
ButtonProps,
'aria-label' | 'children' | 'kind' | 'shape'
> & {
/**
* Define an accessible name for the button.
*/
label: string;
};
const HelpButtonWithRef: ForwardRefRenderFunction<
HTMLButtonElement,
HelpButtonProps
> = ({ className = '', isPressed = false, label, ...props }, ref) => {
const btnClass = `${styles.btn} ${className}`;
return (
<Button
{...props}
className={btnClass}
isPressed={isPressed}
ref={ref}
// eslint-disable-next-line react/jsx-no-literals -- Shape allowed
shape="circle"
>
{/* eslint-disable-next-line react/jsx-no-literals -- Config allowed */}
<Icon aria-hidden className={styles.icon} shape="help" size="sm" />
<VisuallyHidden>{label}</VisuallyHidden>
</Button>
);
};
/**
* HelpButton component
*
* Render a button with an interrogation mark icon.
*/
export const HelpButton = forwardRef(HelpButtonWithRef);
|