Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update reviews page #465

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 42 additions & 24 deletions src/client/src/components/MoreDormInfoBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,36 @@ import { theme } from "../util/GlobalStyles";

const DormInfoBlock = styled.div`
display: flex;
flex-wrap: wrap;
flex-direction: column;

border: 0.05rem solid ${theme.columbiaBlue};
border-radius: 2%;
padding: 2rem;
padding: .5rem 2rem;
margin-top: 1rem;
`;

const Bold = styled.div`
const Bold = styled.p`
font-weight: 800;
margin-right: .2rem;
font-size: inherit;
`;

const Regular = styled.div``;
const Italic = styled.p`
font-style: italic;
margin-right: .2rem;
font-size: inherit;
`;

const Regular = styled.p`
margin-right: .2rem;
font-size: inherit;
`;

const TitleBlock = styled.div`
display: flex;
flex-direction: column;
flex-wrap: wrap;
margin-bottom: 1.5rem;
width: 50%;
flex-direction: row;
justify-content: flex-start;
margin: .75rem 0;

@media (max-width: 786px) {
font-size: 17px;
Expand All @@ -48,17 +58,17 @@ export default class MoreDormInfoBlock extends Component {
let length = string.split(',').length;

if (length === 1) {
return string.charAt(0).toUpperCase() + string.slice(1)
return string.charAt(0).toUpperCase() + string.slice(1, -1)
}

let stringArr = string.split(',').map((word, index) => {
if (index === length - 1) {
return "& " + word.charAt(0).toUpperCase() + word.slice(1);
return "& " + word.charAt(0).toUpperCase() + word.slice(1, -1);
}
else if (index === length - 2) {
return word.charAt(0).toUpperCase() + word.slice(1)
return word.charAt(0).toUpperCase() + word.slice(1, -1)
} else {
return word.charAt(0).toUpperCase() + word.slice(1) + ","
return word.charAt(0).toUpperCase() + word.slice(1, -1) + ","
}
})

Expand All @@ -72,16 +82,16 @@ export default class MoreDormInfoBlock extends Component {
let string = "";

if (single) {
string += "singles"
string += "Singles"
}
if (double) {
if (single) {
string += ","
string += " & "
}
string += "doubles"
string += "Doubles"
}
if (triple) {
string += ",triples"
string += " & Triples"
}

return this.formatList(string);
Expand All @@ -94,20 +104,28 @@ export default class MoreDormInfoBlock extends Component {
return (
<DormInfoBlock>
<TitleBlock>
<Bold>{this.props.dorm === "Wien Hall" ? "Singles & Doubles" : this.formatRooms(this.props.dormInfo.SINGLE_, this.props.dormInfo.DOUBLE_, this.props.dormInfo.TRIPLE_ )}</Bold>
<Regular>dorms</Regular>
<Regular>{this.props.dormInfo.SUITE ? "Suite" : "Corridor"}</Regular>
<Italic>style</Italic>
</TitleBlock>
<TitleBlock>
<Bold>{this.formatRooms(this.props.dormInfo.SINGLE_, this.props.dormInfo.DOUBLE_, this.props.dormInfo.TRIPLE_ )}</Bold>
<Italic><Bold>dorms</Bold></Italic>
</TitleBlock>
<TitleBlock>
<Regular>Lottery</Regular>
<Italic>####</Italic>
</TitleBlock>
<TitleBlock>
<Bold>{this.props.dorm === "Wien Hall" ? "Sophomores, Juniors & Seniors" : this.formatList(this.props.dormInfo.CLASS_MAKEUP)}</Bold>
<Regular>residents</Regular>
<Regular>{this.props.dormInfo.F_KITCHEN ? "Per floor" : this.props.dormInfo.P_KITCHEN ? "Per suite" : "No"}</Regular>
<Italic>kitchen</Italic>
</TitleBlock>
<TitleBlock>
<Bold>Per Floor</Bold>
<Regular>{this.props.dormInfo.F_KITCHEN ? "kitchen" : "bathroom"}</Regular>
<Regular>{this.props.dormInfo.P_BATHROOM ? "Per suite" : "Shared"}</Regular>
<Italic>bathroom</Italic>
</TitleBlock>
<TitleBlock>
<Bold>Per Suite</Bold>
<Regular>{this.props.dormInfo.P_KITCHEN ? "kitchen" : "bathroom"}</Regular>
<Bold>{this.formatList(this.props.dormInfo.CLASS_MAKEUP)}</Bold>
<Italic><Bold>residents</Bold></Italic>
</TitleBlock>
</DormInfoBlock>
)
Expand Down
86 changes: 86 additions & 0 deletions src/client/src/components/NewReviewPageReview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import React, { Component } from "react";
import "../css/Review.css";
import styled from 'styled-components';
import Vote from "./Vote";

let Wrapper = styled.div`
padding: 1.2rem 2rem;
margin-bottom: 2rem;
box-shadow: 5px 5px 10px ${props => props.theme.lightGray};
border: 1px solid ${props => props.theme.lightGray};
`;

let ReviewText = styled.div`
display: flex;
flex-direction: row;
justify-content: left;
align-self: center;
font-style: normal;
font-weight: 500;
font-size: 25px;
`

let Date = styled.div`
margin-left: auto;
`

let InfoWrapper = styled.div`
display: flex;
justify-content: row;
align-items: center;
font-style: normal;
font-weight: 500;
font-size: 15px;
text-align: right;
padding-top: 1rem;
color: #707070;
`;

let monthsDict = {
1: "january",
2: "february",
3: "march",
4: "april",
5: "may",
6: "june",
7: "july",
8: "august",
9: "september",
10: "october",
11: "november",
12: "december"
};

export default class NewReviewPageReview extends Component {
constructor(props) {
super(props);
}


getPublishedDate(timestamp){
// parse year from MySQL timestamp
let posted = "posted: ".toUpperCase()
let month = monthsDict[timestamp.split('/', 3)[0]].toUpperCase()
let date = timestamp.split('/', 3)[1].substring(0, 2)
let year = timestamp.split('/', 3)[2].substring(0, 4)
let parsedDate = date + " " + month + " " + year
return (
<Date>{posted + parsedDate}</Date>
);
}

render() {
let hasNoReviews = (this.props.review === "No Reviews")
return (
<Wrapper>
<ReviewText>
<p>{this.props.review}</p>
</ReviewText>
<InfoWrapper>
<Vote dorm = {this.props.dorm} roomNum = {this.props.room} upvotes = {this.props.thumbs_up} downvotes = {this.props.thumbs_down} />
{hasNoReviews ? null : this.getPublishedDate(this.props.timestamp)}
</InfoWrapper>
</Wrapper>
);
}
}
58 changes: 37 additions & 21 deletions src/client/src/components/Vote.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import styled from 'styled-components';
import styled, { css } from 'styled-components';
import upvote from '../assets/Icons/up_arrow.svg';
import downvote from '../assets/Icons/down_arrow.svg';

Expand All @@ -15,47 +15,63 @@ const Upvotes = styled.div`
display: flex;
justify-content: row;
align-items: center;

${props => props.clicked && css`
${UpIMG} {
filter: invert(55%) sepia(86%) saturate(502%) hue-rotate(70deg) brightness(79%) contrast(85%);
}

${Text} {
color: #28A528;
}
`}
`;

const Downvotes = styled.div`
display: flex;
justify-content: row;
align-items: center;

${props => props.clicked && css`
${DownIMG} {
filter: invert(16%) sepia(92%) saturate(4089%) hue-rotate(352deg) brightness(87%) contrast(93%);
}

${Text} {
color: #D11E1E;
}
`}
`;

const UpIMG = styled.img`
cursor: pointer;
filter: ${props => props.clicked ?
"invert(55%) sepia(86%) saturate(502%) hue-rotate(70deg) brightness(79%) contrast(85%)" :
"invert(90%) sepia(0%) saturate(1681%) hue-rotate(235deg) brightness(93%) contrast(108%)"};
width: 28px;
padding: .5rem;
filter: invert(90%) sepia(0%) saturate(1681%) hue-rotate(235deg) brightness(93%) contrast(108%);

:hover {
filter: ${props => props.clicked ?
"invert(90%) sepia(0%) saturate(1681%) hue-rotate(235deg) brightness(93%) contrast(108%)" :
"invert(55%) sepia(86%) saturate(502%) hue-rotate(70deg) brightness(79%) contrast(85%)"};
filter: invert(55%) sepia(86%) saturate(502%) hue-rotate(70deg) brightness(79%) contrast(85%);
}
`;

const DownIMG = styled.img`
cursor: pointer;
filter: ${props => props.clicked ?
"invert(16%) sepia(92%) saturate(4089%) hue-rotate(352deg) brightness(87%) contrast(93%)" :
"invert(90%) sepia(0%) saturate(1681%) hue-rotate(235deg) brightness(93%) contrast(108%)"};

width: 28px;
padding: .5rem;
filter: invert(90%) sepia(0%) saturate(1681%) hue-rotate(235deg) brightness(93%) contrast(108%);

:hover {
filter: ${props => props.clicked ?
"invert(90%) sepia(0%) saturate(1681%) hue-rotate(235deg) brightness(93%) contrast(108%)" :
"invert(16%) sepia(92%) saturate(4089%) hue-rotate(352deg) brightness(87%) contrast(93%)"};
filter: invert(16%) sepia(92%) saturate(4089%) hue-rotate(352deg) brightness(87%) contrast(93%);
}
`;

const UpText = styled.div``;
const Text = styled.div`
color: #707070;
`;

const DownText = styled.div``;
let agree = "agree ".toUpperCase();
let disagree = "disagree ".toUpperCase();

export default class Vote extends Component{
constructor(props) {
Expand Down Expand Up @@ -128,13 +144,13 @@ export default class Vote extends Component{
render() {
return (
<Wrapper>
<Upvotes>
<UpIMG src = {upvote} alt = "upvote" onClick = {this.upvote} clicked = {this.state.upClicked}/>
<UpText>Agree {this.state.upvotes + this.state.my_upvotes}</UpText>
<Upvotes onClick = {this.upvote} clicked = {this.state.upClicked}>
<UpIMG src = {upvote} alt = "upvote"/>
<Text>{agree}{this.state.upvotes + this.state.my_upvotes}</Text>
</Upvotes>
<Downvotes>
<DownIMG src = {downvote} alt = "downvote" onClick = {this.downvote} clicked = {this.state.downClicked}/>
<DownText>Disagree {this.state.downvotes + this.state.my_downvotes}</DownText>
<Downvotes onClick = {this.downvote} clicked = {this.state.downClicked}>
<DownIMG src = {downvote} alt = "downvote"/>
<Text>{disagree}{this.state.downvotes + this.state.my_downvotes}</Text>
</Downvotes>
</Wrapper>
)
Expand Down
Loading