Skip to content

Commit

Permalink
Merge pull request #3 from Appsilon/uirender
Browse files Browse the repository at this point in the history
Uirender
  • Loading branch information
jakubnowicki authored Jan 3, 2024
2 parents 8004696 + 9137281 commit 2246002
Show file tree
Hide file tree
Showing 9 changed files with 537 additions and 1 deletion.
7 changes: 6 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: semantic.assets
Type: Package
Title: Assets for 'shiny.semantic'
Version: 1.0.0
Version: 1.1.0
Authors@R: c(
person("Jakub", "Nowicki", role = c("aut", "cre"), email = "opensource+kuba@appsilon.com")
)
Expand All @@ -12,3 +12,8 @@ License: LGPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
Imports:
htmlwidgets
Suggests:
shiny,
shiny.semantic
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Generated by roxygen2: do not edit by hand

export(SUPPORTED_THEMES)
export(uirender)
import(htmlwidgets)
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# semantic.assets 1.1.0

- `uirender` added.

# semantic.assets 1.0.0

First release.
47 changes: 47 additions & 0 deletions R/uirender.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#' Render semanticui htmlwidget
#'
#' htmlwidget that adds semanticui dependencies and
#' renders in viewer or rmarkdown.
#'
#' @import htmlwidgets
#'
#' @param ui UI, which will be wrapped in an htmlwidget.
#' @param width Fixed width for widget (in css units). The default is NULL,
#' which results in intelligent automatic sizing.
#' @param height Fixed height for widget (in css units). The default is NULL,
#' which results in intelligent automatic sizing.
#' @param element_id Use an explicit element ID for the widget
#' (rather than an automatically generated one).
#' @examples
#' library(shiny)
#' library(shiny.semantic)
#' library(semantic.assets)
#' uirender(
#' card(
#' div(
#' class = "content",
#' div(class = "header", "Elliot Fu"),
#' div(class = "meta", "Friend"),
#' div(class = "description", "Elliot Fu is a film-maker from New York.")
#' )
#' )
#' )
#'
#' @export
uirender <- function(ui, width = NULL, height = NULL, element_id = NULL) {

# forward options using x
args <- list(
ui = toString(ui)
)

# create widget
htmlwidgets::createWidget(
name = "uirender",
args,
width = width,
height = height,
package = "semantic.assets",
elementId = element_id
)
}
6 changes: 6 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ Appsilon
CMD
RStudio
Rhinoverse
UI
appsilon
css
htmlwidget
rmarkdown
semanticui
wraped
9 changes: 9 additions & 0 deletions inst/htmlwidgets/uirender.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: uirender
version: 1.1.0
src: www/shared/semantic
script:
- semantic.min.js
- uirender.js
stylesheet:
- semantic.uirender.min.css
403 changes: 403 additions & 0 deletions inst/www/shared/semantic/semantic.uirender.min.css

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions inst/www/shared/semantic/uirender.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
HTMLWidgets.widget({
name: 'uirender',
type: 'output',

factory: function(el, width, height) {
console.log('uirender');
return {
renderValue: function(x) {
el.innerHTML = x.ui;
},

resize: function(width, height) {
// TODO: code to re-render the widget with a new size
}
};
}
});
40 changes: 40 additions & 0 deletions man/uirender.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2246002

Please sign in to comment.