Skip to content

Commit

Permalink
done with the site!
Browse files Browse the repository at this point in the history
  • Loading branch information
makon57 committed Jul 2, 2021
1 parent cd9e538 commit 2cab79d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
11 changes: 9 additions & 2 deletions public/javascripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ window.addEventListener("load", (event)=>{
if (editBtn) {
editBtn.addEventListener('click', (event) => {
event.preventDefault();

document.querySelector('.delete-btn').style.visibility = "hidden";
document.querySelector('.edit-btn').style.visibility = "hidden";

const id = event.target.id
let area = document.querySelector(`#text-${id}`);
area.parentElement.innerHTML = `<textarea id="review-text">${area.innerText}</textarea> <button id="save-btn">Save</button>`;
area.parentElement.innerHTML = `<textarea id="review-text">${area.innerText}</textarea> <br> <button id="save-btn">Save</button>`;

let body;

const saveBtn = document.querySelector('#save-btn');
console.log(saveBtn);
if (saveBtn) {
Expand All @@ -30,9 +36,10 @@ window.addEventListener("load", (event)=>{
});
const update = await review.json();
window.location.href = `/trail/${update.trailId}`

});
}
const updateValue = async (event) => {
const updateValue= async (event) => {
body = event.target.value;
console.log(body);
}
Expand Down
48 changes: 46 additions & 2 deletions public/stylesheets/details.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ img {
text-align: center;
font-size: 30px;
font-weight: 700;
padding: 15px;
padding: 30px;
}

.details {
Expand All @@ -142,6 +142,11 @@ img {
width: fit-content;
}

.delete-btn {
background-color: rgb(83, 83, 83);
visibility: visible;
}

.btn-container {
display: flex;
justify-content: center;
Expand Down Expand Up @@ -188,7 +193,46 @@ textarea {
padding: 5px;
}

button.submit-btn {
.submit-btn {
display: block;
margin: auto;
border-radius: 10px;
color: white;
background-color: brown;
border: solid 1px white;
font-size: 15px;
padding: 5px;
width: fit-content;
}

.review-date {
font-size: 10px;
}

.review-username {
font-size: 15px;
}

.review-text {
font-style: italic;
font-weight: 700;
}

#review-text {
margin: 10px;
}

#save-btn {
margin: 5px;
border-radius: 6px;
color: white;
background-color: lightskyblue;
border: solid 1px white;
font-size: 15px;
padding: 5px;
width: fit-content;
}

.edit-btn {
visibility: visible;
}
4 changes: 2 additions & 2 deletions views/trail-detail.pug
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ block content
form(action=`/trail/${trail.id}` method="post" class="")
textarea(name="text" placeholder="Write a review!" class="review-input")
br
button(type="submit" class="submit-btn hi") Submit
button(type="submit" class="submit-btn") Submit
div(class="list-reviews")
each review in reviews
div(class="review")
p(class="review-username")= `User: ${review.User.username}`
div
p(id=`text-${review.id}` class="review-text")= `${review.text}`
p(class="review-username")= `User: ${review.User.username}`
p(class="review-date")= `Reviewed at: ${review.createdAt}`
if (review.User.id === user.id)
button(type="submit" id=`${review.id}` class="edit-btn hi") Edit Review
Expand Down

0 comments on commit 2cab79d

Please sign in to comment.