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

Initial styling and tabbed section #59

Merged
merged 3 commits into from
Sep 18, 2018
Merged
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
1 change: 0 additions & 1 deletion private/sass/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ body {
font-size: medium;
color: $black;
background-color: $white;
padding: $small;
}

h1 {
Expand Down
1 change: 0 additions & 1 deletion public/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/css/style.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

85 changes: 39 additions & 46 deletions public/js/challenges.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,41 @@

var challengePage = document.querySelector(".challenge-page");
var url = window.location.href.split('/')[3];
var h2id = document.querySelector(".h2-id");

let challengePage = document.querySelector(".challenge-page");
let url = window.location.href.split("/")[3];
let h2id = document.querySelector(".h2-id");

(function checkUrlandCreateForm(url) {
var f = document.createElement("form");
var s = document.createElement("input"); //input element, Submit button
var id = document.createElement("input");
var h1 = document.createElement("h1");

if (url === "new-challenges") {
f.setAttribute('method', "post");
f.setAttribute('action', "/challenge/accepted");
s.setAttribute('class', "acceptBtn");
s.setAttribute('type', "submit");
s.setAttribute('value', "accept challenge");
id.setAttribute('name', "challenge_id");
id.setAttribute('type', "hidden");
id.setAttribute('value', h2id.innerHTML);
h1.innerHTML = "Accept Challenge";
f.appendChild(h1);
f.appendChild(s);
f.appendChild(id);
challengePage.appendChild(f);
}

else if (url === "acc-challenges") {
f.setAttribute('method', "post");
f.setAttribute('action', "/challenge/completed");
s.setAttribute('class', "complBtn");
s.setAttribute('type', "submit");
s.setAttribute('value', "complete challenge");
id.setAttribute('name', "challenge_id");
id.setAttribute('type', "hidden");
id.setAttribute('value', h2id.innerHTML);
h1.innerHTML = "Complete Challenge";
f.appendChild(h1);
f.appendChild(s);
f.appendChild(id);
challengePage.appendChild(f);
}
// statement for completed challenges to be deleted or reset

})(url)


let f = document.createElement("form");
let s = document.createElement("input"); //input element, Submit button
let id = document.createElement("input");
let h2 = document.createElement("h2");

if (url === "new-challenges") {
f.setAttribute("method", "post");
f.setAttribute("action", "/challenge/accepted");
s.setAttribute("class", "acceptBtn");
s.setAttribute("type", "submit");
s.setAttribute("value", "accept challenge");
id.setAttribute("name", "challenge_id");
id.setAttribute("type", "hidden");
id.setAttribute("value", h2id.innerHTML);
h2.innerHTML = "Accept Challenge";
f.appendChild(h2);
f.appendChild(s);
f.appendChild(id);
challengePage.appendChild(f);
} else if (url === "acc-challenges") {
f.setAttribute("method", "post");
f.setAttribute("action", "/challenge/completed");
s.setAttribute("class", "complBtn");
s.setAttribute("type", "submit");
s.setAttribute("value", "complete challenge");
id.setAttribute("name", "challenge_id");
id.setAttribute("type", "hidden");
id.setAttribute("value", h2id.innerHTML);
h2.innerHTML = "Complete Challenge";
f.appendChild(h2);
f.appendChild(s);
f.appendChild(id);
challengePage.appendChild(f);
}
// statement for completed challenges to be deleted or reset
})(url);
28 changes: 27 additions & 1 deletion public/js/dom.js
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
// wooooo go dom
// wooooo go dom

function openCity(evt, cityName) {
// Declare all variables

let i, tabcontent, tablinks;

// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}

// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}

// Show the current tab, and add an "active" class to the button that opened the tab
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
}
// To show first tab by default //

document.getElementById("defaultOpen").click();
//
2 changes: 0 additions & 2 deletions src/views/challSelect.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<h1>this is the selected challenge</h1>

<section class="challenge-page">

{{!-- <img class="challenge-img" src="{{challenge.img_link}}"> --}}
Expand Down
33 changes: 25 additions & 8 deletions src/views/dashboard.hbs
Original file line number Diff line number Diff line change
@@ -1,43 +1,60 @@
<h2>This is home dashboard where user can see their challenges</h2>
{{!-- <body onload="document.getElementById('defaultOpen').click()"> --}}
<div class="tab">
<button class="tablinks" onclick="openCity(event, 'new-challenge')" id="defaultOpen">New Challenges</button>
<button class="tablinks" onclick="openCity(event, 'accepted-challenge')">Accepted Challenges</button>
<button class="tablinks" onclick="openCity(event, 'completed-challenge')">Completed Challenges</button>
</div>



