-
Notifications
You must be signed in to change notification settings - Fork 100
Shiny Express is missing panel_title()
#1011
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
Comments
We can add If we were to allow passing in the ui.panel_title("Page title", window_title="Window title") |
@wch would it be easy to support the unnamed argument version that allows either the direct or the context manager versions to be used? Personally, that'd be my preference and feels like a good fit for Express. |
Here are three different possible implementations. It looks like I was wrong about it being possible to have a version that could be used as a context manager and as a regular function.
def panel_title1(
*,
title: str | Tag | TagList,
window_title: str | MISSING_TYPE = MISSING,
) -> RecallContextManager[TagList]:
return RecallContextManager(
ui.panel_title,
kwargs=dict(
title=title,
window_title=window_title,
),
)
# Error
with panel_title1(window_title="window_title"):
"title"
# Error
panel_title1("title", window_title="window_title")
# OK
panel_title1(title="title", window_title="window_title") def panel_title2(
title: str | Tag | TagList,
*,
window_title: str | MISSING_TYPE = MISSING,
) -> RecallContextManager[TagList]:
return RecallContextManager(
ui.panel_title,
args=(title,),
kwargs=dict(
window_title=window_title,
),
)
# Error
with panel_title2(window_title="window_title"):
"title"
# OK
panel_title2("title", window_title="window_title")
# OK
panel_title2(title="title", window_title="window_title") def panel_title3(
*,
window_title: str | MISSING_TYPE = MISSING,
) -> RecallContextManager[TagList]:
return RecallContextManager(
ui.panel_title,
kwargs=dict(
window_title=window_title,
),
)
# OK
with panel_title3(window_title="window_title"):
"title"
# Error
panel_title3("title", window_title="window_title")
# Error
panel_title3(title="title", window_title="window_title") |
@wch Do you still like the kwargs approach best? I don't have any strong feelings, but I lean toward option 2 ( |
@wch Unless there's an advantage to requiring ui.panel_title("My page title")
# or...
ui.panel_title(ui.h1("My page title")) |
Wait, there is one more version that I overlooked; def panel_title4(
*args: str | Tag | TagList,
window_title: str | MISSING_TYPE = MISSING,
) -> RecallContextManager[TagList]:
return RecallContextManager(
ui.panel_title,
args=args,
kwargs=dict(
window_title=window_title,
),
)
# OK
with panel_title4(window_title="window_title"):
"title"
# OK
panel_title4("title", window_title="window_title")
# Error
panel_title4(title="title", window_title="window_title") This supports both the context manager and regular function call, but the function signature is a bit off -- it takes One last possibility: if we were to simply pass through the original # Error
with panel_title(window_title="window_title"):
"title"
# OK
panel_title("title", window_title="window_title")
# OK
panel_title(title="title", window_title="window_title") |
Ooh, option 4 was kind of what I had in mind initially. But I can recognize it's not a common use case (and could be handled in other ways as well). The simplicity of simply passing through to |
The weirdness in option 4 with |
panel_title()
is missing from Shiny Express. Its usage is partially covered byshiny.ui.page_opts()
, which exposestitle
(but notwindow_title
) and passestitle
to page functions that take the argument.I think that, for consistency, we should offer
shiny.express.ui.panel_title()
. Secondarily, we can augmentshiny.express.ui.page_opts()
to takewindow_title
and to also, possibly, inserttitle
into the older page functions likepage_fluid()
.panel_title()
takes two arguments,title
andwindow_title
. When provided by the user,window_title
is always static, buttitle
could be a simple static value or it could involve dynamic UI:The text was updated successfully, but these errors were encountered: