Closed samanthacsik closed 1 year ago
DON'T INCLUDE
Not all fontawesome icons are available for use with shiny -- here's list of icons to use as of now https://fontawesome.com/v4/icons/
Debugging options: https://shiny.rstudio.com/articles/debugging.html
ADDED TO RESOURCES SLIDE
General shiny resources: https://debruine.github.io/shinyintro/index.html Shiny UI editor: https://rstudio.github.io/shinyuieditor/
ADDED TO RESOURCES SLIDE
Using fontawesome icons requires a fontawesome kit -- see here: https://www.r-bloggers.com/2022/09/r-shiny-fontawesome-icons-how-to-use-them-in-your-dashboards/ (must be type tag$head
)
Have not watched this but may be helpful Beyond DataViz: How to Improve the UI/UX of Your Shiny Apps: https://www.crowdcast.io/e/shiny-apps-UX-UI-design/register
ADDED TO RESOURCES SLIDE
increasing app efficiency: https://www.r-bloggers.com/2021/06/speeding-up-r-shiny-the-definitive-guide/
ADDED TO THEMING SECTION
Styling with CSS & Sass: https://www.rstudio.com/resources/rstudioglobal-2021/styling-shiny-with-css-and-sass-and-speeding-up-shiny-apps/
3 ways to add CSS styling:
add styling directly to tags (don't use lots of these! easy to lose track of in large projects, can't resuse the same rules easily in other elements, hard to keep consistent, hard to implement large changes)
# can add a `style` attribute to any html `tags` used in app -- let's you add CSS elements that affect that specific statement
fluidPage(
tags$h1("My application",
style = "font-weight: 500; color: #4d3a7e"))
)
add css to your header (a little bitter; allows code to be reused by using selectors; styles cannot be cached (i.e. saving them for future usage when you reopen the app later) since we're still declaring styles in the code)
ui <- fluidPage(
tags$head(
tags$style(HTML("
@import ulr('my-font.url'),
h1 {
font-weight: 500;
color: #4d3a7e;
}
") # END style
) # END head
) # END fluidPage
add style sheets inside the www directory (ideal; can be cached, all styling in one spot, multiple files can be included and allow some structure, stylesheet can be applied to multiple applications, CSS can get very complicated in large projects)
ui <- fluidPage(
tags$head(
tags$link(rel = "stylesheet", type = "text/css", href = "styles.css")
) # END head
) # END fluidPage
Improving with Sass
There is a {sass} package! The sass()
function takes a sass string or file and returns a string of compiled CSS. (though I'm not sure I'll get into using the package since MEDS students have already been primed with CSS/Sass). A comparison:
Using the R package
library(sass)
sass(input = "
$size: 50%;
foo { margin: $size * .33; }
")
Writing sass
foo {
margin: 16.5%;
}
ADDED TO UX/UI SECTION
From https://engineering-shiny.org/ux-matters.html
validate()
ADDED TO FINAL SECTION
Words of Wisdom (include somewhere in slide deck):
Note for self on how to compile Sass to CSS -- deleting this file since I just learned you can do this more succinctly in global.R
, but wanted to keep for reference:
library(sass)
sass(
input = sass_file("R/my_sass_styles.scss"),
#cache_options = sass_cache_options(FALSE),
options = sass_options(
output_style = "compressed",
source_map_embed = TRUE),
output = "two-file-app/www/my_sass_styles.css"
)
Things to clean up:
January 20 & 27 from 9:00am - 3:00pm
Day 1 (work only with
palmerpenguins
,lterdatasampler
data; will have one single-file shiny app and one two-file shiny app by end of day)global.R
(what is it, where does it live, what should we put here){shinyWidgets}
includeMarkdown()
for larger bodies of textvalidate()
{shinycssloaders}
(find other, easy-to-implement packages)v{reactlog}
{shinytest}
(may have to move to day 2)Day 2 (import data tbd; should have one(?) shinydashboard by the end of the day, and possibly added themes to shiny apps from day 1)
/www
folder{shinydashboards}
{bslib}
(only works withshiny
) and{fresh}
(works withshiny
andshinydashboard
)