Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
roro-lv committed Mar 30, 2022
1 parent 108ab95 commit 4c02954
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 8 deletions.
10 changes: 9 additions & 1 deletion src/frontend/components/Button/ButtonLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ const IconBox = styled(Box)`
text-align: center;
`;

const BadgeBox = styled(Box)`
bottom: 15px;
left: 25px;
position: relative;
`;

const TextBox = styled(Box)`
display: flex;
margin-top: 6px;
Expand Down Expand Up @@ -77,7 +83,9 @@ export const ButtonLayout = ({
{Icon && (
<IconBox screenSize={size}>
<Icon iconColor={iconColor} focusColor={rectColor} height="100%" />
{badge}
<BadgeBox direction="row" align="start">
{badge}
</BadgeBox>
</IconBox>
)}

Expand Down
33 changes: 33 additions & 0 deletions src/frontend/components/LiveControls/BadgeNotification/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Box, Text } from 'grommet';
import React from 'react';
import styled from 'styled-components';

const StyledText = styled(Text)`
font-family: 'Roboto-Bold';
`;

interface BadgeNotificationProps {
color: string;
nbrOfNotifications: number;
}
export const BadgeNotification = ({
color,
nbrOfNotifications,
}: BadgeNotificationProps) => {
return (
<Box
align="center"
background="white"
border={{
color,
size: 'xsmall',
}}
pad={{ horizontal: '3px', vertical: '1px' }}
round="6px"
>
<StyledText color={color} size="0.688rem">
{nbrOfNotifications}
</StyledText>
</Box>
);
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { defineMessages, useIntl } from 'react-intl';

import { Button } from 'components/Button';
import { BadgeNotification } from 'components/LiveControls/BadgeNotification';
import { ViewersSVG } from 'components/SVGIcons/ViewersSVG';
import { useLivePanelState } from 'data/stores/useLivePanelState';

Expand All @@ -18,7 +19,13 @@ const messages = defineMessages({
},
});

export const StudentHideViewersButton = () => {
interface StudentHideViewersButtonProps {
nbrOfOnStageRequests?: number;
}

export const StudentHideViewersButton = ({
nbrOfOnStageRequests,
}: StudentHideViewersButtonProps) => {
const intl = useIntl();
const { setPanelVisibility } = useLivePanelState((state) => ({
setPanelVisibility: state.setPanelVisibility,
Expand All @@ -27,6 +34,14 @@ export const StudentHideViewersButton = () => {
return (
<Button
label={intl.formatMessage(messages.viewers)}
badge={
nbrOfOnStageRequests ? (
<BadgeNotification
color="blue-focus"
nbrOfNotifications={nbrOfOnStageRequests}
/>
) : undefined
}
Icon={ViewersSVG}
onClick={() => {
setPanelVisibility(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { defineMessages, useIntl } from 'react-intl';

import { Button } from 'components/Button';
import { BadgeNotification } from 'components/LiveControls/BadgeNotification';
import { ViewersSVG } from 'components/SVGIcons/ViewersSVG';
import {
LivePanelItem,
Expand All @@ -21,14 +22,27 @@ const messages = defineMessages({
},
});

export const StudentShowViewersButton = () => {
interface StudentShowViewersButtonProps {
nbrOfOnStageRequests?: number;
}
export const StudentShowViewersButton = ({
nbrOfOnStageRequests,
}: StudentShowViewersButtonProps) => {
const intl = useIntl();
const { setPanelVisibility } = useLivePanelState((state) => ({
setPanelVisibility: state.setPanelVisibility,
}));

return (
<Button
badge={
nbrOfOnStageRequests ? (
<BadgeNotification
color="blue-active"
nbrOfNotifications={nbrOfOnStageRequests}
/>
) : undefined
}
label={intl.formatMessage(messages.viewers)}
Icon={ViewersSVG}
onClick={() => {
Expand Down
19 changes: 15 additions & 4 deletions src/frontend/components/LiveControls/ViewersWrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,30 @@ import {
LivePanelItem,
useLivePanelState,
} from 'data/stores/useLivePanelState';

import { Video } from 'types/tracks';
import { StudentHideViewersButton } from './StudentHideViewersButton';
import { StudentShowViewersButton } from './StudentShowViewersButton';

export const ViewersWrapper = () => {
interface ViewersWrapperProps {
video?: Video;
}

export const ViewersWrapper = ({ video }: ViewersWrapperProps) => {
const { currentItem, isPanelVisible } = useLivePanelState((state) => ({
currentItem: state.currentItem,
isPanelVisible: state.isPanelVisible,
}));

const nbrOfOnStageRequests =
video && video.participants_asking_to_join.length;

if (currentItem === LivePanelItem.VIEWERS_LIST && isPanelVisible) {
return <StudentHideViewersButton />;
return (
<StudentHideViewersButton nbrOfOnStageRequests={nbrOfOnStageRequests} />
);
} else {
return <StudentShowViewersButton />;
return (
<StudentShowViewersButton nbrOfOnStageRequests={nbrOfOnStageRequests} />
);
}
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/frontend/components/TeacherLiveControlBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const TeacherLiveControlBar = ({

{availableItems.includes(LivePanelItem.VIEWERS_LIST) && (
<Box height="100%" style={{ minWidth: '60px' }}>
<ViewersWrapper />
<ViewersWrapper video={video} />
</Box>
)}

Expand Down

0 comments on commit 4c02954

Please sign in to comment.