|
| 1 | +import { DEFAULT_COMPONENT_ICONS, DEFAULT_COMPOSITE_ICONS } from '@azure/communication-react'; |
| 2 | +import { Meta, Canvas, Source } from '@storybook/addon-docs'; |
| 3 | +import { IconGridWithSearch } from './IconGrid'; |
| 4 | + |
| 5 | +<Meta id="icons" title="Concepts/Icons" /> |
| 6 | + |
| 7 | +# Icons |
| 8 | + |
| 9 | +Both the Composites and the Components use a set of default icons from the Fluent UI library. All the icons used in Components and Composites are displayed below with their names. |
| 10 | + |
| 11 | +**All the default icons can be replaced with a custom icon by providing a custom JSX element.** |
| 12 | +The method for providing custom icons differs between composites and components. Please read below for more details about each. |
| 13 | + |
| 14 | +## Composites |
| 15 | + |
| 16 | +There is no setup required for rendering icons inside the Composites. |
| 17 | + |
| 18 | +### Custom Icons |
| 19 | + |
| 20 | +All Composites expose a prop `icons` that allows you to override the default icons used inside Composites. |
| 21 | + |
| 22 | +Here is a sample code showcasing how you can override an icon used inside Composites with custom icons. |
| 23 | + |
| 24 | +<Source |
| 25 | + language="tsx" |
| 26 | + code={` |
| 27 | +<CallComposite |
| 28 | + adapter={adapter} |
| 29 | + icons={{ |
| 30 | + LocalDeviceSettingsCamera: <p>My Custom Icon</p> |
| 31 | + }} |
| 32 | +/> |
| 33 | + `} |
| 34 | +/> |
| 35 | + |
| 36 | +### Default Composite Icons |
| 37 | + |
| 38 | +Below is a list of all the default icons you can override in Composites with their names. |
| 39 | + |
| 40 | +<Canvas withSource="none"> |
| 41 | + <IconGridWithSearch icons={DEFAULT_COMPOSITE_ICONS} /> |
| 42 | +</Canvas> |
| 43 | + |
| 44 | +## Components |
| 45 | + |
| 46 | +Before you can render icons in Components, you will need to setup the icons using the `registerIcons` method as shown below. |
| 47 | + |
| 48 | +<Source |
| 49 | + language="tsx" |
| 50 | + code={` |
| 51 | +import { registerIcons } from '@fluentui/react'; |
| 52 | +import { DEFAULT_COMPONENT_ICONS } from '@azure/communication-react'; |
| 53 | +// |
| 54 | +// If you don't want to provide custom icons, you can register the default ones included with the library. |
| 55 | +// This will ensure that all the icons are rendered correctly. |
| 56 | +// |
| 57 | +registerIcons({ icons: DEFAULT_COMPONENT_ICONS }); |
| 58 | + `} |
| 59 | +/> |
| 60 | + |
| 61 | +### Custom Icons |
| 62 | + |
| 63 | +For overriding a default icon, you can provide a custom react element as shown in the example below. |
| 64 | + |
| 65 | +<Source |
| 66 | + language="tsx" |
| 67 | + code={` |
| 68 | +import { registerIcons } from '@fluentui/react'; |
| 69 | +import { DEFAULT_COMPONENT_ICONS } from '@azure/communication-react'; |
| 70 | +const customIcons = {...DEFAULT_COMPONENT_ICONS, { |
| 71 | + ControlButtonCameraOff: <p>My Custom Icon</p> |
| 72 | +}}; |
| 73 | +registerIcons({ icons: customIcons }); |
| 74 | + `} |
| 75 | +/> |
| 76 | + |
| 77 | +### Default Component Icons |
| 78 | + |
| 79 | +Below is a list of all the default icons you can override in Components with their names. |
| 80 | + |
| 81 | +<Canvas withSource="none"> |
| 82 | + <IconGridWithSearch icons={DEFAULT_COMPONENT_ICONS} /> |
| 83 | +</Canvas> |
0 commit comments