Skip to content

Commit 5418fe4

Browse files
committed
updates
1 parent 6488c37 commit 5418fe4

File tree

1 file changed

+14
-9
lines changed
  • tests/playwright/shiny/bugs/2061-css-js-inclusion

1 file changed

+14
-9
lines changed

tests/playwright/shiny/bugs/2061-css-js-inclusion/app.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@
22

33
from shiny import App, Inputs, Outputs, Session, ui
44

5-
js_file = Path(__file__).parent / "js" / "customjs.js"
6-
# We don't know what the temp dir will be called until we make it and that's what we need to reference
7-
# in the app (ex. we can't just reference where it is pre-copy)
8-
js2_file = (
9-
ui.include_js(js_file, method="link_files").attrs["src"][:-11] + "customjs2.js"
5+
custom_css = ui.include_css(
6+
Path(__file__).parent / "css" / "style.css",
7+
method="link_files",
108
)
11-
css_file = Path(__file__).parent / "css" / "style.css"
9+
10+
custom_js = ui.include_js(
11+
Path(__file__).parent / "js" / "customjs.js",
12+
method="link_files",
13+
)
14+
15+
# path where the JS file's parent directory is mounted
16+
href = custom_js.get_dependencies()[0].source_path_map()["href"]
1217

1318
# Define the UI
1419
app_ui = ui.page_fluid(
15-
ui.include_css(css_file, method="link_files"),
16-
ui.include_js(js_file, method="link_files"),
17-
ui.tags.script(src=str(js2_file)),
20+
custom_css,
21+
custom_js,
22+
ui.tags.script(src=href + "/customjs2.js"),
1823
ui.h1("Simple Shiny App with External CSS"),
1924
ui.div(
2025
ui.p("This is a simple Shiny app that demonstrates ui.include_css()"),

0 commit comments

Comments
 (0)