Skip to content

Commit

Permalink
add minified argument to html_dependency_vue for debugging and Vue tools
Browse files Browse the repository at this point in the history
update to Vue `2.1.4`

change tree example by removing now-gone json filter and using minified = FALSE
  • Loading branch information
timelyportfolio committed Dec 5, 2016
1 parent adce451 commit 0f992e4
Show file tree
Hide file tree
Showing 9 changed files with 8,265 additions and 16 deletions.
12 changes: 9 additions & 3 deletions R/dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#'
#' @param offline \code{logical} to use local file dependencies. If \code{FALSE},
#' then the dependencies use cdn as its \code{src}.
#' @param minified \code{logical} to use minified (production) version. Use
#' \code{minified = FALSE} for debugging or working with Vue devtools.
#'
#' @return \code{\link[htmltools]{htmlDependency}}
#' @importFrom htmltools htmlDependency
Expand All @@ -27,17 +29,21 @@
#' ),
#' html_dependency_vue()
#' )
html_dependency_vue <- function(offline=TRUE){
html_dependency_vue <- function(offline=TRUE, minified=TRUE){
hd <- htmltools::htmlDependency(
name = "vue",
version = vue_version(),
src = system.file("www/vue/dist",package="vueR"),
script = c("vue.min.js")
script = "vue.min.js"
)

if(!minified) {
hd$script <- "vue.js"
}

if(!offline) {
hd$src <- list(href=sprintf(
"//cdnjs.cloudflare.com/ajax/libs/vue/%s",
"//unpkg.com/vue/dist",
vue_version()
))
}
Expand Down
2 changes: 1 addition & 1 deletion R/meta.R
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#'@keywords internal
vue_version <- function(){'2.1.3'}
vue_version <- function(){'2.1.4'}
10 changes: 8 additions & 2 deletions R/vue.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@
#' this will not currently have any impact
#' @param elementId \code{character} id of the htmlwidget container
#' element
#' @param minified \code{logical} to indicate minified (\code{minified=TRUE}) or
#' non-minified (\code{minified=FALSE}) Vue.js
#'
#' @import htmlwidgets
#'
#' @export
#' @example ./inst/examples/vue_widget_examples.R
#' @return vue htmlwidget

vue <- function(app = list(), width = NULL, height = NULL, elementId = NULL) {
vue <- function(
app = list(),
width = NULL, height = NULL, elementId = NULL,
minified = TRUE
) {

# forward options using x
x = app
Expand All @@ -33,7 +39,7 @@ vue <- function(app = list(), width = NULL, height = NULL, elementId = NULL) {
)

hw$dependencies <- list(
html_dependency_vue(offline=TRUE)
html_dependency_vue(offline=TRUE, minified=minified)
)

hw
Expand Down
8 changes: 8 additions & 0 deletions build/getvue.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ download.file(
destfile="./inst/www/vue/dist/vue.min.js"
)

download.file(
url=sprintf(
"https://unpkg.com/vue@%s/dist/vue.js",
get_vue_latest()
),
destfile="./inst/www/vue/dist/vue.js"
)

# write function with newest version
# for use when creating dependencies
cat(
Expand Down
10 changes: 6 additions & 4 deletions inst/examples/vue_component_examples.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,21 +187,22 @@ tl_tree <- tagList(
"el-tree",
list(
"ref" = "mytree",
":data" = "data",
":data" = "data.children",
":props" = "defaultProps",
"show-checkbox" = NA,
"@check-change" = "handleCheckChange"
)
),
tags$pre("{{checkedNodes.map(function(d){return d.name}) | json}}")
tags$pre("{{checkedNodes.map(function(d){return d.name})}}")
),
vue(
list(
el="#app",
data = list(
data = d3r::d3_nest(
rhd,
value_cols="x"
value_cols="x",

),
defaultProps = list(
'children' = 'children',
Expand All @@ -221,7 +222,8 @@ function(data, checked, indeterminate){
"
)
)
)
),
minified = FALSE
)
)

Expand Down
Loading

0 comments on commit 0f992e4

Please sign in to comment.