Skip to content

Commit

Permalink
better style for tabBox. Will hopefully fix #342.
Browse files Browse the repository at this point in the history
  • Loading branch information
DivadNojnarg committed Jun 5, 2023
1 parent 82b7f3d commit bb309b6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# bs4Dash 2.2.2.9000

## Minor change
- Fix #342: better title alignment in `tabBox()`. Increase padding for card with pills. Thanks @HugoGit39
for reporting.

## Bug fixes
- Fix #349: allow to pass list of `accordionItem()` with `.list` parameter in `accordion()`. Thanks @vladimirstroganov for reporting.
- Fix #330: allow to use input elements (or any not `menuItem` element) in the sidebar.
Expand Down
35 changes: 24 additions & 11 deletions R/cards.R
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ bs4TabCard <- function(..., id = NULL, selected = NULL, title = NULL, width = 6,
# add card-tabs class
boxTag$children[[1]]$attribs$class <- paste0(
boxTag$children[[1]]$attribs$class,
if (solidHeader) {
if (solidHeader || type == "pills") {
" card-tabs"
} else {
" card-outline-tabs"
Expand All @@ -1190,19 +1190,27 @@ bs4TabCard <- function(..., id = NULL, selected = NULL, title = NULL, width = 6,
# change header class
boxTag$children[[1]]$children[[1]]$attribs$class <- paste0(
boxTag$children[[1]]$children[[1]]$attribs$class,
if (solidHeader) {
" p-0 pt-1"
} else {
" p-0 border-bottom-0"
if (type != "pills") {
if (solidHeader) {
" p-0 pt-1"
} else {
" p-0 border-bottom-0"
}
}
)


# Remove title and add it to tab list
titleTag <- boxTag$children[[1]]$children[[1]]$children[[1]]
if (type == "tabs") {
titleTag$attribs$class <- paste(
titleTag$attribs$class,
"pt-1"
)
}
boxTag$children[[1]]$children[[1]]$children[[1]] <- NULL
titleNavTag <- shiny::tags$li(
class = "pt-2 px-3",
class = if (side == "left") "pt-2 px-3 ml-auto" else "pt-2 px-3",
titleTag
)

Expand All @@ -1224,11 +1232,16 @@ bs4TabCard <- function(..., id = NULL, selected = NULL, title = NULL, width = 6,
}

# Insert box tools at the end of the list
content$children[[1]] <- tagInsertChild(
content$children[[1]],
shiny::tags$li(class = "ml-auto", boxToolTag),
length(content$children[[1]])
)
if (
length(boxToolTag$children[[1]]) > 0 ||
length(boxToolTag$children[[2]]) > 0
) {
content$children[[1]] <- tagInsertChild(
content$children[[1]],
shiny::tags$li(class = if (side == "left") "ml-0" else "ml-auto", boxToolTag),
length(content$children[[1]])
)
}

# Insert tabs at different position in the header tag
if (side == "right") {
Expand Down
2 changes: 1 addition & 1 deletion inst/examples/showcase/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ shinyApp(
ui = dashboardPage(
preloader = list(html = tagList(spin_1(), "Loading ..."), color = "#343a40"),
dark = TRUE,
help = TRUE,
help = FALSE,
fullscreen = TRUE,
scrollToTop = TRUE,
header = dashboardHeader(
Expand Down

0 comments on commit bb309b6

Please sign in to comment.