bs4Dash icon indicating copy to clipboard operation
bs4Dash copied to clipboard

Variable for background color of navbar

Open DavidBarke opened this issue 4 years ago • 5 comments

I couldn't find any variable in bs4dash_vars for setting the background color of the navbar. I'd have expected something like navbar-light-bg and navbar-dark-bg.

Currently the status of the navbar is removed when switching between light and dark mode.

DavidBarke avatar Feb 07 '21 22:02 DavidBarke

Maybe you can have a look at {fresh} by @pvictor

DivadNojnarg avatar Feb 11 '21 15:02 DivadNojnarg

Thanks for pointing me to this resource. If I take the example from {fresh}, I get a white navbar in light mode (and not dark as displayed in the screenshots).

App
library(shiny)
library(bs4Dash)
library(fresh)

theme <- create_theme(
  bs4dash_vars(
    navbar_light_color = "#bec5cb",
    navbar_light_active_color = "#FFF",
    navbar_light_hover_color = "#FFF"
  ),
  bs4dash_yiq(
    contrasted_threshold = 10,
    text_dark = "#FFF",
    text_light = "#272c30"
  ),
  bs4dash_layout(
    main_bg = "#353c42"
  ),
  bs4dash_sidebar_light(
    bg = "#272c30",
    color = "#bec5cb",
    hover_color = "#FFF",
    submenu_bg = "#272c30",
    submenu_color = "#FFF",
    submenu_hover_color = "#FFF"
  ),
  bs4dash_status(
    primary = "#5E81AC", danger = "#BF616A", light = "#272c30"
  ),
  bs4dash_color(
    gray_900 = "#FFF"
  )
)

shinyApp(
  ui = dashboardPage(
    freshTheme = theme,
    header = dashboardHeader(),
    sidebar = dashboardSidebar(),
    body = dashboardBody()
  ),
  server = function(input, output) { }
)

In the help page for bs4DashPage() the same theme is used except for the addition of setting white = #272c30 (dark). This colors the navbar background but also colors everything else that relies on $white, e.g. card-bg.

App
library(shiny)
library(bs4Dash)
library(fresh)

theme <- create_theme(
  bs4dash_vars(
    navbar_light_color = "#bec5cb",
    navbar_light_active_color = "#FFF",
    navbar_light_hover_color = "#FFF"
  ),
  bs4dash_yiq(
    contrasted_threshold = 10,
    text_dark = "#FFF",
    text_light = "#272c30"
  ),
  bs4dash_layout(
    main_bg = "#353c42"
  ),
  bs4dash_sidebar_light(
    bg = "#272c30",
    color = "#bec5cb",
    hover_color = "#FFF",
    submenu_bg = "#272c30",
    submenu_color = "#FFF",
    submenu_hover_color = "#FFF"
  ),
  bs4dash_status(
    primary = "#5E81AC", danger = "#BF616A", light = "#272c30"
  ),
  bs4dash_color(
    gray_900 = "#FFF", white = "#272c30"
  )
)

shinyApp(
  ui = dashboardPage(
    freshTheme = theme,
    header = dashboardHeader(),
    sidebar = dashboardSidebar(),
    body = dashboardBody()
  ),
  server = function(input, output) { }
)

What does the light variable do? It seems to have no effect.

However, I'll probably write my own rule as this seems to be easier as overriding all variables that use $white.

DavidBarke avatar Feb 11 '21 18:02 DavidBarke

I just remember that fresh doesn’t have the same version as bs4Dash for AdminLTE, which impacts the Result.

DivadNojnarg avatar Feb 11 '21 20:02 DivadNojnarg

I'll look into it !

pvictor avatar Feb 11 '21 20:02 pvictor

I've updated AdminLTE to 3.1.0 in fresh.

pvictor avatar Feb 11 '21 21:02 pvictor