-
Notifications
You must be signed in to change notification settings - Fork 117
feat: Add ui.theme() and theme argument to page_*() functions
#1275
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
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
da73121
feat(ui.theme): Add `ui.theme()` to create a shiny theme object
gadenbuie 33b3a03
feat: theme.check_compatibility
gadenbuie a7f6a1a
test(ui.theme): Compatibility check
gadenbuie 5ec185f
feat(express): Export ui.theme() too
gadenbuie e3797ad
feat(bootstrap_deps): Support `theme` argument
gadenbuie 9f05c88
feat(page): Support `theme` argument in page functions
gadenbuie e3a892c
feat(express.ui.page_opts): Support `theme` argument
gadenbuie 4171da0
docs(page): Document `theme` argument
gadenbuie 537416e
docs(ui.theme): Document `ui.theme()` and `Theme` class
gadenbuie 14feb0b
docs: Adjust theme docs
gadenbuie ba78d0b
docs(quartodoc): Add `ui.theme()` to quartodoc listing
gadenbuie 8e2692b
docs: Add `theme` docs to more page functions
gadenbuie 61b3979
docs: more documentation edits
gadenbuie 5b25196
docs(theme): Add an example app
gadenbuie b17e456
docs(theme): Tweak docs again
gadenbuie dd90500
chore: remove unused imports from example app
gadenbuie b1d49ca
Merged origin/main into feat/page-theme
gadenbuie a21f84f
chore: head_content
gadenbuie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,30 @@ | ||
| from pathlib import Path | ||
|
|
||
| from shiny import App, render, ui | ||
|
|
||
| app_ui = ui.page_sidebar( | ||
| ui.sidebar( | ||
| ui.input_numeric("n", "N", min=0, max=100, value=20), | ||
| title="Parameters", | ||
| ), | ||
| ui.h2("Output"), | ||
| ui.output_text_verbatim("txt"), | ||
| ui.markdown( | ||
| """ | ||
| **AI-generated filler text.** In the world of exotic fruits, the durian stands out with its spiky exterior and strong odor. Despite its divisive smell, many people are drawn to its rich, creamy texture and unique flavor profile. This tropical fruit is often referred to as the "king of fruits" in various Southeast Asian countries. | ||
|
|
||
| Durians are known for their large size and thorn-covered husk, which requires careful handling. The flesh inside can vary in color from pale yellow to deep orange, with a custard-like consistency that melts in your mouth. Some describe its taste as a mix of sweet, savory, and creamy, while others find it overpowering and pungent. | ||
| """ | ||
| ), | ||
| title="Theme Example", | ||
| theme=ui.theme(Path(__file__).parent / "theme.css", replace="none"), | ||
| ) | ||
|
|
||
|
|
||
| def server(input, output, session): | ||
| @render.text | ||
| def txt(): | ||
| return f"n*2 is {input.n() * 2}" | ||
|
|
||
|
|
||
| app = App(app_ui, server) |
This file contains hidden or 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,27 @@ | ||
| from pathlib import Path | ||
|
|
||
| from shiny.express import input, render, ui | ||
|
|
||
| ui.page_opts( | ||
| title="Theme Example", | ||
| theme=ui.theme(Path(__file__).parent / "theme.css", replace="none"), | ||
| ) | ||
|
|
||
| with ui.sidebar(title="Parameters"): | ||
| ui.input_numeric("n", "N", min=0, max=100, value=20) | ||
|
|
||
| ui.h2("Output") | ||
|
|
||
|
|
||
| @render.code | ||
| def txt(): | ||
| return f"n*2 is {input.n() * 2}" | ||
|
|
||
|
|
||
| ui.markdown( | ||
| """ | ||
| **AI-generated filler text.** In the world of exotic fruits, the durian stands out with its spiky exterior and strong odor. Despite its divisive smell, many people are drawn to its rich, creamy texture and unique flavor profile. This tropical fruit is often referred to as the "king of fruits" in various Southeast Asian countries. | ||
|
|
||
| Durians are known for their large size and thorn-covered husk, which requires careful handling. The flesh inside can vary in color from pale yellow to deep orange, with a custard-like consistency that melts in your mouth. Some describe its taste as a mix of sweet, savory, and creamy, while others find it overpowering and pungent. | ||
| """ | ||
| ) |
This file contains hidden or 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,39 @@ | ||
| @font-face { | ||
| font-family: InterVariable; | ||
| font-style: normal; | ||
| font-weight: 100 900; | ||
| font-display: swap; | ||
| src: url("https://rsms.me/inter/font-files/InterVariable.woff2?v=4.0") | ||
| format("woff2"); | ||
| } | ||
| @font-face { | ||
| font-family: InterVariable; | ||
| font-style: italic; | ||
| font-weight: 100 900; | ||
| font-display: swap; | ||
| src: url("https://rsms.me/inter/font-files/InterVariable-Italic.woff2?v=4.0") | ||
| format("woff2"); | ||
| } | ||
|
|
||
| :root { | ||
| font-size: 20px; | ||
| --bs-body-font-family: "InterVariable"; | ||
| --bs-heading-color: var(--bs-pink); | ||
|
|
||
| --pink-rgb: 191, 0, 127; | ||
|
|
||
| --bslib-sidebar-bg: rgba(var(--pink-rgb), 0.05); | ||
| --bslib-sidebar-fg: var(--bs-pink); | ||
| --bslib-sidebar-toggle-bg: rgba(var(--pink-rgb), 0.1); | ||
| --bs-border-color-translucent: rgba(var(--pink-rgb), 0.33); | ||
| --bs-border-color: var(--bs-border-color-translucent); | ||
| } | ||
|
|
||
| .bslib-page-sidebar { | ||
| --bslib-page-sidebar-title-bg: var(--bs-pink); | ||
| --bslib-page-sidebar-title-color: var(--bs-white); | ||
| } | ||
|
|
||
| pre { | ||
| background: rgba(var(--pink-rgb), 0.05); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
Could we do this check on
__init__? Could be confusing that a "bad" them can be constructed, but then later throws an error (and probably leads to a confusing stack trace)