Package 'card.pro'

Title: Lightweight Modern & Responsive Card Component for 'shiny'
Description: Responsive and modern 'HTML' card essentials for 'shiny' dashboard. This novel card component in 'Bootstrap' provides a flexible and extensible content container with multiple variants and options for building robust 'R' based apps e.g for graph build or machine learning projects. The features rely on a combination of 'JQuery' <https://jquery.com> and 'CSS' styles to improve the card functionality.
Authors: Obinna Obianom [aut, cre]
Maintainer: Obinna Obianom <[email protected]>
License: MIT + file LICENSE
Version: 2.2.0
Built: 2024-11-19 04:25:28 UTC
Source: https://github.com/oobianom/card.pro

Help Index


Attach jQuery to current document

Description

The current function allows inclusion of jQuery in an HTML output

Usage

add.JQuery(version = "3.5.1")

Arguments

version

jQuery version

Value

script tag with jQuery link

Note

This function holds significance across the entire package, particularly in scenarios where a specific HTML output lacks the inclusion of the jQuery script required by other functions within this package. It serves as a crucial mechanism for ensuring that functionalities within the package remain operable even when the necessary jQuery script is absent from the HTML page by default knitting. By providing a fallback option, this function enhances the robustness and reliability of the package, allowing it to gracefully handle situations where jQuery is not explicitly included. Its role is pivotal in maintaining consistent behavior and functionality across diverse HTML environments, thereby facilitating seamless integration and usage of the package across various web development contexts.

Examples

add.JQuery()
add.JQuery("3.7.0") # add a specific version

New sidebar panel to display content

Description

Customizable sidebar panel for inclusion of various UI elements

Usage

altPanel(..., width = 4, border = FALSE, shadow = FALSE)

Arguments

...

List of content

width

Width of the sidebar panel

border

Should border be declared for the panel

shadow

Should a shadow be added to the panel

Value

Creates an alternate container for displaying contents

Note

For more information on the features of the sidebar panel, look through the Github examples

Examples

altPanel("content 2")

Generate a flexible and extensible card container

Description

Widely used card component from Bootstrap with improvements to improve utility

Usage

card.pro(
  ...,
  title,
  collapsed = FALSE,
  width = 12,
  tabs = NULL,
  icon = NULL,
  xtra.header.content = NULL,
  footer = NULL,
  togglebtn = TRUE,
  editbtn = TRUE,
  expandbtn = TRUE,
  colorbtn = TRUE,
  removebtn = TRUE,
  sortable = TRUE,
  sidebar = NULL,
  shadow = TRUE,
  header.bg = c("white", "green", "greenDark", "greenLight", "purple", "magenta", "pink",
    "pinkDark", "blueLight", "teal", "blue", "blueDark", "darken", "yellow", "orange",
    "orangeDark", "red", "redLight"),
  alert.text = NULL,
  alert.type = c("warning", "info", "success", "danger")
)

Arguments

...

The elements to include within the body of the card

title

The text to display in the header title

collapsed

If TRUE, the card is collapsed. The default is FALSE

width

Select a width from 1 to 12 to indicate the size of the card

tabs

optional. A list containing tabs items, see example

icon

Header icon e.g. shiny::icon('fire')

xtra.header.content

additional header content e.g. "Hi"

footer

Footer content if any

togglebtn

show toggle button

editbtn

show header title edit button

expandbtn

show card expand button

colorbtn

show header color chooser

removebtn

show card closer button

sortable

If FALSE, the card will not be draggable

sidebar

optional. include side bar content

shadow

logical. add shadow to the card exterior

header.bg

Header background color style

alert.text

Enter text for the alert portion. Leave as NULL to exclude the alert

alert.type

Indicate the type of alert to include, choices are "warning", "info", "success", "danger"

Value

HTML code of the container with a class called card.pro that holds the items

Note

For more information on the features of the card, visit the examples section of the help documentation

Examples

