-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathScreenShareButton.tsx
More file actions
88 lines (79 loc) · 2.82 KB
/
ScreenShareButton.tsx
File metadata and controls
88 lines (79 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import React from 'react';
import { useLocale } from '../localization';
import { ControlBarButton, ControlBarButtonProps } from './ControlBarButton';
import { DefaultPalette, IButtonStyles, Icon, mergeStyles, Theme, useTheme } from '@fluentui/react';
/**
* Strings of {@link ScreenShareButton} that can be overridden.
*
* @public
*/
export interface ScreenShareButtonStrings {
/** Label when button is on. */
onLabel: string;
/** Label when button is off. */
offLabel: string;
/** * Tooltip content when the button is disabled. */
tooltipDisabledContent?: string;
/** Tooltip content when the button is on. */
tooltipOnContent?: string;
/** Tooltip content when the button is off. */
tooltipOffContent?: string;
}
/**
* Props for {@link ScreenShareButton}.
*
* @public
*/
export interface ScreenShareButtonProps extends ControlBarButtonProps {
/**
* Utility property for using this component with `communication react eventHandlers`.
* Maps directly to the `onClick` property.
*/
onToggleScreenShare?: () => Promise<void>;
/**
* Optional strings to override in component
*/
strings?: Partial<ScreenShareButtonStrings>;
}
const onRenderScreenShareOnIcon = (): JSX.Element => <Icon iconName="ControlButtonScreenShareStop" />;
const onRenderScreenShareOffIcon = (): JSX.Element => <Icon iconName="ControlButtonScreenShareStart" />;
/**
* A button to start / stop screen sharing.
*
* Can be used with {@link ControlBar}.
*
* @public
*/
export const ScreenShareButton = (props: ScreenShareButtonProps): JSX.Element => {
const localeStrings = useLocale().strings.screenShareButton;
const strings = { ...localeStrings, ...props.strings };
const theme = useTheme();
const styles = screenshareButtonStyles(theme);
return (
<ControlBarButton
{...props}
styles={styles}
onClick={props.onToggleScreenShare ?? props.onClick}
onRenderOnIcon={props.onRenderOnIcon ?? onRenderScreenShareOnIcon}
onRenderOffIcon={props.onRenderOffIcon ?? onRenderScreenShareOffIcon}
strings={strings}
labelKey={props.labelKey ?? 'screenShareButtonLabel'}
/>
);
};
const screenshareButtonStyles = (theme: Theme): IButtonStyles => ({
rootChecked: {
background: theme.palette.themePrimary,
color: DefaultPalette.white,
':focus::after': { outlineColor: `${DefaultPalette.white} !important` } // added !important to avoid override by FluentUI button styles
},
rootCheckedHovered: {
background: theme.palette.themePrimary,
color: DefaultPalette.white,
':focus::after': { outlineColor: `${DefaultPalette.white} !important` } // added !important to avoid override by FluentUI button styles
},
labelHovered: { color: DefaultPalette.white },
labelChecked: { color: DefaultPalette.white }
});