-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<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>Document</title> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" /> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" /> | ||
<link rel="stylesheet" href="style.css" /> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div class="row justify-content-center"> | ||
<div class="col-md-8 mt-5 text-center"> | ||
<h1>Bienvenue</h1> | ||
<p class="mt-3">Ce site est en construction. Il ne gère que le choix du thème pour le moment.</p> | ||
</div> | ||
</div> | ||
|
||
<div class="row justify-content-center"> | ||
<div class="col-md-8 mt-5 text-center"> | ||
<button id="mode"> | ||
<i class="fas fa-moon"></i> | ||
<span>Thème sombre</span> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
let button = document.querySelector("#mode"); | ||
let span = button.querySelector('span'); | ||
|
||
if (localStorage.getItem("theme") && localStorage.getItem("theme") === 'sombre') | ||
{ | ||
modeSombre(); | ||
} | ||
|
||
button.addEventListener('click', () => { | ||
if (document.body.classList.contains('dark')) | ||
{ | ||
document.body.classList = ''; | ||
span.textContent = "Thème sombre"; | ||
localStorage.setItem("theme", "clair"); | ||
} else { | ||
modeSombre(); | ||
} | ||
}) | ||
|
||
function modeSombre() { | ||
document.body.classList.add('dark'); | ||
span.textContent = "Thème clair"; | ||
localStorage.setItem("theme", "sombre"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
html, body { | ||
font-family: arial; | ||
min-width: 300px; | ||
} | ||
|
||
button { | ||
border: 1px; | ||
border-radius: 15px; | ||
padding: 15px; | ||
cursor: pointer; | ||
} | ||
|
||
* { | ||
outline: 0; | ||
} | ||
|
||
.dark { | ||
background-color: #112F41; | ||
color: #ffffff; | ||
} | ||
|
||
.dark button { | ||
background: #144098; | ||
color: #fff; | ||
} |