Skip to content

Commit

Permalink
Merge branch 'dev' into screen-share-modification
Browse files Browse the repository at this point in the history
  • Loading branch information
amar-1995 committed Mar 19, 2024
2 parents 3953ffd + 08ac6c4 commit 8d1c04a
Show file tree
Hide file tree
Showing 21 changed files with 476 additions and 226 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
PUBLISH_FLAG: ${{ github.event.inputs.publishFlag || github.event.client_payload.slash_command.args.unnamed.arg1 || 'alpha' }}

- name: Delay for 2 minutes
run: sleep 120
- name: Delay for 1 minute
run: sleep 60

- name: Notify slack success
if: github.event.inputs.publishFlag == 'latest' && success()
Expand Down
8 changes: 4 additions & 4 deletions packages/roomkit-react/src/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ export const AccordionRoot = StyledAccordion;
export const AccordionItem = StyledItem;

export const AccordionHeader: React.FC<
PropsWithChildren<BaseAccordion.AccordionTriggerProps & { iconStyles?: CSS; css?: CSS }>
PropsWithChildren<BaseAccordion.AccordionTriggerProps & { iconStyles?: CSS; css?: CSS; chevronID?: string }>
> = React.forwardRef<
HTMLButtonElement,
PropsWithChildren<BaseAccordion.AccordionTriggerProps & { iconStyles?: CSS; css?: CSS }>
>(({ children, iconStyles, css, ...props }, forwardedRef) => (
PropsWithChildren<BaseAccordion.AccordionTriggerProps & { iconStyles?: CSS; css?: CSS; chevronID?: string }>
>(({ children, iconStyles, css, chevronID, ...props }, forwardedRef) => (
<StyledHeader css={css}>
<StyledTrigger {...props} ref={forwardedRef}>
{children}
<StyledChevron aria-hidden css={iconStyles} />
<StyledChevron data-testid={chevronID} aria-hidden css={iconStyles} />
</StyledTrigger>
</StyledHeader>
));
Expand Down
9 changes: 2 additions & 7 deletions packages/roomkit-react/src/IconButton/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,14 @@ export const IconButton = styled('button', {
'&[disabled]': {
opacity: 0.5,
cursor: 'not-allowed',
backgroundColor: '$secondary_dim',
color: '$on_primary_high',
},
'&:focus': {
outline: 'none',
},
variants: {
active: {
false: {
backgroundColor: '$secondary_dim',
color: '$on_primary_high',
'&:not([disabled]):hover': {
backgroundColor: '$secondary_default',
},
},
true: {
'&:not([disabled]):hover': {
backgroundColor: '$on_surface_low',
Expand Down
16 changes: 6 additions & 10 deletions packages/roomkit-react/src/Prebuilt/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@ const IconButton = styled(BaseIconButton, {
border: '1px solid $border_bright',
bg: '$background_dim',
r: '$1',
'&[disabled]': {
opacity: 0.5,
cursor: 'not-allowed',
backgroundColor: '$secondary_dim',
color: '$on_primary_high',
},
variants: {
active: {
true: {
color: '$on_surface_high',
backgroundColor: 'transparent',
},
false: {
border: '1px solid transparent',
color: '$on_primary_high',
},
},
disabled: {
true: {
backgroundColor: '$surface_brighter',
color: '$on_surface_low',
},
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useIsSidepaneTypeOpen, useSidepaneToggle } from '../AppData/useSidepane
// @ts-ignore: No implicit Any
import { SIDE_PANE_OPTIONS } from '../../common/constants';

export const ChatToggle = () => {
export const ChatToggle = ({ onClick }: { onClick?: () => void }) => {
const countUnreadMessages = useHMSStore(selectUnreadHMSMessagesCount);
const isChatOpen = useIsSidepaneTypeOpen(SIDE_PANE_OPTIONS.CHAT);
const toggleChat = useSidepaneToggle(SIDE_PANE_OPTIONS.CHAT);
Expand All @@ -21,7 +21,7 @@ export const ChatToggle = () => {
}}
>
<Tooltip key="chat" title={`${isChatOpen ? 'Close' : 'Open'} chat`}>
<IconButton onClick={toggleChat} active={!isChatOpen} data-testid="chat_btn">
<IconButton onClick={() => (onClick ? onClick() : toggleChat())} active={!isChatOpen} data-testid="chat_btn">
<ChatIcon />
</IconButton>
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,15 @@ const HandRaisedAccordionParticipantActions = ({ peerId, role }: { peerId: strin
peerId,
role,
});
if (!shouldShowStageRoleChange) {
return null;
}
return (
<>
<Button variant="standard" css={quickActionStyle} onClick={lowerPeerHand}>
<CrossIcon height={18} width={18} />
</Button>
{shouldShowStageRoleChange && !isInStage && (
{!isInStage && (
<Button variant="primary" onClick={handleStageAction} css={quickActionStyle}>
<AddIcon height={18} width={18} />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const RoleAccordion = ({
return (
<Accordion.Item value={roleName} css={{ '&:hover .role_actions': { visibility: 'visible' }, mb: '$8' }} ref={ref}>
<Accordion.Header
chevronID={`role_accordion_btn_${roleName}`}
iconStyles={{ c: '$on_surface_high' }}
css={{
textTransform: 'capitalize',
Expand Down Expand Up @@ -148,18 +149,17 @@ export const RoleAccordion = ({
<ChevronRightIcon />
</Flex>
) : null}
{isHandRaisedAccordion && (
{isHandRaisedAccordion && canBringToStage && (
<>
<HorizontalDivider />
<Flex css={{ w: '100%', p: '$6', gap: '$4' }} justify="center">
<Button variant="standard" onClick={lowerAllHands} icon css={{ pl: '$2' }}>
<CrossIcon /> Lower all hands
</Button>
{canBringToStage && (
<Button onClick={bringAllToStage} icon css={{ pl: '$2' }}>
<AddIcon /> {bring_to_stage_label}
</Button>
)}

<Button onClick={bringAllToStage} icon css={{ pl: '$2' }}>
<AddIcon /> {bring_to_stage_label}
</Button>
</Flex>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { useWhiteboard } from '@100mslive/react-sdk';
import { useScreenShare, useWhiteboard } from '@100mslive/react-sdk';
import { PencilDrawIcon } from '@100mslive/react-icons';
import { Tooltip } from '../../..';
// @ts-ignore: No implicit Any
Expand All @@ -9,22 +9,36 @@ import { ToastManager } from '../Toast/ToastManager';

export const WhiteboardToggle = () => {
const { toggle, open, isOwner } = useWhiteboard();
const { screenSharingPeerId, amIScreenSharing } = useScreenShare();
const remoteScreenShare = screenSharingPeerId && !amIScreenSharing;
const disabled = remoteScreenShare || (open && !isOwner);

if (!toggle) {
return null;
}

return (
<Tooltip key="whiteboard" title={`${open ? 'Close' : 'Open'} Whiteboard`}>
<Tooltip
key="whiteboard"
title={
remoteScreenShare
? 'Cannot open whiteboard when viewing a shared screen'
: `${open ? 'Close' : 'Open'} Whiteboard`
}
>
<IconButton
onClick={async () => {
if (disabled) {
return;
}
try {
await toggle();
} catch (error) {
ToastManager.addToast({ title: (error as Error).message, variant: 'error' });
}
}}
active={!open}
disabled={open && !isOwner}
disabled={disabled}
data-testid="whiteboard_btn"
>
<PencilDrawIcon />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const HMSVideo = forwardRef(({ children, ...props }, videoRef) => {
size: '100%',
position: 'relative',
justifyContent: 'center',
transition: 'all 0.3s ease-in-out',
'@md': {
height: 'auto',
'& video': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export const PlayPauseButton = ({
height = 20,
}: {
isPaused: boolean;
width: number;
height: number;
width?: number;
height?: number;
}) => {
const { hlsPlayer } = useHMSPlayerContext();
const onClick = async (event: MouseEvent) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
import React from 'react';
import { useMedia } from 'react-use';
import { BackwardArrowIcon, ForwardArrowIcon } from '@100mslive/react-icons';
import { Box, Flex } from '../../../Layout';
import { Text } from '../../../Text';
import { config } from '../../../Theme';
import { PlayPauseButton } from './PlayPauseButton';
import { SeekControl } from './SeekControl';
import { useIsLandscape } from '../../common/hooks';

// desktop buttons
export const PlayPauseSeekControls = ({
isPaused,
onSeekTo,
}: {
isPaused: boolean;
onSeekTo: (value: number) => void;
}) => {
return (
<>
<SeekControl
onClick={e => {
e.stopPropagation();
onSeekTo(-10);
}}
title="backward"
>
<BackwardArrowIcon width={20} height={20} />
</SeekControl>
<PlayPauseButton isPaused={isPaused} />
<SeekControl
onClick={e => {
e.stopPropagation();
onSeekTo(10);
}}
title="forward"
>
<ForwardArrowIcon width={20} height={20} />
</SeekControl>
</>
);
};

// overlay handlers
export const PlayPauseSeekOverlayControls = ({
isPaused,
showControls,
hoverControlsVisible,
}: {
isPaused: boolean;
showControls: boolean;
hoverControlsVisible: {
seekBackward: boolean;
seekForward: boolean;
pausePlay: boolean;
};
}) => {
const isMobile = useMedia(config.media.md);
const isLandscape = useIsLandscape();

if (!isMobile && !isLandscape) {
// show desktopOverflow icons
return (
<>
<Flex
css={{
bg: 'rgba(0, 0, 0, 0.6)',
r: '$round',
size: '$24',
visibility: hoverControlsVisible.seekBackward ? `` : `hidden`,
opacity: hoverControlsVisible.seekBackward ? `1` : '0',
}}
direction="column"
align="center"
>
<SeekControl title="backward">
<BackwardArrowIcon width={52} height={52} />
</SeekControl>
<Text variant="body2" css={{ fontWeight: '$regular' }}>
10 secs
</Text>
</Flex>
<Box
css={{
bg: 'rgba(0, 0, 0, 0.6)',
r: '$round',
visibility: hoverControlsVisible.pausePlay ? `` : `hidden`,
opacity: hoverControlsVisible.pausePlay ? `1` : '0',
}}
>
<PlayPauseButton isPaused={isPaused} width={48} height={48} />
</Box>
<Flex
css={{
bg: 'rgba(0, 0, 0, 0.6)',
r: '$round',
size: '$24',
visibility: hoverControlsVisible.seekForward ? `` : `hidden`,
opacity: hoverControlsVisible.seekForward ? `1` : '0',
}}
direction="column"
align="center"
>
<SeekControl title="forward">
<ForwardArrowIcon width={52} height={52} />
</SeekControl>
<Text variant="body2" css={{ fontWeight: '$regular' }}>
10 secs
</Text>
</Flex>
</>
);
}

return (
<Flex
align="center"
justify="center"
css={{
position: 'absolute',
bg: '#00000066',
display: 'inline-flex',
gap: '$2',
zIndex: 1,
size: '100%',
visibility: showControls ? `` : `hidden`,
opacity: showControls ? `1` : '0',
}}
>
<SeekControl
title="backward"
css={{
visibility: hoverControlsVisible.seekBackward ? `` : `hidden`,
opacity: hoverControlsVisible.seekBackward ? `1` : '0',
}}
>
<BackwardArrowIcon width={32} height={32} />
</SeekControl>
<Box
css={{
bg: 'rgba(0, 0, 0, 0.6)',
r: '$round',
}}
>
<PlayPauseButton isPaused={isPaused} width={48} height={48} />
</Box>
<SeekControl
title="forward"
css={{
visibility: hoverControlsVisible.seekForward ? `` : `hidden`,
opacity: hoverControlsVisible.seekForward ? `1` : '0',
}}
>
<ForwardArrowIcon width={32} height={32} />
</SeekControl>
</Flex>
);
};
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { MouseEventHandler } from 'react';
import { IconButton, Tooltip } from '../../..';

export const SeekControls = ({
export const SeekControl = ({
title,
onClick,
children,
css,
}: {
title: string;
onClick?: MouseEventHandler<HTMLButtonElement>;
css: any;
css?: any;
children: React.ReactNode;
}) => {
return (
Expand Down
Loading

0 comments on commit 8d1c04a

Please sign in to comment.