| 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150 |
89x
10x
10x
10x
10x
10x
10x
10x
10x
89x
89x
89x
| import React from 'react';
import PropTypes from 'prop-types';
import { snakeCase } from '@collab-ui/react/utils/snakeCase';
import { Spinner } from '@collab-ui/react';
const FileContentItem = props => {
const {
actionNode,
aspect,
className,
content,
gifIcon,
isProtected,
loading,
loadingText,
onClick,
style,
subtitle,
title,
...otherProps
} = props;
const kebabify = (aspect) => {
Iif(aspect === 'wide'){
aspect = 'sixteenNine';
}
Iif(aspect === 'tall'){
aspect = 'nineSixteen';
}
const kebab = snakeCase(aspect);
return `cui-content-file--${kebab}`;
};
const handleKeyDown = e => {
if (
e.which === 32
|| e.which === 13
|| e.charCode === 32
|| e.charCode === 13
) {
onClick && onClick(e);
e.preventDefault();
}
};
return (
<div
className='cui-content__container'
{...otherProps}
>
{
loading
?
<div
className='cui-content-file'
style={{backgroundImage:content && `url(${content})`}}
>
<div className={`${(content && ' cui-content--opacity') || ''}`}>
<Spinner />
</div>
</div>
:
<div
className={
'cui-content-file__block' +
`${(aspect === 'oneOne' && ' content-file--no-border' || aspect === 'fourThree' && ' content-file--no-border') || ''}`
}
>
<div
className={
`${(aspect && kebabify(aspect)) || ''}` +
`${(!aspect && ' cui-content-file--full') || ''}` +
`${(onClick && ' cui-content-file--clickable') || ''}` +
`${(className && ` ${className}`) || ''}`
}
onKeyDown={handleKeyDown}
onClick={onClick}
role='presentation'
style={{
backgroundImage: content && `url(${content})`,
...style
}}
/>
{
!isProtected && actionNode &&
<div className='cui-content-file__aspect'>
{actionNode}
</div>
}
{
gifIcon &&
<i className={
`${gifIcon} cui-content__gif` +
`${(aspect === 'oneOne' && ' cui-content__gif--oneOne' || aspect === 'fourThree' && ' cui-content__gif--fourThree') || ''}`
}
/>
}
</div>
}
<div className='cui-content-file__info-container'>
{
title &&
<span title={title} key='title' className='cui-content-file__title'>
{loading ? loadingText : title}
</span>
}
{
subtitle &&
<span key='subtitle' className='cui-content-file__subtitle'>{subtitle}</span>
}
</div>
</div>
);
};
FileContentItem.defaultProps = {
actionNode: null,
aspect: null,
className: '',
content: '',
gifIcon: '',
icon: '',
isProtected: null,
loading: false,
loadingText: 'Loading',
onClick: null,
style: null,
subtitle: '',
title: '',
};
FileContentItem.propTypes = {
actionNode: PropTypes.node,
aspect: PropTypes.oneOf(['fourThree', 'nineSixteen', 'oneOne', 'sixteenNine', 'tall', 'threeFour', 'threeTwo', 'twoThree', 'wide']),
className: PropTypes.string,
content: PropTypes.string,
gifIcon: PropTypes.string,
icon: PropTypes.string,
isProtected: PropTypes.bool,
loading: PropTypes.bool,
loadingText: PropTypes.string,
onClick: PropTypes.func,
style: PropTypes.object,
subtitle: PropTypes.string,
title: PropTypes.string,
};
FileContentItem.displayName = 'FileContentItem';
export default FileContentItem; |