|
45 | 45 | #' wrapped in a `<header>` element with class `sidebar-title`. You can also |
46 | 46 | #' provide a custom [htmltools::tag()] for the title element, in which case |
47 | 47 | #' you'll likely want to give this element `class = "sidebar-title"`. |
| 48 | +#' @param collapse_icon A [htmltools::tag()] child to use for the collapse icon. |
| 49 | +#' Consider using a \pkg{bsicons} icon like `bsicons::bs_icon("sliders")`. |
48 | 50 | #' @param bg,fg A background or foreground color. If only one of either is |
49 | 51 | #' provided, an accessible contrasting color is provided for the opposite |
50 | 52 | #' color, e.g. setting `bg` chooses an appropriate `fg` color. |
@@ -75,6 +77,7 @@ sidebar <- function( |
75 | 77 | open = c("desktop", "open", "closed", "always"), |
76 | 78 | id = NULL, |
77 | 79 | title = NULL, |
| 80 | + collapse_icon = NULL, |
78 | 81 | bg = NULL, |
79 | 82 | fg = NULL, |
80 | 83 | class = NULL, |
@@ -130,7 +133,7 @@ sidebar <- function( |
130 | 133 | title = "Toggle sidebar", |
131 | 134 | "aria-expanded" = if (open %in% c("open", "desktop")) "true" else "false", |
132 | 135 | "aria-controls" = id, |
133 | | - collapse_icon() |
| 136 | + collapse_icon %||% sidebar_collapse_icon() |
134 | 137 | ) |
135 | 138 | } |
136 | 139 |
|
@@ -293,12 +296,12 @@ toggle_sidebar <- function(id, open = NULL, session = get_current_session()) { |
293 | 296 | #' @export |
294 | 297 | sidebar_toggle <- toggle_sidebar |
295 | 298 |
|
296 | | -collapse_icon <- function() { |
| 299 | +sidebar_collapse_icon <- function() { |
297 | 300 | if (!is_installed("bsicons")) { |
298 | | - icon <- "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" class=\"bi bi-chevron-left collapse-icon\" style=\"fill:currentColor;\" aria-hidden=\"true\" role=\"img\" ><path fill-rule=\"evenodd\" d=\"M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z\"></path></svg>" |
| 301 | + icon <- "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" class=\"bi bi-chevron-left\" style=\"fill:currentColor;\" aria-hidden=\"true\" role=\"img\" ><path fill-rule=\"evenodd\" d=\"M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z\"></path></svg>" |
299 | 302 | return(HTML(icon)) |
300 | 303 | } |
301 | | - bsicons::bs_icon("chevron-left", class = "collapse-icon", size = NULL) |
| 304 | + bsicons::bs_icon("chevron-left") |
302 | 305 | } |
303 | 306 |
|
304 | 307 | sidebar_init_js <- function() { |
|
0 commit comments