Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions shiny/ui/_include_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,12 @@ def maybe_copy_files(path: Path | str, include_files: bool) -> tuple[str, str]:

def get_hash(path: Path | str, include_files: bool) -> str:
if include_files:
key = get_file_key(path)
else:
dir = os.path.dirname(path)
files = glob.iglob(os.path.join(dir, "**"), recursive=True)
key = "\n".join([get_file_key(x) for x in files])
else:
key = get_file_key(path)

return hash_deterministic(key)


Expand Down
27 changes: 27 additions & 0 deletions tests/playwright/shiny/bugs/2061-css-js-inclusion/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from pathlib import Path

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

js_file = Path(__file__).parent / "js" / "customjs.js"
css_file = Path(__file__).parent / "css" / "style.css"

# Define the UI
app_ui = ui.page_fluid(
ui.include_css(css_file, method="link_files"),
ui.include_js(js_file, method="link_files"),
ui.h1("Simple Shiny App with External CSS"),
ui.div(
ui.p("This is a simple Shiny app that demonstrates ui.include_css()"),
ui.p("The styling comes from an external CSS file!"),
class_="content",
),
)


# Define the server
def server(input: Inputs, output: Outputs, session: Session):
pass


# Create and run the app
app = App(app_ui, server)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background-color: #c8e1f7;
}
19 changes: 19 additions & 0 deletions tests/playwright/shiny/bugs/2061-css-js-inclusion/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@import url("more.css");

body {
font-family: Arial, sans-serif;
}

h1 {
color: black;
border-bottom: 2px solid #4682b4;
padding-bottom: 10px;
}

.content {
margin: 20px;
padding: 15px;
background-color: white;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const newParagraph = document.createElement('p');
newParagraph.textContent = 'Heyo!';
const bodyElement = document.body;
bodyElement.appendChild(newParagraph);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from playwright.sync_api import Page, expect

from shiny.run import ShinyAppProc


def test_inclusion(page: Page, local_app: ShinyAppProc) -> None:
page.goto(local_app.url)

expect(page.locator("body > p")).to_have_text("Heyo!")
Loading