mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-08 11:33:55 +09:00
Add rx_color_scheme cookie for detecting and setting color scheme
This commit is contained in:
parent
6d4fe58c2f
commit
9fffc050b4
4 changed files with 57 additions and 0 deletions
|
|
@ -368,6 +368,17 @@ a img {
|
|||
}
|
||||
}
|
||||
|
||||
/* Color scheme detection */
|
||||
#rhymix_color_scheme {
|
||||
display: none;
|
||||
@media (prefers-color-scheme: dark) {
|
||||
display: block;
|
||||
position: absolute;
|
||||
bottom: 0; right: 0;
|
||||
width: 1px; height: 1px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Button (for XE compatibility) */
|
||||
.btnArea_mixin(@enabled) when (@enabled = true) {
|
||||
clear: both;
|
||||
|
|
|
|||
|
|
@ -349,6 +349,16 @@ jQuery(function($) {
|
|||
}
|
||||
});
|
||||
|
||||
/* Detect color scheme */
|
||||
var color_scheme_cookie = XE.cookie.get('rx_color_scheme');
|
||||
var color_scheme_check = $('#rhymix_color_scheme').is(':visible') ? 'dark' : 'light';
|
||||
if (color_scheme_cookie && color_scheme_cookie !== color_scheme_check) {
|
||||
XE.cookie.set('rx_color_scheme', color_scheme_check, { path: window.XE.URI(default_url).pathname(), expires: 365 });
|
||||
} else if (color_scheme_check === 'dark') {
|
||||
XE.cookie.set('rx_color_scheme', color_scheme_check, { path: window.XE.URI(default_url).pathname(), expires: 365 });
|
||||
$('#rhymix_color_scheme').hide();
|
||||
}
|
||||
|
||||
/* Editor preview replacement */
|
||||
$(".editable_preview").addClass("rhymix_content xe_content").attr("tabindex", 0);
|
||||
$(".editable_preview").on("click", function() {
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@
|
|||
<div id="rhymix_alert"></div>
|
||||
<div id="rhymix_debug_panel"></div>
|
||||
<div id="rhymix_debug_button"></div>
|
||||
<div id="rhymix_color_scheme"></div>
|
||||
|
||||
<!-- BODY JS -->
|
||||
<block loop="Context::getJsFile('body', true) => $key, $js_file">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue