-
Couldn't load subscription status.
- Fork 115
fix: Introduce a more ergonomic API for express.ui.insert_accordion_panel()
#2042
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
22f0223
fix: Introduce a more ergonomic API for express.ui.insert_accordion_p…
cpsievert 266b662
Update changelog
cpsievert 0c68c53
Be more graceful about backwards-compat
cpsievert e3ded2b
Merge branch 'main' into fix/insert-accordion-panel
karangattu 86e1252
Add test for Shiny Express insert accordion panel behavior
karangattu bf58ee2
Refactor accordion panel creation in app-express.py
karangattu 47ccb7c
cleanup
cpsievert a96032f
Refactor accordion app to use shiny.express and simplify logic
karangattu d3802c9
for python 3.9 compatibility
karangattu 7a19f4f
Merge branch 'main' into fix/insert-accordion-panel
karangattu bc4a91a
Merge branch 'main' into fix/insert-accordion-panel
cpsievert 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,80 @@ | ||
| """ | ||
| Shims for `ui.insert_*()`, `ui.update_*()`, etc. functions that lead to a more ergonomic | ||
| Express API. | ||
|
|
||
| These functions tend to have one issue in common: if they were re-exported verbatim from | ||
| Core to Express, they would want to take RecallContextManager(s) as input, which leads | ||
| to a somewhat awkward API. That's because, you'd have to know to use something like | ||
| @ui.hold() pass the UI as a value without displaying it. | ||
| """ | ||
|
|
||
| from typing import Literal, Optional | ||
|
|
||
| from htmltools import TagAttrs, TagChild | ||
|
|
||
| from ..._docstring import add_example | ||
| from ...session import Session | ||
| from ...types import MISSING, MISSING_TYPE | ||
|
|
||
|
|
||
| @add_example() | ||
| def insert_accordion_panel( | ||
| id: str, | ||
| panel_title: str, | ||
| *panel_contents: TagChild | TagAttrs, | ||
| panel_value: str | MISSING_TYPE | None = MISSING, | ||
| panel_icon: TagChild = None, | ||
| target: Optional[str] = None, | ||
| position: Literal["after", "before"] = "after", | ||
| session: Optional[Session] = None, | ||
| ) -> None: | ||
| """ | ||
| Insert an accordion panel into an existing accordion. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| id | ||
| A string that matches an existing :func:`~shiny.ui.express.accordion`'s `id`. | ||
| panel_title | ||
| The title to appear in the panel header. | ||
| panel_contents | ||
| UI elements for the panel's body. Can also be a dict of tag attributes for the | ||
| body's HTML container. | ||
| panel_value | ||
| A character string that uniquely identifies this panel. If `MISSING`, the | ||
| `title` will be used. | ||
| panel_icon | ||
| A :class:`~htmltools.TagChild` which is positioned just before the `title`. | ||
| target | ||
| The `value` of an existing panel to insert next to. | ||
| position | ||
| Should `panel` be added before or after the target? When `target=None`, | ||
| `"after"` will append after the last panel and `"before"` will prepend before | ||
| the first panel. | ||
| session | ||
| A Shiny session object (the default should almost always be used). | ||
|
|
||
| References | ||
| ---------- | ||
| [Bootstrap Accordion](https://getbootstrap.com/docs/5.3/components/accordion/) | ||
|
|
||
| See Also | ||
| -------- | ||
| * :func:`~shiny.ui.express.accordion` | ||
| * :func:`~shiny.ui.express.accordion_panel` | ||
| * :func:`~shiny.ui.express.update_accordion` | ||
| """ | ||
|
|
||
| from ...ui import accordion_panel, insert_accordion_panel | ||
|
|
||
| panel = accordion_panel( | ||
| panel_title, *panel_contents, value=panel_value, icon=panel_icon | ||
| ) | ||
|
|
||
| insert_accordion_panel( | ||
| id=id, | ||
| panel=panel, | ||
| target=target, | ||
| position=position, | ||
| session=session, | ||
| ) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.