Skip to content

Commit a6e5881

Browse files
authored
fix: bugs found during QA testing (#573)
1 parent 5f008c8 commit a6e5881

File tree

6 files changed

+46
-45
lines changed

6 files changed

+46
-45
lines changed

examples/penguins/app.py

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
import pandas as pd
88
import seaborn as sns
9-
10-
# import shinyswatch
9+
import shinyswatch
1110
from colors import bg_palette, palette
1211

1312
import shiny.experimental as x
@@ -22,38 +21,32 @@
2221
species: List[str] = df["Species"].unique().tolist()
2322
species.sort()
2423

25-
app_ui = ui.page_fluid(
26-
# shinyswatch.theme.pulse(), # Uncomment when shinyswatch it updated
27-
ui.layout_sidebar(
28-
ui.panel_sidebar(
29-
# Artwork by @allison_horst
30-
ui.tags.img(
31-
src="palmerpenguins.png", width="80%", class_="mt-0 mb-2 mx-auto"
32-
),
33-
ui.input_selectize(
34-
"xvar",
35-
"X variable",
36-
numeric_cols,
37-
selected="Bill Length (mm)",
38-
),
39-
ui.input_selectize(
40-
"yvar",
41-
"Y variable",
42-
numeric_cols,
43-
selected="Bill Depth (mm)",
44-
),
45-
ui.input_checkbox_group(
46-
"species", "Filter by species", species, selected=species
47-
),
48-
ui.hr(),
49-
ui.input_switch("by_species", "Show species", value=True),
50-
ui.input_switch("show_margins", "Show marginal plots", value=True),
24+
app_ui = x.ui.page_sidebar(
25+
x.ui.sidebar(
26+
# Artwork by @allison_horst
27+
ui.tags.img(src="palmerpenguins.png", width="80%", class_="mt-0 mb-2 mx-auto"),
28+
ui.input_selectize(
29+
"xvar",
30+
"X variable",
31+
numeric_cols,
32+
selected="Bill Length (mm)",
33+
),
34+
ui.input_selectize(
35+
"yvar",
36+
"Y variable",
37+
numeric_cols,
38+
selected="Bill Depth (mm)",
5139
),
52-
ui.panel_main(
53-
ui.output_ui("value_boxes"),
54-
x.ui.output_plot("scatter", fill=True),
40+
ui.input_checkbox_group(
41+
"species", "Filter by species", species, selected=species
5542
),
43+
ui.hr(),
44+
ui.input_switch("by_species", "Show species", value=True),
45+
ui.input_switch("show_margins", "Show marginal plots", value=True),
5646
),
47+
shinyswatch.theme.pulse(),
48+
ui.output_ui("value_boxes"),
49+
x.ui.output_plot("scatter", fill=True),
5750
)
5851

5952

@@ -104,7 +97,6 @@ def penguin_value_box(title: str, count: int, bgcol: str, showcase_img: str):
10497
),
10598
theme_color=None,
10699
style=f"background-color: {bgcol};",
107-
height="90px",
108100
full_screen=True,
109101
)
110102

shiny/experimental/e2e/accordion/app.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,18 @@ def _():
5959

6060
has_efg = False
6161
has_alternate = True
62+
has_updates = False
6263

6364
@reactive.Effect
6465
def _():
6566
req(input.alternate())
6667

67-
sections = ["Section A", "Section B", "Section C", "Section D"]
68+
sections = [
69+
"updated_section_a" if has_updates else "Section A",
70+
"Section B",
71+
"Section C",
72+
"Section D",
73+
]
6874
if has_efg:
6975
sections.extend(["Section E", "Section F", "Section G"])
7076

@@ -87,8 +93,6 @@ def _():
8793
x.ui.accordion_panel_insert("acc", make_panel("G"), "Section F")
8894
has_efg = not has_efg
8995

90-
has_updates = False
91-
9296
@reactive.Effect
9397
def _():
9498
req(input.toggle_updates())

shiny/experimental/examples/accordion_panel_remove/app.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,22 @@ def make_panel(letter: str) -> x.ui.AccordionPanel:
2828

2929

3030
def server(input: Inputs, output: Outputs, session: Session):
31+
# Copy the list for user
32+
user_choices = [choice for choice in choices]
33+
3134
@reactive.Effect
3235
@reactive.event(input.remove_panel)
3336
def _():
34-
if len(choices) == 0:
37+
if len(user_choices) == 0:
3538
ui.notification_show("No more panels to remove!")
3639
return
3740

3841
# Remove panel
39-
x.ui.accordion_panel_remove("acc", f"Section { choices.pop() }")
42+
x.ui.accordion_panel_remove("acc", f"Section { user_choices.pop() }")
4043

4144
label = "No more panels to remove!"
42-
if len(choices) > 0:
43-
label = f"Remove Section {choices[-1]}"
45+
if len(user_choices) > 0:
46+
label = f"Remove Section {user_choices[-1]}"
4447
ui.update_action_button("remove_panel", label=label)
4548

4649

shiny/experimental/ui/_navs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def tagify(self) -> TagList | Tag:
114114
nav, content = _render_navset(
115115
*self.args, ul_class=ul_class, id=id, selected=self.selected, context={}
116116
)
117-
return self.layout(nav, content)
117+
return self.layout(nav, content).tagify()
118118

119119
# Types must match output of `_render_navset() -> Tuple[Tag, Tag]`
120120
def layout(self, nav: Tag, content: Tag) -> TagList | Tag:

shiny/experimental/ui/_sidebar.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ def __init__(
4040
self.color_fg = color_fg
4141
self.color_bg = color_bg
4242

43-
# # This does not contain the `collapse_tag`
44-
# # The `Sidebar` class should use it's fields, not this method
45-
# def tagify(self) -> Tag:
46-
# return self.tag.tagify()
43+
# The `Sidebar` class should use it's fields, not this method
44+
def tagify(self) -> Tag:
45+
# Similar to `NavMenu.tagify()`
46+
raise NotImplementedError(
47+
"`Sidebar` objects must be handled by `layout_sidebar(sidebar)`."
48+
)
4749

4850

4951
# TODO-maindocs; @add_example()

shiny/ui/_navs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def tagify(self) -> TagList | Tag:
367367
nav, content = render_navset(
368368
*self.args, ul_class=ul_class, id=id, selected=self.selected, context={}
369369
)
370-
return self.layout(nav, content)
370+
return self.layout(nav, content).tagify()
371371

372372
def layout(self, nav: TagChild, content: TagChild) -> TagList | Tag:
373373
return TagList(nav, self.header, content, self.footer)

0 commit comments

Comments
 (0)