mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-29 03:00:45 -04:00
remove widths parameter from columnLayout; add width parameter to sidebarPanel and mainPanel
This commit is contained in:
@@ -224,10 +224,6 @@ titlePanel <- function(title, windowTitle=title) {
|
||||
#' or "right")
|
||||
#' @param fluid \code{TRUE} to use fluid layout; \code{FALSE} to use fixed
|
||||
#' layout.
|
||||
#' @param widths The columns widths of the sidebar and main panel (the first
|
||||
#' value is for the sidebar; the second for the main panel). Note that if
|
||||
#' you are using fixed layout you may need to adjust these to accomodate
|
||||
#' the size of the container if it's less than 12 units wide.
|
||||
#'
|
||||
#' @examples
|
||||
#' # Define UI
|
||||
@@ -258,13 +254,8 @@ titlePanel <- function(title, windowTitle=title) {
|
||||
sidebarLayout <- function(sidebarPanel,
|
||||
mainPanel,
|
||||
position = c("left", "right"),
|
||||
fluid = TRUE,
|
||||
widths = c(4, 8)) {
|
||||
|
||||
# validate that inputs were created by their respective functions
|
||||
validateSpan(sidebarPanel, "sidebarPanel", widths[[1]])
|
||||
validateSpan(mainPanel, "mainPanel", widths[[2]])
|
||||
|
||||
fluid = TRUE) {
|
||||
|
||||
# determine the order
|
||||
position <- match.arg(position)
|
||||
if (position == "left") {
|
||||
@@ -314,25 +305,4 @@ verticalLayout <- function(..., fluid = TRUE) {
|
||||
}
|
||||
|
||||
|
||||
# Helper function to test whether an element has a span class
|
||||
validateSpan <- function(element, name, width = NA) {
|
||||
|
||||
if (!is.list(element) ||
|
||||
is.null(element$attribs) ||
|
||||
is.null(element$attribs$class)) {
|
||||
stop(name, " does not have a valid column span", call. = FALSE)
|
||||
}
|
||||
else {
|
||||
test <- paste0("span", ifelse(is.na(width), "", width))
|
||||
if (!grepl(test, element$attribs$class)) {
|
||||
msg <- paste(name, "does not have a valid column span")
|
||||
if (!is.na(width)) {
|
||||
msg <- paste0(msg, " (it must be span", width, ")")
|
||||
stop(msg, call. = FALSE)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -308,12 +308,15 @@ wellPanel <- function(...) {
|
||||
|
||||
#' Create a sidebar panel
|
||||
#'
|
||||
#' Create a sidebar panel containing input controls that can in turn be
|
||||
#' passed to \link{pageWithSidebar}.
|
||||
#' Create a sidebar panel containing input controls that can in turn be passed
|
||||
#' to \code{\link{sidebarLayout}}.
|
||||
#'
|
||||
#' @param ... UI elements to include on the sidebar
|
||||
#' @return A sidebar that can be passed to \link{pageWithSidebar}
|
||||
#'
|
||||
#' @param width The width of the sidebar. For fluid layouts this is out of 12
|
||||
#' total units; for fixed layouts it is out of whatever the width of the
|
||||
#' sidebar's parent column is.
|
||||
#' @return A sidebar that can be passed to \code{\link{sidebarLayout}}
|
||||
#'
|
||||
#' @examples
|
||||
#' # Sidebar with controls to select a dataset and specify
|
||||
#' # the number of observations to view
|
||||
@@ -324,8 +327,8 @@ wellPanel <- function(...) {
|
||||
#' numericInput("obs", "Observations:", 10)
|
||||
#' )
|
||||
#' @export
|
||||
sidebarPanel <- function(...) {
|
||||
div(class="span4",
|
||||
sidebarPanel <- function(..., width = 4) {
|
||||
div(class=paste0("span", width),
|
||||
tags$form(class="well",
|
||||
...
|
||||
)
|
||||
@@ -334,12 +337,15 @@ sidebarPanel <- function(...) {
|
||||
|
||||
#' Create a main panel
|
||||
#'
|
||||
#' Create a main panel containing output elements that can in turn be
|
||||
#' passed to \link{pageWithSidebar}.
|
||||
#'
|
||||
#' @param ... Ouput elements to include in the main panel
|
||||
#' @return A main panel that can be passed to \link{pageWithSidebar}
|
||||
#' Create a main panel containing output elements that can in turn be passed to
|
||||
#' \code{\link{sidebarLayout}}.
|
||||
#'
|
||||
#' @param ... Output elements to include in the main panel
|
||||
#' @param width The width of the main panel. For fluid layouts this is out of 12
|
||||
#' total units; for fixed layouts it is out of whatever the width of the main
|
||||
#' panel's parent column is.
|
||||
#' @return A main panel that can be passed to \code{\link{sidebarLayout}}.
|
||||
#'
|
||||
#' @examples
|
||||
#' # Show the caption and plot of the requested variable against mpg
|
||||
#' mainPanel(
|
||||
@@ -347,8 +353,8 @@ sidebarPanel <- function(...) {
|
||||
#' plotOutput("mpgPlot")
|
||||
#' )
|
||||
#' @export
|
||||
mainPanel <- function(...) {
|
||||
div(class="span8",
|
||||
mainPanel <- function(..., width = 8) {
|
||||
div(class=paste0("span", width),
|
||||
...
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user