Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lourdu-radjou: changed the ui and added the dark theme #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<title>Memory Game</title>
<link rel="stylesheet" href="style.css"></link>
<script src="app.js" charset="utf-8"></script>
</head>
<body>
<head>
<meta charset="UTF-8" />
<title>Memory Game</title>
<link rel="stylesheet" href="style.css" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
/>
<script src="toggleTheme.js" defer></script>
<script src="app.js" defer></script>
</head>
<body class="light-theme">
<h3>Memory Game</h3>
<div class="header">
<h3>Score: <span id="result"></span></h3>
<div class="theme-toggle">
<i class="fas fa-toggle-off fa-3x" id="themeIcon"></i>
</div>
</div>

<h3>Score:<span id="result"></span></h3>

<div class="grid">
</div>

</body>
<div class="grid"></div>
</body>
</html>
70 changes: 66 additions & 4 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,68 @@
html {
margin: 0;
padding: 0;
}

body {
min-height: 80vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #0a0908;
transition: background-color 0.5s, color 0.5s; /* Smooth transition */
user-select: none;
}

.header {
display: flex;
align-items: center;
}

.grid {
display: flex;
flex-wrap: wrap;
width: 400px;
height: 300px;
display: grid;
grid-template-columns: repeat(4, 100px); /* Adjust based on your layout */
gap: 4px; /* Space between cards */
}

h3 {
color: #eae0d5;
font-size: 2rem;
}

#grid img {
max-width: 98px;
max-height: 98px;
}

body.light-theme {
background-color: #f1f1f1;
h3,
h2 {
color: #333;
}
#themeIcon {
color: #333;
}
}

body.dark-theme {
background-color: #333;
h3,
h2 {
color: #f1f1f1;
}
#themeIcon {
color: #f1f1f1;
}
}

.theme-toggle {
margin-left: 40px;
text-align: center;
}

.theme-toggle i {
cursor: pointer;
transition: color 0.5s;
}
22 changes: 22 additions & 0 deletions toggleTheme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
document.addEventListener('DOMContentLoaded', () => {
const themeIcon = document.getElementById('themeIcon');
const body = document.body;

let isDarkTheme = false;

themeIcon.addEventListener('click', () => {
if (!isDarkTheme) {
body.classList.remove('light-theme');
body.classList.add('dark-theme');
themeIcon.classList.remove('fa-toggle-off');
themeIcon.classList.add('fa-toggle-on');
isDarkTheme = true;
} else {
body.classList.remove('dark-theme');
body.classList.add('light-theme');
themeIcon.classList.remove('fa-toggle-on');
themeIcon.classList.add('fa-toggle-off');
isDarkTheme = false;
}
});
});