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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
add background color based on the OS mode #7117
Merged
abidlabs
merged 9 commits into
gradio-app:main
from
aileenvl:avl/issue-5392-white-background-dark-mode
Jan 30, 2024
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c7c6171
add background color based on the OS mode
aileenvl 14ce2a5
add changeset
gradio-pr-bot d45ec57
Merge branch 'main' into avl/issue-5392-white-background-dark-mode
abidlabs b047ee9
use static css instead
pngwn abb601b
Merge branch 'main' into avl/issue-5392-white-background-dark-mode
pngwn bf666cb
format
pngwn c1e671d
changes
1beca25
changes
fb22d4c
Merge branch 'main' into avl/issue-5392-white-background-dark-mode
abidlabs File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@gradio/app": patch | ||
"gradio": patch | ||
--- | ||
|
||
fix:add background color based on the OS mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,29 @@ | |
content="width=device-width, initial-scale=1, shrink-to-fit=no" | ||
/> | ||
|
||
<style> | ||
:root { | ||
--bg: {{ config.get('body_css', {}).get('body_background_fill', 'white') }}; | ||
--col: {{ config.get('body_css', {}).get('body_text_color', '#1f2937') }}; | ||
--bg-dark: {{ config.get('body_css', {}).get('body_background_fill_dark', '#0b0f19') }}; | ||
--col-dark: {{ config.get('body_css', {}).get('body_text_color_dark', '#f3f4f6') }}; | ||
} | ||
|
||
|
||
body { | ||
background: var(--bg); | ||
color: var(--col); | ||
font-family: Arial, Helvetica, sans-serif; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prevents the janky switch from a default serif to our sans-serif. |
||
} | ||
|
||
@media (prefers-color-scheme: dark) { | ||
body { | ||
background: var(--bg-dark); | ||
color: var(--col-dark); | ||
} | ||
} | ||
</style> | ||
|
||
<script type="module" src="./src/main.ts"></script> | ||
<meta property="og:url" content="https://gradio.app/" /> | ||
<meta property="og:type" content="website" /> | ||
|
@@ -74,6 +97,7 @@ | |
</gradio-app> | ||
<script> | ||
const ce = document.getElementsByTagName("gradio-app"); | ||
|
||
if (ce[0]) { | ||
ce[0].addEventListener("domchange", () => { | ||
document.body.style.padding = "0"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,7 @@ export default defineConfig(({ mode }) => { | |
} else if ( | ||
selector.indexOf(":root") > -1 || | ||
selector.indexOf("dark") > -1 || | ||
selector.indexOf("body") > -1 || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want to add a prefix to |
||
fileName.indexOf(".svelte") > -1 | ||
) { | ||
return selector; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't want to raise an exception in case there were "broken" themes with circular references before. They didn't error out before and don't want a breaking change.