Newer
Older

Lucas Eduardo Schoenfelder
committed
/*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 } from 'react';

Lucas Eduardo Schoenfelder
committed
import Card from '@material-ui/core/Card';

vgm18
committed
import Grid from '@material-ui/core/Grid';

Lucas Eduardo Schoenfelder
committed
import CardContent from '@material-ui/core/CardContent';
import CardMedia from '@material-ui/core/CardMedia';
import styled from 'styled-components'
import Options from './ContactCardOptions.js'
import FollowButton from './ContactButtons/FollowButton.js'
import FollowingButton from './ContactButtons/FollowingButton.js'
import FollowersCountButton from './ContactButtons/FollowersCountButton.js'

Lucas Eduardo Schoenfelder
committed
//Image Import
import { noAvatar } from "ImportImages.js";

Lucas Eduardo Schoenfelder
committed
export default function ImgMediaCard(props) {
const [followedBoolean, setFollowedBoolean] = useState(props.followed)
const toggleFollowed = () => { setFollowedBoolean(!followedBoolean) }
return (

Lucas Eduardo Schoenfelder
committed
<StyledCard>

vgm18
committed
<CardDiv className={`${props.contrast}BackColor ${props.contrast}Border ${props.contrast}Text`}>

Lucas Eduardo Schoenfelder
committed
<CardAreaDiv>
{/*Top part of contat card (background image, number of followers and avatar)*/}
<Header>
<StyledCardMedia image={props.cover}>
<div style={{ display: "flex", backgroundColor: "inherit", float: "right" }}>
<Link to={props.href} style={{textDecoration : "none"}}>

vgm18
committed
<FollowersCountButton contrast={props.contrast} followCount={props.follow_count} />

Lucas Eduardo Schoenfelder
committed
</Link>
<Link to={props.href}>
<AvatarDiv>
<img src={props.avatar ? props.avatar : noAvatar} alt='user avatar'
style={{ height: "100%", width: "100%", borderRadius: "50%" }} />
</AvatarDiv>

Lucas Eduardo Schoenfelder
committed
</Link>
</div>
</StyledCardMedia>
</Header>
{/*Rest of the card content. Button to be rendered depends on whether the contact is followed by the user*/}

vgm18
committed
<CardContent style={{height: "148px", padding: "0", bottom: "0"}}>

Lucas Eduardo Schoenfelder
committed
<UserInfo>

vgm18
committed
<Link to={props.href} className={`${props.contrast}LinkColor`}>

Lucas Eduardo Schoenfelder
committed
<p className="p1">
{props.name}
</p>
</Link>

vgm18
committed
<Link to={props.href} className={`${props.contrast}LinkColor`}>
<span style={{ fontSize: "14px", fontWeight: "normal" }}>
<b>{props.numCollections}</b> {props.numCollections !== 1 ? "Coleções" : "Coleção"} | <b>{props.numLearningObjects}</b> {props.numLearningObjects !== 1 ? "Recursos" : "Recurso"}

Lucas Eduardo Schoenfelder
committed
</span>
</Link>

vgm18
committed
</UserInfo>
</CardContent>
<CardContent style={{padding: "0"}}>
<Grid container>
<Grid item xs={2}></Grid>
{
followedBoolean ?
(
<>
<Grid item xs={8} style={{ display: "flex", justifyContent: "center" }}>

vgm18
committed
contrast={props.contrast}
followedID={props.followerID ? props.followerID : props.followedID}
toggleFollowed={toggleFollowed} />

vgm18
committed
</Grid>
<Grid item xs={2} style={{ display: "flex", justifyContent: "flex-start" }}>

vgm18
committed
contrast={props.contrast}
followableID={props.followerID ? props.followerID : props.followedID}
followed={followedBoolean}
toggleFollowed={toggleFollowed} />

vgm18
committed
</Grid>
</>
)
:
(
<>
<Grid item xs={8} style={{ display: "flex", justifyContent: "center" }}>

vgm18
committed
contrast={props.contrast}
followerID={props.followedID ? props.followedID : props.followerID}
toggleFollowed={toggleFollowed} />

vgm18
committed
</Grid>
<Grid item xs={2} style={{ display: "flex", justifyContent: "flex-start" }}>

vgm18
committed
contrast={props.contrast}
followableID={props.followedID ? props.followedID : props.followerID}
followed={followedBoolean}
toggleFollowed={toggleFollowed} />

vgm18
committed
</Grid>
</>
)
}
</Grid>
</CardContent>
</CardAreaDiv>
</CardDiv>
</StyledCard>
);

Lucas Eduardo Schoenfelder
committed
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
}
/*Controls top part of Card*/
const Header = styled.div`
display : flex;
height : 152px;
position : relative;
`
/* Had to create these classes so I could avoid using card action Area -------*/
export const CardAreaDiv = styled.div`
display : flex;
flex-direction : column;
height : 360px;
width : 272.5px;
margin : 0 auto;
`
export const CardDiv = styled.div`
text-align : start;
font-family : 'Roboto', sans serif;
`
/*----------------------------------------------------------------------------*/
/*Override Material UI styling -----------------------------------------------*/

Lucas Eduardo Schoenfelder
committed
height : 100%;

vgm18
committed
width : 270.5px;

Lucas Eduardo Schoenfelder
committed
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
background-size : cover;
background-position : center;
`
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) !important;
`
/*----------------------------------------------------------------------------*/
const UserInfo = styled.div`
text-align : center;
margin-top : 50px;
a {
color : #666;
}
.p1 {
font-size : 17px;
margin : 0 0 10px;
overflow : hidden;
text-overflow : ellipsis;
white-space : nowrap;
}
`
/*Rounded div to be used with avatar pic*/
const AvatarDiv = styled.div`
border-radius : 100%;
left : 50%;
position : absolute;
-webkit-transform : translateX(-50%);
transform : translateX(-50%);
top : 65px;
height : 126px;
width : 126px;
border : 2px solid #fff;
`