A Pen by Baker Kong_MSFT on CodePen.
Created
December 2, 2020 09:10
-
-
Save kongmengfei/04bf300bd925ec770ad8e3895a5876e7 to your computer and use it in GitHub Desktop.
Fabric Example Pen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//unpkg.com/@fluentui/react@7/dist/fluentui-react.js"></script> | |
<script src="//unpkg.com/@uifabric/react-hooks@7/dist/react-hooks.js"></script> | |
<div id="content"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { DefaultButton, IButtonProps, TeachingBubble, Fabric, initializeIcons } = window.FluentUIReact; | |
const { useBoolean } = window.FabricReactHooks; | |
// Initialize icons in case this example uses them | |
initializeIcons(); | |
const TeachingBubbleBasicExample: React.FunctionComponent = () => { | |
const [teachingBubbleVisible, { toggle: toggleTeachingBubbleVisible }] = useBoolean(false); | |
const [SecteachingBubbleVisible, { toggle: SectoggleTeachingBubbleVisible }] = useBoolean(false); | |
const examplePrimaryButtonProps: IButtonProps = React.useMemo( | |
() => ({ | |
children: 'Show 2nd buble!', | |
onClick: SectoggleTeachingBubbleVisible, | |
}), | |
[SectoggleTeachingBubbleVisible], | |
); | |
const exampleSecondaryButtonProps: IButtonProps = React.useMemo( | |
() => ({ | |
children: 'Maybe later', | |
onClick: toggleTeachingBubbleVisible, | |
}), | |
[toggleTeachingBubbleVisible], | |
); | |
return ( | |
<div> | |
<DefaultButton | |
id="targetButton" | |
onClick={toggleTeachingBubbleVisible} | |
text={teachingBubbleVisible ? 'Hide TeachingBubble' : 'Show TeachingBubble'} | |
/> | |
{teachingBubbleVisible && ( | |
<TeachingBubble | |
target="#targetButton" | |
primaryButtonProps={examplePrimaryButtonProps} | |
secondaryButtonProps={exampleSecondaryButtonProps} | |
onDismiss={toggleTeachingBubbleVisible} | |
headline="Discover what’s trending around you" | |
> | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facere, nulla, ipsum? Molestiae quis aliquam magni | |
harum non? | |
</TeachingBubble> | |
)} | |
{SecteachingBubbleVisible && ( | |
<TeachingBubble | |
target=".ms-TeachingBubble-primaryButton" | |
onDismiss={SectoggleTeachingBubbleVisible} | |
headline="This is my Second techingbubble" | |
> | |
some text goes here ! | |
</TeachingBubble> | |
)} | |
</div> | |
); | |
}; | |
const TeachingBubbleBasicExampleWrapper = () => <Fabric><TeachingBubbleBasicExample /></Fabric>; | |
ReactDOM.render(<TeachingBubbleBasicExampleWrapper />, document.getElementById('content')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment