Skip to content

Commit f0452c4

Browse files
committed
better style for tabcard title when ribbon is present.
1 parent f54dd24 commit f0452c4

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

R/cards.R

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,9 @@ bs4InfoBox <- function(title, value = NULL, subtitle = NULL, icon = shiny::icon(
10691069
#'
10701070
#' @note User will access the \link{tabBox} input with input$<id>_box. This allows
10711071
#' to get the state of the box and update it on the server with \link{updateBox}.
1072+
#' Don't forget that the title should not be too long, especially
1073+
#' if you have more than 3 tabs and want the box to be collapsible,
1074+
#' closable and maximizable, as these elements take extra horizontal space.
10721075
#'
10731076
#' @examples
10741077
#' if (interactive()) {
@@ -1142,6 +1145,14 @@ bs4TabCard <- function(..., id = NULL, selected = NULL, title = NULL, width = 6,
11421145
sidebar = NULL, .list = NULL) {
11431146
side <- match.arg(side)
11441147
if (is.null(type)) type <- "pills"
1148+
1149+
# If the card has ribbon, we must apply more margin to the
1150+
# title when the tabs position is left (title right side).
1151+
body_items <- list(...)
1152+
has_ribbon <- unlist(lapply(body_items, function(item) {
1153+
if (item$attribs$class == "ribbon-wrapper") TRUE
1154+
}))
1155+
if (is.null(has_ribbon)) has_ribbon <- FALSE
11451156

11461157
# Build tabs
11471158
content <- tabsetPanel(
@@ -1210,7 +1221,11 @@ bs4TabCard <- function(..., id = NULL, selected = NULL, title = NULL, width = 6,
12101221
}
12111222
boxTag$children[[1]]$children[[1]]$children[[1]] <- NULL
12121223
titleNavTag <- shiny::tags$li(
1213-
class = if (side == "left") "pt-2 px-3 ml-auto" else "pt-2 px-3",
1224+
class = if (side == "left") {
1225+
if (has_ribbon) "pt-2 px-5 ml-auto" else "pt-2 px-3 ml-auto"
1226+
} else {
1227+
"pt-2 px-3"
1228+
},
12141229
titleTag
12151230
)
12161231

man/tabBox.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)