2018-10-30 05:02:23 +00:00
|
|
|
/* @flow */
|
|
|
|
|
2017-03-30 16:58:31 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
import { translate } from '../../base/i18n';
|
|
|
|
|
|
|
|
|
2017-03-30 16:58:31 +00:00
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* The type of the React {@code Component} props of
|
|
|
|
* {@link DesktopSourcePreview}.
|
2017-03-30 16:58:31 +00:00
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
type Props = {
|
|
|
|
|
2017-03-30 16:58:31 +00:00
|
|
|
/**
|
2018-10-30 05:02:23 +00:00
|
|
|
* The callback to invoke when the component is clicked. The id of the
|
|
|
|
* clicked on DesktopCapturerSource will be passed in.
|
2017-03-30 16:58:31 +00:00
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
onClick: Function,
|
2017-03-30 16:58:31 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* The callback to invoke when the component is double clicked. The id of
|
|
|
|
* the DesktopCapturerSource will be passed in.
|
|
|
|
*/
|
|
|
|
onDoubleClick: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The indicator which determines whether this DesktopSourcePreview is
|
|
|
|
* selected. If true, the 'is-selected' CSS class will be added to the root
|
|
|
|
* of Component.
|
|
|
|
*/
|
|
|
|
selected: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The DesktopCapturerSource to display.
|
|
|
|
*/
|
|
|
|
source: Object,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The source type of the DesktopCapturerSources to display.
|
|
|
|
*/
|
2021-06-10 12:48:44 +00:00
|
|
|
type: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: Function
|
2018-10-30 05:02:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* React component for displaying a preview of a DesktopCapturerSource.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments Component
|
2018-10-30 05:02:23 +00:00
|
|
|
*/
|
|
|
|
class DesktopSourcePreview extends Component<Props> {
|
2017-03-30 16:58:31 +00:00
|
|
|
/**
|
|
|
|
* Initializes a new DesktopSourcePreview instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
constructor(props: Props) {
|
2017-03-30 16:58:31 +00:00
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._onClick = this._onClick.bind(this);
|
|
|
|
this._onDoubleClick = this._onDoubleClick.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2017-04-06 16:45:36 +00:00
|
|
|
const selectedClass = this.props.selected ? 'is-selected' : '';
|
|
|
|
const displayClasses = `desktop-picker-source ${selectedClass}`;
|
2017-03-30 16:58:31 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className = { displayClasses }
|
|
|
|
onClick = { this._onClick }
|
|
|
|
onDoubleClick = { this._onDoubleClick }>
|
|
|
|
<div className = 'desktop-source-preview-image-container'>
|
|
|
|
<img
|
2021-06-10 12:48:44 +00:00
|
|
|
alt = { this.props.t('welcomepage.logo.desktopPreviewThumbnail') }
|
2017-03-30 16:58:31 +00:00
|
|
|
className = 'desktop-source-preview-thumbnail'
|
|
|
|
src = { this.props.source.thumbnail.toDataURL() } />
|
|
|
|
</div>
|
|
|
|
<div className = 'desktop-source-preview-label'>
|
|
|
|
{ this.props.source.name }
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
_onClick: () => void;
|
|
|
|
|
2017-03-30 16:58:31 +00:00
|
|
|
/**
|
|
|
|
* Invokes the passed in onClick callback.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
2017-07-07 22:45:24 +00:00
|
|
|
const { source, type } = this.props;
|
|
|
|
|
|
|
|
this.props.onClick(source.id, type);
|
2017-03-30 16:58:31 +00:00
|
|
|
}
|
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
_onDoubleClick: () => void;
|
|
|
|
|
2017-03-30 16:58:31 +00:00
|
|
|
/**
|
|
|
|
* Invokes the passed in onDoubleClick callback.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onDoubleClick() {
|
2017-07-07 22:45:24 +00:00
|
|
|
const { source, type } = this.props;
|
|
|
|
|
|
|
|
this.props.onDoubleClick(source.id, type);
|
2017-03-30 16:58:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-10 12:48:44 +00:00
|
|
|
export default translate(DesktopSourcePreview);
|