-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect dark theme via css variable #17800
Conversation
Seems like a good approach, the old way with the name check was a hack. I'm not sure about the removal of the |
Thought I guess if a dark theme is loaded as part of the auto-detection, it will have the variable as well, so I guess it's fine this way. |
Codecov Report
@@ Coverage Diff @@
## main #17800 +/- ##
==========================================
- Coverage 45.54% 45.54% -0.01%
==========================================
Files 807 808 +1
Lines 89859 90009 +150
==========================================
+ Hits 40930 40993 +63
- Misses 42381 42468 +87
Partials 6548 6548
Continue to review full report at Codecov.
|
* detect dark theme via css variable * minor refactor, add documentation If your custom theme is considered a dark theme, set the global css variable `--is-dark-theme` to `true`. This allows gitea to adjust the Monaco code editor's theme accordingly.
I have just created a custom dark theme for my Gitea instance. It looks good, but the Monaco text editor did not pick up the dark theme like it does with the
arc-green
theme enabled.So I looked into the source and found out that the dark editor theme only gets enabled when the builtin
arc-green
orauto
theme is chosen. Any additional themes are treated as light themes.That's why I updated the
isDarkTheme()
function to look for the--is-dark-theme
css variable. If that variable is set totrue
, the editor dark mode gets enabled.And because CSS variables can be set within queries, too, responsive themes like
auto
are possible without additional js logic.