Code Monkey home page Code Monkey logo

Comments (10)

chendaniely avatar chendaniely commented on August 22, 2024

Current hack by Tobi Guennel for a project we're working on.

# create a new dashboardHeader function with the ability to pass in a title

dashboardHeader <- function(..., title = NULL, disable = FALSE,title.navbar=NULL, .list = NULL) {
  items <- c(list(...), .list)
  #lapply(items, tagAssert, type = "li", class = "dropdown")
  tags$header(class = "main-header",
              style = if (disable) "display: none;",
              span(class = "logo", title),
              tags$nav(class = "navbar navbar-static-top", role = "navigation",
                       # Embed hidden icon so that we get the font-awesome dependency
                       span(shiny::icon("bars"), style = "display:none;"),
                       # Sidebar toggle button
                       a(href="#", class="sidebar-toggle", `data-toggle`="offcanvas",
                         role="button",
                         span(class="sr-only", "Toggle navigation")
                       ),title.navbar,
                       div(class = "navbar-custom-menu",
                           tags$ul(class = "nav navbar-nav",
                                   items
                           )
                       )
              )
  )
}

title.navbar.html <- tags$div(style="color:white;text-align:left;vertical-align:middle;display:inline-block;font-size: 30px;font-size: 1.5vw;padding-left: 5px",
                              HTML(paste0("TITLE HERE")))

header <- dashboardHeader(
  title = img(src="PATH_logo_white.png", height = 45),
  title.navbar = title.navbar.html
)
)

from shinydashboard.

chendaniely avatar chendaniely commented on August 22, 2024

This hack doesn't work very well when the screen width get's smaller. The text will shrink to fit in the space, and not actually create a new line.

May not be a problem for shorter titles, but can be an issue for larger ones.

from shinydashboard.

pssguy avatar pssguy commented on August 22, 2024

+1 for any progress on this.
I would also like an elegant as possible option to have say email and twitter icons with relevant url links where the messageItems currently reside

from shinydashboard.

wch avatar wch commented on August 22, 2024

I added an example for this in the docs:
http://rstudio.github.io/shinydashboard/appearance.html#long-titles

It's not as simple as an option to the R functions, but I think that using custom CSS is the least bad way to do it here.

from shinydashboard.

wch avatar wch commented on August 22, 2024

I've changed my mind and added a titleWidth option, so you don't need to use custom CSS. The docs have been updated to reflect this.

from shinydashboard.

chendaniely avatar chendaniely commented on August 22, 2024

looks good @wch!

I'm assuming you are still able to add an image as well by using img tags?

from shinydashboard.

wch avatar wch commented on August 22, 2024

Yup, that should work.

I've just realized that adding width control in the way that I did may cause problems on mobile devices, so it might take more time to get a proper fix in there.

from shinydashboard.

chendaniely avatar chendaniely commented on August 22, 2024

That seems like it can be fixed with CSS media queries. But I'm not sure how the dashboardHeader handles line breaks IIRC, it doesn't like things that are taller than the current height

from shinydashboard.

wch avatar wch commented on August 22, 2024

Unfortunately, the standard title/sidebar width of 230px is coded into the AdminLTE CSS. Making width an option with proper behavior in various screen widths would probably require manually overriding all of those instances in the CSS. :(

from shinydashboard.

wch avatar wch commented on August 22, 2024

OK, I think I have it straightened out, so there should be no trouble on mobile devices. I also implemented a sidebar width option.

from shinydashboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.