# Example 1
if (interactive()) {
  library(shiny)
  library(card.pro)

  shiny::shinyApp(
    ui = fluidPage(
      titlePanel("Change customizations.
      Its preserved across refresh!"),
      moveable(
        card.pro(
          "Lorem ipsum odor amet.",
          title = "Box 1",
          icon = icon("fire"),
          tabs = list(
            tabEntry(
              "Tab 1",
              textInput("nor1", "Enter name"),
              "Content for 1"
            ),
            tabEntry(
              "Tab 2",
              actionButton("nor1", "Try click"),
              "sample"
            )
          )
        ),
        card.pro(
          "Another something",
          title = "Box 2",
          width = 6,
          header.bg = "blue",
          alert.text = "Its an alert!",
          colorbtn = FALSE,
          editbtn = FALSE
        )
      )
    ),
    server = empty.server
  )
}

# Example 2
if (interactive()) {
  library(shiny)
  library(card.pro)

  shiny::shinyApp(
    ui = fluidPage(
      titlePanel("Change order and refresh"),
      wrapper(
        moveable(
          card.pro(
            "A plot for test",
            textInput("test6", "Plot title"),
            actionButton("test9", "Make plot"),
            title = "Box 3",
            width = 6,
            header.bg = "red",
            collapsed = TRUE,
            sortable = FALSE
          ),
          card.pro(
            "Box 4 content",
            "shinyappstore.com",
            title = "Box 1",
            width = 8,
            header.bg = "red",
            sidebar = div(
              "My settings",
              textInput("test2", "Input change"),
              actionButton("test3", "Click to save")
            )
          )
        )
      )
    ),
    server = empty.server
  )
}

Empty server function

Description

For use in simple shiny apps not requiring server functions

Usage

empty.server(input, output, session)

Arguments

input

the input object

output

the output object

session

the session object

Value

Empty server function

Examples

if(interactive()){
  library(shiny)
  library(card.pro)
  ui = fluidPage("Obi Obianom")
  shinyApp(ui = ui, server = empty.server)
}

Generate a moveable grid

Description

A grid that holds draggable items

Usage

moveable(...)

Arguments

...

The elements to include within the body of the moveable grid

Value

HTML code of a container that allows items within it to be draggable

Note

For more information on the features of a sortable grid, visit the examples section of the help documentation

Examples

moveable(
  htmltools::tags$div("A"),
  htmltools::tags$div("B")
)

Main panel to display content

Description

Customizable main panel for inclusion of various UI elements

Usage

primePanel(..., width = 8, border = FALSE, shadow = FALSE)

Arguments

...

List of content

width

Width of the main panel

border

Should border be declared for the panel

shadow

Should a shadow be added to the panel

Value

Creates a container for displaying contents

Note

For more information on the features of the main panel, look through the Github examples

Examples

primePanel("content 1")

Generate a row div

Description

A simple row div

Usage

row(...)

Arguments

...

The elements to include within the body of the row

Value

An HTML containing elements of a container with class row to be embedded in a page

Examples

row(shiny::div(width=12,"Hello nextGenShinyApps"))

Create a tab panel item

Description

Create a tab panel item that is enclosed by a list

Usage

tabEntry(title, ...)

Arguments

title

title of the tab

...

content of the tab

Value

An list containing the title and content of a tab

Examples

if (interactive()) {
tabEntry("Summary", "Convallis aesus.")
tabEntry("Summary", "nextGenShinyApps.")
}

Template location full text

Description

Fetch the location of the scripts

Usage

template.loc(template = "bundle")

Arguments

template

The type of template to fetch

Value

A path for the location of the package

Examples

template.loc('bundle')

Include stylesheets and scripts

Description

Use the package scripts and stylesheets in a page

Usage

use.cardpro(
  theme = letters[1:5],
  jquery = FALSE,
  jqueryui = TRUE,
  fontawesome = FALSE,
  template = "bundle",
  fix.header = FALSE
)

Arguments

theme

The template type

jquery

option. logical. include jquery

jqueryui

option. logical. include jquery UI

fontawesome

option. logical. include fontawesome

template

template folder

fix.header

logical. fix header if titlePanel2() is used in UI

Value

A list of files to be inserted in the header of a page

Examples

if(interactive()){
use.cardpro()
use.cardpro(theme="a",jqueryui = T, fontawesome = F)
}

A wrapper for panels

Description

Create a wrapper div for pannels

Usage

wrapper(
  ...,
  bg = c("default", "primary", "secondary", "warning", "info", "danger", "success")
)

Arguments

...

div contents

bg

background color of the wrapper

Value

a container for other containers

Examples

wrapper(altPanel("hello"), shiny::mainPanel("test"))
wrapper(shiny::mainPanel("hello"), shiny::column(width = 2, "test"))