Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
25c71d8a
Commit
25c71d8a
authored
Mar 27, 2024
by
Danny Liu
Browse files
Update theme options and persist OLED dark theme if selected
parent
c24d9d3b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
src/app.html
src/app.html
+5
-1
src/lib/components/chat/Settings/General.svelte
src/lib/components/chat/Settings/General.svelte
+12
-9
No files found.
src/app.html
View file @
25c71d8a
...
...
@@ -9,7 +9,11 @@
<script>
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
(()
=>
{
if
(
if
(
localStorage
.
theme
.
includes
(
'
oled
'
))
{
document
.
documentElement
.
style
.
setProperty
(
'
--color-gray-900
'
,
'
#000000
'
);
document
.
documentElement
.
classList
.
add
(
'
dark
'
);
}
else
if
(
localStorage
.
theme
===
'
light
'
||
(
!
(
'
theme
'
in
localStorage
)
&&
window
.
matchMedia
(
'
(prefers-color-scheme: light)
'
).
matches
)
)
{
...
...
src/lib/components/chat/Settings/General.svelte
View file @
25c71d8a
...
...
@@ -14,7 +14,7 @@
export let getModels: Function;
// General
let themes = ['dark', 'light', 'rose-pine dark', 'rose-pine-dawn light', 'oled'];
let themes = ['dark', 'light', 'rose-pine dark', 'rose-pine-dawn light', 'oled
-dark
'];
let selectedTheme = 'system';
let languages = [];
...
...
@@ -93,11 +93,15 @@
const applyTheme = (_theme: string) => {
let themeToApply = _theme;
if (themeToApply.includes('oled')) {
themeToApply = 'dark';
}
if (_theme === 'system') {
themeToApply = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
if (themeToApply === 'dark') {
if (themeToApply === 'dark'
&& !_theme.includes('oled')
) {
document.documentElement.style.setProperty('--color-gray-900', '#171717');
}
...
...
@@ -117,14 +121,13 @@
};
const themeChangeHandler = (_theme: string) => {
if (_theme === 'oled') {
document.documentElement.style.setProperty('--color-gray-900', '#000000');
} else {
theme.set(_theme);
localStorage.setItem('theme', _theme);
applyTheme(_theme);
if (_theme.includes('oled')) {
document.documentElement.style.setProperty('--color-gray-900', '#000000');
document.documentElement.classList.add('dark');
}
applyTheme(_theme);
};
</script>
...
...
@@ -147,7 +150,7 @@
<option value="light">☀️ {$i18n.t('Light')}</option>
<option value="rose-pine dark">🪻 {$i18n.t('Rosé Pine')}</option>
<option value="rose-pine-dawn light">🌷 {$i18n.t('Rosé Pine Dawn')}</option>
<option value="oled">🌌 {$i18n.t('OLED Dark')}</option>
<option value="oled
-dark
">🌌 {$i18n.t('OLED Dark')}</option>
</select>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment