-
Notifications
You must be signed in to change notification settings - Fork 3
Feat: Add Theming with config.yml #15
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
base: main
Are you sure you want to change the base?
Conversation
feat: add functions for coloring svg files feat: replace sass colors with css colors
jakubnowicki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, this is a nice improvement 👍 It needs a little bit more polishing; please check my comments.
app/main.R
Outdated
| @@ -1,31 +1,17 @@ | |||
| # nolint start: box_func_import_count_linter | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove nolint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I've removed all nolints!
app/main.R
Outdated
| branding <- get("branding") | ||
|
|
||
| output$dynamic_colors <- shiny$renderUI({ | ||
| css_content <- generate_css_variables(branding) | ||
| shiny$tags$style(shiny$HTML(css_content)) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using renderUI, it could be simpler to just read and create the style outside of ui and server and than use it inside (something like the good old global.R).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was a great suggestion, saves us the extra reactive usage when none is required. I've moved the code to a section above the ui()
app/logic/general_utils.R
Outdated
| #' @return a string of CSS variables within :root {} | ||
| #' @export | ||
| generate_css_variables <- function( | ||
| config = get("branding") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need a default here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. I've removed the default value.
| #' @param config the config file | ||
| #' @return a string of CSS variables within :root {} | ||
| #' @export | ||
| generate_css_variables <- function( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is a good moment to start adding unit tests? This function looks like an opportunity :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added tests for all the general_utils functions! :D
app/logic/empty_state_utils.R
Outdated
| text = "Select an application and a job to view logs", | ||
| image_path = "static/illustrations/empty_state.svg" | ||
| image_path = "static/illustrations/empty_state.svg", | ||
| color = NULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is inconsistent, as replace_svg_fill will not accept NULL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved!
config.yml
Outdated
| grey-text: grey | ||
| black-text: "#333" | ||
| selected-row: "#00000010" | ||
| primary: "#0099f9" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be good to move primary to the top?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I've moved it to the top!
| - This may mean that the Posit Connect API's response did not send proper data. | ||
| - So far, one documented reason for this is that OAuth on Posit Connect instances may prevent the `/content` endpoint from sending app data. | ||
| - How do I rebrand the application? | ||
| - You can edit the branding in the `config.yml` file. You'll find the `colors` key which will build the CSS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest expanding this with some description of what particular colors do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! I've added a few points explaining how the colors work. It should at least indicate the user what colors affect what values.
…refactor/simplify-state
vituri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Later we will be able to use the new brand.yml file.
I see that all other comments by Jakub Nowicki were solved as well since his last review.
| describe("check_text_error()", { | ||
| it("returns TRUE for error keywords", { | ||
| expect_true( | ||
| check_text_error( | ||
| "Error: job failed" | ||
| ) | ||
| ) | ||
| expect_true( | ||
| check_text_error( | ||
| "Halt: job terminated" | ||
| ) | ||
| ) | ||
| expect_true( | ||
| check_text_error( | ||
| "Error: file not found" | ||
| ) | ||
| ) | ||
| }) | ||
|
|
||
| it("returns FALSE for non-error keywords", { | ||
| expect_true( | ||
| !check_text_error( | ||
| "Job completed successfully" | ||
| ) | ||
| ) | ||
| expect_true( | ||
| !check_text_error( | ||
| "Processing" | ||
| ) | ||
| ) | ||
| }) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a chance that the message is something like the following?
> check_text_error("No error found")
[1] TRUEIf yes, maybe to explicit that the string start with one of the wordlist is enough, like the following:
check_text_error <- function(
text,
wordlist = c("halt", "err", "terminat", "not found"),
ignore_case = TRUE
) {
grepl(
paste0("^", wordlist, collapse = "|"),
text,
ignore.case = ignore_case
)
}
check_text_error("No error found")
check_text_error("Error: aaa")There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch! I finally took a look at this and added your code. Thanks for the suggestion.
|
@jakubnowicki I believe we should be good here and @vituri already confirmed all the comments were addressed. I believe (2?) sequential branches have already been merged into this by him as well. So, we should avoid bloating this further and merge it. Additionally, I could not push to the main repository anymore (I assumed I would be able to do it but some permission issue prevented it) so I forked and created a !23 to add his suggestion for |
Have you read the Contributing Guidelines?
Closes #14
Note to reviewers: This was changed before
brand.ymlcame into the picture and works quite similarly. Still, since this is underway and has existing PRs in sequence (#17, #20), it would make sense to go forward with this and then, do a cleanup refactor to use brand.yml with minor changes, if necessary. Although, I don't see the need as of yet because the branding is not as widely present in this app, owing to its simplicity. But it can be something we decide in the future.Description
config.ymlbranding + Sass modifications to access itREADME.mdfor the sameonClickin the app list and job listreactabletablesLoom recording with demo
Definition of Done
R CMD check, linter, unit tests, spelling)..Rdfiles withroxygen2::roxygenise())