Skip to content

Commit 353b39d

Browse files
committed
Initial commit
1 parent 9b0b0c7 commit 353b39d

File tree

6 files changed

+277
-0
lines changed

6 files changed

+277
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

app.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// set inital value to zero
2+
let count = 0;
3+
// select value and buttons
4+
const value = document.querySelector("#value");
5+
const btns = document.querySelectorAll(".btn");
6+
7+
btns.forEach(function (btn) {
8+
btn.addEventListener("click", function (e) {
9+
const styles = e.currentTarget.classList;
10+
if (styles.contains("decrease")) {
11+
count--;
12+
} else if (styles.contains("increase")) {
13+
count++;
14+
} else {
15+
count = 0;
16+
}
17+
18+
if (count > 0) {
19+
value.style.color = "green";
20+
}
21+
if (count < 0) {
22+
value.style.color = "red";
23+
}
24+
if (count === 0) {
25+
value.style.color = "#222";
26+
}
27+
value.textContent = count;
28+
});
29+
});

index.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html>
2+
3+
<html>
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
7+
<title>Counter</title>
8+
<meta name="description" content="" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1" />
10+
<link rel="stylesheet" href="style.css" />
11+
</head>
12+
<body>
13+
<main>
14+
<div class="container">
15+
<h1>
16+
Counter
17+
</h1>
18+
<span id="value">
19+
0
20+
</span>
21+
<div class="button-container">
22+
<button class="btn decrease">decrease</button>
23+
<button class="btn reset">reset</button>
24+
<button class="btn increase">increase</button>
25+
</div>
26+
</div>
27+
</main>
28+
<script src="app.js" async defer></script>
29+
</body>
30+
</html>

package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "simple-counter",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.html",
6+
"scripts": {
7+
"start": "serve",
8+
"build": "echo This is a static template, there is no bundler or bundling involved!"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/codesandbox-app/static-template.git"
13+
},
14+
"keywords": [],
15+
"author": "Ives van Hoorne",
16+
"license": "MIT",
17+
"bugs": {
18+
"url": "https://github.com/codesandbox-app/static-template/issues"
19+
},
20+
"homepage": "https://github.com/codesandbox-app/static-template#readme",
21+
"devDependencies": {
22+
"serve": "^11.2.0"
23+
}
24+
}

sandbox.config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"template": "static"
3+
}

