Skip to content

Commit 9ba54db

Browse files
very incomplete but minimally working start
0 parents  commit 9ba54db

File tree

14 files changed

+62633
-0
lines changed

14 files changed

+62633
-0
lines changed

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
^roffice\.Rproj$
2+
^\.Rproj\.user$

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.Rproj.user
2+
.Rhistory

DESCRIPTION

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Package: roffice
2+
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"))
6+
License: MIT + file LICENSE
7+
Encoding: UTF-8
8+
LazyData: true
9+
ByteCompile: true
10+
RoxygenNote: 6.0.1

LICENSE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
YEAR: 2018
2+
COPYRIGHT HOLDER: Kenton Russell

NAMESPACE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Generated by roxygen2: do not edit by hand
2+
3+
export(officeuiwidget)
4+
export(roffice_deps)
5+
import(htmlwidgets)

R/dependencies.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#' Dependencies for "office-ui-fabric-react"
2+
#'
3+
#' @return htmltools::htmlDependency
4+
#' @export
5+
roffice_deps <- function() {
6+
htmltools::htmlDependency(
7+
name = "office-ui-fabric-react",
8+
version = "6.118.0",
9+
src = "htmlwidgets/office-ui-fabric-react",
10+
script = "office-ui-fabric-react.js",
11+
package = "roffice"
12+
)
13+
}

R/widget.R

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#' <Add Title>
2+
#'
3+
#' <Add Description>
4+
#'
5+
#' @import htmlwidgets
6+
#'
7+
#' @export
8+
officeuiwidget <- function(...) {
9+
htmlwidgets::createWidget(
10+
name = 'officeuiwidget',
11+
list(tag = reactR::component("Fragment", c(list(...)))),
12+
width = NULL,
13+
height = NULL,
14+
package = 'roffice',
15+
elementId = NULL
16+
)
17+
}
18+
19+
# Magical
20+
officeuiwidget_html <- function(id, style, class, ...) {
21+
htmltools::tagList(
22+
reactR::html_dependency_corejs(),
23+
reactR::html_dependency_react(),
24+
reactR::html_dependency_reacttools(),
25+
roffice_deps(),
26+
htmltools::tags$div(id = id, class = class)
27+
)
28+
}

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# roffice
2+
3+
`roffice` is a package designed to demonstrate the new functionality included in [`reactR`](https://github.com/timelyportfolio/reactR) to leverage [`React`](https://reactjs.org/) and its diverse array of components as `htmlwidgets` in R.
4+
5+
> Alan Dilpert session at [rstudio::conf](http://www.cvent.com/events/rstudio-conf-austin/agenda-dd6d75526f3c4554b67c4de32aeffb47.aspx)
6+
7+
In `roffice` we illustrate some alternate techniques
8+
9+
## Installation
10+
11+
You can install the released version of `roffice` from Github. We will also need to install the `enhancements` branch of `reactR`.
12+
13+
``` r
14+
devtools::install_github("timelyportfolio/reactR@enhancements")
15+
devtools::install_github("timelyportfolio/roffice")
16+
```
17+
18+
## Example
19+
20+
This is a basic example which shows you how to solve a common problem:
21+
22+
``` r
23+
## basic example code
24+
```
25+

inst/examples/starter.R

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#devtools::install_github("timelyportfolio/reactR@enhancements")
2+
#devtools::install_github("timelyportfolio/roffice")
3+
4+
library(reactR)
5+
library(roffice)
6+
7+
# just one prop
8+
officeuiwidget(
9+
reactR::React$Slider(label = "Basic Slider")
10+
# alternately
11+
# component("Slider", varArgs = list(label = "Basic Slider"))
12+
)
13+
14+
# more props and a combination
15+
officeuiwidget(
16+
reactR::React$Slider(label = "Basic Slider"),
17+
reactR::React$Slider(
18+
label = "slider with props",
19+
min = 1,
20+
max = 5,
21+
step = 1,
22+
defaultValue = 2,
23+
showValue = TRUE
24+
)
25+
)

0 commit comments

Comments
 (0)