mirror of
https://github.com/Tailszefox/Pony-Fusion.git
synced 2024-11-27 07:57:58 +01:00
Added dark mode switch
This commit is contained in:
parent
38b7bf53cc
commit
5045416a4d
5 changed files with 49 additions and 2 deletions
|
@ -39,6 +39,16 @@ body
|
||||||
font-size: 36pt;
|
font-size: 36pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#darkSwitch
|
||||||
|
{
|
||||||
|
float: right;
|
||||||
|
height: 100%;
|
||||||
|
position: relative;
|
||||||
|
top: -10px;
|
||||||
|
left: -15px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
#content
|
#content
|
||||||
{
|
{
|
||||||
padding-bottom: 50px;
|
padding-bottom: 50px;
|
||||||
|
|
|
@ -48,7 +48,7 @@ else
|
||||||
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
|
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
|
||||||
<link href="css/style.css" rel="stylesheet" media="screen">
|
<link href="css/style.css" rel="stylesheet" media="screen">
|
||||||
<link href="css/style-small.css" rel="stylesheet" media="screen and (max-width: 800px)">
|
<link href="css/style-small.css" rel="stylesheet" media="screen and (max-width: 800px)">
|
||||||
<link href="css/dark.css" rel="stylesheet" media="screen and (prefers-color-scheme: dark)">
|
<link href="css/dark.css" rel="stylesheet" media="screen and (prefers-color-scheme: dark)" id="darkSheet">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="faqWrapper">
|
<div id="faqWrapper">
|
||||||
|
@ -66,6 +66,7 @@ else
|
||||||
<div id="container">
|
<div id="container">
|
||||||
|
|
||||||
<div id="header">
|
<div id="header">
|
||||||
|
<img src="mode_light.png" id="darkSwitch" title="Switch to Dark Mode" data-mode="light">
|
||||||
<p>Pony Fusion</p>
|
<p>Pony Fusion</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
36
js/base.js
36
js/base.js
|
@ -215,4 +215,40 @@ $(function ()
|
||||||
var urlQuery = new URLSearchParams(window.location.search);
|
var urlQuery = new URLSearchParams(window.location.search);
|
||||||
if(urlQuery.get("from") == null || urlQuery.get("to") == null)
|
if(urlQuery.get("from") == null || urlQuery.get("to") == null)
|
||||||
randomizePonies(0);
|
randomizePonies(0);
|
||||||
|
|
||||||
|
// Switch to dark/light mode
|
||||||
|
function switchMode()
|
||||||
|
{
|
||||||
|
var darkSwitch = $("#darkSwitch")[0];
|
||||||
|
|
||||||
|
// Switch to dark mode
|
||||||
|
if(darkSwitch.dataset["mode"] == "light")
|
||||||
|
{
|
||||||
|
$("#darkSheet")[0].media = "screen";
|
||||||
|
darkSwitch.dataset["mode"] = "dark";
|
||||||
|
darkSwitch.src = "mode_dark.png";
|
||||||
|
darkSwitch.title = "Switch to Light Mode";
|
||||||
|
}
|
||||||
|
// Switch to light mode
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#darkSheet")[0].media = "not all";
|
||||||
|
darkSwitch.dataset["mode"] = "light";
|
||||||
|
darkSwitch.src = "mode_light.png";
|
||||||
|
darkSwitch.title = "Switch to Dark Mode";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If dark mode is the default, change the switch button
|
||||||
|
var darkDefault = window.matchMedia("screen and (prefers-color-scheme: dark)").matches;
|
||||||
|
|
||||||
|
if(darkDefault)
|
||||||
|
{
|
||||||
|
switchMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle clicking on mode switch
|
||||||
|
$("#darkSwitch").click(function (e) {
|
||||||
|
switchMode();
|
||||||
|
});
|
||||||
});
|
});
|
BIN
mode_dark.png
Normal file
BIN
mode_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
mode_light.png
Normal file
BIN
mode_light.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
Loading…
Reference in a new issue