grid_template: Define a template of a CSS grid

View source: R/grid.R

grid_templateR Documentation

Define a template of a CSS grid

Description

Define a template of a CSS grid

Usage

grid_template(default = NULL, mobile = NULL)

Arguments

default

(required) Template for desktop: list(areas = [data.frame of character], rows_height = [vector of character], cols_width = [vector of character])

mobile

(optional) Template for mobile (screen width below 768px): list(areas = [data.frame of character], rows_height = [vector of character], cols_width = [vector of character])

Value

list(template = [character], area_names = [vector of character])

template - contains template that can be parsed by htmlTemplate() function

area_names - contains all unique area names used in grid definition

Examples

myGrid <- grid_template(
  default = list(
    areas = rbind(
      c("header", "header", "header"),
      c("menu",   "main",   "right1"),
      c("menu",   "main",   "right2")
    ),
    rows_height = c("50px", "auto", "100px"),
    cols_width = c("100px", "2fr", "1fr")
  ),
  mobile = list(
    areas = rbind(
      "header",
      "menu",
      "main",
      "right1",
      "right2"
    ),
    rows_height = c("50px", "50px", "auto", "150px", "150px"),
    cols_width = c("100%")
  )
)
if (interactive()) display_grid(myGrid)
subGrid <- grid_template(default = list(
  areas = rbind(
    c("top_left", "top_right"),
    c("bottom_left", "bottom_right")
  ),
  rows_height = c("50%", "50%"),
  cols_width = c("50%", "50%")
))

if (interactive()) display_grid(subGrid)

Appsilon/shiny.semantic documentation built on April 21, 2024, 5:49 p.m.