PLT-7115 Changed cropping for unposted files to match posted ones (#6926)

* PLT-7115 Changed cropping for unposted files to match ones that have been posted

* Cleaned up file_preview.jsx
Этот коммит содержится в:
Harrison Healey
2017-07-19 16:47:50 -04:00
коммит произвёл Christopher Speller
родитель ea6f37e68d
Коммит 23a59b03dd
2 изменённых файлов: 30 добавлений и 25 удалений

Просмотреть файл

@@ -1,17 +1,28 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information. // See License.txt for license information.
import ReactDOM from 'react-dom';
import * as Utils from 'utils/utils.jsx';
import {getFileThumbnailUrl} from 'mattermost-redux/utils/file_utils';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
import loadingGif from 'images/load.gif'; import loadingGif from 'images/load.gif';
import Constants from 'utils/constants.jsx';
import * as Utils from 'utils/utils.jsx';
import {getFileThumbnailUrl} from 'mattermost-redux/utils/file_utils';
export default class FilePreview extends React.Component { export default class FilePreview extends React.Component {
static propTypes = {
onRemove: PropTypes.func.isRequired,
fileInfos: PropTypes.arrayOf(PropTypes.object).isRequired,
uploadsInProgress: PropTypes.array
};
static defaultProps = {
fileInfos: [],
uploadsInProgress: []
};
constructor(props) { constructor(props) {
super(props); super(props);
@@ -20,7 +31,7 @@ export default class FilePreview extends React.Component {
componentDidUpdate() { componentDidUpdate() {
if (this.props.uploadsInProgress.length > 0) { if (this.props.uploadsInProgress.length > 0) {
ReactDOM.findDOMNode(this.refs[this.props.uploadsInProgress[0]]).scrollIntoView(); this.refs[this.props.uploadsInProgress[0]].scrollIntoView();
} }
} }
@@ -36,10 +47,20 @@ export default class FilePreview extends React.Component {
let className = 'file-preview'; let className = 'file-preview';
let previewImage; let previewImage;
if (type === 'image' || type === 'svg') { if (type === 'image' || type === 'svg') {
let imageClassName = 'post-image';
if (info.width < Constants.THUMBNAIL_WIDTH && info.height < Constants.THUMBNAIL_HEIGHT) {
imageClassName += ' small';
} else {
imageClassName += ' normal';
}
previewImage = ( previewImage = (
<img <div
className='file-preview__image' className={imageClassName}
src={getFileThumbnailUrl(info.id)} style={{
backgroundImage: `url(${getFileThumbnailUrl(info.id)})`
}}
/> />
); );
} else { } else {
@@ -95,13 +116,3 @@ export default class FilePreview extends React.Component {
); );
} }
} }
FilePreview.defaultProps = {
fileInfos: [],
uploadsInProgress: []
};
FilePreview.propTypes = {
onRemove: PropTypes.func.isRequired,
fileInfos: PropTypes.arrayOf(PropTypes.object).isRequired,
uploadsInProgress: PropTypes.array
};

Просмотреть файл

@@ -35,12 +35,6 @@
} }
} }
.file-preview__image {
display: block;
height: auto;
max-width: 100%;
}
.file-preview__remove { .file-preview__remove {
background: alpha-color($black, .5); background: alpha-color($black, .5);
border-radius: 0 0 0 2px; border-radius: 0 0 0 2px;