Skip to content

Commit 478c8ae

Browse files
committed
Cleanup
1 parent c5a5b73 commit 478c8ae

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { _HighContrastAwareIcon } from './HighContrastAwareIcon';
2727
import {
2828
calculateScaledSize,
2929
getTogetherModeParticipantOverlayStyle,
30+
participantStatusTransitionStyle,
3031
REACTION_MAX_TRAVEL_HEIGHT,
3132
REACTION_TRAVEL_HEIGHT,
3233
setTogetherModeSeatPositionStyle,
@@ -218,7 +219,7 @@ export const TogetherModeOverlay = memo(
218219
)}
219220

220221
{participantStatus.showDisplayName && (
221-
<div>
222+
<div style={{ ...participantStatusTransitionStyle }}>
222223
<div
223224
style={{
224225
...togetherModeParticipantStatusContainer(

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

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,25 @@ export const togetherModeParticipantDisplayName = (
198198
isParticipantHovered: boolean,
199199
participantSeatingWidth: number,
200200
color: string
201-
): CSSProperties => {
202-
const MIN_DISPLAY_NAME_WIDTH = 100;
201+
): React.CSSProperties => {
202+
const width =
203+
isParticipantHovered || participantSeatingWidth * 16 > 100
204+
? 'fit-content'
205+
: _pxToRem(0.7 * participantSeatingWidth * 16);
206+
207+
const display = isParticipantHovered || participantSeatingWidth * 16 > 150 ? 'inline-block' : 'none';
208+
203209
return {
204210
textOverflow: 'ellipsis',
205-
flexGrow: 1, // Allow text to grow within available space
206-
overflow: isParticipantHovered ? 'visible' : 'hidden',
207211
whiteSpace: 'nowrap',
208212
textAlign: 'center',
209213
color,
210-
display: isParticipantHovered || participantSeatingWidth > MIN_DISPLAY_NAME_WIDTH ? 'inline-block' : 'none' // Completely remove the element when hidden
214+
overflow: isParticipantHovered ? 'visible' : 'hidden',
215+
width,
216+
display,
217+
fontSize: `${_pxToRem(13)}`,
218+
lineHeight: `${_pxToRem(20)}`,
219+
maxWidth: isParticipantHovered ? 'fit-content' : _pxToRem(0.7 * participantSeatingWidth * 16)
211220
};
212221
};
213222

@@ -221,11 +230,28 @@ export const togetherModeParticipantEmojiSpriteStyle = (
221230
participantSeatWidth: string
222231
): CSSProperties => {
223232
const participantSeatWidthInPixel = parseFloat(participantSeatWidth) * REM_TO_PX_MULTIPLIER;
224-
const emojiScaledSizeInPercent = (emojiScaledSize / participantSeatWidthInPixel) * 100;
233+
const emojiScaledSizeInPercent = 100 - (emojiScaledSize / participantSeatWidthInPixel) * 100;
225234
return {
226235
width: `${emojiSize}`,
227236
position: 'absolute',
228237
// Center the emoji sprite within the participant seat
229-
left: `${emojiScaledSizeInPercent / 2}%`
238+
left: `${emojiScaledSizeInPercent / 2}%`,
239+
zIndex: 3
230240
};
231241
};
242+
243+
/**
244+
* The style for the transition of the participant status container in Together Mode.
245+
* @private
246+
*/
247+
export const participantStatusTransitionStyle: CSSProperties = {
248+
position: 'absolute',
249+
bottom: `${_pxToRem(2)}`,
250+
width: 'fit-content',
251+
textAlign: 'center',
252+
border: '1px solid white',
253+
transform: 'translate(-50%)',
254+
transition: 'width 0.3s ease, transform 0.3s ease',
255+
left: '50%',
256+
zIndex: 0
257+
};

0 commit comments

Comments
 (0)