Skip to content

Commit 4a69db2

Browse files
committed
Add page_main_container() and wrap layout_sidebar() contents
1 parent 9693009 commit 4a69db2

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

shiny/ui/_page.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from ._tag import consolidate_attrs
4242
from ._utils import get_window_title
4343
from .css import CssUnit, as_css_padding, as_css_unit
44-
from .fill._fill import as_fillable_container
44+
from .fill._fill import add_fill_classes, as_fillable_container
4545

4646
page_sidebar_default: SidebarOpen = SidebarOpen(desktop="open", mobile="always")
4747

@@ -128,7 +128,7 @@ def page_sidebar(
128128
navbar_title,
129129
layout_sidebar(
130130
sidebar,
131-
*children,
131+
page_main_container(*children),
132132
attrs,
133133
fillable=fillable,
134134
border=False,
@@ -143,6 +143,14 @@ def page_sidebar(
143143
)
144144

145145

146+
def page_main_container(*args: TagChild) -> Tag:
147+
return add_fill_classes(
148+
tags.main({"class": "bslib-page-main bslib-gap-spacing"}, *args),
149+
fill_item=True,
150+
fillable_container=True,
151+
)
152+
153+
146154
@no_example()
147155
def page_navbar(
148156
*args: NavSetArg | MetadataNode | Sequence[MetadataNode],

shiny/ui/fill/_fill.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,15 @@ def is_fill_item(tag: object) -> bool:
215215
# renders_to_tag_class(x, FILL_ITEM_CLASS, ".html-widget")
216216

217217
return isinstance(tag, Tag) and tag.has_class(FILL_ITEM_CLASS)
218+
219+
220+
def add_fill_classes(
221+
tag: Tag, fill_item: bool = True, fillable_container: bool = True
222+
) -> Tag:
223+
if fill_item:
224+
tag.add_class(FILL_ITEM_CLASS)
225+
if fillable_container:
226+
tag.add_class(FILL_CONTAINER_CLASS)
227+
if fill_item or fillable_container:
228+
tag.append(fill_dependency())
229+
return tag

0 commit comments

Comments
 (0)