Skip to content

Commit

Permalink
add header and footer arguments to mwModuleUI()
Browse files Browse the repository at this point in the history
  • Loading branch information
bthieurmel committed Dec 4, 2017
1 parent 950b014 commit 180f621
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## New features
* `mwModule()` now return `controller` value, with possibility to use new `clear()` method
* add `header` and `footer` arguments to `mwModuleUI()`

# manipulateWidget 0.8.0 (2017-10-25)

Expand Down
13 changes: 10 additions & 3 deletions R/module_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ mwModule <- function(id, controller, ...) {
#' units.
#' @param width Width of the module UI.
#' @param height Height of the module UI.
#' @param header Tag or list of tags to display as a common header above all tabPanels.
#' @param footer Tag or list of tags to display as a common footer below all tabPanels
#' @rdname mwModule
#' @export
mwModuleUI <- function(id, border = TRUE, okBtn = FALSE, saveBtn = TRUE, margin = 0, width = "100%", height = 400) {
mwModuleUI <- function(id, border = TRUE, okBtn = FALSE, saveBtn = TRUE, margin = 0, width = "100%", height = 400,
header = NULL, footer = NULL) {
ns <- shiny::NS(id)
for (i in seq_along(margin)) {
margin[i] <- shiny::validateCssUnit(margin[i])
Expand All @@ -83,15 +86,19 @@ mwModuleUI <- function(id, border = TRUE, okBtn = FALSE, saveBtn = TRUE, margin
if(!saveBtn) class <- c(class, "without-save")
class <- paste(class, collapse = " ")

res <- shiny::tagList(
res <- shiny::fluidRow(
shiny::column(12,
header,
shiny::uiOutput(ns("ui"), container = function(...) {
tags$div(style=sprintf("width:%s;height:%s;padding:%s",
shiny::validateCssUnit(width),
shiny::validateCssUnit(height),
margin),
class = class,
...)
})
}),
footer
)
)

htmldep <- htmltools::htmlDependency(
Expand Down

0 comments on commit 180f621

Please sign in to comment.