Skip to content
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
191 changes: 190 additions & 1 deletion public/css/styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,192 @@
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
background-color:#F8F8F8;
font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;
}

div.comments {
display:flex;
flex-flow:column nowrap;
justify-content:center;
}

div.comments > div.comments__comment > div.comments__comment__card {
margin-top:4%;
}

div.comments > div.comments__comment:first-child > div.comments__comment__card {
margin-top:0;
}

div.comments__child > div.comments__comment {
float:right;
width:calc(100% - 10%);
}

div.comments__child > div.comments__comment > div.comments__comment__card {
background-color:#FFF;
}

div.comments__child > div.comments__comment > div.comments__comment__triangle::after {
border-color:#FFF transparent transparent;
}

div.comments__comment > div.comments__comment__triangle {
border-color:#e1e1e1 transparent transparent;
border-style:solid;
border-width:24px 30px 0 0;
position:relative;
width:0;
}

div.comments__comment > div.comments__comment__triangle::after {
border-color:#f4f4f4 transparent transparent;
border-style:solid;
border-width:23px 29px 0 0;
content:"";
left:1px;
position:absolute;
top:-25px;
}

div.comments__comment > div.comments__comment__triangle::before {
border-color:#e1e1e1 transparent transparent;
border-style:solid;
}

div.comments__comment__card {
align-items:center;
background-color:#F5F5F5;
border:1px solid #E1E1E1;
border-radius:2% 2% 2% 0;
display:flex;
min-height:106px;
}

div.comments__comment__card > div.comments__comment__card__body {
display:flex;
flex-flow:column;
padding-left:2%;
}

div.comments__comment__card > div.comments__comment__card__body > p.comments__message {
margin-top:1%;
}

div.comments__comment__card > div.comments__comment__card__body > p.comments__title {
font-size:.9rem;
font-weight:700;
margin-bottom:0;
}

div.comments__comment__card > div.comments__comment__card__body > p.comments__title > span {
font-weight:400;
}

div.comments__comment__card > img.comments__profile_picture {
height:75px;
padding:4%;
width:75px;
}

div.container {
margin:7% 2.5%;
}

div.container > div.row {
align-items:center;
display:flex;
flex-flow:column nowrap;
justify-content:center;
}

div.container > div.row > div.column {
margin:0 25px;
max-width:463px;
width:100%;
}

div.container > div.row > div.column > div.event {
background-color:#FFF;
border:1px solid #E1E1E1;
border-radius:1%;
margin-bottom:5%;
max-width:463px;
}

div.event > div.event__description {
height:35%;
padding:1% 2%;
}

div.event > div.event__details {
background-color:#F5F5F5;
border:1px solid #E1E1E1;
display:flex;
font-size:.8rem;
margin:2%;
padding:0 2%;
}

div.event > div.event__details > div {
padding:2%;
width:46%;
}

div.event > div.event__details > div[class*="event__details__"] > strong {
text-transform:uppercase;
}

div.event > div.event__funding {
border-top:1px solid #E1E1E1;
margin:2%;
}

div.event > div.event__funding > div.event__progress {
background-color:#F5F5F5;
border:1px solid #E1E1E1;
}

div.event > div.event__funding > div.event__progress > b.event__progress_meter {
background-color:#32cd32;
display:block;
height:20px;
}

div.event > div.event__funding > div.event__progress > p.event__progress__total {
display:none;
}

div.event > div.event__funding > p.event__funding__totals {
color:#245626;
font-size:1.3rem;
margin:4% 1%;
}

div.event > div.event__funding > p.event__funding__totals > span.event__funding__raised {
display:block;
font-size:2.3rem;
font-weight:700;
}

div.event > h1.event__title {
background-color:#F5F5F5;
border-bottom:1px solid #E1E1E1;
border-radius:2%;
font-size:1rem;
height:12%;
margin:0;
padding:2%;
}

@media screen and (min-width: 1247px) {
div.container > div.row {
align-items:flex-start;
display:flex;
flex-flow:row nowrap;
justify-content:center;
}

div.container > div.row > div.column {
width:48%;
}
}
105 changes: 105 additions & 0 deletions src/components/comments/elements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import {uniqueRandomProfilePicture} from "./helper";

/**
* ProfilePicture Component
*/

export class ProfilePicture {
constructor(userId) {
this.imgSrc = `images/faces/128-${userId}.jpg`;
}

render() {
return `
<img class="comments__profile_picture" src="${this.imgSrc}" alt='Profile Picture'>
`;
}
}

/**
* Title Component
*/

export class Title {
constructor(name, donation) {
this.name = name;
this.donation = donation;
}

renderTitle() {

return this.donation === 0 ?
this.name :
`${this.name} <span>donated £${this.donation}</span>`;
}

render() {
return `
<p class="comments__title">${this.renderTitle()}</p>
`;
}
}

/**
* Message Component
*/

export class Message {
constructor(message) {
this.message = message;
}

render() {
return `
<p class="comments__message">${this.message}</p>
`;
}
}

/**
* Comment Component
*/

export class Comment {
constructor({userId, name, donationAmount, message, children}) {
this.profilePicture = new ProfilePicture(userId);
this.title = new Title(name, donationAmount);
this.message = new Message(message);
this.children = children;
}

renderChildren() {
return this.children ? this.children.map((child) => {
const childComment = new Comment({
userId: uniqueRandomProfilePicture(),
name: child.name,
donationAmount: child.donation,
message: child.comment,
children: child.children
}
);

return `
<div class="comments__comment comments__child">
${childComment.render()}
</div>
`;
}) : '';
}

render() {
return `
<div class="comments__comment">
<div class="comments__comment__card">
${this.profilePicture.render()}
<div class="comments__comment__card__body">
${this.title.render()}
${this.message.render()}
</div>
</div>
<div class="comments__comment__triangle"></div>
</div>
${this.renderChildren()}
`;
}
}
23 changes: 23 additions & 0 deletions src/components/comments/helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Just for fun, a way to get a unique photo for each user, since data provides no user id.

function uniqueRandomUserId() {
const takenNumbers = [];

function generate() {
let number = randomNumberBetween(1, 20);
while (takenNumbers.indexOf(number) !== -1) {
number = randomNumberBetween(1, 20);
}

takenNumbers.push(number);
return number;
}

return generate;
}

function randomNumberBetween(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}

export const uniqueRandomProfilePicture = uniqueRandomUserId();
38 changes: 28 additions & 10 deletions src/components/comments/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
import {Comment} from "./elements";
import {uniqueRandomProfilePicture} from "./helper";

export default class {
constructor(data) {
this.data = data;
this.createFactories();
this.render();
}
constructor(data) {
this.data = data;
this.createFactories();
this.render();
}

createFactories() {
}
createFactories() {
this.comments = this.data.comments.map(comment =>
new Comment(
{
userId: uniqueRandomProfilePicture(),
name: comment.name,
donationAmount: comment.donation,
message: comment.comment,
children: comment.children
}
)
);
}

render() {
return "comments";
}
render() {
return `
<div class="comments">
${this.comments.map(comment => comment.render()).join("")}
</div>
`;
}
}
2 changes: 1 addition & 1 deletion src/components/event/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class Funding {
return `
<div class="event__funding">
<p class="event__funding__totals">
<span class="event__funding__raised">£${this.funding.raised/100}</span>
<span class="event__funding__raised">£${this.funding.raised/100} raised</span>
of £${this.funding.target/100} target.
</p>
${this.renderProgress()}
Expand Down