diff --git a/DESCRIPTION b/DESCRIPTION index c9bcbef..37396e9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -17,7 +17,6 @@ URL: https://github.com/dreamRs/fresh BugReports: https://github.com/dreamRs/fresh/issues License: GPL-3 Encoding: UTF-8 -LazyData: true Imports: bslib, htmltools, @@ -25,6 +24,7 @@ Imports: sass, shiny Suggests: + bsicons, shinyWidgets, shinydashboard, bs4Dash, diff --git a/NAMESPACE b/NAMESPACE index e5347e0..0d9698e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,6 +14,8 @@ export(bs4dash_sidebar_light) export(bs4dash_status) export(bs4dash_vars) export(bs4dash_yiq) +export(bs_theme_nord_dark) +export(bs_theme_nord_light) export(bs_vars) export(bs_vars_alert) export(bs_vars_badge) diff --git a/R/bs_theme_nord.R b/R/bs_theme_nord.R new file mode 100644 index 0000000..4a0d991 --- /dev/null +++ b/R/bs_theme_nord.R @@ -0,0 +1,59 @@ + +#' Bootstrap Theme based on Nord palette +#' +#' @param version The major version of Bootstrap to use, see [bslib::bs_theme()]. +#' @param preset The name of a theme preset, default to "bootstrap". +#' +#' @return Returns a [sass::sass_bundle()] (list-like) object. +#' @export +#' +#' @name bs-theme-nord +#' +#' @example examples/bs_theme_nord-ex.R +bs_theme_nord_light <- function(version = bslib::version_default(), preset = "bootstrap") { + bs_theme( + version = version, + preset = preset, + primary = "#5E81AC", + secondary = "#B48EAD", + info = "#88C0D0", + danger = "#BF616A", + warning = "#D08770", + success = "#A3BE8C", + "navbar-bg" = "#5E81AC", + "navbar-dark-color" = "#ECEFF4", + "navbar-dark-color" = "#ECEFF4", + "navbar-dark-active-color" = "#E5E9F0", + "navbar-dark-hover-color" = "#D8DEE9", + "bslib-sidebar-bg" = "#D8DEE9", + "body-bg" = "#ECEFF4", + "body-color" = "#2E3440" + ) +} + +#' @export +#' +#' @rdname bs-theme-nord +bs_theme_nord_dark <- function(version = bslib::version_default(), preset = "bootstrap") { + bs_theme( + version = version, + preset = preset, + primary = "#5E81AC", + secondary = "#B48EAD", + info = "#88C0D0", + danger = "#BF616A", + warning = "#D08770", + success = "#A3BE8C", + "navbar-bg" = "#2E3440", + "navbar-dark-color" = "#ECEFF4", + "navbar-dark-color" = "#ECEFF4", + "navbar-dark-active-color" = "#E5E9F0", + "navbar-dark-hover-color" = "#D8DEE9", + "bslib-sidebar-bg" = "#3B4252", + "bslib-sidebar-fg" = "#ECEFF4", + "body-bg" = "#434C5E", + "body-color" = "#ECEFF4", + "card-bg" = "#4C566A", + "body-emphasis-color" = "#ECEFF4" + ) +} diff --git a/cran-comments.md b/cran-comments.md index 6165b75..cbba446 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,7 +1,7 @@ ## Test environments -* local OS Windows 10 install, R 3.6.3 -* ubuntu 16.04 (on Github Actions), R 4.0.0 -* macOS latest (on Github Actions), R 4.0.0 +* local OS Windows 10 install, R 4.3.3 +* ubuntu 16.04 (on Github Actions), R 4.4.1 +* macOS latest (on Github Actions), R 4.4.1 * win-builder (devel and release) ## R CMD check results diff --git a/examples/bs_theme_nord-ex.R b/examples/bs_theme_nord-ex.R new file mode 100644 index 0000000..56aa08e --- /dev/null +++ b/examples/bs_theme_nord-ex.R @@ -0,0 +1,130 @@ + +library(shiny) +library(bslib) +library(bsicons) + +make_btns <- function(outline = FALSE) { + lapply( + X = c("primary", "secondary", "success", "danger", "warning", "info"), + FUN = function(x) { + if (outline) + x <- paste0("outline-", x) + actionButton(paste0("btn", x), paste("Button", x), class = paste("btn", x, sep = "-")) + } + ) +} + +ui <- page_navbar( + title = "Nord theme", + + theme = bs_theme_nord_light(), + + fillable = FALSE, + sidebar = sidebar( + "Sidebar", + selectInput("id", "Choice:", month.name) + ), + nav_panel( + "Page 1", + + make_btns(), + tags$br(), tags$br(), + make_btns(TRUE), + tags$br(), tags$br(), + + layout_column_wrap( + width = 1 / 5, + value_box( + title = "1st value", + value = "123", + showcase = bs_icon("bar-chart"), + theme = "primary", + p("The 1st detail") + ), + value_box( + title = "2nd value", + value = "456", + showcase = bs_icon("graph-up"), + theme = "success", + p("The 2nd detail"), + p("The 3rd detail") + ), + value_box( + title = "3rd value", + value = "789", + showcase = bs_icon("pie-chart"), + theme = "danger", + p("The 4th detail"), + p("The 5th detail"), + p("The 6th detail") + ), + value_box( + title = "4th value", + value = "123", + showcase = bs_icon("bar-chart"), + theme = "warning", + p("The 1st detail") + ), + value_box( + title = "5th value", + value = "123", + showcase = bs_icon("bar-chart"), + theme = "info", + p("The 1st detail") + ) + ), + layout_column_wrap( + width = 1 / 5, + card( + card_header( + class = "bg-primary", + "A header" + ), + card_body("Some content") + ), + card( + card_header( + class = "bg-success", + "A header" + ), + card_body("Some content") + ), + card( + card_header( + class = "bg-danger", + "A header" + ), + card_body("Some content") + ), + card( + card_header( + class = "bg-warning", + "A header" + ), + card_body("Some content") + ), + card( + card_header( + class = "bg-info", + "A header" + ), + card_body("Some content") + ) + ) + ), + nav_panel("Page 2", "Page 2 content"), + nav_spacer(), + nav_item( + input_switch("dark_mode", "Dark mode", width = "120px") + ) +) + +server <- function(input, output, session) { + observe(session$setCurrentTheme( + if (isTRUE(input$dark_mode)) bs_theme_nord_dark() else bs_theme_nord_light() + )) +} + +if (interactive()) + shinyApp(ui, server) + diff --git a/man/bs-theme-nord.Rd b/man/bs-theme-nord.Rd new file mode 100644 index 0000000..ff0377a --- /dev/null +++ b/man/bs-theme-nord.Rd @@ -0,0 +1,155 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/bs_theme_nord.R +\name{bs-theme-nord} +\alias{bs-theme-nord} +\alias{bs_theme_nord_light} +\alias{bs_theme_nord_dark} +\title{Bootstrap Theme based on Nord palette} +\usage{ +bs_theme_nord_light(version = bslib::version_default(), preset = "bootstrap") + +bs_theme_nord_dark(version = bslib::version_default(), preset = "bootstrap") +} +\arguments{ +\item{version}{The major version of Bootstrap to use, see \code{\link[bslib:bs_theme]{bslib::bs_theme()}}.} + +\item{preset}{The name of a theme preset, default to "bootstrap".} +} +\value{ +Returns a \code{\link[sass:sass_layer]{sass::sass_bundle()}} (list-like) object. +} +\description{ +Bootstrap Theme based on Nord palette +} +\examples{ + +library(shiny) +library(bslib) +library(bsicons) + +make_btns <- function(outline = FALSE) { + lapply( + X = c("primary", "secondary", "success", "danger", "warning", "info"), + FUN = function(x) { + if (outline) + x <- paste0("outline-", x) + actionButton(paste0("btn", x), paste("Button", x), class = paste("btn", x, sep = "-")) + } + ) +} + +ui <- page_navbar( + title = "Nord theme", + + theme = bs_theme_nord_light(), + + fillable = FALSE, + sidebar = sidebar( + "Sidebar", + selectInput("id", "Choice:", month.name) + ), + nav_panel( + "Page 1", + + make_btns(), + tags$br(), tags$br(), + make_btns(TRUE), + tags$br(), tags$br(), + + layout_column_wrap( + width = 1 / 5, + value_box( + title = "1st value", + value = "123", + showcase = bs_icon("bar-chart"), + theme = "primary", + p("The 1st detail") + ), + value_box( + title = "2nd value", + value = "456", + showcase = bs_icon("graph-up"), + theme = "success", + p("The 2nd detail"), + p("The 3rd detail") + ), + value_box( + title = "3rd value", + value = "789", + showcase = bs_icon("pie-chart"), + theme = "danger", + p("The 4th detail"), + p("The 5th detail"), + p("The 6th detail") + ), + value_box( + title = "4th value", + value = "123", + showcase = bs_icon("bar-chart"), + theme = "warning", + p("The 1st detail") + ), + value_box( + title = "5th value", + value = "123", + showcase = bs_icon("bar-chart"), + theme = "info", + p("The 1st detail") + ) + ), + layout_column_wrap( + width = 1 / 5, + card( + card_header( + class = "bg-primary", + "A header" + ), + card_body("Some content") + ), + card( + card_header( + class = "bg-success", + "A header" + ), + card_body("Some content") + ), + card( + card_header( + class = "bg-danger", + "A header" + ), + card_body("Some content") + ), + card( + card_header( + class = "bg-warning", + "A header" + ), + card_body("Some content") + ), + card( + card_header( + class = "bg-info", + "A header" + ), + card_body("Some content") + ) + ) + ), + nav_panel("Page 2", "Page 2 content"), + nav_spacer(), + nav_item( + input_switch("dark_mode", "Dark mode", width = "120px") + ) +) + +server <- function(input, output, session) { + observe(session$setCurrentTheme( + if (isTRUE(input$dark_mode)) bs_theme_nord_dark() else bs_theme_nord_light() + )) +} + +if (interactive()) + shinyApp(ui, server) + +}