【问题标题】:How to make Fluent UI Nav collapse horizontally如何使 Fluent UI Nav 水平折叠
【发布时间】:2021-04-14 10:24:07
【问题描述】:

我开始使用基于 Microsoft 的 Fluent UI 的 shiny.fluent R 包来构建应用程序,但我坚持制作导航组件 点击折叠(第一个链接,导航栏图标)和小屏幕尺寸

这是来自 shiny.fluent 示例的示例代码:

library(shiny)
library(shiny.fluent)

navigation_styles <- list(
  root = list(
    height = "100%",
    width = "30%",
    boxSizing = "border-box",
    border = "1px solid #eee",
    overflowY = "auto"
  )
)

link_groups <- list(
  list(
    links = list(
      list(key = "toggle_hide", icon = "GlobalNavButton"),
      list(
        name = "Home",
        expandAriaLabel = "Expand Home section",
        collapseAriaLabel = "Collapse Home section",
        links = list(
          list(
            name = "Activity",
            url = "http://msn.com",
            key = "key1",
            target = "_blank"
          ),
          list(
            name = "MSN",
            url = "http://msn.com",
            disabled = TRUE,
            key = "key2",
            target = "_blank"
          )
        ),
        isExpanded = TRUE
      ),
      list(
        name = "Documents",
        url = "http://example.com",
        key = "key3",
        isExpanded = TRUE
      ),
      list(
        name = "Pages",
        url = "http://msn.com",
        key = "key4"
      ),
      list(
        name = "Notebook",
        url = "http://msn.com",
        key = "key5",
        disabled = TRUE
      ),
      list(
        name = "Communication and Media",
        url = "http://msn.com",
        key = "key6"
      ),
      list(
        name = "News",
        url = "http://cnn.com",
        icon = "News",
        key = "key7",
        target = "_blank",
        iconProps = list(
          iconName = "News",
          styles = list(
            root = list(
              fontSize = 20,
              color = "#106ebe"
            )
          )
        )
      )
    )
  )
)

shinyApp(
  ui = withReact(
    Nav(
      groups = link_groups,
      selectedKey = "key1",
      styles = navigation_styles
    )
  ),
  server = function(input, output) {
  }
)

我想要的视觉输出是:

请帮我解决这个问题,我仍然无法在网上找到任何可用的解决方案

【问题讨论】:

    标签: r shiny fluent-ui


    【解决方案1】:

    我通过在悬停时使用过渡而不是展开按钮来实现这一点。检查我在风格上所做的改变。不过,嵌套菜单会成为这种方法的问题。

        navigation_styles <- list(
        root = list(
            height = "100%",
            width = "30%",
            boxSizing = "border-box",
            border = "1px solid #eee",
            overflowY = "auto",
    
    
            //TRYOUT THE CODE BELOW
            transition: 'width 0.3s ease-in-out',
            selectors: {
                         ':hover':{
                             width: '100%'
                          }
                       }
            )
         )
    

    【讨论】:

    • 我用了一些JS来更新CSS,但是你的回答简单多了,非常感谢
    • 我也试过你的代码,但它不是我的情况。我认为我的问题是导航栏位于包含网格的位置。这会导致这个问题吗?谢谢!
    猜你喜欢
    • 2013-09-30
    • 1970-01-01
    • 2020-06-13
    • 1970-01-01
    • 2015-02-22
    • 1970-01-01
    • 1970-01-01
    • 2017-03-17
    • 2019-01-09
    相关资源
    最近更新 更多