import * as React from 'react'; import { CommandBar, ICommandBarItemProps } from '@fluentui/react/lib/CommandBar'; import { DirectionalHint } from '@fluentui/react/lib/Callout'; import { Coachmark } from '@fluentui/react/lib/Coachmark'; import { IComponentAsProps, IComponentAs } from '@fluentui/react/lib/Utilities'; import { TeachingBubbleContent } from '@fluentui/react/lib/TeachingBubble'; import { CommandBarButton, IButtonProps } from '@fluentui/react/lib/Button'; interface IIndividualCommandBarButtonAsExampleProps { onDismissCoachmark: () => void; isCoachmarkVisible: boolean; } interface ICoachmarkCommandBarButtonProps extends IComponentAsProps { onDismiss: () => void; isCoachmarkVisible?: boolean; } /** Command bar button with a coachmark and teaching bubble */ const CoachmarkCommandBarButton: React.FunctionComponent = props => { const targetButton = React.useRef(null); const { defaultRender, isCoachmarkVisible, onDismiss, ...buttonProps } = props; const ButtonComponent = defaultRender || CommandBarButton; return ( <>
{isCoachmarkVisible && ( Welcome to the land of Coachmarks! )} ); }; const overflowButtonProps: IButtonProps = { ariaLabel: 'More commands', }; /** Command bar which renders the Share button with a coachmark */ // eslint-disable-next-line @fluentui/max-len const IndividualCommandBarButtonAsExample: React.FunctionComponent = props => { const { onDismissCoachmark, isCoachmarkVisible } = props; const items: ICommandBarItemProps[] = React.useMemo(() => { const CoachmarkButtonWrapper: IComponentAs = (p: IComponentAsProps) => { return ( ); }; return [ { key: 'newItem', text: 'New', iconProps: { iconName: 'Add' }, onClick: () => console.log('New') }, { key: 'upload', text: 'Upload', iconProps: { iconName: 'Upload' }, onClick: () => console.log('Upload') }, { key: 'share', text: 'Share', iconProps: { iconName: 'Share' }, // The Share button will have a coachmark commandBarButtonAs: CoachmarkButtonWrapper, onClick: () => console.log('Share'), }, { key: 'download', text: 'Download', iconProps: { iconName: 'Download' }, onClick: () => console.log('Download'), }, ]; }, [onDismissCoachmark, isCoachmarkVisible]); return ( ); }; export const IndividualCommandBarButtonAsExampleWrapper: React.FunctionComponent = () => { const [isCoachmarkVisible, setIsCoachmarkVisible] = React.useState(true); const onDismissCoachmark = React.useCallback(() => setIsCoachmarkVisible(false), []); return ( ); };