|
| 1 | +// Copyright (c) Microsoft Corporation. |
| 2 | +// Licensed under the MIT License. |
| 3 | +import { |
| 4 | + AccessibilityComponentRef, |
| 5 | + AccessibilityProvider as AccessibilityProviderComponent, |
| 6 | + ParticipantList, |
| 7 | + useAccessibility |
| 8 | +} from '@azure/communication-react'; |
| 9 | +import { Stack, Panel, DefaultButton } from '@fluentui/react'; |
| 10 | +import React, { useRef, useState } from 'react'; |
| 11 | + |
| 12 | +// eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 13 | +const AccessibilityProviderStory = (props: any): JSX.Element => { |
| 14 | + return ( |
| 15 | + <AccessibilityProviderComponent> |
| 16 | + <Children></Children> |
| 17 | + </AccessibilityProviderComponent> |
| 18 | + ); |
| 19 | +}; |
| 20 | + |
| 21 | +const Children = (): JSX.Element => { |
| 22 | + const [showPane, setShowPane] = useState(false); |
| 23 | + const accessibility = useAccessibility(); |
| 24 | + const componentRef = useRef<AccessibilityComponentRef>(null); |
| 25 | + const mockParticipants = [ |
| 26 | + { displayName: 'Tom', isRemovable: true, userId: 'acs:test:1234' }, |
| 27 | + { displayName: 'Jerry', isRemovable: true, userId: 'acs:test:1234' } |
| 28 | + ]; |
| 29 | + return ( |
| 30 | + <Stack |
| 31 | + styles={{ root: { width: '100%', height: '100%', padding: '3rem' } }} |
| 32 | + horizontalAlign="center" |
| 33 | + verticalAlign="center" |
| 34 | + > |
| 35 | + <DefaultButton |
| 36 | + componentRef={componentRef} |
| 37 | + iconProps={{ iconName: 'Panel Right Add' }} |
| 38 | + onClick={() => setShowPane(!showPane)} |
| 39 | + > |
| 40 | + {'Participants'} |
| 41 | + </DefaultButton> |
| 42 | + <Panel |
| 43 | + onDismiss={() => { |
| 44 | + setShowPane(false); |
| 45 | + accessibility?.componentRef?.focus(); |
| 46 | + }} |
| 47 | + isOpen={showPane} |
| 48 | + headerText="AccessibilityProvider Example" |
| 49 | + > |
| 50 | + <ParticipantList participants={mockParticipants}></ParticipantList> |
| 51 | + </Panel> |
| 52 | + </Stack> |
| 53 | + ); |
| 54 | +}; |
| 55 | + |
| 56 | +export const AccessibilityProvider = AccessibilityProviderStory.bind({}); |
0 commit comments