Skip to content

Commit 9ca8a2a

Browse files
add back shiny
1 parent c41a1c5 commit 9ca8a2a

File tree

6 files changed

+76
-5
lines changed

6 files changed

+76
-5
lines changed

DESCRIPTION

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
Package: roffice
22
Version: 0.0.0.9000
3-
Title: What the Package Does (One Line, Title Case)
4-
Description: What the package does (one paragraph).
5-
Authors@R: person("First", "Last", , "[email protected]", c("aut", "cre"))
3+
Date: 2018-12-30
4+
Title: 'office-ui-fabric-react' Wrapped as a 'htmlwidget'
5+
Description: Demonstrates how to use the new helper functionality in 'reactR' to inject the world
6+
of office-ui-fabric-react components into the R experience.
7+
Authors@R: person("Kenton", "Russell", , "[email protected]", c("aut", "cre"))
68
License: MIT + file LICENSE
79
Encoding: UTF-8
10+
URL: https://github.com/timelyportfolio/roffice
11+
BugReports: https://github.com/timelyportfolio/roffice/issues
812
LazyData: true
913
ByteCompile: true
1014
RoxygenNote: 6.0.1
15+
Imports:
16+
htmltools,
17+
htmlwidgets,
18+
reactR
19+

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(officeuiwidget)
4+
export(officeuiwidgetOutput)
5+
export(renderOfficeuiwidget)
46
export(roffice_deps)
57
import(htmlwidgets)

R/shiny.R

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#' Shiny bindings for officeuiwidget
2+
#'
3+
#' Output and render functions for using officeuiwidget within Shiny
4+
#' applications and interactive Rmd documents.
5+
#'
6+
#' @param outputId output variable to read from
7+
#' @param width,height Must be a valid CSS unit (like \code{'100\%'},
8+
#' \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a
9+
#' string and have \code{'px'} appended.
10+
#' @param expr An expression that generates a officeuiwidget
11+
#' @param env The environment in which to evaluate \code{expr}.
12+
#' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
13+
#' is useful if you want to save an expression in a variable.
14+
#'
15+
#' @name officeuiwidget-shiny
16+
#'
17+
#' @export
18+
officeuiwidgetOutput <- function(outputId, width = '100%', height = '400px'){
19+
htmlwidgets::shinyWidgetOutput(outputId, 'officeuiwidget', width, height, package = 'roffice')
20+
}
21+
22+
#' @rdname officeuiwidget-shiny
23+
#' @export
24+
renderOfficeuiwidget <- function(expr, env = parent.frame(), quoted = FALSE) {
25+
if (!quoted) { expr <- substitute(expr) } # force quoted
26+
htmlwidgets::shinyRenderWidget(expr, officeuiwidgetOutput, env, quoted = TRUE)
27+
}

inst/examples/starter.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
library(reactR)
55
library(roffice)
66

7-
# just one prop
7+
# slider with just one prop
88
officeuiwidget(
99
reactR::React$Slider(label = "Basic Slider")
1010
# alternately
1111
# component("Slider", varArgs = list(label = "Basic Slider"))
1212
)
1313

14-
# more props and a combination
14+
# slider with more props and a combination
1515
officeuiwidget(
1616
reactR::React$Slider(label = "Basic Slider"),
1717
reactR::React$Slider(

inst/htmlwidgets/officeuiwidget.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// trick to include React Fragment component
2+
// which is like an empty container
13
Fabric.Fragment = React.Fragment;
24

5+
// office-ui-fabric namespaces all the components with Fabric
36
reactR.reactWidget('officeuiwidget', 'output', Fabric);

man/officeuiwidget-shiny.Rd

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)