<section class="challenges-container">
<!-- New Challenges -->
<section id="new-challenge" class="challenges-container tabcontent">
<header class="challenges-header">
<h1 class="main-title">New Challenges</h1>
<h2 class="main-title">New Challenges</h2>
</header>
<div class="challenges-container">
{{#each newChallenges}}
<div class="challenge-overview">
{{!-- <img src='{{this.img_link}}'> --}}
<h3 class="newChallH3">{{this.title}} : {{this.id}}</h3>
<p>Reward Points: {{this.reward_points}}</p>
<button class="new-challenge-button" id="{{this.id}}" onclick="window.location.href='/new-challenges/{{this.id}}'">
Find out more
</button>
{{/each}}
</div>
{{/each}}

</section>

<section class="challenges-container">
<!-- Accepted Challenges -->

<section id="accepted-challenge" class="challenges-container tabcontent">
<header class="challenges-header">
<h1 class="main-title">Accepted Challenges</h1>
<h2 class="main-title">Accepted Challenges</h2>
</header>
<div class="challenges-container">
{{#each acceptedChallenges}}
<div class="challenge-overview">
{{!-- <img src='{{this.img_link}}'>
--}}
<h3>{{this.title}} : {{ this.challenge_id }}</h3>
<p>Reward Points: {{this.reward_points}}</p>
<button class="acc-challenge-button" id="{{this.id}}" onclick="window.location.href='/acc-challenges/{{this.challenge_id}}'">
Find out more </button> {{/each}}
</div>
</section>
<section class="challenges-container">

<!-- Accepted challenge -->

<section id="completed-challenge" class="challenges-container tabcontent">
<header class="challenges-header">
<h1 class="main-title">Completed Challenges</h1>
<h2 class="main-title">Completed Challenges</h2>
</header>
<div class="challenges-container">
{{#each completedChallenges}}
<div class="challenge-overview">
<h3>{{this.title}} : {{ this.challenge_id }}</h3>
<p>Reward Points: {{this.reward_points}}</p>
<button class="challenge-button" id="id-{{this.id}}" onclick="window.location.href='/comp-challenges/{{this.challenge_id}}'">
Find out more
</button>
Expand Down
9 changes: 9 additions & 0 deletions src/views/helpers/getPoints.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const queries = require("../model");

const getPoints = () =>{
queries.getUserPoints(1).then(points => {
console.log(points)
})
}

module.exports = getPoints;
8 changes: 2 additions & 6 deletions src/views/inventory.hbs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<h2>Items you own</h2>

{{!-- <h2>{{{boughtItems.title}}}</h2> --}}

<section class="items-container">
<header class="items-header">
<h1 class="main-title">Bought Items</h1>
<h2 class="main-title">Bought Items</h2>
</header>
<div class="items-container">
{{#each boughtItems}}
Expand All @@ -21,7 +17,7 @@

<section class="items-container">
<header class="items-header">
<h1 class="main-title">Suggested Items</h1>
<h2 class="main-title">Suggested Items</h2>
</header>
<div class="items-container">
{{#each suggestedItems}}
Expand Down
17 changes: 16 additions & 1 deletion src/views/landing.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
{{!-- hello --}}

<h1>Hello World</h1>
<h1>RACE TO ZERO</h1>

<p>Your step-by-step guide to start reducing
waste and set you on the way to
achieving a zero waste lifestyle.

Tackle the challenges, save your city and
become a true Zero Hero!</p>

<button class="start-button" name="start-button" onclick="window.location.href='/dashboard'">
<h3>Start your adventure!</h3>
</button>

<button class="learn-button" name="learn-button" onclick="window.location.href='/learn'">
<h3>Wait! What's zero waste?</h3>
</button>
1 change: 0 additions & 1 deletion src/views/layouts/content-selected.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
{{> navbar}}

<main>
<h1>Content Selected Layout!</h1>
{{{body}}}
</main>
{{> footer}}
Expand Down
5 changes: 1 addition & 4 deletions src/views/layouts/logged-out.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
{{> header}}

<body>
{{> navbar}}

{{> navbar-loggedout}}
<main>
<h1>Logged-out layout!</h1>
{{{body}}}
</main>
{{> footer}}

</body>

Expand Down
9 changes: 9 additions & 0 deletions src/views/partials/navbar-loggedout.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<header>
<nav>
<div id="sign-in">
<button class="sign-in-button" name="sign-in-button" onclick="window.location.href='/dashboard'">
<h3>Sign In</h3>
</button>
</div>
</nav>
</header>