Skip to content

Commit

Permalink
Migrate stories for Providers and Hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
xuesichao committed Apr 6, 2023
1 parent e35fd90 commit 1304536
Show file tree
Hide file tree
Showing 47 changed files with 193 additions and 86 deletions.
7 changes: 6 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ const config: StorybookConfig = {
prop.parent ? !/node_modules/.test(prop.parent.fileName) : true,
},
},
stories: ['../src/components/sdk/**/*.mdx', '../src/components/*.mdx'],
stories: [
'../src/components/sdk/**/*.mdx',
'../src/components/*.mdx',
'../src/hooks/**/*.mdx',
'../src/providers/**/*.mdx',
],
addons: [
{
name: '@storybook/addon-essentials',
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/introduction.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/Introduction" />

# SDK Hooks
Expand Down
6 changes: 4 additions & 2 deletions src/hooks/sdk/docs/useActiveSpeakersState.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useActiveSpeakersState" />

# useActiveSpeakersState
Expand Down Expand Up @@ -29,7 +31,7 @@ The hook depends on the `MeetingProvider`.
import React from 'react';
import {
MeetingProvider,
useActiveSpeakersState
useActiveSpeakersState,
} from 'amazon-chime-sdk-component-library-react';

const App = () => (
Expand All @@ -40,7 +42,7 @@ const App = () => (

const MyChild = () => {
const activeSpeakers = useActiveSpeakersState();
const list = activeSpeakers.map(id => (
const list = activeSpeakers.map((id) => (
<li>Attendee {id} is an active speaker</li>
));

Expand Down
4 changes: 3 additions & 1 deletion src/hooks/sdk/docs/useAttendeeAudioStatus.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useAttendeeAudioStatus" />

# useAttendeeAudioStatus
Expand Down Expand Up @@ -30,7 +32,7 @@ The hook depends on the `AudioVideoProvider`. If you are using `MeetingProvider`
import React from 'react';
import {
MeetingProvider,
useAttendeeAudioStatus
useAttendeeAudioStatus,
} from 'amazon-chime-sdk-component-library-react';

const App = () => (
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/sdk/docs/useAttendeeStatus.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useAttendeeStatus" />

# useAttendeeStatus
Expand Down
3 changes: 3 additions & 0 deletions src/hooks/sdk/docs/useDeviceLabelTriggerStatus.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useDeviceLabelTriggerStatus" />

# useDeviceLabelTriggerStatus
Expand All @@ -16,6 +18,7 @@ enum DeviceLabelTriggerStatus {
```

`DeviceLabelTriggerStatus.UNTRIGGERED` could mean three cases:

1. `DeviceLabelTrigger` is not triggered to request device permission.
2. Device permission is already granted before and thus `DeviceLabelTrigger` can not be triggered.
3. Device permission is already denied before and thus `DeviceLabelTrigger` can not be triggered.
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/sdk/docs/useLocalAudioInputActivity.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useLocalAudioInputActivity" />

# useLocalAudioInputActivity
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/sdk/docs/useLocalAudioInputActivityPreview.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useLocalAudioInputActivityPreview" />

# useLocalAudioInputActivityPreview
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/sdk/docs/useMediaStreamMetrics.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useMediaStreamMetrics" />

# useMediaStreamMetrics
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/sdk/docs/useMeetingStatus.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useMeetingStatus" />

# useMeetingStatus
Expand Down Expand Up @@ -37,7 +39,7 @@ The hook depends on the `MeetingProvider`.
import React from 'react';
import {
MeetingProvider,
useMeetingStatus
useMeetingStatus,
} from 'amazon-chime-sdk-component-library-react';

const App = () => (
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/sdk/docs/useSelectVideoQuality.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useSelectVideoQuality" />

# useSelectVideoQuality
Expand Down
17 changes: 10 additions & 7 deletions src/hooks/sdk/docs/useToggleLocalMute.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import useToggleLocalMute from '../useToggleLocalMute';

import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useToggleLocalMute" />

# useToggleLocalMute
Expand All @@ -14,7 +16,7 @@ The `useToggleLocalMute` hook returns the state of whether the local user is mut
muted: boolean;

// A function to toggle the local user's mute state
toggleMute: () => void;
toggleMute: () => void;
}
```

Expand All @@ -30,7 +32,10 @@ The hook depends on the `AudioVideoProvider`. If you are using `MeetingProvider`

```jsx
import React from 'react';
import { MeetingProvider, useToggleLocalMute } from 'amazon-chime-sdk-component-library-react';
import {
MeetingProvider,
useToggleLocalMute,
} from 'amazon-chime-sdk-component-library-react';

const App = () => (
<MeetingProvider>
Expand All @@ -42,11 +47,9 @@ const MyChild = () => {
const { muted, toggleMute } = useToggleLocalMute();

return (
<button onClick={toggleMute}>
{ muted ? 'Umute myself' : 'Mute}
</button>
)
}
<button onClick={toggleMute}>{muted ? 'Unmute myself' : 'Mute'}</button>
);
};
```

### Dependencies
Expand Down
2 changes: 2 additions & 0 deletions src/providers/AudioVideoProvider/docs/AudioVideoProvider.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Providers/AudioVideoProvider" />

# AudioVideoProvider
Expand Down
2 changes: 2 additions & 0 deletions src/providers/AudioVideoProvider/docs/useAudioVideo.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useAudioVideo" />

# useAudioVideo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Meta, ArgTypes } from '@storybook/blocks';
import { useBackgroundBlur } from '../';
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useBackgroundBlur" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Meta, ArgTypes } from '@storybook/blocks';
import { useBackgroundReplacement } from '../';
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useBackgroundReplacement" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Providers/ContentShareProvider" />

# ContentShareProvider
Expand Down Expand Up @@ -35,7 +37,7 @@ If you are using `MeetingProvider`, the `ContentShareProvider` is rendered by de
import React from 'react';
import {
MeetingProvider,
useContentShareState
useContentShareState,
} from 'amazon-chime-sdk-component-library-react';

const App = () => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useContentShareControls" />

# useContentShareControls
Expand Down Expand Up @@ -78,15 +80,16 @@ const MyChild = () => {
toggleContentShare(mediaStream);
};

return <button onClick={toggleContentShareCustom}>Toggle content share</button>;
return (
<button onClick={toggleContentShareCustom}>Toggle content share</button>
);
};

const App = () => (
<MeetingProvider>
<MyChild />
</MeetingProvider>
);

```

### Dependencies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useContentShareState" />

# useContentShareState
Expand Down Expand Up @@ -39,7 +41,7 @@ The hook depends on the `ContentShareProvider`. If you are using `MeetingProvide
import React from 'react';
import {
MeetingProvider,
useContentShareState
useContentShareState,
} from 'amazon-chime-sdk-component-library-react';

const App = () => (
Expand Down
27 changes: 18 additions & 9 deletions src/providers/DevicesProvider/docs/AudioInputProvider.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { Meta, ArgTypes } from '@storybook/blocks';
import { AudioInputProvider } from '../AudioInputProvider.tsx';

<Meta title="SDK Providers/AudioInputProvider" />

# AudioInputProvider
Expand All @@ -23,19 +26,23 @@ The `AudioInputProvider` provides a list of the user's available audio input dev
NOTE:

1. In Chrome, there is a "default" device which can used as the current audio input device. When a new device is added during the
meeting, the new device will become the current audio input device also the new "default" device. If you want to get this device change,
it would be better to use `devices`. When a new "default" device is added, the `devices` list will have changed. We suggest you to
watch for changes to `devices[0]` - this will indicate when the "default" device has changed. `selectedDevice` will not be updated when
switching to a new audio device since it stands for the deviceId, and the value of deviceId remains the same, still being `default`.
The deviceId that was previously in use was `default`. When you switch to a new device, that device becomes "default" device. Since the old
deviceId was `default` and the new deviceId is still `default`, so `selectedDevice` does not change. But actually they correspond to different physical devices.
meeting, the new device will become the current audio input device also the new "default" device. If you want to get this device change,
it would be better to use `devices`. When a new "default" device is added, the `devices` list will have changed. We suggest you to
watch for changes to `devices[0]` - this will indicate when the "default" device has changed. `selectedDevice` will not be updated when
switching to a new audio device since it stands for the deviceId, and the value of deviceId remains the same, still being `default`.
The deviceId that was previously in use was `default`. When you switch to a new device, that device becomes "default" device. Since the old
deviceId was `default` and the new deviceId is still `default`, so `selectedDevice` does not change. But actually they correspond to different physical devices.

2. If you are joining a meeting with `DeviceLabels.None` or overriding the default device label trigger function (Check "Get Device Permissions From the Browser" under the [quickstarts](https://aws.github.io/amazon-chime-sdk-component-library-react/?path=/story/quick-starts--page) for more information),
then, the `AudioInputProvider` will not automatically select an audio input device when audio input device list changes. To keep the auto-selection of the audio input device on audio input changes,
you have to either provide `DeviceLabels.Audio` or `DeviceLabels.AudioVideo` to `meetingManager.join` API or `meetingManager.invokeDeviceProvider` API.
then, the `AudioInputProvider` will not automatically select an audio input device when audio input device list changes. To keep the auto-selection of the audio input device on audio input changes,
you have to either provide `DeviceLabels.Audio` or `DeviceLabels.AudioVideo` to `meetingManager.join` API or `meetingManager.invokeDeviceProvider` API.

You can access the state by using the [useAudioInputs](/docs/sdk-hooks-useaudioinputs--page) hook.

## Props

<ArgTypes of={AudioInputProvider} />

## Importing

```javascript
Expand Down Expand Up @@ -67,7 +74,9 @@ const MyChild = () => {

return (
<div>
<p>Current Selected Audio Input Device: {JSON.stringify(selectedDevice)}</p>
<p>
Current Selected Audio Input Device: {JSON.stringify(selectedDevice)}
</p>
<p>Devices</p>
<ul>{items}</ul>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/providers/DevicesProvider/docs/AudioOutputProvider.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Providers/AudioOutputProvider" />

# AudioOutputProvider
Expand Down
7 changes: 7 additions & 0 deletions src/providers/DevicesProvider/docs/DevicesProvider.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { Meta, ArgTypes } from '@storybook/blocks';
import { DevicesProvider } from '../';

<Meta title="SDK Providers/DevicesProvider" />

# DevicesProvider

The `DevicesProvider` renders the audio and video providers, which provide state around the available and currently selected audio and video devices.

## Props

<ArgTypes of={DevicesProvider} />

## Importing

```jsx
Expand Down
2 changes: 2 additions & 0 deletions src/providers/DevicesProvider/docs/VideoInputProvider.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Providers/VideoInputProvider" />

# VideoInputProvider
Expand Down
3 changes: 1 addition & 2 deletions src/providers/DevicesProvider/docs/useAudioOutputs.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Meta, ArgTypes } from '@storybook/blocks';
import { useAudioOutputs } from '../';
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useAudioOutputs" />

Expand Down
4 changes: 3 additions & 1 deletion src/providers/DevicesProvider/docs/useVideoInputs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ const MyChild = () => {

return (
<div>
<p>Current Selected Video Input Device: {JSON.stringify(selectedDevice)}</p>
<p>
Current Selected Video Input Device: {JSON.stringify(selectedDevice)}
</p>
<p>Devices</p>
<ul>{items}</ul>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Providers/FeaturedVideoTileProvider" />

# FeaturedVideoTileProvider

The `FeaturedVideoTileProvider` provides the tile ID of the **most** active speaker, if the speaker is sharing video. If there are no active speakers, or the active speaker is not sharing video, there will be no tile ID.

### State
## State

```javascript
{
Expand All @@ -22,7 +24,7 @@ If you are using `MeetingProvider`, the `FeaturedVideoTileProvider` is rendered
import React from 'react';
import {
MeetingProvider,
useFeaturedTileState
useFeaturedTileState,
} from 'amazon-chime-sdk-component-library-react';

const App = () => (
Expand All @@ -49,7 +51,7 @@ import React from 'react';
import {
RemoteVideoTileProvider,
ActiveSpeakersProvider,
FeaturedVideoTileProvider
FeaturedVideoTileProvider,
} from 'amazon-chime-sdk-component-library-react';

const App = () => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Meta } from '@storybook/blocks';

<Meta title="SDK Hooks/useFeaturedTileState" />

# useFeaturedTileState
Expand Down Expand Up @@ -28,7 +30,7 @@ The hook depends on the `FeaturedVideoTileProvider`. If you are using `MeetingPr
import React from 'react';
import {
MeetingProvider,
useFeaturedTileState
useFeaturedTileState,
} from 'amazon-chime-sdk-component-library-react';

const App = () => (
Expand Down
Loading

0 comments on commit 1304536

Please sign in to comment.