diff --git a/packages/react-components/react-infobutton/stories/Infobutton/InfoButtonDefault.stories.tsx b/packages/react-components/react-infobutton/stories/Infobutton/InfoButtonDefault.stories.tsx index 337698c2baf854..b9d6fa6e965006 100644 --- a/packages/react-components/react-infobutton/stories/Infobutton/InfoButtonDefault.stories.tsx +++ b/packages/react-components/react-infobutton/stories/Infobutton/InfoButtonDefault.stories.tsx @@ -1,14 +1,46 @@ import * as React from 'react'; -import { InfoButton, InfoButtonProps } from '@fluentui/react-infobutton'; -import { Link } from '@fluentui/react-components'; - -export const Default = (props: Partial) => ( - - This is example information for an InfoButton. Learn more - - } - /> -); +import { InfoButton } from '@fluentui/react-infobutton'; +import { Label, Link, makeStyles, useId } from '@fluentui/react-components'; +import type { InfoButtonProps } from '@fluentui/react-infobutton'; +import type { PopoverProps } from '@fluentui/react-components'; + +const useStyles = makeStyles({ + infoButton: { + verticalAlign: 'top', + }, +}); + +export const Default = (props: Partial) => { + const styles = useStyles(); + const labelId = useId('label'); + const infobuttonId = useId('infobutton'); + const infobuttonInfoId = infobuttonId + '__info'; + + const [open, setOpen] = React.useState(false); + + const info = ( + <> + This is example information for an InfoButton. Learn more + + ); + + const onOpenChange: PopoverProps['onOpenChange'] = (e, data) => setOpen(data.open); + + return ( +
+ + +
+ ); +}; diff --git a/packages/react-components/react-infobutton/stories/Infobutton/InfoButtonSize.stories.tsx b/packages/react-components/react-infobutton/stories/Infobutton/InfoButtonSize.stories.tsx index ef4aaff0149969..7404b280b2dc81 100644 --- a/packages/react-components/react-infobutton/stories/Infobutton/InfoButtonSize.stories.tsx +++ b/packages/react-components/react-infobutton/stories/Infobutton/InfoButtonSize.stories.tsx @@ -1,6 +1,8 @@ import * as React from 'react'; import { InfoButton } from '@fluentui/react-infobutton'; -import { Link, makeStyles, shorthands } from '@fluentui/react-components'; +import { Label, Link, makeStyles, shorthands, useId } from '@fluentui/react-components'; +import type { InfoButtonProps } from '@fluentui/react-infobutton'; +import type { PopoverProps } from '@fluentui/react-components'; const useStyles = makeStyles({ base: { @@ -10,42 +12,56 @@ const useStyles = makeStyles({ ...shorthands.gap('80px'), ...shorthands.padding('20px'), }, + infoButton: { + verticalAlign: 'top', + }, }); -export const Size = () => { +const InfoButtonSize: React.FC<{ size: InfoButtonProps['size'] }> = ({ size }) => { const styles = useStyles(); + const labelId = useId('label'); + const infobuttonId = useId('infobutton'); + const infobuttonInfoId = infobuttonId + '__info'; + + const [open, setOpen] = React.useState(false); + + const info = ( + <> + This is example information for an InfoButton. Learn more + + ); + + const onOpenChange: PopoverProps['onOpenChange'] = (e, data) => setOpen(data.open); return ( -
+
+ - This is example information for a small InfoButton.{' '} - Learn more. - - } + size={size} + id={infobuttonId} + className={styles.infoButton} + info={{ + id: infobuttonInfoId, + children: info, + }} + popover={{ + onOpenChange, + }} /> +
+ ); +}; - - This is example information for a medium InfoButton.{' '} - Learn more. - - } - /> +export const Size = () => { + const styles = useStyles(); - - This is example information for a large InfoButton.{' '} - Learn more. - - } - /> + return ( +
+ + +
); };