Skip to content

Commit ce3d98a

Browse files
add storybook page
1 parent bd9d330 commit ce3d98a

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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({});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { AccessibilityProvider } from '@azure/communication-react';
2+
import * as AccessibilityStories from './index.stories';
3+
import { Canvas, Meta, ArgTypes } from '@storybook/blocks';
4+
5+
<Meta of={AccessibilityStories} />
6+
7+
# AccessibilityProvider
8+
9+
The AccessibilityProvider component is used to provide accessibility features to the components within its context. It allows you to customize the accessibility behavior of the components in your application.
10+
It is important to note that the AccessibilityProvider component should be used at the root of your application or at a higher level in the component tree to ensure that all child components can access the accessibility features.
11+
12+
<Canvas of={AccessibilityStories.AccessibilityProvider} />
13+
14+
## Usage
15+
16+
To use the provider you need to make sure that your application is wrapped in the AccessibilityProvider component. This can be done by wrapping your application in the provider in your main entry file or at a higher level in your component tree.
17+
18+
```tsx
19+
import { AccessibilityProvider } from '@azure/communication-react';
20+
import { App } from './App';
21+
22+
const Main = () => (
23+
<AccessibilityProvider>
24+
<App />
25+
</AccessibilityProvider>
26+
);
27+
```
28+
29+
Then when you are wanting to make sure that you are
30+
31+
<ArgTypes of={AccessibilityProvider} />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
import { AccessibilityProvider } from '@azure/communication-react';
5+
import { Meta } from '@storybook/react';
6+
7+
export { AccessibilityProvider } from './AccessibilityProvider.story';
8+
9+
const meta: Meta = {
10+
title: 'Components/AccessibilityProvider',
11+
component: AccessibilityProvider,
12+
argTypes: {
13+
children: { control: undefined, table: { disable: true } }
14+
}
15+
};
16+
17+
export default meta;

0 commit comments

Comments
 (0)