-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
116 lines (103 loc) · 2.73 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>A simple counter</title>
<style>
:root {
--c-bg: #f5f5f5;
--c-on-bg: #232323;
--c-primary: #3030f1;
--c-primary-light: #3030f1cc;
--c-on-primary: #fff;
}
@media (prefers-color-scheme: dark) {
:root {
--c-bg: #232323;
--c-on-bg: #efefef;
}
}
* {
color: inherit;
font: inherit;
}
body {
background-color: var(--c-bg);
color: var(--c-on-bg);
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
}
.h1 {
font-size: 96px;
font-weight: 900;
line-height: 1;
margin: 0;
}
.h2 {
font-size: 32px;
font-weight: 400;
line-height: 1;
margin: 0;
}
.u--text-center {
text-align: center;
}
.button {
-webkit-appearance: none;
background-color: var(--c-primary);
border: 0;
border-radius: 6px;
color: var(--c-on-primary);
cursor: pointer;
padding: 16px 20px;
transition: background-color .2s ease-out;
width: 100%;
}
.button:hover {
background-color: var(--c-primary-light);
}
.counter {
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: space-between;
min-height: 100vh;
max-width: 420px;
margin: 0 auto;
padding: 60px;
}
@media (min-height: 420px) {
.counter {
min-height: calc(100vh - 114px); /* Adjusts for the Safari toolbar */
}
}
</style>
</head>
<body>
<div class="counter">
<h1 class="h2 u--text-center">Simple Counter</h1>
<p id="js--count" class="h1 u--text-center">0</p>
<button type="button" id="js--button" class="button">Increment</button>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const countEle = document.querySelector('#js--count')
const buttonEle = document.querySelector('#js--button')
let count = 0
const handleClick = event => {
event.preventDefault()
incrementCount()
updateCountUI()
}
const incrementCount = () => {
count++
}
const updateCountUI = () => {
countEle.innerHTML = count.toString()
}
buttonEle.addEventListener('click', handleClick)
})
</script>
</body>
</html>