-
Notifications
You must be signed in to change notification settings - Fork 58
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
feat!: Introduce navbar_options()
#1141
base: main
Are you sure you want to change the base?
Conversation
…-related options in `navset_bar()`
collapsible = collapsible, | ||
underline = underline, | ||
.fn_caller = "page_navbar", | ||
.warn_deprecated = !was_called_by_shiny |
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.
I would really really like to decouple shiny::navbarPage()
from bslib::page_navbar()
. I'm thinking it'd be an update to add page_navbar_legacy()
that we'd export but mark as internal so it doesn't show up in docs and indices.
What I want out of that change is to have a clear line around what parts of the navbar API we shouldn't touch without thinking carefully about backwards compatibility or API changes and which parts are owned by bslib. Currently it feels too entangled and over time entropy wins leading to more entanglement.
Do you have any immediate/near-term plans to do this? |
Yeah, I'm planning to immediately use this to introduce |
Sounds good, thanks. FWIW, I do want to be conservative about adding more to the |
Here is the idea I had earlier, but had a hard time articulating. It does drop the extra warning about |
Thanks for the suggestion. I also tried something similar this morning, but I think it's important that I also think it's important to consider that the code is currently a little complicated to give the best transition experience. In a year or so we could delete most of it and hard-deprecate the direct arguments (once we deal with |
R/navs-legacy.R
Outdated
navbar_options <- function( | ||
position = c("static-top", "fixed-top", "fixed-bottom"), | ||
bg = NULL, | ||
inverse = "auto", | ||
collapsible = TRUE, | ||
underline = TRUE | ||
) { |
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.
Should we include ...
here to make future expansion easier? Maybe even making all arguments required?
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.
I made this change. We'll need the cover from ...
and because there's no clear ordering I'd rather not encourage the positional argument usage that would make future expansion difficult.
This PR consolidates the
position
,bg
,collapse
,inverse
andunderline
arguments ofnavset_bar()
andpage_navbar()
into anavbar_options()
helper and replaces their use in the parent functions with a singlenavbar_options
argument.Before
After
Using the direct arguments results in a lifecycle deprecation warning
and another warning is emitted if the same argument is used in both places
Background
The reason for this PR is two-fold:
The arguments of
page_navbar()
andnavset_bar()
are applied in several different contexts, but there are clear groupings. This change makes it clearer which arguments apply to the navbar appearance and style by separating them from the remaining arguments.This change makes it easier to introduce new navbar options to
page_navbar()
andnavset_bar()
. Bootstrap 5 has moved away from the default/inverse terminology and has improved the terminology around the navbar colors. (Isinverse = TRUE
for light on dark background or dark text on light background? I can never remember.)Bootstrap 5 now uses
data-bs-theme="dark"
and the color mode terminology, where"light"
is like a light color mode, i.e. dark text on a light background. It'd be nice to make the navbar functions consistent with this new language in a backwards-compatible way.However, if we were to introduce
mode
ortype
as a top-level argument, it'd be far too confusing with the other arguments. If we introducenavbar_mode
ornavbar_type
, it's equally confusing -- why is onlymode
ortype
prefixed withnavbar_
? Introducing anavbar_options()
helper gives us the space to have better named arguments. It also creates space to have Bootstrap version-aware options and defaults.