-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
148 lines (127 loc) · 4.49 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!DOCTYPE html>
<html lang="en">
<!------------------------------------------------- head------------------------------------- ------------------------>
<head>
<!-- meta tags -->
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- title and stylesheet -->
<title>Side Navbar</title>
<link rel="stylesheet" href="styles.css" />
<!-- box icons for the menu -->
<link href="https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css" rel="stylesheet"/>
</head>
<!-- ------------------------------------------------body --------------------------------------------------------->
<body>
<section class="sidebar">
<div class="nav-header">
<p class="logo">Code Macrocosm</p>
<i class="bx bx-menu btn-menu"></i>
</div>
<ul class="nav-links">
<li>
<i class="bx bx-search search-btn"></i>
<input type="text" placeholder="search..." />
<span class="tooltip">Search</span>
</li>
<li>
<a href="#">
<i class="bx bx-home-alt-2"></i>
<span class="title">Home</span>
</a>
<span class="tooltip">Home</span>
</li>
<li>
<a href="#">
<i class="bx bx-phone-call"></i>
<span class="title">Calls</span>
</a>
<span class="tooltip">Calls</span>
</li>
<li>
<a href="#">
<i class="bx bx-bookmark"></i>
<span class="title">Bookmarks</span>
</a>
<span class="tooltip">Bookmarks</span>
</li>
<li>
<a href="#">
<i class="bx bx-wallet-alt"></i>
<span class="title">Wallet</span>
</a>
<span class="tooltip">Wallet</span>
</li>
<li>
<a href="#">
<i class="bx bxs-devices"></i>
<span class="title">Devices</span>
</a>
<span class="tooltip">Devices</span>
</li>
<li>
<a href="#">
<i class="bx bx-cog"></i>
<span class="title">Setting</span>
</a>
<span class="tooltip">Setting</span>
</li>
</ul>
<div class="theme-wrapper">
<i class="bx bxs-moon theme-icon"></i>
<p>Dark Theme</p>
<div class="theme-btn">
<span class="theme-ball"></span>
</div>
</div>
</section>
<section class="home">
<p>Home Content Here</p>
</section>
<!--------------------------------------------- javascript -------------------------------------------------------->
<script>
// Selecting Elements:
const btn_menu = document.querySelector(".btn-menu");
const side_bar = document.querySelector(".sidebar");
// Adding Click Event Listener:
btn_menu.addEventListener("click", function () {
side_bar.classList.toggle("expand");
changebtn();
});
// Function to Change Button Icon:
function changebtn() {
if (side_bar.classList.contains("expand")) {
btn_menu.classList.replace("bx-menu", "bx-menu-alt-right");
} else {
btn_menu.classList.replace("bx-menu-alt-right", "bx-menu");
}
}
// Theme Switching:
const btn_theme = document.querySelector(".theme-btn");
const theme_ball = document.querySelector(".theme-ball");
const localData = localStorage.getItem("theme");
if (localData == null) {
localStorage.setItem("theme", "light");
}
if (localData == "dark") {
document.body.classList.add("dark-mode");
theme_ball.classList.add("dark");
} else if (localData == "light") {
document.body.classList.remove("dark-mode");
theme_ball.classList.remove("dark");
}
btn_theme.addEventListener("click", function () {
document.body.classList.toggle("dark-mode");
theme_ball.classList.toggle("dark");
if (document.body.classList.contains("dark-mode")) {
localStorage.setItem("theme", "dark");
} else {
localStorage.setItem("theme", "light");
}
});
</script>
<!-- Loading Boxicons Library: -->
<script src="https://unpkg.com/boxicons@2.1.4/dist/boxicons.js"></script>
</body>
</html>