diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-04-07 22:57:15 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-04-07 22:57:15 +0200 |
| commit | a1e8f1e4426ed3560ce1b76fb73a6969388ed253 (patch) | |
| tree | 1322e27552bbf49b3f14e80d3e0111e154b0ab78 /src/components/molecules/buttons | |
| parent | 4bd651b9e32c568d86b30463858c20ef290d8c07 (diff) | |
chore: add a SelectWithTooltip component
Diffstat (limited to 'src/components/molecules/buttons')
| -rw-r--r-- | src/components/molecules/buttons/help-button.stories.tsx | 28 | ||||
| -rw-r--r-- | src/components/molecules/buttons/help-button.tsx | 15 |
2 files changed, 40 insertions, 3 deletions
diff --git a/src/components/molecules/buttons/help-button.stories.tsx b/src/components/molecules/buttons/help-button.stories.tsx index 2b04a9c..7ed953e 100644 --- a/src/components/molecules/buttons/help-button.stories.tsx +++ b/src/components/molecules/buttons/help-button.stories.tsx @@ -5,6 +5,34 @@ import HelpButtonComponent from './help-button'; export default { title: 'Molecules/Buttons', component: HelpButtonComponent, + argTypes: { + classes: { + control: { + type: 'text', + }, + description: 'Set additional classes to the button.', + table: { + category: 'Options', + }, + type: { + name: 'string', + required: false, + }, + }, + onClick: { + control: { + type: null, + }, + description: 'A callback function to handle click on button.', + table: { + category: 'Events', + }, + type: { + name: 'function', + required: false, + }, + }, + }, } as ComponentMeta<typeof HelpButtonComponent>; const Template: ComponentStory<typeof HelpButtonComponent> = (args) => ( diff --git a/src/components/molecules/buttons/help-button.tsx b/src/components/molecules/buttons/help-button.tsx index 4945bb4..d933829 100644 --- a/src/components/molecules/buttons/help-button.tsx +++ b/src/components/molecules/buttons/help-button.tsx @@ -3,14 +3,19 @@ import { FC } from 'react'; import { useIntl } from 'react-intl'; import styles from './help-button.module.scss'; -export type HelpButtonProps = Pick<ButtonProps, 'onClick'>; +export type HelpButtonProps = Pick<ButtonProps, 'onClick'> & { + /** + * Set additional classes to the button. + */ + classes?: string; +}; /** * HelpButton component * * Render a button with an interrogation mark icon. */ -const HelpButton: FC<HelpButtonProps> = ({ onClick }) => { +const HelpButton: FC<HelpButtonProps> = ({ classes = '', onClick }) => { const intl = useIntl(); const text = intl.formatMessage({ defaultMessage: 'Help', @@ -19,7 +24,11 @@ const HelpButton: FC<HelpButtonProps> = ({ onClick }) => { }); return ( - <Button shape="circle" additionalClasses={styles.btn} onClick={onClick}> + <Button + shape="circle" + additionalClasses={`${styles.btn} ${classes}`} + onClick={onClick} + > <span className="screen-reader-text">{text}</span> <span className={styles.icon}>?</span> </Button> |
