improve thumbnail preview styling

This commit is contained in:
Sean Yesmunt 2018-07-18 11:46:21 -04:00
parent 45de83fdf3
commit 6df4032c90
4 changed files with 63 additions and 53 deletions

View file

@ -9,7 +9,7 @@ type Props = {
type: string,
currentPath: ?string,
onFileChosen: (string, string) => void,
fileLabel: ?string,
fileLabel?: string,
directoryLabel?: string,
};
@ -56,7 +56,7 @@ class FileSelector extends React.PureComponent<Props> {
type === 'file' ? fileLabel || __('Choose File') : directoryLabel || __('Choose Directory');
return (
<FormRow verticallyCentered padded>
<FormRow verticallyCentered>
<Button button="primary" onClick={() => this.handleButtonClick()} label={label} />
<input
webkitdirectory="true"

View file

@ -73,7 +73,7 @@ class PublishForm extends React.PureComponent<Props> {
}
componentWillMount() {
const { isStillEditing, thumbnail } = this.props;
const { thumbnail } = this.props;
if (!thumbnail) {
this.props.resetThumbnailStatus();
}
@ -356,14 +356,17 @@ class PublishForm extends React.PureComponent<Props> {
/>
</div>
)}
<FileSelector currentPath={filePath} onFileChosen={this.handleFileChange} />
{!!isStillEditing && (
<p className="card__content card__subtitle">
{__("If you don't choose a file, the file from your existing claim")}
{` "${name}" `}
{__('will be used.')}
</p>
)}
<div className="card__content">
<FileSelector currentPath={filePath} onFileChosen={this.handleFileChange} />
{!!isStillEditing &&
name && (
<p className="card__content card__subtitle">
{__("If you don't choose a file, the file from your existing claim")}
{` "${name}" `}
{__('will be used.')}
</p>
)}
</div>
</section>
<div className={classnames({ 'card--disabled': formDisabled })}>
<section className="card card--section">
@ -400,10 +403,9 @@ class PublishForm extends React.PureComponent<Props> {
__('Enter a URL for your thumbnail.')
) : (
<React.Fragment>
{__(
'Upload your thumbnail (.png/.jpg/.jpeg/.gif) to spee.ch, or enter the URL manually. Learn more about spee.ch '
)}
<Button button="link" label={__('here')} href="https://spee.ch/about" />.
{__('Upload your thumbnail (.png/.jpg/.jpeg/.gif) to')}{' '}
<Button button="link" label={__('spee.ch')} href="https://spee.ch/about" />.{' '}
{__('Recommended size: 800x450 (16:9)')}
</React.Fragment>
)}
</div>

View file

@ -1,7 +1,7 @@
// @flow
import { THUMBNAIL_STATUSES, MODALS } from 'lbry-redux';
import React from 'react';
import { FormField, FormRow } from 'component/common/form';
import * as React from 'react';
import { FormField } from 'component/common/form';
import FileSelector from 'component/common/file-selector';
import Button from 'component/button';
import Native from 'native';
@ -17,28 +17,28 @@ type Props = {
};
type State = {
thumbnailValid: boolean,
}
thumbnailError: boolean,
};
class SelectThumbnail extends React.PureComponent<Props, State> {
constructor() {
super();
this.state = {
thumbnailValid: false,
thumbnailError: false,
};
(this: any).handleThumbnailChange = this.handleThumbnailChange.bind(this);
}
handleThumbnailChange(e) {
handleThumbnailChange(e: SyntheticInputEvent<*>) {
const { updatePublishForm } = this.props;
const newThumbnail = e.target.value.replace(' ', '');
updatePublishForm({ thumbnail: newThumbnail });
this.setState({ thumbnailValid: true })
this.setState({ thumbnailError: false });
}
render() {
const {
thumbnail,
@ -49,43 +49,46 @@ class SelectThumbnail extends React.PureComponent<Props, State> {
thumbnailPath,
resetThumbnailStatus,
} = this.props;
const { thumbnailValid } = this.state;
const { thumbnailError } = this.state;
const thumbnailSrc =
!thumbnail || thumbnailError ? Native.imagePath('thumbnail.png') : thumbnail;
return (
<div className="card__content">
{status === THUMBNAIL_STATUSES.API_DOWN || status === THUMBNAIL_STATUSES.MANUAL ? (
<div className="column">
<img
src={thumbnailSrc}
className="column__item thumbnail-preview"
alt={__('Thumbnail Preview')}
onError={() => {
this.setState({ thumbnailError: true });
}}
/>
<div className="column__item">
<FormField
stretch
className="input--thumbnail"
type="text"
name="content_thumbnail"
label={'URL'}
label="URL"
placeholder="http://spee.ch/mylogo"
value={thumbnail}
disabled={formDisabled}
onChange={this.handleThumbnailChange}
/>
/>
<div className="card__actions">
<Button
button="link"
label={__('Use thumbnail upload tool')}
onClick={() => updatePublishForm({ uploadThumbnailStatus: THUMBNAIL_STATUSES.READY })}
onClick={() =>
updatePublishForm({ uploadThumbnailStatus: THUMBNAIL_STATUSES.READY })
}
/>
</div>
</div>
<img
src={(!thumbnail || !thumbnailValid) ? Native.imagePath('thumbnail.png') : thumbnail}
className="column__item thumbnail-preview"
alt="Thumbnail Preview"
onError={() => {
this.setState({ thumbnailValid: false })
}}
/>
</div>
) : (
<div className="form-row--padded">
<React.Fragment>
{status === THUMBNAIL_STATUSES.READY && (
<FileSelector
currentPath={thumbnailPath}
@ -98,20 +101,25 @@ class SelectThumbnail extends React.PureComponent<Props, State> {
<img
className="column__item thumbnail-preview"
src={thumbnail}
/>
alt={__('Thumbnail Preview')}
/>
<div className="column__item">
<p>
Upload complete.{' '}
<Button button="link" href={thumbnail} label={__('View it on spee.ch')} />
</p>
<Button button="link" label={__('New thumbnail')} onClick={resetThumbnailStatus} />
<Button
button="link"
label={__('New thumbnail')}
onClick={resetThumbnailStatus}
/>
</div>
</div>
</div>
)}
</div>
</React.Fragment>
)}
<div className="card__actions">
{status === THUMBNAIL_STATUSES.READY && (
{status === THUMBNAIL_STATUSES.READY && (
<div className="card__actions">
<Button
button="link"
label={__('Or enter a URL manually')}
@ -119,8 +127,8 @@ class SelectThumbnail extends React.PureComponent<Props, State> {
updatePublishForm({ uploadThumbnailStatus: THUMBNAIL_STATUSES.MANUAL })
}
/>
)}
</div>
</div>
)}
{status === THUMBNAIL_STATUSES.IN_PROGRESS && <p>{__('Uploading thumbnail')}...</p>}
</div>

View file

@ -67,8 +67,8 @@
width: 35px;
}
input.paginate-channel {
width: 35px;
input.input--thumbnail {
width: 370px;
}
&.form-field--auto-height {