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

custom CSS does not link to app in current format #1

Open
mxblsdl opened this issue Apr 15, 2022 · 1 comment
Open

custom CSS does not link to app in current format #1

mxblsdl opened this issue Apr 15, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@mxblsdl
Copy link

mxblsdl commented Apr 15, 2022

I added a CSS file with golem::add_css_file("styles") which creates the file inst/app/www/styles.css and triggers a console message from golem saying the file will be automatically bundled in the app, but the app does not recognize files in the www folder and does not include them in the head of the file.

I noticed you changed the golem_add_ external_resources function which bundles the www files together. I changed that function back to its original golem format and made a change in the app_ui.R file as well.
golem_add_external_resources.R

golem_add_external_resources <- function(){
  add_resource_path(
    "www",
    app_sys("app/www")
  )

## Reintroduced below ##
  tags$head(
    favicon(),
    bundle_resources(
      path = app_sys("app/www"),
      app_title = "<NAME_OF_APP>"
    )
    # Add here other external resources
    # for example, you can add shinyalert::useShinyalert()
  )
}

I was getting an odd stack trace error with only this change so I put all of the UI elements into a taglist
app_ui.R old

app_ui <- function() {
  tagList(
    golem_add_external_resources()
  )
 dashboardPage(
      header(),
      sidebar(),
      body()
    )
}

app_ui.R new

app_ui <- function() {
  tagList(
    golem_add_external_resources(),
    dashboardPage(
      header(),
      sidebar(),
      body()
    )
  )
}

This gets the files in app/www/ to be recognized and bundled and also allows for use of golem::add_css/js_file()

I understand you are going for simplicity in the package and I love what you have done, but this functionality seems at odds with the underlying golem functions.

@alancarlson alancarlson self-assigned this Apr 15, 2022
@alancarlson alancarlson added the bug Something isn't working label Apr 15, 2022
@alancarlson
Copy link
Collaborator

fascinating. i'm trying to figure out why i would have deleted that part of the golem_add_resources but I cannot for the life of me figure out why I did that. Likely a vestige of my initial attempt at trying to get our logo to work.

In reality, there probably shouldn't be a separate function file, and instead have golem_add_resources in the app_ui.R (and the tagList logic) like golem does by default. Thanks for bringing it to my attention; I'll work on this fix right away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants