Skip to content

Commit e319d9c

Browse files
Revert "Adding a feature and improving overall UI"
1 parent f60e2da commit e319d9c

File tree

3 files changed

+12
-76
lines changed

3 files changed

+12
-76
lines changed

color-changing-app-main/color-changing-app-main/app.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22
let colors = [ 'red', 'blue', 'green', 'orange', 'purple', 'black', 'yellow'];
33

44

5+
56
//change the background of canvas when button is clicked
67
let button = document.getElementById('button');
7-
let canvas = document.getElementById('canvas');
8-
9-
function bgchange(color){
10-
canvas.style.backgroundColor = color;
11-
}
128

139
button.addEventListener('click', function(){
1410
//select a random number between 0 - 6
1511
let index = parseInt((Math.random()*colors.length)+1);
12+
//grab the canvas
13+
let canvas = document.getElementById('canvas');
1614

1715
canvas.style.background = `${colors[index]}`
1816
})

color-changing-app-main/color-changing-app-main/index.html

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,12 @@
88
<title>JavaScript Color Changing App</title>
99
</head>
1010
<body>
11-
<div class="container">
12-
<div id="canvas">
13-
My background color will change when my button below is clicked.
14-
</div>
15-
16-
<button id="button">Click me!</button>
17-
18-
<div class="exactcolor">
19-
<span onclick="bgchange('#ff0000')" id = 'red' class = 'colorbutton'></span>
20-
<span onclick="bgchange('#0000ff')" id = 'blue' class = 'colorbutton'></span>
21-
<span onclick="bgchange('#008000')" id = 'green' class = 'colorbutton'></span>
22-
<span onclick="bgchange('#ffa500')" id = 'orange' class = 'colorbutton'></span>
23-
<span onclick="bgchange('#800080')" id = 'purple' class = 'colorbutton'></span>
24-
<span onclick="bgchange('#000000')" id = 'black' class = 'colorbutton'></span>
25-
<span onclick="bgchange('#ffff00')" id = 'yellow' class = 'colorbutton'></span>
26-
</div>
11+
<div id="canvas">
12+
My background color will change when my button below is clicked.
2713
</div>
2814

15+
<button id="button">Click me!</button>
16+
2917

3018

3119
<script src="app.js"></script>
Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,26 @@
1-
html{
2-
background-image: linear-gradient(120deg, #5f57d1, #c065c0);
3-
}
4-
5-
.container{
6-
min-height: 100vh;
7-
}
8-
91
#canvas{
10-
background-color: white;
11-
color: black;
2+
background-color: red;
3+
color: white;
124
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
13-
font-size: 23px;
14-
font-weight: bold;
5+
font-size: 25px;
156
width: 600px;
167
height: 500px;
178
margin: 50px auto 50px;
189
text-align: center;
1910
display: flex;
2011
justify-content: center;
2112
align-items: center;
22-
border-radius: 10px;
2313
}
2414

2515
#button{
26-
cursor: pointer;
2716
text-align: center;
2817
width: 200px;
2918
height: 50px;
3019
margin: 50px auto 50px;
31-
color: black;
32-
font-weight: bold;
33-
font-size: 1.2rem;
20+
color: white;
3421
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
35-
background: linear-gradient(-40deg,rgb(221, 106, 18),coral,rgb(255, 77, 77));
22+
background: black;
3623
border-radius: 5px;
3724
border-style: none;
3825
display: block;
39-
border-radius: 10px;
40-
}
41-
42-
.exactcolor{
43-
display: flex;
44-
justify-content: center;
45-
}
46-
47-
.colorbutton{
48-
cursor: pointer;
49-
margin: 5px;
50-
height: 30px;
51-
width: 30px;
52-
border-radius: 50%;
5326
}
54-
55-
#red{
56-
background-color: #ff0000;
57-
}
58-
#blue{
59-
background-color: #0000ff;
60-
}
61-
#green{
62-
background-color: #008000;
63-
}
64-
#orange{
65-
background-color: #ffa500;
66-
}
67-
#purple{
68-
background-color: #800080;
69-
}
70-
#black{
71-
background-color: #000000;
72-
}
73-
#yellow{
74-
background-color: #ffff00;
75-
}
76-

0 commit comments

Comments
 (0)