Newer
Older

Lucas Eduardo Schoenfelder
committed
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
/*Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre
Departamento de Informatica - Universidade Federal do Parana
This file is part of Plataforma Integrada MEC.
Plataforma Integrada MEC is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Plataforma Integrada MEC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Plataforma Integrada MEC. If not, see <http://www.gnu.org/licenses/>.*/
import React, {useState, useEffect} from 'react';
import Card from '@material-ui/core/Card';
import {apiDomain, apiUrl} from '../env';
import Options from './CardOptions'
import noAvatar from "../img/default_profile.png";
import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import styled from 'styled-components'
import animacao from "../img/laranja/ANIMACAO_SIMULACAO.jpg";
import apresentacao from "../img/laranja/APRESENTACAO.jpg";
import aplicativo from "../img/laranja/APP.jpg";
import audio from "../img/laranja/AUDIO.jpg";
import vazio from "../img/laranja/EMPTY.jpg";
import imagem from "../img/laranja/IMAGEM.jpg";
import grafico from "../img/laranja/INFOGRAFICO.jpg";
import jogo from "../img/laranja/JOGO.jpg";
import livro from "../img/laranja/LIVRO_DIGITAL.jpg";
import mapa from "../img/laranja/MAPA.jpg";
import outros from "../img/laranja/OUTROS.jpg";
import software from "../img/laranja/SOFTWARE.jpg";
import texto from "../img/laranja/TEXTO.jpg";
import video from "../img/laranja/VIDEO.jpg";
import Rating from '@material-ui/lab/Rating';
import StarBorderIcon from '@material-ui/icons/StarBorder';
import AddIcon from '@material-ui/icons/CreateNewFolder';
import Video from '@material-ui/icons/OndemandVideo';
import MoreIcon from '@material-ui/icons/More';
import FavoriteIcon from '@material-ui/icons/Favorite';
import ButtonGuardarColecao from './ButtonGuardarColecao.js'
import Slide from '@material-ui/core/Slide';
import Grid from '@material-ui/core/Grid';

