You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's currently difficult to add page-level attributes, and our page functions provide an inconsistent API. Supposing I'd like to add the foo class to the <body> element, only page() and page_fillable() give the desired results.
Function Call
Result
page(class = "foo")
.foo is added to the <body>
page_fillable(class = "foo")
.foo is added to the <body>
page_navbar(class = "foo")
Errors
page_sidebar(class = "foo")
.foo is added to the .main content area of the sidebar layout (passes class to layout_sidebar())
page_fluid(class = "foo")
Returns a div.container-fluid.foo, not a body tag
page_fixed(class = "foo")
Returns a div.container.foo element, not a body tag
There are two key challenges in resolving this problem:
We can upgrade page_fluid() and page_fixed() to use bslib::page() but for backwards compatibility, the ... elements should be handed to div(class = "container, ...).
We can't redirect the ... in page_sidebar() and page_navbar() without breaking behavior since they're used by layout_sidebar() and the navset generator function.
Proposal
We add an argument that collects page-level attributes to each of the above functions, named something likepage_attrs or .attributes. This argument would take a list – created with list() or a helper like page_attributes() – and would apply the attributes to the page element.
In page_fillable() and page(), where the ... are already passed to the tags$body(), we'd fold this list into that call. In page_fluid() and page_fixed() we'd pass the page_attrs to the page() function and continue to pass the ... to the container div.
A more automagical approach would be to allow page_attributes() to be included unnamed in the ... of the above functions. The page functions could inspect the ..., pull out the page attributes object and apply the attributes appropriately to the body tag.
Oh interesting. I kind of like the idea of page_attributes(), which could be implemented as a web components that add/removes attributes on the document.body during connectedCallback()/disconnectedCallback() ?
It's currently difficult to add page-level attributes, and our page functions provide an inconsistent API. Supposing I'd like to add the
foo
class to the<body>
element, onlypage()
andpage_fillable()
give the desired results.page(class = "foo")
.foo
is added to the<body>
page_fillable(class = "foo")
.foo
is added to the<body>
page_navbar(class = "foo")
page_sidebar(class = "foo")
.foo
is added to the.main
content area of the sidebar layout (passesclass
tolayout_sidebar()
)page_fluid(class = "foo")
div.container-fluid.foo
, not abody
tagpage_fixed(class = "foo")
div.container.foo
element, not abody
tagThere are two key challenges in resolving this problem:
page_fluid()
andpage_fixed()
to usebslib::page()
but for backwards compatibility, the...
elements should be handed todiv(class = "container, ...)
....
inpage_sidebar()
andpage_navbar()
without breaking behavior since they're used bylayout_sidebar()
and the navset generator function.Proposal
We add an argument that collects page-level attributes to each of the above functions, named something like
page_attrs
or.attributes
. This argument would take a list – created withlist()
or a helper likepage_attributes()
– and would apply the attributes to the page element.In
page_fillable()
andpage()
, where the...
are already passed to thetags$body()
, we'd fold this list into that call. Inpage_fluid()
andpage_fixed()
we'd pass thepage_attrs
to thepage()
function and continue to pass the...
to the container div.A more automagical approach would be to allow
page_attributes()
to be included unnamed in the...
of the above functions. The page functions could inspect the...
, pull out the page attributes object and apply the attributes appropriately to the body tag.The text was updated successfully, but these errors were encountered: