Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bs4InfoBox: Make the icon optional #333

Open
wants to merge 61 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
f971f3f
Use `span` instead of `p` tags in `menuSidebarItems` such that word w…
yogat3ch Sep 8, 2021
8279d52
Add auto-reload when maximized to hopefully fix resize issues on Mac …
yogat3ch Sep 13, 2021
1952f9e
Add `tip_icon` argument to `bs4Card`, add `tippy` to suggests
yogat3ch Sep 13, 2021
34aacee
Apply style to card, not card-body
yogat3ch Sep 17, 2021
8d4db64
Fix collapse on app start
yogat3ch Sep 27, 2021
c36ba63
remove `console.log`
yogat3ch Sep 28, 2021
2f59b6a
Comment out resize stuff that isn't working. Fix the sidebar collapse…
yogat3ch Sep 30, 2021
e65af57
The sidebar collapse/not collapsed on load seems to be a browser spec…
yogat3ch Sep 30, 2021
91a4b37
Fix progressBars
yogat3ch Dec 16, 2021
7e7e772
Merge remote-tracking branch 'RinteRface/master'
yogat3ch Dec 23, 2021
cbf2d87
Scale value between min & max so the bars appear the right size
yogat3ch Dec 30, 2021
e573fd9
Add `id` for easy CSS selection
yogat3ch Dec 30, 2021
70ac339
Calculation must subtract the min too, move calculation just to the C…
yogat3ch Dec 31, 2021
11deaad
## useful-items: Re-add `bs4Alert`
yogat3ch Mar 18, 2022
7505a1d
##useful-items: fix scaling of values based on max/min on bs4progress…
yogat3ch Mar 18, 2022
a965cc8
Merge branch 'bs4Alert'
yogat3ch Apr 19, 2022
f69149e
Merge branch 'progressBar_improvements'
yogat3ch Apr 19, 2022
3570db9
Add `tip_icon` to `bs4Card`
yogat3ch Apr 19, 2022
f5fe44a
Support multiple tag types for `sidebarMenuItem`
yogat3ch Apr 20, 2022
c5d4e5b
Merge branch 'tips_to_bs4Card'
yogat3ch Apr 20, 2022
5736a2e
Merge branch 'sidebarMenuItem_allow_multiple_tag_types'
yogat3ch Apr 20, 2022
62417f9
Merge branch 'RinteRface:master' into master
yogat3ch Apr 20, 2022
236b823
Add negation
yogat3ch Apr 20, 2022
0d9be78
Merge branch 'RinteRface:master' into sidebarMenuItem_allow_multiple_…
yogat3ch Apr 20, 2022
f84de3a
Merge branch 'sidebarMenuItem_allow_multiple_tag_types'
yogat3ch Apr 20, 2022
383c04d
Merge remote-tracking branch 'origin/master'
yogat3ch Jun 1, 2022
acd1c29
Add support for an HTML id to bs4ProgressBar & bs4MultiProgressBar
yogat3ch Jun 1, 2022
40073f1
`validateColors`: allows for `validStatusesPlus`, `grDevices::colors`…
yogat3ch Jun 1, 2022
d188c60
`col2css`: converts a `grDevices::color` to `rgba` css declaration
yogat3ch Jun 1, 2022
97f64c5
`bs4MultiProgressBar` & `bs4ProgressBar`: support all colors
yogat3ch Jun 1, 2022
5ffead4
Add namespace to `col2rgb`
yogat3ch Jun 1, 2022
813d1db
Fix typo
yogat3ch Jun 1, 2022
571997a
Documentation. Add `grDevices` to Imports
yogat3ch Jun 1, 2022
3a70a1f
`bs4ProgressBar` add ID param docs
yogat3ch Jun 1, 2022
7e630ea
Merge branch 'master' into progress_bar_color_support
yogat3ch Jun 1, 2022
147a14a
Merge pull request #2 from yogat3ch/progress_bar_color_support
yogat3ch Jun 1, 2022
d510c07
Add inline style with non status colors back in
yogat3ch Jun 1, 2022
822b852
Merge pull request #3 from yogat3ch/progress_bar_color_support
yogat3ch Jun 1, 2022
dd99786
Add Docs
yogat3ch Jun 2, 2022
020e4f1
bs4Alert box
yogat3ch Jun 2, 2022
af76a35
Merge pull request #4 from yogat3ch/progress_bar_color_support
yogat3ch Jun 2, 2022
c97335f
Add `values_cumulative` arg to `multiProgressBar` to support scaling …
yogat3ch Jun 2, 2022
3068f60
Fix grDevices doc link
yogat3ch Jun 2, 2022
6316174
Fix case where `values_cumulative = TRUE` and `vertical = TRUE`
yogat3ch Jun 3, 2022
1aeb8bf
`values_cumulative = TRUE`: value order appears top to bottom, this m…
yogat3ch Jun 3, 2022
0d736bc
when bar is vertical it sets position: absolute; forcing each segment…
yogat3ch Jun 3, 2022
6226687
Bump version on local
yogat3ch Jul 21, 2022
901015b
Revert version as internal dependency versions must match
yogat3ch Jul 21, 2022
45bd557
modified bs4Accordion to accept a new arg that turns off only having …
Sep 9, 2022
a82d466
Merge remote-tracking branch 'RinteRface/master'
yogat3ch Sep 12, 2022
a3f98e9
Merge remote-tracking branch 'Martin-McCoy/add_no_collapse_functional…
yogat3ch Sep 12, 2022
173cb2b
`bs4MultiProgressBar`: add `style` argument back in. Fix bs4Card test
yogat3ch Sep 12, 2022
4494684
Doc updates
yogat3ch Sep 12, 2022
abcb275
NavBar accepts more diverse set of tags
yogat3ch Oct 31, 2022
4755182
Merge remote-tracking branch 'RinteRface/master'
yogat3ch Oct 31, 2022
079e577
Merge branch 'navbar_tag_flexibility'
yogat3ch Oct 31, 2022
237ba12
Add UU Reimports
yogat3ch Nov 16, 2022
f00ab7e
Relax ui element class in navbar to include shiny.tag.list
yogat3ch Nov 16, 2022
06a08e7
Remove bottom margin from progress bars
yogat3ch Dec 7, 2022
338c804
Merge remote-tracking branch 'RinteRface/master'
yogat3ch Jan 11, 2023
69ebf4f
`bs4InfoBox`: make icon optional (so it can instead be added to the `…
yogat3ch Jan 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ Imports:
htmltools (>= 0.5.1.1),
jsonlite (>= 0.9.16),
fresh,
grDevices,
waiter (>= 0.2.3),
httpuv (>= 1.5.2),
lifecycle,
bslib (>= 0.2.4),
httr
httr,
UU (>= 1.5.1)
Suggests:
knitr,
rmarkdown,
Expand All @@ -35,6 +37,7 @@ Encoding: UTF-8
RoxygenNote: 7.2.1
VignetteBuilder: knitr
Collate:
'aaa_reimports.R'
'feedbacks.R'
'useful-items.R'
'tabs.R'
Expand All @@ -56,3 +59,5 @@ Collate:
'skinSelector.R'
'utils.R'
RdMacros: lifecycle
Remotes:
yogat3ch/UU
17 changes: 17 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Generated by roxygen2: do not edit by hand

export("%nin%")
export("%|%")
export("%|0|%")
export("%|legit|%")
export("%|try|%")
export("%|zchar|%")
export("%||%")
export(accordion)
export(accordionItem)
export(actionButton)
Expand All @@ -20,6 +27,7 @@ export(boxProfileItem)
export(boxSidebar)
export(bs4Accordion)
export(bs4AccordionItem)
export(bs4Alert)
export(bs4Badge)
export(bs4Callout)
export(bs4Card)
Expand Down Expand Up @@ -82,6 +90,7 @@ export(cardSidebar)
export(carousel)
export(carouselItem)
export(closeAlert)
export(col2css)
export(column)
export(controlbarItem)
export(controlbarMenu)
Expand Down Expand Up @@ -179,7 +188,15 @@ export(userPost)
export(userPostMedia)
export(userPostTagItem)
export(userPostTagItems)
export(validateColors)
export(valueBox)
export(valueBoxOutput)
importFrom(UU,`%nin%`)
importFrom(UU,`%|0|%`)
importFrom(UU,`%|legit|%`)
importFrom(UU,`%|try|%`)
importFrom(UU,`%|zchar|%`)
importFrom(jsonlite,toJSON)
importFrom(lifecycle,deprecated)
importFrom(rlang,`%|%`)
importFrom(rlang,`%||%`)
28 changes: 28 additions & 0 deletions R/aaa_reimports.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#' @title Re-imports
#' @name Re-imports
#' @description Useful functions from other packages
#' @importFrom rlang `%||%` `%|%`
#' @importFrom UU `%|0|%` `%|try|%` `%|zchar|%` `%|legit|%` `%nin%`
NULL


#' @export
rlang::`%||%`

#' @export
rlang::`%|%`

#' @export
UU::`%|try|%`

#' @export
UU::`%|0|%`

#' @export
UU::`%|zchar|%`

#' @export
UU::`%|legit|%`

#' @export
UU::`%nin%`
99 changes: 84 additions & 15 deletions R/cards.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#' @param closable If TRUE, display a button in the upper right that allows the user to close the box.
#' @param maximizable If TRUE, the card can be displayed in full screen mode.
#' @param icon Header icon. Displayed before title. Expect \code{\link[shiny]{icon}}.
#' @param tip_icon Tip icon. Tooltip Icon displayed after title. Expect \code{\link[tippy]{tippy}}.
#' @param gradient Whether to allow gradient effect for the background color. Default to FALSE.
#' @param boxToolSize Size of the toolbox: choose among "xs", "sm", "md", "lg".
#' @param elevation Card elevation.
Expand Down Expand Up @@ -135,11 +136,29 @@
#' @author David Granjon, \email{dgranjon@@ymail.com}
#'
#' @export
bs4Card <- function(..., title = NULL, footer = NULL, status = NULL,
solidHeader = FALSE, background = NULL, width = 6, height = NULL,
collapsible = TRUE, collapsed = FALSE, closable = FALSE, maximizable = FALSE, icon = NULL,
gradient = FALSE, boxToolSize = "sm", elevation = NULL, headerBorder = TRUE, label = NULL, dropdownMenu = NULL,
sidebar = NULL, id = NULL) {
bs4Card <- function(...,
title = NULL,
footer = NULL,
status = NULL,
solidHeader = FALSE,
background = NULL,
width = 6,
height = NULL,
collapsible = TRUE,
collapsed = FALSE,
closable = FALSE,
maximizable = FALSE,
icon = NULL,
tip_icon = NULL,
gradient = FALSE,
boxToolSize = "sm",
elevation = NULL,
headerBorder = TRUE,
label = NULL,
dropdownMenu = NULL,
sidebar = NULL,
id = NULL) {


if (is.null(status)) solidHeader <- TRUE

Expand Down Expand Up @@ -242,15 +261,14 @@ bs4Card <- function(..., title = NULL, footer = NULL, status = NULL,

headerTag <- shiny::tags$div(
class = if (headerBorder) "card-header" else "card-header border-0",
shiny::tags$h3(class = "card-title", icon, title)
shiny::tags$h3(class = "card-title", tip_icon, icon, title)
)
headerTag <- shiny::tagAppendChild(headerTag, cardToolTag)


# body
bodyTag <- shiny::tags$div(
class = "card-body",
style = style,
...,
sidebar[[2]]
)
Expand All @@ -263,7 +281,7 @@ bs4Card <- function(..., title = NULL, footer = NULL, status = NULL,
)
}

cardTag <- shiny::tags$div(class = cardCl, id = id)
cardTag <- shiny::tags$div(class = cardCl, id = id, style = style)
cardTag <- shiny::tagAppendChildren(cardTag, headerTag, bodyTag, footerTag)

# wrapper
Expand All @@ -280,6 +298,54 @@ bs4Card <- function(..., title = NULL, footer = NULL, status = NULL,
json_verbatim = TRUE
)
)
# , if (maximizable)
# shiny::tags$script(
# type = "text/javascript",
# paste0("
# $(document).ready(function() {
# var ids = $('div",ifelse(is.null(id), "", paste0("#",id))," div.card-body div').map(function(){
# return $(this).attr('id');
# }).get();
# function resizeBoxContent(trigger, target) {
# var target = '#' + target
# $(trigger).on('click', function() {
# setTimeout(function() {
# var isMaximized = $('html').hasClass('maximized-card');
# if (isMaximized) {
# $(target).css('height', '100%');
# $(target).css('width', 'auto');
# } else {
# $(target).css('height', '400px');
# $(target).css('width', 'auto');
# }
# console.log('resizing '+ target)
# }, 300);
# $(target).trigger('resize');
# });
# };
# setTimeout(function() {
# ids.map(function(x){
# resizeBoxContent('div.card button[data-card-widget=\"maximize\"]', x);
# })
#
# }, 500);
# console.log(ids);
# });"),
# paste0("
# $(document).ready(function() {
# $('[data-card-widget=\"maximize\"]').on('click', function() {
# setTimeout(function() {
# var isMaximized = $('html').hasClass('maximized-card');
# if (isMaximized) {
# window.location.reload()
# }
# }, 300);
# $('",ifelse(is.null(id), "", paste0(id)),"').resize();
# });
# }
# ")
# )

)
}

Expand Down Expand Up @@ -936,7 +1002,6 @@ bs4InfoBox <- function(title, value = NULL, subtitle = NULL, icon = shiny::icon(
elevation = NULL, iconElevation = NULL, tabName = NULL) {

# check conditions
tagAssert(icon, "i")
if (!is.null(color)) validateStatusPlus(color)

if (is.null(color) && (fill || gradient)) {
Expand Down Expand Up @@ -987,12 +1052,16 @@ bs4InfoBox <- function(title, value = NULL, subtitle = NULL, icon = shiny::icon(
}
if (!is.null(iconElevation)) infoBoxIconCl <- paste0(infoBoxIconCl, " elevation-", iconElevation)

iconTag <- shiny::tags$span(
class = infoBoxIconCl,
id = if (!is.null(tabName)) paste0("icon-", tabName),
# icon
icon
)
if (!is.null(icon)) {
tagAssert(icon, "i")
iconTag <- shiny::tags$span(
class = infoBoxIconCl,
id = if (!is.null(tabName)) paste0("icon-", tabName),
# icon
icon
)
} else
iconTag <- icon


contentTag <- shiny::tags$div(
Expand Down
9 changes: 5 additions & 4 deletions R/dashboardHeader.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,24 @@ bs4DashNavbar <- function(..., title = NULL, titleWidth = NULL, disable = FALSE,
# by the end user.
if (skin == "dark" && is.null(status)) status <- "gray-dark"

.types <- c("li", "a", "button", "div", "shiny.tag", "shiny.tag.list")
if (!is.null(leftUi)) {
if (inherits(leftUi, "shiny.tag.list")) {
lapply(leftUi, function(item) {
tagAssert(item, type = "li", class = "dropdown")
tagAssert(item, type = .types)
})
} else {
tagAssert(leftUi, type = "li", class = "dropdown")
tagAssert(leftUi, type = .types)
}
}

if (!is.null(rightUi)) {
if (inherits(rightUi, "shiny.tag.list")) {
lapply(rightUi, function(item) {
tagAssert(item, type = "li", class = "dropdown")
tagAssert(item, type = .types)
})
} else {
tagAssert(rightUi, type = "li", class = "dropdown")
tagAssert(rightUi, type = .types)
}
}

Expand Down
8 changes: 4 additions & 4 deletions R/dashboardSidebar.R
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ bs4SidebarMenuItem <- function(text, ..., icon = NULL, badgeLabel = NULL, badgeC
subItems <- c(list(...), .list)

if (!is.null(icon)) {
tagAssert(icon, type = "i")
tagAssert(icon, type = c("i", "img"))
icon$attribs$class <- paste0(icon$attribs$class, " nav-icon")
}

Expand Down Expand Up @@ -412,7 +412,7 @@ bs4SidebarMenuItem <- function(text, ..., icon = NULL, badgeLabel = NULL, badgeC
# needed by leftSidebar.js
`data-start-selected` = if (isTRUE(selected)) 1 else NULL,
icon,
shiny::tags$p(text, badgeTag)
shiny::tags$span(text, badgeTag)
)
)
)
Expand Down Expand Up @@ -454,7 +454,7 @@ bs4SidebarMenuItem <- function(text, ..., icon = NULL, badgeLabel = NULL, badgeC
class = "nav-link",
`data-start-selected` = if (isTRUE(selected)) 1 else NULL,
icon,
shiny::tags$p(
shiny::tags$span(
text,
shiny::tags$i(class = "right fas fa-angle-left")
)
Expand Down Expand Up @@ -517,7 +517,7 @@ bs4SidebarMenuSubItem <- function(text, tabName = NULL, href = NULL,
# below this is needed by leftSidebar.js
`data-start-selected` = if (isTRUE(selected)) 1 else NULL,
icon,
shiny::tags$p(text)
shiny::tags$span(text)
)
)
}
Expand Down
Loading