Lucas Eduardo Schoenfelder
committed
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
const types = [{label: "Animação", thumb: animacao}, {label: "Apresentação", thumb: apresentacao},
{label: "Aplicativo" , thumb: aplicativo}, {label: "Áudio", thumb: audio}, {label: "Vazio", thumb: vazio}, {label: "Imagem", thumb: imagem}, {label: "Gráfico", thumb: grafico}, {label: "Jogo", thumb: jogo}, {label: "Livro", thumb: livro}, {label:"Livro digital", thumb: livro}, {label: "Mapa", thumb: mapa}, {label: "Outros", thumb: outros}, {label: "Software Educacional", thumb:software}, {label: "Software", thumb:software}, {label: "Texto", thumb:texto}, {label: "Vídeo", thumb:video}]
export default function ResourceCardFunction (props) {
const [thumbnail, setThumbnail] = useState(null)
const [label, setLabel] = useState(props.type ? props.type : "Outros")
const [userAvatar, setUserAvatar] = useState(noAvatar)
const [slideIn, setSlide] = useState(false)
const controlSlide = () => {setSlide(!slideIn)}
useEffect( () => {
//decide which thumbnail to use
if (props.thumbnail) {
setThumbnail(`${apiDomain}` + props.thumbnail)
}
else {
//props.type is either the object type or "Outros"
const aux = types.find(function(element){return element.label === props.type})
setThumbnail(aux.thumb)
}
if (props.avatar) {
setUserAvatar(`${apiDomain}` + props.avatar)
}
}, [])
const SlideAnimationContent = () => {
return (
<SlideContentDiv>
<div style={{display:"flex", flex:"1"}}>{/*marginBottom:10px*/}
<AvatarDiv>
<img className="img" src={userAvatar} alt="user avatar"/>
</AvatarDiv>
<EnviadoPor>
Enviado por:
<br/>
<p>{props.author}</p>
</EnviadoPor>
</div>
<TagContainer>
<Grid container spacing={1} justify='safe' style={{height : "inherit"}}>
{
props.tags.map( (tag) =>
<Grid item key={tag.id}>
<span key={tag.id}>{tag.name}</span>
</Grid>
)
}
</Grid>
</TagContainer>
</SlideContentDiv>
)
}
return (
<StyledCard>
<CardDiv>
<CardReaDiv>
<Header onMouseEnter={controlSlide} onMouseLeave={controlSlide}>
{
props.published &&
<Slide direction="right" in={slideIn}>

Lucas Eduardo Schoenfelder
committed
{SlideAnimationContent()}

Lucas Eduardo Schoenfelder
committed
</Slide>
}
<Link to={props.href}> {/*add link to learningObject*/}

Lucas Eduardo Schoenfelder
committed
<img className="img-cover" src={thumbnail} alt="learning object thumbnail"/>

Lucas Eduardo Schoenfelder
committed
</Header>
<Description>
<Link to={props.href} className="text"> {/*add link to learningObject*/}

Lucas Eduardo Schoenfelder
committed
<span>
{props.title}
</span>

Lucas Eduardo Schoenfelder
committed
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
{
props.published &&
<Rating
name="customized-empty"
value={props.rating*10}
precision={0.5}
style={{color:"#666"}}
emptyIcon={<StarBorderIcon fontSize="inherit" />}
/>
}
<Footer>
<Type>
<MoreIcon style={{color:"#ff7f00"}}/> {/*get icon based on object type*/}
<span>{label}</span>
</Type>
{
props.published &&
<LikeCounter>
<span>{props.likeCount}</span>
<ButtonNoWidth>
<FavoriteIcon style={{color : props.liked ? "red" : "#666" }}/>
</ButtonNoWidth>
</LikeCounter>
}
</Footer>
</Description>
</CardReaDiv>
{
props.published &&
<CardReaFooter>
<div style={{display : "flex", height : "100%"}}>
<ButtonGuardarColecao/>
</div>
<Options/>
</CardReaFooter>
}
</CardDiv>
</StyledCard>
)
}
/*---------- USED IN SLIDE DIV ONLY -----------*/
export const TagContainer = styled.div`
display : flex;
flex-direction : row;
width : 100%;
overflow : hidden;
flex : 2;
height : 120px;
span {
background-color : #fff;
height : 20px;
overflow : hidden;
margin : 2px;
padding : 3px 8px;
border-radius : 10px;
color : #666;
font-size : 11px;
}
`
export const EnviadoPor = styled.div`
display : inline-block;
padding-left : 10px;
overflow : hidden;
color : #fff;
padding-right : 1em;
p {
text-overflow : ellipsis;
overflow : hidden;
white-space : nowrap;
margin : 0;
}
`
const AvatarDiv = styled.div`
vertical-align : middle;
border : 0;
img {
height : 40px;
width : 40px;
border : 0;
vertical-align : middle;
border-radius : 50%;
}
`
const SlideContentDiv = styled.div`
background-color : #ff9226;
padding : 10px;
width : 100%;
height : 100%;
position : absolute;
display : flex;
flex-direction : column;
`
/*--------------------------------------------*/
const CardReaFooter = styled.div`
height : 60px;
display : flex;
justify-content : space-between;
border-top : 1px solid #e5e5e5;
border-bottom : 1px solid #e5e5e5;
align-items : center;
padding : 0 15px 0 15px;
`
export const ButtonNoWidth = styled(Button)`
max-width : 24px !important;
width : 24px !important;
min-width : 24px !important;
max-height : 24px !important;
padding : 0 !important;
background-color : #fff !important;
color : #a5a5a5 !important;
border : 0 !important;
.MuiButton-root {
width : 24px !important;
min-width : 12px !important;
}
.MuiSvgIcon-root {
padding-right : 0 !important;
}
.MuiButton-label {
padding-left : 4px !important;
}
`
export const LikeCounter = styled.div`
font-size : 14px;
.btn-like {
padding : 0 !important;
background-color : #fff !important;
border : 0 !important;
min-width : min-content;
}
.MuiSvgIcon-root {
font-size : 21px;
vertical-align : middle;
padding-right : .4em;
}
`
const Type = styled.div`
line-height : 1;
.MuiSvgIcon-root {
font-size : 21px;
vertical-align : middle;
padding-right : .4em;
}
`
export const Footer = styled.div`
display : flex;
flex-direction : row;
justify-content : space-between;
`
const Description = styled.div`
display : flex;
flex : 1;
background-color : #fff;
flex-direction : column;
justify-content: space-between;
padding : 15px;
a {
text-decoration : none !important;
color : inherit;
}
.title {
text-overflow : ellipsis;
overflow : hidden;
margin-bottom : 10px;
font-size : 1.2em;
line-height : 1.1;
max-height : 46px;
color : #666;
}
`
export const Header = styled.div`
display : flex;
flex : 2;
position : relative;
overflow : hidden;
`
export const CardReaDiv = styled.div`
display : flex;
flex-direction : column;
height : 320px;
width : 272.5px;
margin : 0 auto;
.img-cover {
background-color : #e5e5e5;
height : 100%;
object-fit : cover;
overflow : hidden;
display : block;
background-position : center;
background-size : cover;
width : 100%;
}
`
export const CardDiv = styled.div`
background-color : #fff;
text-align : start;
font-family : 'Roboto', sans serif;
color : #666;
`
export const StyledCard = styled(Card)`
width : 272.5px;
max-height : 380px;
margin-top : 10px;
margin-bottom : 10px;
max-width : 345px;
border-radius : 0;
box-shadow : 0 0 5px 0 rgba(0,0,0,.25);
`