-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: storybook hooks docs #1010
Closed
+2,476
−118
Closed
Changes from 51 commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
7b56f48
fix: remove unused @param peerId from jsdoc
zakybilfagih 26c42a8
fix: export pagination component from story
zakybilfagih 98e22e3
fix: role should be roleName
zakybilfagih c2585cc
feat: add fake role on fake store
zakybilfagih 86b5b26
feat: add more stub on storybooksdk reactsdk stub
zakybilfagih d0b9e72
feat: useAVToggle hook example
zakybilfagih 8ad1b1c
feat: useCustomEvent example
zakybilfagih 3611ad5
feat: useRemoteAVToggle example
zakybilfagih 2b9148c
feat: useVideo example
zakybilfagih 48703b7
feat: useVideoList example
zakybilfagih 0c9ac1f
fix: useState dependency array errors
zakybilfagih 2337b7c
fix: add type to custom event message
zakybilfagih 8a37720
fix: remove unused block statement
zakybilfagih 5e2049f
fix: move hooks stories to seperate folder
zakybilfagih 233a82b
fix: move mdx file
zakybilfagih eec1050
feat: add useDevices hook
zakybilfagih e405300
feat: add useScreenShare hook
zakybilfagih 6c619b0
feat: docs for av toogle
amar-1995 aaf15cd
fix: try to resolve hooks error (still not working)
zakybilfagih 7b8fe39
feat: av toggle updated docs
amar-1995 3f80c31
fix: minor fixes
zakybilfagih 7160974
fix: change text variant screenshare story
zakybilfagih e8ed15b
feat: add useParticipants hook
zakybilfagih 6fe8627
fix: merge with latest remote
zakybilfagih 32d9cd4
feat: add useVideo docs
zakybilfagih 4ae95f3
feat: added interface to useAVToggle hook
zakybilfagih 76026fe
feat: add useVideoList mdx
zakybilfagih db509e3
fix: move example above code snippet
zakybilfagih 6478dae
feat: add useScreenShare mdx
zakybilfagih 5d04c96
feat: add useDevices mdx
zakybilfagih 19cefb0
feat: add useCustomEvent mdx
zakybilfagih 7dabc0f
fix: updated and revert useAVToggle mdx
zakybilfagih ec71727
feat: stub foir useAutoPlayError hook
zakybilfagih 254d4c4
feat: added docs of use participants
amar-1995 513de1a
feat: added docs block in stories
amar-1995 6432ff2
feat: added story for useautoplayError
amar-1995 23ddb19
feat: lint fix story for useautoplayError
amar-1995 d7c5b45
feat: docs update for remote av
amar-1995 180cbb3
feat: added stub storybook notification
zakybilfagih b3fb00e
feat: useAutoplayError
zakybilfagih 0b0a4ec
fix: minor changes
zakybilfagih fd7eb53
fix: make icon name uniform
zakybilfagih 8db3ace
fix: prettier error
zakybilfagih 4cbfa39
fix: remove ts-ignore
zakybilfagih 6546dbc
fix: av toogle docs update
amar-1995 d1e5edd
feat: added docs for useaudioLevelStyles
amar-1995 f9de301
feat: added docs for usePreviewjoin
amar-1995 ad9ab67
fix: minor style changes
zakybilfagih dd18ecf
feat: added stub for useAudioLevelStyles
zakybilfagih f6a7002
feat: added stub for usePreviewJoin
zakybilfagih 6abffc5
fix: update mdx to current example
zakybilfagih 984f7d6
fix: add the definition of DialogContent
zakybilfagih 4641223
fix: wrap function in useCallback
zakybilfagih 51a9d30
feat: added css reset on storybook entry file
zakybilfagih 233cd62
fix: remove previous css on pagination
zakybilfagih bbd08cb
fix: added default font on select component
zakybilfagih d5956a5
fix: move pagination, center story
zakybilfagih 0721770
fix: video list remove overflow
zakybilfagih 91289df
fix: theme map merging
zakybilfagih 0ff2f24
fix: remove value from effect deps
zakybilfagih 89bfbd7
fix: fix not adding className
zakybilfagih 0f31e86
Merge branch 'main' into feat/storybook-hooks
zakybilfagih 4ebeb83
fix: dark mode styling issue
zakybilfagih 7369a18
fix: eslint rule and prettier error
zakybilfagih a74dd6e
fix: try removing base css
zakybilfagih e8cb426
fix: change merging strategy
zakybilfagih File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
74 changes: 44 additions & 30 deletions
74
packages/react-icons/src/100MsLogo.tsx → packages/react-icons/src/100MsLogoIcon.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as React from 'react'; | ||
import { SVGProps } from 'react'; | ||
|
||
const SvgAlternativeHeadphonesIcon = (props: SVGProps<SVGSVGElement>) => ( | ||
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}> | ||
<path | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
d="M8.16 7.317A5.456 5.456 0 0 1 12 5.719a5.455 5.455 0 0 1 5.438 5.439v.39a4.138 4.138 0 0 0-.375-.017 1.875 1.875 0 0 0-1.875 1.875v4.5a1.875 1.875 0 0 0 1.874 1.875 4.125 4.125 0 0 0 1.875-7.799v-.828a6.955 6.955 0 0 0-6.935-6.935l-.002.75-.002-.75a6.956 6.956 0 0 0-6.935 6.935v.828a4.126 4.126 0 0 0 1.875 7.8 1.875 1.875 0 0 0 1.875-1.876v-4.5a1.875 1.875 0 0 0-1.876-1.875c-.125 0-.25.006-.375.017v-.39A5.456 5.456 0 0 1 8.16 7.316ZM6.937 13.03a2.625 2.625 0 0 0 0 5.25.375.375 0 0 0 .375-.375v-4.5a.375.375 0 0 0-.375-.375Zm10.125 0a.375.375 0 0 0-.375.375v4.5a.375.375 0 0 0 .375.375 2.625 2.625 0 1 0 0-5.25Z" | ||
fill="#000" | ||
/> | ||
</svg> | ||
); | ||
|
||
export default SvgAlternativeHeadphonesIcon; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as React from 'react'; | ||
import { SVGProps } from 'react'; | ||
|
||
const SvgHandRaiseSlashedIcon = (props: SVGProps<SVGSVGElement>) => ( | ||
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}> | ||
<path | ||
d="M3.046 4.107a.75.75 0 1 1 1.06-1.06l16.848 16.846a.75.75 0 1 1-1.06 1.06L3.045 4.108Z" | ||
fill="currentColor" | ||
/> | ||
<path | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
d="m4.026 7.208 1.061 7.467.011.064c.388 1.858 1.035 3.47 2.113 4.626 1.111 1.192 2.596 1.808 4.442 1.808 1.337 0 2.512-.273 3.521-.872a5.767 5.767 0 0 0 1.098-.847l-.707-.707c-.975.952-2.239 1.426-3.912 1.426-3.2 0-4.836-2.094-5.576-5.638l-.874-6.15-1.177-1.177Zm3.01.89-.22-1.144a.9.9 0 0 0-.904-.904.912.912 0 0 0-.654.269l-.707-.707a1.912 1.912 0 0 1 1.57-.551l1.896 1.895.228 2.125.026.251-1.234-1.235Zm.506 2.627.138.716.063.323c.147-.096.346-.209.534-.305l-.735-.734Zm8.954 6.831.725.726c.112-.173.218-.352.32-.537.16-.257.31-.53.45-.814l-.75-.75c-.173.377-.36.734-.563 1.059a7.82 7.82 0 0 1-.182.316Zm-3.649-7.89-.074-2.698-.084-3.056A.903.903 0 0 0 11.776 3a.901.901 0 0 0-.904.912l.105 3.742.004.145L9.843 6.66l-.273-2.16a.9.9 0 0 0-.904-.905.901.901 0 0 0-.912.904l.008.08-.848-.848a1.906 1.906 0 0 1 1.752-1.136c.532 0 1.012.216 1.357.565A1.896 1.896 0 0 1 11.776 2c.905 0 1.655.615 1.858 1.454.32-.249.724-.396 1.165-.396a1.903 1.903 0 0 1 1.911 1.956L16.5 9.86c.122-.17.261-.33.425-.467a1.91 1.91 0 0 1 1.396-.44c.462.03.912.22 1.239.586.328.368.467.841.437 1.314-.02.343-.144.792-.25 1.153-.082.275-.18.578-.269.857a78.86 78.86 0 0 0-.106.332c-.21.693-.453 1.474-.744 2.25l-.78-.78c.21-.597.396-1.199.569-1.766l.113-.354c.214-.67.449-1.4.469-1.754.031-.471-.276-.81-.747-.84-.543-.04-.881.274-1.22.982l-.639 1.376-.252.543-.034.072-.71-.71.006-.147.31-7.097a.903.903 0 0 0-.913-.912.901.901 0 0 0-.904.912l-.121 2.015-.18 2.996-.024.407-.723-.723Zm-2.697-.577.892.892.021.763a9.783 9.783 0 0 0-.692.095l-.01-.075-.116-.918-.095-.757Z" | ||
fill="currentColor" | ||
/> | ||
</svg> | ||
); | ||
|
||
export default SvgHandRaiseSlashedIcon; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as React from 'react'; | ||
import { SVGProps } from 'react'; | ||
|
||
const SvgOpenBookIcon = (props: SVGProps<SVGSVGElement>) => ( | ||
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}> | ||
<path | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
d="M14.145 4.71c-.677.134-1.342.32-1.99.558a.457.457 0 0 1-.121.025l-.033-.001h-.034a.5.5 0 0 1-.101-.018 11.17 11.17 0 0 0-7.698-.162 1.953 1.953 0 0 0-1.354 1.863v10.752a1.943 1.943 0 0 0 .753 1.547 1.951 1.951 0 0 0 1.687.352l.016-.005a9.497 9.497 0 0 1 6.069.32 1.95 1.95 0 0 0 1.343-.008 9.497 9.497 0 0 1 6.048-.312l.016.005a1.954 1.954 0 0 0 1.684-.351h.001c.235-.183.425-.417.556-.685h.001c.13-.268.198-.562.198-.861V6.974a1.957 1.957 0 0 0-1.36-1.862c-.5-.161-1.01-.292-1.526-.392a1.871 1.871 0 0 0-1.518-.775h-1.125a1.875 1.875 0 0 0-1.512.766Zm-2.894 1.935a9.654 9.654 0 0 0-6.62-.107.463.463 0 0 0-.318.435V17.73a.47.47 0 0 0 .046.2.463.463 0 0 0 .511.245 11 11 0 0 1 6.381.139V6.644Zm2.531-.314a11.67 11.67 0 0 0-1.031.316v11.667a11.004 11.004 0 0 1 6.38-.138.46.46 0 0 0 .509-.245.466.466 0 0 0 .046-.201V6.975a.457.457 0 0 0-.316-.434h-.002a11.068 11.068 0 0 0-.711-.204v5.108a.75.75 0 0 1-1.28.53l-1.157-1.157-1.157 1.157a.75.75 0 0 1-1.281-.53V6.33Zm3.375 3.303-.407-.407a.75.75 0 0 0-1.061 0l-.407.407V5.82a.375.375 0 0 1 .375-.375h1.125c.1 0 .195.039.265.11a.37.37 0 0 1 .11.265v3.814Z" | ||
fill="#000" | ||
/> | ||
</svg> | ||
); | ||
|
||
export default SvgOpenBookIcon; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as React from 'react'; | ||
import { SVGProps } from 'react'; | ||
|
||
const SvgSunWithFaceIcon = (props: SVGProps<SVGSVGElement>) => ( | ||
<svg width="24px" height="24px" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}> | ||
<path | ||
d="M36 62.7a1.546 1.546 0 0 1-1.382-.847l-2.7-5.331-4.536 3.894c-.286.241-.645.37-1.008.37a1.542 1.542 0 0 1-1.542-1.426l-.456-5.964-5.682 1.861a1.55 1.55 0 0 1-1.951-1.955l1.86-5.681-5.958-.452a1.555 1.555 0 0 1-1.313-.95 1.55 1.55 0 0 1 .255-1.601l3.891-4.536-5.33-2.7a1.55 1.55 0 0 1 0-2.763l5.33-2.7-3.89-4.536a1.553 1.553 0 0 1-.256-1.6c.224-.538.73-.908 1.313-.95l5.958-.456-1.86-5.682a1.551 1.551 0 0 1 .375-1.577 1.553 1.553 0 0 1 1.576-.375l5.682 1.86.456-5.958a1.547 1.547 0 0 1 2.55-1.057l4.536 3.89 2.7-5.33a1.546 1.546 0 0 1 2.762 0l2.703 5.33 4.536-3.89a1.543 1.543 0 0 1 1.6-.255c.537.223.905.73.951 1.312l.455 5.958 5.677-1.86a1.542 1.542 0 0 1 1.575.375c.414.414.56 1.023.378 1.577l-1.861 5.682 5.964.456a1.55 1.55 0 0 1 1.056 2.55l-3.894 4.536 5.33 2.7a1.55 1.55 0 0 1 .002 2.763l-5.33 2.7 3.893 4.536a1.55 1.55 0 0 1-1.06 2.551l-5.96.452 1.862 5.682a1.544 1.544 0 0 1-.378 1.576 1.54 1.54 0 0 1-1.575.378l-5.678-1.861-.454 5.96a1.551 1.551 0 0 1-1.545 1.43c-.36 0-.72-.129-1.007-.37l-4.536-3.894-2.703 5.33A1.55 1.55 0 0 1 36 62.7z" | ||
fill="#F4900C" | ||
/> | ||
<path | ||
d="M55.5 36c0 10.769-8.731 19.5-19.5 19.5-10.768 0-19.5-8.73-19.5-19.5S25.232 16.5 36 16.5c10.769 0 19.5 8.732 19.5 19.5z" | ||
fill="#FFCC4D" | ||
/> | ||
<path | ||
d="M36 41.206c-9.334 0-12-3.492-12-1.842-.002 3.25 5.334 8.755 12 8.755s12-5.505 12-8.755c0-1.65-2.666 1.843-12 1.843zM48 31c0 2.21-1.791 1.665-4.001 1.665C41.791 32.665 40 33.21 40 31a4 4 0 1 1 8 0zm-16.001 0c0 2.21-1.793 1.665-4 1.665-2.208 0-4.001.545-4.001-1.665 0-2.209 1.794-4 4.002-4a4 4 0 0 1 3.999 4z" | ||
fill="#F4900C" | ||
/> | ||
</svg> | ||
); | ||
|
||
export default SvgSunWithFaceIcon; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as React from 'react'; | ||
import { SVGProps } from 'react'; | ||
|
||
const SvgVideoConferencingIcon = (props: SVGProps<SVGSVGElement>) => ( | ||
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}> | ||
<path | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
d="M5.496 4.12a.625.625 0 0 1 .441-.183h13.5a.625.625 0 0 1 .625.626v9a.624.624 0 0 1-.625.624h-5.625a.5.5 0 0 0 0 1h1.75v1.25h-.624a.5.5 0 0 0 0 1H17.75a.5.5 0 0 0 0-1h-1.188v-1.25h2.875a1.625 1.625 0 0 0 1.625-1.624v-9a1.625 1.625 0 0 0-1.625-1.625h-13.5a1.625 1.625 0 0 0-1.625 1.624V6.25a.5.5 0 0 0 1 0V4.562c0-.165.066-.324.184-.441Zm7.332 1.708a2.187 2.187 0 1 1 2.595 3.467 3.313 3.313 0 0 1 2.264 3.143.5.5 0 0 1-1 0 2.312 2.312 0 0 0-2.312-2.313.5.5 0 0 1-.486-.617 2.187 2.187 0 0 1-1.06-3.68Zm1.547.36a1.188 1.188 0 1 0 0 2.375 1.188 1.188 0 0 0 0-2.376ZM8.75 16a4.313 4.313 0 0 0-4.313 4.313.75.75 0 0 1-1.5 0 5.813 5.813 0 0 1 4.51-5.665 3.843 3.843 0 1 1 2.605 0 5.813 5.813 0 0 1 4.51 5.665.75.75 0 0 1-1.5 0A4.313 4.313 0 0 0 8.75 16ZM7.093 9.374a2.344 2.344 0 1 1 3.314 3.315 2.344 2.344 0 0 1-3.314-3.315Z" | ||
fill="#000" | ||
/> | ||
</svg> | ||
); | ||
|
||
export default SvgVideoConferencingIcon; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as React from 'react'; | ||
import { SVGProps } from 'react'; | ||
|
||
const SvgWiredMicIcon = (props: SVGProps<SVGSVGElement>) => ( | ||
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}> | ||
<path | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
d="M14.706 3.17a4.687 4.687 0 0 1 5.596 7.072l.308.307a.75.75 0 0 1-1.06 1.061l-.308-.308a4.69 4.69 0 0 1-2.509.88l-7.78 6.455a1.875 1.875 0 0 1-2.447-.082l-2.413 2.413a.75.75 0 0 1-1.06-1.06l2.41-2.412a1.875 1.875 0 0 1-.08-2.447l.006-.008 6.45-7.774a4.689 4.689 0 0 1 .879-2.509l-.308-.307a.75.75 0 1 1 1.06-1.061l.309.308c.293-.212.611-.39.947-.529Zm-2.564 6.056-5.614 6.767a.375.375 0 0 0 .029.497l.956.953a.375.375 0 0 0 .497.029l6.764-5.614a4.69 4.69 0 0 1-2.632-2.632Zm7.303-.506c-.063.153-.138.3-.224.44L14.84 4.78a3.185 3.185 0 0 1 3.914.467 3.187 3.187 0 0 1 .69 3.474Zm-5.89-2.44c.063-.153.138-.3.224-.44l4.381 4.38a3.18 3.18 0 0 1-2.88.225 3.188 3.188 0 0 1-1.725-4.165Zm-.58 4.861a1.033 1.033 0 0 0-1.45.002l-.002.002a1.032 1.032 0 1 0 1.459.002l-.002-.002-.004-.004Z" | ||
fill="currentColor" | ||
/> | ||
</svg> | ||
); | ||
|
||
export default SvgWiredMicIcon; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
## useAVToggle | ||
|
||
Use this hook to implement mute/unmute for local audio and video. | ||
`isAllowedToPublish` can be used to decide whether to show the toggle buttons in the UI. | ||
|
||
import { Story, Preview } from '@storybook/addon-docs'; | ||
|
||
### Interface | ||
|
||
```ts | ||
interface useAVToggleInput { | ||
/** | ||
* to handle any error during toggle of audio/video | ||
*/ | ||
handleError?: (err: Error, method?: string) => void; | ||
} | ||
``` | ||
|
||
```ts | ||
interface useAVToggleResult { | ||
/** | ||
* true if unmuted and vice versa | ||
*/ | ||
isLocalAudioEnabled: boolean; | ||
isLocalVideoEnabled: boolean; | ||
/** | ||
* use this function to toggle audio state, the function will only be present if the user | ||
* has permission to unmute audio | ||
*/ | ||
toggleAudio?: () => void; | ||
/** | ||
* use this function to toggle video state, the function will only be present if the user | ||
* has permission to unmute video | ||
*/ | ||
toggleVideo?: () => void; | ||
} | ||
``` | ||
|
||
### Example | ||
|
||
<Story id="hooks-useavtoggle--use-video-hook" /> | ||
|
||
```jsx | ||
import { selectLocalVideoTrackID, useAVToggle, useHMSStore } from '@100mslive/react-sdk'; | ||
import { Flex, Box, Video, Button } from '@100mslive/react-ui'; | ||
|
||
() => { | ||
const localVideoTrackID = useHMSStore(selectLocalVideoTrackID); | ||
const { isLocalVideoEnabled, isLocalAudioEnabled, toggleVideo, toggleAudio } = useAVToggle(err => { | ||
console.log(err); | ||
}); | ||
|
||
return ( | ||
<Box> | ||
<Flex gap="1"> | ||
<Button onClick={() => toggleVideo && toggleVideo()}> | ||
{isLocalVideoEnabled ? 'Disable video' : 'Enable video'} | ||
</Button> | ||
<Button variant="standard" onClick={() => toggleAudio && toggleAudio()}> | ||
{isLocalAudioEnabled ? 'Disable audio' : 'Enable audio'} | ||
</Button> | ||
</Flex> | ||
<Video trackId={localVideoTrackID} /> | ||
</Box> | ||
); | ||
}; | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { selectLocalVideoTrackID, useAVToggle, useHMSStore } from '@100mslive/react-sdk'; | ||
import Video, { StyledVideo } from '../Video/Video'; | ||
import React from 'react'; | ||
import UseAVToggleDocs from './UseAVToggle.mdx'; | ||
import { ComponentStory } from '@storybook/react'; | ||
import { Box, Flex } from '../Layout'; | ||
import { Button } from '../Button'; | ||
|
||
const VideoHook: ComponentStory<typeof StyledVideo> = () => { | ||
const localVideoTrackID = useHMSStore(selectLocalVideoTrackID); | ||
const { isLocalVideoEnabled, isLocalAudioEnabled, toggleVideo, toggleAudio } = useAVToggle(); | ||
|
||
return ( | ||
<Box> | ||
<Flex gap="1"> | ||
<Button onClick={() => toggleVideo && toggleVideo()}> | ||
{isLocalVideoEnabled ? 'Disable video' : 'Enable video'} | ||
</Button> | ||
<Button variant="standard" onClick={() => toggleAudio && toggleAudio()}> | ||
{isLocalAudioEnabled ? 'Disable audio' : 'Enable audio'} | ||
</Button> | ||
</Flex> | ||
<Video css={{ bg: '$backgroundDark', mt: '$4', maxWidth: '800px' }} trackId={localVideoTrackID} /> | ||
</Box> | ||
); | ||
}; | ||
|
||
const VideoStories = { | ||
title: 'Hooks/useAVToggle', | ||
component: VideoHook, | ||
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes | ||
parameters: { | ||
docs: { | ||
page: UseAVToggleDocs, | ||
}, | ||
}, | ||
}; | ||
|
||
export default VideoStories; | ||
|
||
export const UseVideoHook = VideoHook.bind({}); | ||
UseVideoHook.storyName = 'useAVToggle'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
## useAudioLevelStyles | ||
|
||
This hook can be used to apply css properties on an element based on the current audio level for the passed in track. | ||
It doesn't return the audio level as it's optimised for performance. As audio level could be changing frequently we | ||
want to minimise the number of components an audio level change causes to re render. | ||
An e.g. use of this hook will be to apply box-shadow on parent tile based on audio level. | ||
|
||
### Interface | ||
|
||
```ts | ||
interface useAudioLevelStylesInput { | ||
/** | ||
* audio track id for which audio level needs to be used | ||
*/ | ||
trackId?: HMSTrackID; | ||
/** | ||
* a function which can take in current audio level and return the style to apply for the ref | ||
*/ | ||
getStyle: (level: number) => Record<string, string>; | ||
/** | ||
* the ref of the element on which you want the css to apply | ||
*/ | ||
ref: React.RefObject<any>; | ||
} | ||
``` | ||
|
||
### Example | ||
|
||
```jsx | ||
import { useCallback, useRef } from 'react'; | ||
import { useTheme } from '@100mslive/react-ui'; | ||
import { useAudioLevelStyles } from '@100mslive/react-sdk'; | ||
import { HMSTrackID } from '@100mslive/hms-video-store'; | ||
|
||
export function adjustBorderAudioLevel(audioTrackId?: HMSTrackID) { | ||
const { theme } = useTheme(); | ||
const color = theme.colors.brandDefault.value; | ||
const getStyle = useCallback( | ||
(level: number) => { | ||
return { | ||
transition: 'box-shadow 0.4s ease-in-out', | ||
'box-shadow': level | ||
? `0px 0px ${24 * sigmoid(level)}px ${color}, 0px 0px ${16 * sigmoid(level)}px ${color}` | ||
: '', | ||
}; | ||
}, | ||
[color] | ||
); | ||
|
||
const ref = useRef(null); | ||
|
||
useAudioLevelStyles({ | ||
trackId: audioTrackId, | ||
getStyle, | ||
ref, | ||
}); | ||
|
||
return ref; | ||
} | ||
|
||
const sigmoid = (z: number) => { | ||
return 1 / (1 + Math.exp(-z)); | ||
}; | ||
|
||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's follow the order of imports.