daattali / shinyjs

💡 Easily improve the user experience of your Shiny apps in seconds
https://deanattali.com/shinyjs
Other
728 stars 119 forks source link

inlineCSS: Add parameter to generate human-readable CSS #262

Closed warnes closed 11 months ago

warnes commented 1 year ago

This PR enhances the inlineCSS function to optionally (disabled by default) generate human readable well formatted CSS text. This is enabled by setting the new .human_readable parameter to TRUE. Examples added to the man page:

> # By default, generates minimized CSS rules
> rulesTxt <-
+     inlineCSS(
+         list(
+             "#big" = "font-size:30px",
+             ".red" = c("color: red", "border: 1px solid black")
+         ),
+         .human_readable=FALSE
+     )
> print(rulesTxt)
<style>#big{ font-size:30px} .red{ color: red; border: 1px solid black} </style>
> 
> # Use `.human_readable` argument to include whitespace for readability
> rulesTxtReadable <-
+     inlineCSS(
+         list(
+             "#big" = "font-size:30px",
+             ".red" = c("color: red", "border: 1px solid black")
+         ),
+         .human_readable=TRUE
+     )
> print(rulesTxtReadable)
<style>
#big {
     font-size:30px
} 

.red {
     color: red;
     border: 1px solid black
} 
</style>
daattali commented 1 year ago

Thanks for the initiative. I made some code style changes, I'll merge it at a later date after a few more changes go in first

warnes commented 1 year ago

You're very welcome. Thanks for all pf your hard work!

daattali commented 11 months ago

Finally remembered to merge your feature!

warnes commented 11 months ago

Finally remembered to merge your feature!

Excellent! Now I can point my project's renv you the main repo.