style.css

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
/*
2+
===============
3+
Fonts
4+
===============
5+
*/
6+
@import url("https://fonts.googleapis.com/css?family=Open+Sans|Roboto:400,700&display=swap");
7+
8+
/*
9+
===============
10+
Variables
11+
===============
12+
*/
13+
14+
:root {
15+
/* dark shades of primary color*/
16+
--clr-primary-1: hsl(205, 86%, 17%);
17+
--clr-primary-2: hsl(205, 77%, 27%);
18+
--clr-primary-3: hsl(205, 72%, 37%);
19+
--clr-primary-4: hsl(205, 63%, 48%);
20+
/* primary/main color */
21+
--clr-primary-5: hsl(205, 78%, 60%);
22+
/* lighter shades of primary color */
23+
--clr-primary-6: hsl(205, 89%, 70%);
24+
--clr-primary-7: hsl(205, 90%, 76%);
25+
--clr-primary-8: hsl(205, 86%, 81%);
26+
--clr-primary-9: hsl(205, 90%, 88%);
27+
--clr-primary-10: hsl(205, 100%, 96%);
28+
/* darkest grey - used for headings */
29+
--clr-grey-1: hsl(209, 61%, 16%);
30+
--clr-grey-2: hsl(211, 39%, 23%);
31+
--clr-grey-3: hsl(209, 34%, 30%);
32+
--clr-grey-4: hsl(209, 28%, 39%);
33+
/* grey used for paragraphs */
34+
--clr-grey-5: hsl(210, 22%, 49%);
35+
--clr-grey-6: hsl(209, 23%, 60%);
36+
--clr-grey-7: hsl(211, 27%, 70%);
37+
--clr-grey-8: hsl(210, 31%, 80%);
38+
--clr-grey-9: hsl(212, 33%, 89%);
39+
--clr-grey-10: hsl(210, 36%, 96%);
40+
--clr-white: #fff;
41+
--clr-red-dark: hsl(360, 67%, 44%);
42+
--clr-red-light: hsl(360, 71%, 66%);
43+
--clr-green-dark: hsl(125, 67%, 44%);
44+
--clr-green-light: hsl(125, 71%, 66%);
45+
--clr-black: #222;
46+
--ff-primary: "Roboto", sans-serif;
47+
--ff-secondary: "Open Sans", sans-serif;
48+
--transition: all 0.3s linear;
49+
--spacing: 0.1rem;
50+
--radius: 0.25rem;
51+
--light-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
52+
--dark-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
53+
--max-width: 1170px;
54+
--fixed-width: 620px;
55+
}
56+
/*
57+
===============
58+
Global Styles
59+
===============
60+
*/
61+
62+
*,
63+
::after,
64+
::before {
65+
margin: 0;
66+
padding: 0;
67+
box-sizing: border-box;
68+
}
69+
body {
70+
font-family: var(--ff-secondary);
71+
background: var(--clr-grey-10);
72+
color: var(--clr-grey-1);
73+
line-height: 1.5;
74+
font-size: 0.875rem;
75+
}
76+
ul {
77+
list-style-type: none;
78+
}
79+
a {
80+
text-decoration: none;
81+
}
82+
h1,
83+
h2,
84+
h3,
85+
h4 {
86+
letter-spacing: var(--spacing);
87+
text-transform: capitalize;
88+
line-height: 1.25;
89+
margin-bottom: 0.75rem;
90+
font-family: var(--ff-primary);
91+
}
92+
h1 {
93+
font-size: 3rem;
94+
}
95+
h2 {
96+
font-size: 2rem;
97+
}
98+
h3 {
99+
font-size: 1.25rem;
100+
}
101+
h4 {
102+
font-size: 0.875rem;
103+
}
104+
p {
105+
margin-bottom: 1.25rem;
106+
color: var(--clr-grey-5);
107+
}
108+
@media screen and (min-width: 800px) {
109+
h1 {
110+
font-size: 4rem;
111+
}
112+
h2 {
113+
font-size: 2.5rem;
114+
}
115+
h3 {
116+
font-size: 1.75rem;
117+
}
118+
h4 {
119+
font-size: 1rem;
120+
}
121+
body {
122+
font-size: 1rem;
123+
}
124+
h1,
125+
h2,
126+
h3,
127+
h4 {
128+
line-height: 1;
129+
}
130+
}
131+
/* global classes */
132+
133+
/* section */
134+
.section {
135+
padding: 5rem 0;
136+
}
137+
138+
.section-center {
139+
width: 90vw;
140+
margin: 0 auto;
141+
max-width: 1170px;
142+
}
143+
@media screen and (min-width: 992px) {
144+
.section-center {
145+
width: 95vw;
146+
}
147+
}
148+
main {
149+
min-height: 100vh;
150+
display: grid;
151+
place-items: center;
152+
}
153+
154+
/*
155+
===============
156+
Counter
157+
===============
158+
*/
159+
160+
main {
161+
min-height: 100vh;
162+
display: grid;
163+
place-items: center;
164+
}
165+
.container {
166+
text-align: center;
167+
}
168+
#value {
169+
font-size: 6rem;
170+
font-weight: bold;
171+
}
172+
.btn {
173+
text-transform: uppercase;
174+
background: transparent;
175+
color: var(--clr-black);
176+
padding: 0.375rem 0.75rem;
177+
letter-spacing: var(--spacing);
178+
display: inline-block;
179+
transition: var(--transition);
180+
font-size: 0.875rem;
181+
border: 2px solid var(--clr-black);
182+
cursor: pointer;
183+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
184+
border-radius: var(--radius);
185+
margin: 0.5rem;
186+
}
187+
.btn:hover {
188+
color: var(--clr-white);
189+
background: var(--clr-black);
190+
}

0 commit comments

Comments
 (0)