import * as React from 'react'; import { Callout, DirectionalHint, Dropdown, IDropdownOption, Toggle, Slider, mergeStyleSets, FontWeights, Link, Text, Stack, } from '@fluentui/react'; import { useBoolean, useId } from '@fluentui/react-hooks'; import { DefaultButton } from '@fluentui/react/lib/Button'; export const CalloutDirectionalExample: React.FunctionComponent = () => { const [isCalloutVisible, { toggle: toggleIsCalloutVisible }] = useBoolean(false); const [isBeakVisible, { toggle: toggleIsBeakVisible }] = useBoolean(true); const [gapSpace, setGapSpace] = React.useState(); const [beakWidth, setBeakWidth] = React.useState(); const [directionalHint, setDirectionalHint] = React.useState(DirectionalHint.bottomLeftEdge); const buttonId = useId('callout-button'); const labelId = useId('callout-label'); const descriptionId = useId('callout-description'); const onDirectionalChanged = (event: React.FormEvent, option: IDropdownOption): void => { setDirectionalHint(option.key as DirectionalHint); }; const onGapSliderChange = (value: number): void => { setGapSpace(value); }; const onBeakWidthSliderChange = (value: number): void => { setBeakWidth(value); }; const onShowBeakChange = () => { toggleIsBeakVisible(); setBeakWidth(10); }; return ( <> {/* eslint-disable react/jsx-no-bind */} {isBeakVisible && ( )} {/* eslint-enable react/jsx-no-bind */}
{isCalloutVisible ? ( Callout title here Message body is optional. If help documentation is available, consider adding a link to learn more at the bottom. Sample link ) : null} ); }; const DIRECTION_OPTIONS: IDropdownOption[] = [ { key: DirectionalHint.topLeftEdge, text: 'Top left edge' }, { key: DirectionalHint.topCenter, text: 'Top center' }, { key: DirectionalHint.topRightEdge, text: 'Top right edge' }, { key: DirectionalHint.topAutoEdge, text: 'Top auto edge' }, { key: DirectionalHint.bottomLeftEdge, text: 'Bottom left edge' }, { key: DirectionalHint.bottomCenter, text: 'Bottom center' }, { key: DirectionalHint.bottomRightEdge, text: 'Bottom right edge' }, { key: DirectionalHint.bottomAutoEdge, text: 'Bottom auto edge' }, { key: DirectionalHint.leftTopEdge, text: 'Left top edge' }, { key: DirectionalHint.leftCenter, text: 'Left center' }, { key: DirectionalHint.leftBottomEdge, text: 'Left bottom edge' }, { key: DirectionalHint.rightTopEdge, text: 'Right top edge' }, { key: DirectionalHint.rightCenter, text: 'Right center' }, { key: DirectionalHint.rightBottomEdge, text: 'Right bottom edge' }, ]; const styles = mergeStyleSets({ buttonArea: { verticalAlign: 'top', display: 'inline-block', textAlign: 'center', margin: '0 100px', minWidth: 130, height: 32, }, configArea: { width: 300, display: 'inline-block', }, button: { width: 130, }, callout: { width: 320, padding: '20px 24px', }, title: { marginBottom: 12, fontWeight: FontWeights.semilight, }, link: { display: 'block', marginTop: 20, }, });