Skip to content

Commit 80ddf49

Browse files
Fix control bar button label styling. Fix screenshare button hover and checked styling. (#1178)
1 parent 533ed4a commit 80ddf49

17 files changed

Lines changed: 118 additions & 98 deletions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Update screenshare button background when active",
4+
"packageName": "@internal/react-components",
5+
"email": "2684369+JamesBurnside@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "Moved code",
4+
"packageName": "@internal/react-composites",
5+
"email": "2684369+JamesBurnside@users.noreply.github.com",
6+
"dependentChangeType": "none"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "update jest snapshots",
4+
"packageName": "@internal/storybook",
5+
"email": "2684369+JamesBurnside@users.noreply.github.com",
6+
"dependentChangeType": "none"
7+
}

packages/react-components/src/components/ControlBarButton.tsx

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4-
import React, { useCallback } from 'react';
5-
import {
6-
DefaultButton,
7-
IButtonProps,
8-
IRenderFunction,
9-
Text,
10-
concatStyleSets,
11-
mergeStyles,
12-
IButtonStyles
13-
} from '@fluentui/react';
14-
import { useTheme } from '../theming';
15-
import { controlButtonLabelStyles, controlButtonStyles } from './styles/ControlBar.styles';
4+
import React from 'react';
5+
import { DefaultButton, IButtonProps, IRenderFunction, concatStyleSets, IButtonStyles } from '@fluentui/react';
6+
import { controlButtonStyles } from './styles/ControlBar.styles';
167
import { ControlButtonTooltip } from './ControlButtonTooltip';
178

