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
3,884 changes: 3,884 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"url": "https://github.com/thebeansgroup/frontender-task_vanilla"
},
"author": "sam",
"dependencies": {
},
"dependencies": {},
"devDependencies": {
"babel-core": "^5.5.8",
"babel-loader": "^5.1.4",
Expand Down
160 changes: 160 additions & 0 deletions public/css/styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,163 @@
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
background-color: #f8f8f8;
}

.container {
padding: 7% 10%;
}

.row {
display: flex;
justify-content: space-between;
}

.column {
width: 47%;
}

/* Event */

.event {
border: 1px solid #e1e1e1;
border-radius: 5px;
padding-bottom: 10px;
background: white;
}

.event__title {
font-size: 1rem;
background: #f4f4f4;
border: 1px solid #e1e1e1;
border-radius: 5px;
margin: -1px;
padding: 10px 15px;
}

.event__info {
padding: 5px 10px 11px 10px;
}

.event__description {
padding-bottom: 20px;
border-bottom: 1px solid #e1e1e1;
}

.event__funding__raised {
font-size: 2.3rem;
font-weight: bold;
}

.event__funding__totals {
color: #006400;
}

.event__progress {
background: #f4f4f4;
border: 1px solid #e1e1e1;
margin-bottom: 12px;
}

.event__progress_meter {
background: #32cd32;
display: block;
height: 20px;
}

.event__details {
display: flex;
font-size: 0.8rem;
padding: 15px;
background: #f4f4f4;
border: 1px solid #e1e1e1;
}

.event__details > div {
width: 50%;
margin-left: 10px;
}

.event__description {
font-size: 1rem;
}

.event__description > p {
margin: 1.1rem 0rem;
}

/* Comments */
.comment__holder {
margin-bottom: 14px;
}

.comment__card {
display: flex;
padding: 12px 14px;
background: #f4f4f4;
border: 1px solid #e1e1e1;
border-radius: 5px 5px 5px 0px;
}

.comment__image {
height: 80px;
width: 80px;
}

.comment__details {
margin-left: 15px;
}

.comment__user {
font-size: 0.9rem;
}

.comment__quote {
margin-top: 8px;
font-size: 1.1rem;
}

.comment__triangle {
position: relative;
width: 0;
border-style: solid;
border-width: 24px 30px 0 0;
border-color: #e1e1e1 transparent transparent transparent;
}
.comment__triangle::before {
border-style: solid;
border-color: #e1e1e1 transparent transparent transparent;
}
.comment__triangle::after {
position: absolute;
content: "";
top: -25px;
left: 1px;
border-style: solid;
border-width: 23px 29px 0 0;
border-color: #f4f4f4 transparent transparent transparent;
}

.comment__child {
background: white;
width: calc(100% - 110px);
margin-left: 80px;
margin-top: -20px;
}

.triangle__child {
margin-left: 80px;
}

.triangle__child::after {
border-color: white transparent transparent transparent;
}

@media screen and (max-width: 768px) {
.row {
flex-direction: column;
}
.column {
width: 100%;
margin-bottom: 42px;
}
}
86 changes: 86 additions & 0 deletions src/components/comments/elements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* Image Component
*/

export class Image {
constructor(userId) {
this.userId = userId;
}

render() {
return `
<img class="comment__image" src="./images/faces/128-${this.userId}.jpg"/>
`
}
}

/**
* User Component
*/

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

render() {
return `
<div class="comment__user">
<strong>${this.name}</strong>
${this.isChild ? '' : `donated £${this.donation / 100}`}
</div>
`
}
}

/**
* Quote Component
*/

export class Quote {
constructor(quote) {
this.quote = quote;
}

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

}

/**
* Comment Component
*/

export class Comment {
constructor(comment, isChild = false) {
this.comment = comment;
this.isChild = isChild;
this.createFactories();
}

createFactories() {
this.image = new Image(this.comment.userId);
this.user = new User(this.comment.name, this.comment.donation, this.isChild);
this.quote = new Quote(this.comment.comment);
}

render() {
return `
<div class="comment__holder">
<div class="comment__card ${this.isChild ? 'comment__child' : ''}">
${this.image.render()}
<div class="comment__details">
${this.user.render()}
${this.quote.render()}
</div>
</div>
<div class="comment__triangle ${this.isChild ? 'triangle__child' : ''}"></div>
</div>
`;
}
}
27 changes: 24 additions & 3 deletions src/components/comments/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
// -- comments
// -- -- comment
// -- -- -- image
// -- -- -- user
// -- -- -- quote

import {Comment} from './elements.js';

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

createFactories() {
createComments() {
let commentList = '';
this.data.comments.forEach(comment => {
commentList += new Comment(comment).render();
if (comment.children.length) {
comment.children.forEach(childComment => {
commentList += new Comment(childComment, true).render();
})
}
})
return commentList;
}

render() {
return "comments";
return `
<div class="comments__container">
${this.createComments()}
</div>
`
}
}
7 changes: 3 additions & 4 deletions src/components/event/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export class Funding {

return `
<div class="event__progress">
<p class="event__progress__total">${percentage}% of total raised</p>
<b class="event__progress_meter" style="width: ${percentage}%"></b>
</div>
`;
Expand All @@ -54,7 +53,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}.00 raised</span></br>
of £${this.funding.target/100} target.
</p>
${this.renderProgress()}
Expand All @@ -77,10 +76,10 @@ export class Details {
return `
<div class="event__details">
<div class="event__details__date">
<strong>Date:</strong> ${this.date}
<strong>DATE:</strong> ${this.date}
</div>
<div class="event__details__location">
<strong>Location:</strong> ${this.location}
<strong>LOCATION:</strong> ${this.location}
</div>
</div>
`
Expand Down
8 changes: 5 additions & 3 deletions src/components/event/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ export default class {
return `
<div class="event">
${this.title.render()}
${this.description.render()}
${this.funding.render()}
${this.details.render()}
<div class="event__info">
${this.description.render()}
${this.funding.render()}
${this.details.render()}
</div>
</div>
`;
}
Expand Down
4 changes: 4 additions & 0 deletions src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ const data = {
},
comments: [
{
userId: 13,
name: "Person A",
donation: 5000,
comment: "Good luck with your thing!",
children: [
{
userId: 10,
name: "Person D",
donation: 0,
comment: "Thank you",
Expand All @@ -24,12 +26,14 @@ const data = {
]
},
{
userId: 12,
name: "Person B",
donation: 1000,
comment: "Good luck. Well done! A great achievement for a great cause.",
children: []
},
{
userId: 11,
name: "Person C",
donation: 4000,
comment: "Hope all goes well and you successfully achieve your goal. A cause close to our hearts.",
Expand Down