Add dark mode to portable.py
This commit is contained in:
+101
-1
@@ -9,6 +9,7 @@ googlebot_headers = {
|
|||||||
html = """
|
html = """
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
@@ -25,19 +26,22 @@ html = """
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 90vh;
|
height: 90vh;
|
||||||
|
transition: background-color 0.3s, color 0.3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type=text] {
|
input[type=text] {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
@@ -47,6 +51,7 @@ html = """
|
|||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="submit"] {
|
input[type="submit"] {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
background-color: #6a0dad;
|
background-color: #6a0dad;
|
||||||
@@ -59,29 +64,124 @@ html = """
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background-color 0.3s ease;
|
transition: background-color 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="submit"]:hover {
|
input[type="submit"]:hover {
|
||||||
background-color: #4e0875;
|
background-color: #4e0875;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Toggle switch styles */
|
||||||
|
.dark-mode-toggle {
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark-mode-toggle input {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark-mode-toggle label {
|
||||||
|
cursor: pointer;
|
||||||
|
text-indent: -9999px;
|
||||||
|
width: 52px;
|
||||||
|
height: 27px;
|
||||||
|
background: grey;
|
||||||
|
display: block;
|
||||||
|
border-radius: 100px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark-mode-toggle label:after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 2px;
|
||||||
|
left: 2px;
|
||||||
|
width: 23px;
|
||||||
|
height: 23px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 90px;
|
||||||
|
transition: 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark-mode-toggle input:checked+label {
|
||||||
|
background: #6a0dad;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark-mode-toggle input:checked+label:after {
|
||||||
|
left: calc(100% - 2px);
|
||||||
|
transform: translateX(-100%);
|
||||||
|
}
|
||||||
|
|
||||||
/* Responsive adjustments */
|
/* Responsive adjustments */
|
||||||
@media only screen and (max-width: 600px) {
|
@media only screen and (max-width: 600px) {
|
||||||
form {
|
form {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Dark mode styles */
|
||||||
|
body.dark-mode {
|
||||||
|
background-color: #333;
|
||||||
|
color: #FFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode h1 {
|
||||||
|
color: #FFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode input[type=text] {
|
||||||
|
background-color: #555;
|
||||||
|
border: 1px solid #777;
|
||||||
|
color: #FFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode input[type="submit"] {
|
||||||
|
background-color: #9b30ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode input[type="submit"]:hover {
|
||||||
|
background-color: #7a1bb5;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div class="dark-mode-toggle">
|
||||||
|
<input type="checkbox" id="dark-mode-toggle">
|
||||||
|
<label for="dark-mode-toggle" title="Toggle Dark Mode"></label>
|
||||||
|
</div>
|
||||||
<form action="/article" method="post">
|
<form action="/article" method="post">
|
||||||
<h1>Enter Website Link</h1>
|
<h1>Enter Website Link</h1>
|
||||||
<label for="link">Link of the website you want to remove paywall for:</label>
|
<label for="link">Link of the website you want to remove paywall for:</label>
|
||||||
<input type="text" id="link" name="link" required>
|
<input type="text" id="link" name="link" required>
|
||||||
<input type="submit" value="Submit">
|
<input type="submit" value="Submit">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const toggleSwitch = document.getElementById('dark-mode-toggle');
|
||||||
|
const currentTheme = localStorage.getItem('theme') || (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
|
||||||
|
|
||||||
|
if (currentTheme === "dark") {
|
||||||
|
document.body.classList.add("dark-mode");
|
||||||
|
toggleSwitch.checked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleSwitch.addEventListener('change', function () {
|
||||||
|
if (this.checked) {
|
||||||
|
document.body.classList.add("dark-mode");
|
||||||
|
localStorage.setItem('theme', 'dark');
|
||||||
|
} else {
|
||||||
|
document.body.classList.remove("dark-mode");
|
||||||
|
localStorage.setItem('theme', 'light');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user