#' <Add Title>
#'
#' <Add Description>
#'
#' @import htmlwidgets
#'
#' @export
starrating <- function(message, width = NULL, height = NULL, elementId = NULL) {
# describe a React component to send to the browser for rendering.
component <- reactR::reactMarkup(htmltools::tag("div", list(message)))
# create widget
htmlwidgets::createWidget(
name = 'starrating',
component,
width = width,
height = height,
package = 'starrating',
elementId = elementId
)
}
#' Shiny bindings for starrating
#'
#' Output and render functions for using starrating within Shiny
#' applications and interactive Rmd documents.
#'
#' @param outputId output variable to read from
#' @param width,height Must be a valid CSS unit (like \code{'100\%%'},
#' \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a
#' string and have \code{'px'} appended.
#' @param expr An expression that generates a starrating
#' @param env The environment in which to evaluate \code{expr}.
#' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
#' is useful if you want to save an expression in a variable.
#'
#' @name starrating-shiny
#'
#' @export
starratingOutput <- function(outputId, width = '100%%', height = '400px'){
htmlwidgets::shinyWidgetOutput(outputId, 'starrating', width, height, package = 'starrating')
}
#' @rdname starrating-shiny
#' @export
renderStarrating <- function(expr, env = parent.frame(), quoted = FALSE) {
if (!quoted) { expr <- substitute(expr) } # force quoted
htmlwidgets::shinyRenderWidget(expr, starratingOutput, env, quoted = TRUE)
}
#' Called by HTMLWidgets to produce the widget's root element.
#' @rdname starrating-shiny
starrating_html <- function(id, style, class, ...) {
htmltools::tagList(
# Necessary for RStudio viewer version < 1.2
reactR::html_dependency_corejs(),
reactR::html_dependency_react(),
reactR::html_dependency_reacttools(),
htmltools::tags$div(id = id, class = class)
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.