-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(VideoControls): split into smaller components, update layout, lo…
…gic and styles
- Loading branch information
1 parent
06adcc8
commit 1b684dc
Showing
7 changed files
with
400 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/script/components/calling/VideoControls/EmojisBar/EmojisBar.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2020 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
import {CSSObject} from '@emotion/react'; | ||
|
||
import {media} from '@wireapp/react-ui-kit'; | ||
|
||
export const wrapperStyles: CSSObject = { | ||
position: 'absolute', | ||
bottom: '130%', | ||
left: '50%', | ||
display: 'grid', | ||
padding: '0.4rem', | ||
borderRadius: '1rem', | ||
backgroundColor: 'var(--app-bg-secondary)', | ||
boxShadow: '0px 7px 15px 0 #0000004d', | ||
gap: '0.5rem', | ||
gridTemplateColumns: 'repeat(3, 1fr)', | ||
transform: 'translateX(-50%)', | ||
|
||
[media.tablet]: { | ||
transform: 'none', | ||
left: 'auto', | ||
right: 0, | ||
}, | ||
|
||
'&::after': { | ||
position: 'absolute', | ||
bottom: '-0.5rem', | ||
left: '50%', | ||
width: 0, | ||
height: 0, | ||
borderTop: '0.5rem solid var(--app-bg-secondary)', | ||
borderRight: '0.5rem solid transparent', | ||
borderLeft: '0.5rem solid transparent', | ||
content: '""', | ||
transform: 'translateX(-50%)', | ||
|
||
[media.tablet]: { | ||
transform: 'none', | ||
left: 'auto', | ||
right: '1.5rem', | ||
}, | ||
}, | ||
}; | ||
|
||
export const buttonStyles: CSSObject = { | ||
backgroundColor: 'transparent', | ||
border: 0, | ||
padding: '0.5rem', | ||
borderRadius: '1rem', | ||
fontSize: '1.5rem', | ||
|
||
'&:disabled': { | ||
cursor: 'not-allowed', | ||
opacity: 0.5, | ||
}, | ||
|
||
'&:hover': { | ||
backgroundColor: 'var(--inactive-call-button-hover-bg)', | ||
}, | ||
}; |
71 changes: 71 additions & 0 deletions
71
src/script/components/calling/VideoControls/EmojisBar/EmojisBar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2021 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
import React, {useState} from 'react'; | ||
|
||
import {CallingRepository} from 'src/script/calling/CallingRepository'; | ||
import {t} from 'Util/LocalizerUtil'; | ||
|
||
import {buttonStyles, wrapperStyles} from './EmojisBar.styles'; | ||
|
||
const EMOJIS_LIST = ['👍', '🎉', '❤️', '😂', '😮', '👏', '🤔', '😢', '👎']; | ||
|
||
export interface EmojisBarProps { | ||
onEmojiClick: (emoji: string) => void; | ||
} | ||
|
||
export const EmojisBar: React.FC<EmojisBarProps> = ({onEmojiClick}) => { | ||
const [disabledEmojis, setDisabledEmojis] = useState<string[]>([]); | ||
|
||
const handleEmojiClick = (selectedEmoji: string) => { | ||
setDisabledEmojis(prev => [...prev, selectedEmoji]); | ||
|
||
onEmojiClick(selectedEmoji); | ||
|
||
setTimeout(() => { | ||
setDisabledEmojis(prev => [...prev].filter(emoji => emoji !== selectedEmoji)); | ||
}, CallingRepository.EMOJI_TIME_OUT_DURATION); | ||
}; | ||
|
||
return ( | ||
<div | ||
role="toolbar" | ||
data-uie-name="video-controls-emojis-bar" | ||
aria-label={t('callReactionButtonsAriaLabel')} | ||
css={wrapperStyles} | ||
> | ||
{EMOJIS_LIST.map(emoji => { | ||
const isDisabled = disabledEmojis.includes(emoji); | ||
return ( | ||
<button | ||
aria-label={t('callReactionButtonAriaLabel', {emoji})} | ||
data-uie-name="video-controls-emoji" | ||
data-uie-value={emoji} | ||
key={emoji} | ||
disabled={isDisabled} | ||
onClick={() => handleEmojiClick(emoji)} | ||
css={buttonStyles} | ||
> | ||
{emoji} | ||
</button> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.