Skip to content

Commit

Permalink
Support HTML in React context (#66)
Browse files Browse the repository at this point in the history
* feat: support html in react context

* fix: disable import/no-unresolved linter for html-react-parser

* chore: build js

* chore: update dependencies

* fix: js lint

* chore: add asReactData.html to NAMESPACE

* fix: remove isHTML function

* feat: add tests for rendering html in react

* feat: cleanup shinytest2 files after tests

* fix: namespaces in tests

* refactor: switch to testing html instead of screenshots

* chore: sort suggests field in DESCRIPTION

---------

Co-authored-by: Jakub Sobolewski <jakub.sobolewski@appsilon.com>
  • Loading branch information
jakubsob and Jakub Sobolewski committed Oct 2, 2023
1 parent 6e2e837 commit d32126c
Show file tree
Hide file tree
Showing 12 changed files with 3,266 additions and 23 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
^pkgdown$

^js$
_\.new\.png$
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
# R CMD CHECK output
/check/
/docs/
# {shinytest2}: Ignore new debug snapshots for `$expect_values()`
*_.new.png
7 changes: 5 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ Imports:
rlang,
shiny
Suggests:
chromote,
covr,
knitr,
leaflet,
methods,
lintr (>= 3.0.0),
methods,
rcmdcheck,
rmarkdown,
shinytest2,
styler,
testthat
testthat,
withr
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ S3method(asReactData,JS_EVAL)
S3method(asReactData,ReactData)
S3method(asReactData,data.frame)
S3method(asReactData,default)
S3method(asReactData,html)
S3method(asReactData,html_dependency)
S3method(asReactData,list)
S3method(asReactData,shiny.tag)
Expand Down
9 changes: 9 additions & 0 deletions R/reactData.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ asReactData <- function(x) UseMethod("asReactData")
#' @export
asReactData.ReactData <- function(x) x

#' @export
asReactData.html <- function(x) {
ReactData(
type = "html",
value = dropDeps(x),
deps = getDeps(x)
)
}

#' @export
asReactData.default <- function(x) {
ReactData(
Expand Down
Loading

0 comments on commit d32126c

Please sign in to comment.