This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ICU-648] Fix download tooltip (#692)
* fix download tooltip * change text to `Download` only and change tooltip position closer to download icon * fix conflicts * removed unnecessary props and add constant for max filename length
- Loading branch information
1 parent
e57ee0d
commit ad3dd8f
Showing
10 changed files
with
505 additions
and
313 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
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,67 @@ | ||
// Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved. | ||
// See License.txt for license information. | ||
|
||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
|
||
import {getFileThumbnailUrl, getFileUrl} from 'mattermost-redux/utils/file_utils'; | ||
|
||
import Constants, {FileTypes} from 'utils/constants.jsx'; | ||
import { | ||
getFileType, | ||
getIconClassName, | ||
isGIFImage | ||
} from 'utils/utils.jsx'; | ||
|
||
export default class FileThumbnail extends React.PureComponent { | ||
|
||
static propTypes = { | ||
|
||
/* | ||
* File detailed information | ||
*/ | ||
fileInfo: PropTypes.object.isRequired | ||
} | ||
|
||
render() { | ||
const {fileInfo} = this.props; | ||
const type = getFileType(fileInfo.extension); | ||
|
||
let thumbnail; | ||
if (type === FileTypes.IMAGE) { | ||
let className = 'post-image'; | ||
|
||
if (fileInfo.width < Constants.THUMBNAIL_WIDTH && fileInfo.height < Constants.THUMBNAIL_HEIGHT) { | ||
className += ' small'; | ||
} else { | ||
className += ' normal'; | ||
} | ||
|
||
let thumbnailUrl = getFileThumbnailUrl(fileInfo.id); | ||
if (isGIFImage(fileInfo.extension) && !fileInfo.has_preview_image) { | ||
thumbnailUrl = getFileUrl(fileInfo.id); | ||
} | ||
|
||
return ( | ||
<div | ||
className={className} | ||
style={{ | ||
backgroundImage: `url(${thumbnailUrl})`, | ||
backgroundSize: 'cover' | ||
}} | ||
/> | ||
); | ||
} else if (fileInfo.extension === FileTypes.SVG) { | ||
thumbnail = ( | ||
<img | ||
className='post-image normal' | ||
src={getFileUrl(fileInfo.id)} | ||
/> | ||
); | ||
} else { | ||
thumbnail = <div className={'file-icon ' + getIconClassName(type)}/>; | ||
} | ||
|
||
return thumbnail; | ||
} | ||
} |
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
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.