This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 970
/
Copy pathbookmarkTitleCell.js
58 lines (50 loc) · 1.64 KB
/
bookmarkTitleCell.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const React = require('react')
// Components
const ImmutableComponent = require('../../components/immutableComponent')
// Constants
const {iconSize} = require('../../../../js/constants/config')
// Utils
const cx = require('../../../../js/lib/classSet')
const bookmarkFoldersUtil = require('../../../common/lib/bookmarkFoldersUtil')
class BookmarkTitleCell extends ImmutableComponent {
render () {
let iconStyle
const icon = this.props.siteDetail.get('favicon')
if (!bookmarkFoldersUtil.isFolder(this.props.siteDetail)) {
if (icon) {
iconStyle = {
minWidth: iconSize,
width: iconSize,
backgroundImage: `url(${icon})`,
backgroundSize: iconSize,
height: iconSize
}
}
}
const bookmarkTitle = this.props.siteDetail.get('title')
const bookmarkLocation = this.props.siteDetail.get('location')
const defaultIcon = 'fa fa-file-o'
return <div>
{
<span
className={cx({
bookmarkFavicon: true,
bookmarkFile: !icon,
[defaultIcon]: !icon
})}
data-test-id='bookmarkFavicon'
data-test2-id={!icon ? 'defaultIcon' : null}
style={iconStyle}
/>
}
<span>{bookmarkTitle || bookmarkLocation}</span>
{
bookmarkTitle ? <span className='bookmarkLocation'>{bookmarkLocation}</span> : null
}
</div>
}
}
module.exports = BookmarkTitleCell