189
/**
@@ -123,22 +114,10 @@ const DefaultRenderIcon = (props?: ControlBarButtonProps): JSX.Element | null =>
123114
*/
124115
export const ControlBarButton = (props: ControlBarButtonProps): JSX.Element => {
125116
const componentStyles = concatStyleSets(controlButtonStyles, props.styles ?? {});
126-
const theme = useTheme();
127117

128118
const labelText =
129119
props?.text ?? props?.strings?.label ?? (props?.checked ? props?.strings?.onLabel : props?.strings?.offLabel);
130120

131-
const DefaultRenderText = useCallback(() => {
132-
return (
133-
<Text
134-
key={props?.labelKey}
135-
className={mergeStyles(controlButtonLabelStyles, theme.palette.neutralPrimary, props?.styles?.label)}
136-
>
137-
{labelText}
138-
</Text>
139-
);
140-
}, [labelText, props?.labelKey, props?.styles?.label, theme]);
141-
142121
const tooltipContent =
143122
props?.strings?.tooltipContent ??
144123
(props?.disabled
@@ -154,9 +133,11 @@ export const ControlBarButton = (props: ControlBarButtonProps): JSX.Element => {
154133
<DefaultButton
155134
{...props}
156135
styles={componentStyles}
157-
onRenderText={props.showLabel ? props.onRenderText ?? DefaultRenderText : undefined}
136+
onRenderText={props.showLabel && props.onRenderText ? props.onRenderText : undefined}
158137
onRenderIcon={props.onRenderIcon ?? DefaultRenderIcon}
159-
/>
138+
>
139+
{props.showLabel ? labelText : <></>}
140+
</DefaultButton>
160141
</ControlButtonTooltip>
161142
);
162143
};

packages/react-components/src/components/ScreenShareButton.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import React from 'react';
55
import { useLocale } from '../localization';
66
import { ControlBarButton, ControlBarButtonProps } from './ControlBarButton';
7-
import { Icon } from '@fluentui/react';
7+
import { DefaultPalette, IButtonStyles, Icon, Theme, useTheme } from '@fluentui/react';
88

99
/**
1010
* Strings of {@link ScreenShareButton} that can be overridden.
@@ -56,9 +56,13 @@ export const ScreenShareButton = (props: ScreenShareButtonProps): JSX.Element =>
5656
const localeStrings = useLocale().strings.screenShareButton;
5757
const strings = { ...localeStrings, ...props.strings };
5858

59+
const theme = useTheme();
60+
const styles = screenshareButtonStyles(theme);
61+
5962
return (
6063
<ControlBarButton
6164
{...props}
65+
styles={styles}
6266
onClick={props.onToggleScreenShare ?? props.onClick}
6367
onRenderOnIcon={props.onRenderOnIcon ?? onRenderScreenShareOnIcon}
6468
onRenderOffIcon={props.onRenderOffIcon ?? onRenderScreenShareOffIcon}
@@ -67,3 +71,18 @@ export const ScreenShareButton = (props: ScreenShareButtonProps): JSX.Element =>
6771
/>
6872
);
6973
};
74+
75+
const screenshareButtonStyles = (theme: Theme): IButtonStyles => ({
76+
rootChecked: {
77+
background: theme.palette.themePrimary,
78+
color: DefaultPalette.white,
79+
':focus::after': { outlineColor: `${DefaultPalette.white} !important` } // added !important to avoid override by FluentUI button styles
80+
},
81+
rootCheckedHovered: {
82+
background: theme.palette.themePrimary,
83+
color: DefaultPalette.white,
84+
':focus::after': { outlineColor: `${DefaultPalette.white} !important` } // added !important to avoid override by FluentUI button styles
85+
},
86+
labelHovered: { color: DefaultPalette.white },
87+
labelChecked: { color: DefaultPalette.white }
88+
});

packages/react-components/src/components/styles/ControlBar.styles.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,17 @@ export const controlButtonStyles: IButtonStyles = {
125125
flexContainer: {
126126
flexFlow: 'column',
127127
display: 'contents'
128+
},
129+
label: {
130+
fontSize: '0.625rem',
131+
fontWeight: '400',
132+
lineHeight: '1rem',
133+
cursor: 'pointer',
134+
display: 'block',
135+
margin: '0rem 0.25rem'
128136
}
129137
};
130138

131-
/**
132-
* @private
133-
*/
134-
export const controlButtonLabelStyles: IStyle = {
135-
fontSize: '0.625rem',
136-
lineHeight: '1rem',
137-
cursor: 'pointer',
138-
display: 'block',
139-
margin: '0rem 0.25rem'
140-
};
141-
142139
/**
143140
* making it Partial as IContextualMenuStyles has all its props non-optional and we only need title to be defined here.
144141
*

packages/react-composites/src/composites/CallComposite/components/CallControls.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ import {
1111
MicrophoneButton,
1212
ParticipantMenuItemsCallback,
1313
ParticipantsButton,
14-
ScreenShareButton,
15-
useTheme
14+
ScreenShareButton
1615
} from '@internal/react-components';
1716
import React, { useMemo } from 'react';
1817
import { useLocale } from '../../localization';
1918
import { usePropsFor } from '../hooks/usePropsFor';
2019
import { useSelector } from '../hooks/useSelector';
2120
import { getCallStatus, getLocalMicrophoneEnabled } from '../selectors/baseSelectors';
2221
import {
23-
checkedButtonOverrideStyles,
2422
controlButtonBaseStyle,
2523
devicesButtonWithIncreasedTouchTargets,
2624
groupCallLeaveButtonCompressedStyle,
@@ -128,13 +126,6 @@ export const CallControls = (props: CallControlsProps): JSX.Element => {
128126
const devicesButtonProps = usePropsFor(DevicesButton);
129127
const hangUpButtonProps = usePropsFor(EndCallButton);
130128

131-
const theme = useTheme();
132-
133-
const screenShareButtonStyles = useMemo(
134-
() => mergeButtonBaseStyles(checkedButtonOverrideStyles(theme, screenShareButtonProps.checked)),
135-
[screenShareButtonProps.checked, theme.palette.themePrimary]
136-
);
137-
138129
const participantsButtonStyles = useMemo(
139130
() => mergeButtonBaseStyles(props.increaseFlyoutItemSize ? participantButtonWithIncreasedTouchTargets : {}),
140131
[props.increaseFlyoutItemSize]
@@ -170,7 +161,6 @@ export const CallControls = (props: CallControlsProps): JSX.Element => {
170161
<ScreenShareButton
171162
data-ui-id="call-composite-screenshare-button"
172163
{...screenShareButtonProps}
173-
styles={screenShareButtonStyles}
174164
showLabel={!compactMode}
175165
disabled={options?.screenShareButton !== true && options?.screenShareButton?.disabled}
176166
/>

packages/react-composites/src/composites/CallComposite/styles/CallControls.styles.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4-
import { DefaultPalette as palette, IButtonStyles, IContextualMenuItemStyles, IStyle, Theme } from '@fluentui/react';
4+
import { IButtonStyles, IContextualMenuItemStyles, IStyle } from '@fluentui/react';
55
import { DevicesButtonStyles, ParticipantsButtonStyles } from '@internal/react-components';
66

77
const MINIMUM_TOUCH_TARGET_HEIGHT_REM = 3;
@@ -46,18 +46,6 @@ export const groupCallLeaveButtonCompressedStyle = {
4646
}
4747
};
4848

49-
/**
50-
* @private
51-
*/
52-
export const checkedButtonOverrideStyles = (theme: Theme, isChecked?: boolean): IButtonStyles => ({
53-
rootChecked: {
54-
background: theme.palette.themePrimary,
55-
color: palette.white,
56-
':focus::after': { outlineColor: `${palette.white} !important` } // added !important to avoid override by FluentUI button styles
57-
},
58-
label: isChecked ? { color: palette.white } : {}
59-
});
60-
6149
/**
6250
* Styles that can be applied to ensure flyout items have the minimum touch target size.
6351
*
289 Bytes
Loading
-375 Bytes
Loading

0 commit comments

Comments
 (0)