Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
411d8335
Unverified
Commit
411d8335
authored
Apr 15, 2026
by
boojack
Committed by
GitHub
Apr 15, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: set native color scheme for dark themes (#5840)
parent
a3a5b52d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
theme.ts
web/src/utils/theme.ts
+14
-1
No files found.
web/src/utils/theme.ts
View file @
411d8335
...
@@ -182,6 +182,17 @@ const updateThemeColorMeta = (theme: ResolvedTheme): void => {
...
@@ -182,6 +182,17 @@ const updateThemeColorMeta = (theme: ResolvedTheme): void => {
}
}
};
};
const
isDarkTheme
=
(
theme
:
ResolvedTheme
):
boolean
=>
{
return
theme
.
endsWith
(
"-dark"
)
||
theme
.
endsWith
(
".dark"
);
};
/**
* Updates the browser native control color scheme to match the current theme.
*/
const
updateColorScheme
=
(
theme
:
ResolvedTheme
):
void
=>
{
document
.
documentElement
.
style
.
colorScheme
=
isDarkTheme
(
theme
)
?
"dark"
:
"light"
;
};
// ============================================================================
// ============================================================================
// Main Theme Loading
// Main Theme Loading
// ============================================================================
// ============================================================================
...
@@ -193,7 +204,8 @@ const updateThemeColorMeta = (theme: ResolvedTheme): void => {
...
@@ -193,7 +204,8 @@ const updateThemeColorMeta = (theme: ResolvedTheme): void => {
* 2. Resolves "system" to actual theme
* 2. Resolves "system" to actual theme
* 3. Injects theme CSS
* 3. Injects theme CSS
* 4. Sets data-theme attribute
* 4. Sets data-theme attribute
* 5. Persists to localStorage
* 5. Updates browser native UI colors
* 6. Persists to localStorage
*/
*/
export
const
loadTheme
=
(
themeName
:
string
):
void
=>
{
export
const
loadTheme
=
(
themeName
:
string
):
void
=>
{
const
validTheme
=
validateTheme
(
themeName
);
const
validTheme
=
validateTheme
(
themeName
);
...
@@ -202,6 +214,7 @@ export const loadTheme = (themeName: string): void => {
...
@@ -202,6 +214,7 @@ export const loadTheme = (themeName: string): void => {
injectThemeStyle
(
resolvedTheme
);
injectThemeStyle
(
resolvedTheme
);
setThemeAttribute
(
resolvedTheme
);
setThemeAttribute
(
resolvedTheme
);
updateThemeColorMeta
(
resolvedTheme
);
updateThemeColorMeta
(
resolvedTheme
);
updateColorScheme
(
resolvedTheme
);
setStoredTheme
(
validTheme
);
// Store original theme preference (not resolved)
setStoredTheme
(
validTheme
);
// Store original theme preference (not resolved)
};
};
...
...
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