Sha256: c081ab6673ee79e489d2e3b89eeafda1f243472e2b1ff308cfc2fd6973bc77a4

Contents?: true

Size: 1.66 KB

Versions: 18

Compression:

Stored size: 1.66 KB

Contents

import React from "react"
import { Nav, NavItem, useCollapsible } from "../.."

const CollapsibleNav = (props) => {
  const navItems = ["Overview", "Albums", "Similar Artists"]
  // eslint-disable-next-line react-hooks/rules-of-hooks
  const collapsibles = navItems.map(() => useCollapsible(true))

  const handleMainClick = (index) => {
    collapsibles.forEach(([, , setCollapsed], idx) => {
      if (idx === index) {
        setCollapsed(false)
      } else {
        setCollapsed(true)
      }
    })
  }


  const handleIconRightClick = (index) => {
    const [isCollapsed, setCollapsed] = collapsibles[index]
    setCollapsed(!isCollapsed)
  }

  return (
    <>
      <Nav variant='subtle'>
        {navItems.map((text, index) => {
          const [collapsed] = collapsibles[index]
          return (
            <NavItem
                collapsible
                collapsibleClick={() => handleMainClick(index)}
                iconLeft="chevron-down"
                iconRightClick={() => handleIconRightClick(index)}
                id={`collapsible-nav-item-${index + 1}`}
                key={index}
                link="#"
                text={text}
                toggleCollapsed={collapsed}
                {...props}
            >
              <NavItem link="#" 
                  text="City" 
                  {...props} 
              />
              <NavItem link="#" 
                  text="People" 
                  {...props} 
              />
              <NavItem link="#" 
                  text="Business" 
                  {...props} 
              />
            </NavItem>
          );
        })}
      </Nav>
    </>
  )
}

export default CollapsibleNav

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
playbook_ui_docs-12.38.0.pre.alpha.PBNTR78selectkitmultipleprop1094 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui-12.38.0.pre.alpha.PBNTR78selectkitmultipleprop1094 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui_docs-12.38.0.pre.alpha.PLAY932removemomentqp1088 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui-12.38.0.pre.alpha.PLAY932removemomentqp1088 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui_docs-12.38.0.pre.alpha.audiencesalpha1083 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui-12.38.0.pre.alpha.audiencesalpha1083 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui_docs-12.38.0.pre.alpha.PLAYaddingdatapropselectkit1080 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui-12.38.0.pre.alpha.PLAYaddingdatapropselectkit1080 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui_docs-12.38.0.pre.alpha.playbook123801077 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui-12.38.0.pre.alpha.playbook123801077 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui_docs-12.37.0.pre.alpha.PLAYaddingdatapropselectkit1071 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui-12.37.0.pre.alpha.PLAYaddingdatapropselectkit1071 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui-12.38.0 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui_docs-12.37.0.pre.alpha.svgiconmethods1064 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui-12.37.0.pre.alpha.svgiconmethods1064 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui-12.37.0 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui_docs-12.36.0.pre.alpha.PLAY942collapsiblenav21035 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx
playbook_ui-12.36.0.pre.alpha.PLAY942collapsiblenav21035 app/pb_kits/playbook/pb_nav/docs/_collapsible_nav.jsx