I need this feature too, I'm looking into this ?
Enable Dark Theme on user choice option
I see, its a custom theme design made for a 3rd party web browser extension.
- Edited
sijad choose dark mode in front-end, save that settings, regenerate css, etc.
Regenerating css is not necessary. Because then you're assuming css is related to a user, it would require compilation of the same amount of css as you have users. @Felli has a point here, you'd have to ensure the Less compiler is spitting out a light and dark variant and save the state of the user selection (dark, light). Nothing more I think?
Never mind you were thinking the same: flarum/core865#issuecomment-348709128
luceos Regenerating css is not necessary. Because then you're assuming css is related to a user, it would require compilation of the same amount of css as you have users. @Felli has a point here, you'd have to ensure the Less compiler is spitting out a light and dark variant and save the state of the user selection (dark, light). Nothing more I think?
I mean regenerating diff from dark and light css, you see there's a script that parses both light and dark css and only keeps the different, prioritizes remained css selectors by adding a prefix (e.g. a css class). maybe I did over thinking it, but there's two reason for creating this script:
- making dark css manually is not a good solution.
- I'm not sure changing colors in admin section does or does not effect colors in dark mod. for this reason, dark mode colors should regenerated after changing admin settings.
How does the current "theme_dark_mode" setting in the settings table actually work? And can it be utilized given there is a @config-dark-mode LESS variable available?
Is it not possible to make an extension that moves the dark theme option from the admin appearance options to the users settings?
Maybe give admin option of allowing users to control theme or not.
duman that was my first solution. but currently there's no way to prevent loading main css so user has to download both css files each time he/she reloads the page.
sijad I've thought of this issue as well while working on theming for HumHub, and I've not been able to do much on this issue myself, I at the moment use the following to toggle between two different CSS files.
<form id="switchform">
<a href="javascript:chooseStyle('none', 60)" checked="checked"><i class="fa fa-sun-o"></i></a>
<a href="javascript:chooseStyle('dark-theme', 60)"<i class="fa fa-moon-o"></i></a>
</form>
While this does work, it requires two different CSS files to be called. none
is seen as the default theme display while dark-theme
is the one everyone wishes to switch to for dark mode.
- Edited
Couldnt the single css that controls the whole flarum site include global variables for the different themes and a switch in the users settings that determines which variable the user wants?
/* MyComponent.css */
.root {
color: black;
}
/* Dark theme */
:global(.dark-theme) {
.root {
color: white;
}
}
/* Blue theme */
:global(.blue-theme) {
.root {
color: blue;
}
}
or
More than one css.
//index.css
.btn { font-weight: bold; }
//theme.dark.css
.btn { color:green; }
//theme.light.css
.btn { color: red; }
Or just give them a color picker and let them go crazy ?