Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tippyjs-react for Tooltips #931

Merged
merged 1 commit into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@testing-library/react": "^9.5.0",
"@theme-ui/color": "^0.3.5",
"@theme-ui/components": "^0.3.5",
"@tippyjs/react": "^4.2.6",
"deepmerge": "^4.2.2",
"eslint": "^7.32.0",
"eslint-config-react-app": "^6.0.0",
Expand Down
31 changes: 31 additions & 0 deletions src/Tooltip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//; -*- mode: rjsx;-*-
/** @jsx jsx */
import { jsx } from 'theme-ui';

import Tippy from '@tippyjs/react';
import 'tippy.js/dist/tippy.css';
import './style/global-style';

const Tooltip = ({ content, ...props }) => (

<Tippy
content = { <span> {content} </span> }
interactive={true}
delay={300}
theme='studio'

sx={{
fontSize: '16px',
backgroundColor: '#43a472',
color: 'white',
lineHeight: 'normal',
fontFamily: 'Open Sans',
}}

{...props}
>
<span> { props.children} </span>
</Tippy>
);

export default Tooltip;
5 changes: 4 additions & 1 deletion src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,8 @@
"warning-recorder-not-supported": "Your browser does not support recording media streams.",
"warning-recorder-safari-hint": "If you are using Safari, you can enable the experimental feature 'MediaRecorder' in settings. However, on macOS, we recommend switching to Chrome or Firefox.",
"warning-missing-connection-settings": "Connection to Opencast is not fully established: uploading is disabled. Please configure the connection in <1>the settings</1> (you won't lose your recording).",
"settings-back-to-recording": "Back to recording"
"settings-back-to-recording": "Back to recording",

"video-settings-open": "Open video settings",
"video-settings-close": "Close video settings"
}
4 changes: 4 additions & 0 deletions src/style/global-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ button:focus-visible {
outline: 5px solid #2e724f !important;
outline-offset: -3px;
}

.tippy-box[data-theme~='studio'] > .tippy-arrow::before {
color: #43a472;
}
`;

export default GlobalStyle;
3 changes: 0 additions & 3 deletions src/ui/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,23 +199,20 @@ const Navigation = props => {
}}
>
<NavElement
title={t('nav-recording')}
target="/"
icon={faVideo}
onClick={closeMenu}
>
{t('nav-recording')}
</NavElement>
<NavElement
title={t('nav-settings')}
target="/settings"
icon={faWrench}
onClick={closeMenu}
>
{t('nav-settings')}
</NavElement>
<NavElement
title={t('nav-about')}
target="/about"
icon={faInfoCircle}
onClick={closeMenu}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/settings/opencast.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function OpencastSettings({ settingsManager }) {
/> }

<footer sx={{ mt: 4 }}>
<Button title={t('upload-settings-button-store')} sx={{ verticalAlign: 'middle' }}>
<Button sx={{ verticalAlign: 'middle' }}>
{t('upload-settings-button-store')}
</Button>
{ icon && <FontAwesomeIcon
Expand Down
1 change: 0 additions & 1 deletion src/ui/studio/audio-setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ const OptionButton = ({ children, icon, label, onClick }) => {
return (
<button
onClick={onClick}
title={label}
sx={{
fontFamily: 'inherit',
color: 'gray.0',
Expand Down
2 changes: 0 additions & 2 deletions src/ui/studio/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export function ActionButtons({ prev = null, next = null, children }) {
onClick={prev.onClick}
disabled={prev.disabled}
danger={prev.danger || false}
title={t(prev.label || 'back-button-label')}
>
<FontAwesomeIcon icon={faCaretLeft} />
{t(prev.label || 'back-button-label')}
Expand All @@ -72,7 +71,6 @@ export function ActionButtons({ prev = null, next = null, children }) {
}}
onClick={next.onClick}
disabled={next.disabled}
title={t(next.label || 'next-button-label')}
>
{t(next.label || 'next-button-label')}
<FontAwesomeIcon icon={faCaretRight} />
Expand Down
52 changes: 29 additions & 23 deletions src/ui/studio/recording/recording-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { PauseButton, RecordButton, ResumeButton, StopButton } from './recording
import Clock from './clock';
import { STATE_INACTIVE, STATE_PAUSED, STATE_RECORDING } from './index.js';

import Tooltip from '../../../Tooltip';

function addRecordOnStop(dispatch, deviceType) {
return ({ media, url, mimeType, dimensions }) => {
dispatch({ type: 'ADD_RECORDING', payload: { deviceType, media, url, mimeType, dimensions } });
Expand Down Expand Up @@ -152,38 +154,42 @@ export default function RecordingControls({
<div className="buttons" sx={{ display: 'flex', alignItems: 'center' }}>
{recordingState !== STATE_INACTIVE && <div sx={{ flex: 1, textAlign: 'right' }}>
{recordingState === STATE_RECORDING && (
<PauseButton
title={t('pause-button-title')}
recordingState={recordingState}
onClick={handlePause}
/>
<Tooltip content={t('pause-button-title')} offset={[0,50]}>
<PauseButton
recordingState={recordingState}
onClick={handlePause}
/>
</Tooltip>
)}

{recordingState === STATE_PAUSED && (
<ResumeButton
title={t('resume-button-title')}
recordingState={recordingState}
onClick={handleResume}
/>
<Tooltip content={t('resume-button-title')} offset={[0,50]}>
<ResumeButton
recordingState={recordingState}
onClick={handleResume}
/>
</Tooltip>
)}
</div>}

<div className="center">
{recordingState === STATE_INACTIVE ? (
<RecordButton
large
title={t('record-button-title')}
recordingState={recordingState}
onClick={handleRecord}
disabled={!canRecord}
/>
<Tooltip content={t('record-button-title')} offset={[0,50]}>
<RecordButton
large
recordingState={recordingState}
onClick={handleRecord}
disabled={!canRecord}
/>
</Tooltip>
) : (
<StopButton
large
title={t('stop-button-title')}
recordingState={recordingState}
onClick={handleStop}
/>
<Tooltip content={t('stop-button-title')} offset={[0,50]}>
<StopButton
large
recordingState={recordingState}
onClick={handleStop}
/>
</Tooltip>
)}
</div>

Expand Down
60 changes: 32 additions & 28 deletions src/ui/studio/review/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useSettings } from '../../../settings';
import Notification from '../../notification';
import { ReactComponent as CutOutIcon } from './cut-out-icon.svg';
import { ReactComponent as CutHereIcon } from './cut-here-icon.svg';
import Tooltip from '../../../Tooltip';


// In some situation we would like to set the current time to 0 or check for it.
Expand Down Expand Up @@ -237,25 +238,26 @@ const VideoControls = ({ currentTime, previewController }) => {
invariant={(start, end) => start < end}
{ ...{ recordingDispatch, previewController, currentTime } }
/>}
<button
title={previewController.current?.isPlaying ? t('review-pause') : t('review-play')}
sx={{ backgroundColor: 'transparent', border: 'none', mx: 3 }}
onClick={() => {
const controller = previewController.current;
if (controller) {
if (controller.isPlaying) {
controller.pause();
} else if (controller.isReadyToPlay) {
controller.play();
<Tooltip content={previewController.current?.isPlaying ? t('review-pause') : t('review-play')}>
<button
sx={{ backgroundColor: 'transparent', border: 'none', mx: 3 }}
onClick={() => {
const controller = previewController.current;
if (controller) {
if (controller.isPlaying) {
controller.pause();
} else if (controller.isReadyToPlay) {
controller.play();
}
}
}
}}
>
<FontAwesomeIcon
icon={previewController.current?.isPlaying ? faPause : faPlay}
sx={{ fontSize: '50px', opacity: 0.8, '&:hover': { opacity: 1 } }}
/>
</button>
}}
>
<FontAwesomeIcon
icon={previewController.current?.isPlaying ? faPause : faPlay}
sx={{ fontSize: '50px', opacity: 0.8, '&:hover': { opacity: 1 } }}
/>
</button>
</Tooltip>
{settings.review?.disableCutting || <CutControls
marker="end"
value={end}
Expand All @@ -282,14 +284,16 @@ const CutControls = (
previewController.current.currentTime = value;
}} />
</Trans>
<IconButton title={t(`review-remove-cut-point`, { context: marker })} onClick={
() => recordingDispatch({
type: `UPDATE_${marker.toUpperCase()}`,
payload: null,
})
}>
<FontAwesomeIcon icon={faTrash} />
</IconButton>
<Tooltip content={t(`review-remove-cut-point`)}>
<IconButton context={marker} onClick={
() => recordingDispatch({
type: `UPDATE_${marker.toUpperCase()}`,
payload: null,
})
}>
<FontAwesomeIcon icon={faTrash} />
</IconButton>
</Tooltip>
</Fragment> }
</div>
);
Expand All @@ -305,8 +309,8 @@ const CutControls = (
})();

const button = (
<Tooltip content={t(`review-set-${marker}`)}>
<button
title={t(`review-set-${marker}`)}
{...{ disabled }}
onClick={() => {
let value = previewController.current.currentTime;
Expand Down Expand Up @@ -337,7 +341,7 @@ const CutControls = (
}}
>
<CutHereIcon sx={{ height: '32px', transform: marker === 'end' ? 'scaleX(-1)' : '' }} />
</button>
</button></Tooltip>
);

return marker === 'start'
Expand Down
1 change: 0 additions & 1 deletion src/ui/studio/save-creation/recording-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ const RecordingPreview = ({ onDownload, recording, title, presenter }) => {
<Button
as="a"
role="button"
title={t('save-creation-download-button')}
sx={{
width: '100%',
maxWidth: '215px',
Expand Down
Loading