Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not possible to include CSS & Javascript #1427

Open
Konkrad opened this issue May 27, 2024 · 2 comments
Open

Not possible to include CSS & Javascript #1427

Konkrad opened this issue May 27, 2024 · 2 comments

Comments

@Konkrad
Copy link

Konkrad commented May 27, 2024

Hello,
my app fails when I include both CSS and Javascript, only one of them is loaded

Shiny version: 0.10.1
Example:

# app.py
from shiny import ui

ui.page_fluid(
    ui.head_content(ui.include_css("custom.css"), ui.include_js("script.js")),

    # You can also inline css by passing a dictionary with a `style` element.
    ui.div(
        {"style": "font-weight: bold;"},
        ui.p("Some text!"),
    )
)

What do I expect? That both custom.css and script.js will be added to the HTML.

What happens? One of them generates a 404 error

Screenshot from 2024-05-27 11-20-49

@Konkrad
Copy link
Author

Konkrad commented May 27, 2024

Workaround: Create a separate folder for each file. Problem should be somewhere here:

def maybe_copy_files(path: Path | str, include_files: bool) -> tuple[str, str]:

@Konkrad
Copy link
Author

Konkrad commented May 31, 2024

Furthermore, I discovered that when you use (in the core syntax)

app_ui = ui.page_output("page_generator")

and return both in the headers, it will not be copied too

    @output
    @render.ui
    def page_generator():
        return ui.page_fillable(
            ui.head_content(ui.include_css(Path(__file__).parent / "css/style.css")),
            ui.head_content(
                ui.include_js(Path(__file__).parent / "js/script.js"),
            ),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant