Skip to content
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

Sync dark mode on browser_info object #7382

Merged
merged 4 commits into from
Oct 16, 2024
Merged

Sync dark mode on browser_info object #7382

merged 4 commits into from
Oct 16, 2024

Conversation

philippjfr
Copy link
Member

Eventually useful when we want to dynamically toggle between dark and light themes.

panel/models/browser.ts Outdated Show resolved Hide resolved
panel/models/browser.ts Outdated Show resolved Hide resolved
panel/models/browser.ts Outdated Show resolved Hide resolved
panel/models/browser.ts Outdated Show resolved Hide resolved
@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Oct 9, 2024

Would this enable that if the user has not set ?theme=... as query args then pn.config.theme is set to his/ hers browser preferences? Today its just set to default.

And that if ?theme=... is set it takes precedence.

That would be a big improvement.

@philippjfr
Copy link
Member Author

That's already possible in principle.

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Oct 9, 2024

That's already possible in principle.

How? And could it (please) be the default behaviour?

@philippjfr
Copy link
Member Author

philippjfr commented Oct 16, 2024

How?

pn.config.theme = 'dark' if state.browser_info.dark_mode else 'default'

And could it (please) be the default behaviour?

Maybe in future, but not in a patch release.

@philippjfr
Copy link
Member Author

pre-commit.ci autofix

panel/models/browser.ts Outdated Show resolved Hide resolved
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.22%. Comparing base (4e146af) to head (e5eec5f).
Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7382      +/-   ##
==========================================
+ Coverage   81.42%   82.22%   +0.80%     
==========================================
  Files         337      337              
  Lines       50514    50557      +43     
==========================================
+ Hits        41131    41571     +440     
+ Misses       9383     8986     -397     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@philippjfr philippjfr merged commit 0b59d53 into main Oct 16, 2024
17 checks passed
@philippjfr philippjfr deleted the watch_dark_mode branch October 16, 2024 14:11
ahuang11 pushed a commit that referenced this pull request Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants