Skip to content

Commit 5a77348

Browse files
author
Vertika Jain
committed
first commit
0 parents  commit 5a77348

File tree

7 files changed

+332
-0
lines changed

7 files changed

+332
-0
lines changed

.gitignore

Whitespace-only changes.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Projects on Javascript basic.

color-flipper/app.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const hex = ["green", "red", "rgba(133,122,200)", "#f15025"];
2+
const btn=document.getElementById("btn");
3+
const color=document.querySelector(".color");
4+
5+
btn.addEventListener('click',()=>{
6+
const randomNumber=getRandomNumber();
7+
document.body.style.backgroundColor=hex[randomNumber];
8+
color.textContent=hex[randomNumber];
9+
})
10+
11+
getRandomNumber=()=>{
12+
return Math.floor(Math.random()*hex.length);
13+
}

color-flipper/hex.html

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>
7+
Color Flipper || Simple
8+
</title>
9+
<!-- styles -->
10+
<link rel="stylesheet" href="styles.css" />
11+
</head>
12+
13+
<body>
14+
<nav>
15+
<div class="nav-center">
16+
<h4>VJ color flipper</h4>
17+
<ul class="nav-links">
18+
<li><a href="index.html">simple</a></li>
19+
<li><a href="hex.html">hex</a></li>
20+
</ul>
21+
</div>
22+
</nav>
23+
<main>
24+
<div class="container">
25+
<h2>background color : <span class="color">#f1f5f8</span></h2>
26+
<button class="btn btn-hero" id="btn">click me</button>
27+
</div>
28+
</main>
29+
<!-- javascript -->
30+
<script src="hex.js"></script>
31+
</body>
32+
</html>

color-flipper/hex.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const hex = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F"];
2+
const btn=document.getElementById("btn");
3+
const color=document.querySelector(".color");
4+
5+
btn.addEventListener('click',()=>{
6+
let hexColor="#";
7+
for(let i=0;i<6;i++){
8+
hexColor+=hex[getRandomNumber()];
9+
}
10+
document.body.style.backgroundColor=hexColor;
11+
color.textContent=hexColor;
12+
})
13+
14+
getRandomNumber=()=>{
15+
return Math.floor(Math.random()*hex.length);
16+
}

color-flipper/index.html

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Color Flipper || Simple</title>
7+
<!-- styles -->
8+
<link rel="stylesheet" href="styles.css" />
9+
</head>
10+
<body>
11+
<nav>
12+
<div class="nav-center">
13+
<h4>VJ Color Flipper</h4>
14+
<ul class="nav-links">
15+
<li>
16+
<a href="index.html">simple</a>
17+
</li>
18+
<li>
19+
<a href="hex.html">hex</a>
20+
</li>
21+
</ul>
22+
</div>
23+
</nav>>
24+
<main>
25+
<div class="container">
26+
<h2>Background color : <span class="color">#f1f5f8</span></h2>
27+
<button class="btn btn-hero" id="btn">Click Me</button>
28+
</div>
29+
</main>
30+
<!-- javascript -->
31+
<script src="app.js"></script>
32+
</body>
33+
</html>

color-flipper/styles.css

+237
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
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(206, 33%, 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.25rem;
50+
--radius: 0.5rem;
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+
img:not(.nav-logo) {
83+
width: 100%;
84+
display: block;
85+
}
86+
87+
h1,
88+
h2,
89+
h3,
90+
h4 {
91+
letter-spacing: var(--spacing);
92+
text-transform: capitalize;
93+
line-height: 1.25;
94+
margin-bottom: 0.75rem;
95+
font-family: var(--ff-primary);
96+
}
97+
h1 {
98+
font-size: 3rem;
99+
}
100+
h2 {
101+
font-size: 2rem;
102+
}
103+
h3 {
104+
font-size: 1.25rem;
105+
}
106+
h4 {
107+
font-size: 0.875rem;
108+
}
109+
p {
110+
margin-bottom: 1.25rem;
111+
color: var(--clr-grey-5);
112+
}
113+
@media screen and (min-width: 800px) {
114+
h1 {
115+
font-size: 4rem;
116+
}
117+
h2 {
118+
font-size: 2.5rem;
119+
}
120+
h3 {
121+
font-size: 1.75rem;
122+
}
123+
h4 {
124+
font-size: 1rem;
125+
}
126+
body {
127+
font-size: 1rem;
128+
}
129+
h1,
130+
h2,
131+
h3,
132+
h4 {
133+
line-height: 1;
134+
}
135+
}
136+
/* global classes */
137+
138+
.btn {
139+
font-family: var(--ff-primary);
140+
text-transform: uppercase;
141+
background: transparent;
142+
color: var(--clr-black);
143+
padding: 0.375rem 0.75rem;
144+
letter-spacing: var(--spacing);
145+
display: inline-block;
146+
font-weight: 700;
147+
transition: var(--transition);
148+
font-size: 0.875rem;
149+
border: 2px solid var(--clr-black);
150+
cursor: pointer;
151+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
152+
border-radius: var(--radius);
153+
}
154+
.btn:hover {
155+
color: var(--clr-white);
156+
background: var(--clr-black);
157+
}
158+
.btn-hero {
159+
font-size: 1rem;
160+
padding: 0.75rem 1.25rem;
161+
}
162+
/* section */
163+
.section {
164+
padding: 5rem 0;
165+
}
166+
167+
.section-center {
168+
width: 90vw;
169+
margin: 0 auto;
170+
max-width: 1170px;
171+
}
172+
@media screen and (min-width: 992px) {
173+
.section-center {
174+
width: 95vw;
175+
}
176+
}
177+
/*
178+
===============
179+
Nav
180+
===============
181+
*/
182+
nav {
183+
background: var(--clr-white);
184+
height: 3rem;
185+
display: grid;
186+
align-items: center;
187+
box-shadow: var(--dark-shadow);
188+
}
189+
.nav-center {
190+
width: 90vw;
191+
max-width: var(--fixed-width);
192+
margin: 0 auto;
193+
display: flex;
194+
align-items: center;
195+
justify-content: space-between;
196+
}
197+
.nav-center h4 {
198+
margin-bottom: 0;
199+
color: var(--clr-primary-5);
200+
}
201+
.nav-links {
202+
display: flex;
203+
}
204+
nav a {
205+
text-transform: capitalize;
206+
font-weight: 700;
207+
font-size: 1rem;
208+
color: var(--clr-primary-1);
209+
letter-spacing: var(--spacing);
210+
margin-right: 1rem;
211+
}
212+
nav a:hover {
213+
color: var(--clr-primary-5);
214+
}
215+
/*
216+
===============
217+
Container
218+
===============
219+
*/
220+
main {
221+
min-height: calc(100vh - 3rem);
222+
display: grid;
223+
place-items: center;
224+
}
225+
.container {
226+
text-align: center;
227+
}
228+
.container h2 {
229+
background: var(--clr-black);
230+
color: var(--clr-white);
231+
padding: 1rem;
232+
border-radius: var(--radius);
233+
margin-bottom: 2.5rem;
234+
}
235+
.color {
236+
color: var(--clr-primary-5);
237+
}

0 commit comments

Comments
 (0)