ghcarlalan / graveler

Other
30 stars 6 forks source link

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

Open mxblsdl opened 2 years ago

mxblsdl commented 2 years ago

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 commented 2 years ago

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.