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
46e3208c
Unverified
Commit
46e3208c
authored
Mar 27, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Mar 27, 2024
Browse files
Merge pull request #1325 from dannyl1u/feat/oled-dark-theme
feat: OLED dark theme
parents
c6bb0ded
67865fc5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
src/app.html
src/app.html
+6
-1
src/lib/components/chat/Settings/General.svelte
src/lib/components/chat/Settings/General.svelte
+13
-3
tailwind.config.js
tailwind.config.js
+2
-3
No files found.
src/app.html
View file @
46e3208c
...
@@ -9,7 +9,12 @@
...
@@ -9,7 +9,12 @@
<script>
<script>
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
// 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
.
style
.
setProperty
(
'
--color-gray-950
'
,
'
#000000
'
);
document
.
documentElement
.
classList
.
add
(
'
dark
'
);
}
else
if
(
localStorage
.
theme
===
'
light
'
||
localStorage
.
theme
===
'
light
'
||
(
!
(
'
theme
'
in
localStorage
)
&&
window
.
matchMedia
(
'
(prefers-color-scheme: light)
'
).
matches
)
(
!
(
'
theme
'
in
localStorage
)
&&
window
.
matchMedia
(
'
(prefers-color-scheme: light)
'
).
matches
)
)
{
)
{
...
...
src/lib/components/chat/Settings/General.svelte
View file @
46e3208c
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
export let getModels: Function;
export let getModels: Function;
// General
// General
let themes = ['dark', 'light', 'rose-pine dark', 'rose-pine-dawn light'];
let themes = ['dark', 'light', 'rose-pine dark', 'rose-pine-dawn light'
, 'oled-dark'
];
let selectedTheme = 'system';
let selectedTheme = 'system';
let languages = [];
let languages = [];
...
@@ -91,12 +91,17 @@
...
@@ -91,12 +91,17 @@
});
});
const applyTheme = (_theme: string) => {
const applyTheme = (_theme: string) => {
let themeToApply = _theme;
let themeToApply =
_theme === 'oled-dark' ? 'dark' :
_theme;
if (_theme === 'system') {
if (_theme === 'system') {
themeToApply = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
themeToApply = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
}
if (themeToApply === 'dark' && !_theme.includes('oled')) {
document.documentElement.style.setProperty('--color-gray-900', '#171717');
document.documentElement.style.setProperty('--color-gray-950', '#0d0d0d');
}
themes
themes
.filter((e) => e !== themeToApply)
.filter((e) => e !== themeToApply)
.forEach((e) => {
.forEach((e) => {
...
@@ -115,7 +120,11 @@
...
@@ -115,7 +120,11 @@
const themeChangeHandler = (_theme: string) => {
const themeChangeHandler = (_theme: string) => {
theme.set(_theme);
theme.set(_theme);
localStorage.setItem('theme', _theme);
localStorage.setItem('theme', _theme);
if (_theme.includes('oled')) {
document.documentElement.style.setProperty('--color-gray-900', '#000000');
document.documentElement.style.setProperty('--color-gray-950', '#000000');
document.documentElement.classList.add('dark');
}
applyTheme(_theme);
applyTheme(_theme);
};
};
</script>
</script>
...
@@ -136,6 +145,7 @@
...
@@ -136,6 +145,7 @@
>
>
<option value="system">⚙️ {$i18n.t('System')}</option>
<option value="system">⚙️ {$i18n.t('System')}</option>
<option value="dark">🌑 {$i18n.t('Dark')}</option>
<option value="dark">🌑 {$i18n.t('Dark')}</option>
<option value="oled-dark">🌃 {$i18n.t('OLED Dark')}</option>
<option value="light">☀️ {$i18n.t('Light')}</option>
<option value="light">☀️ {$i18n.t('Light')}</option>
<option value="rose-pine dark">🪻 {$i18n.t('Rosé Pine')}</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="rose-pine-dawn light">🌷 {$i18n.t('Rosé Pine Dawn')}</option>
...
...
tailwind.config.js
View file @
46e3208c
...
@@ -16,9 +16,8 @@ export default {
...
@@ -16,9 +16,8 @@ export default {
700
:
'
#4e4e4e
'
,
700
:
'
#4e4e4e
'
,
800
:
'
#333
'
,
800
:
'
#333
'
,
850
:
'
#262626
'
,
850
:
'
#262626
'
,
900
:
'
var(--color-gray-900, #171717)
'
,
900
:
'
#171717
'
,
950
:
'
var(--color-gray-950, #0d0d0d)
'
950
:
'
#0d0d0d
'
}
}
},
},
typography
:
{
typography
:
{
...
...
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