plugins.SideBar.Menu.NavItems.Dropdown.DropdownWrapper.tsx Maven / Gradle / Ivy
The newest version!
import React, { useState, useRef } from 'react'
import classNames from 'classnames'
import { NavItemImage } from '@i-novus/n2o-components/lib/display/NavItemImage'
import { Tooltip } from '../../../../../components/snippets/Tooltip/TooltipHOC'
import { Icon } from '../../../utils'
interface DropdownWrapperProps {
sidebarOpen: boolean
title?: string
children?: JSX.Element
icon?: string
src: string
showContent: boolean
isMiniView: boolean
id: string
imageSrc?: string
imageShape?: string
open?: boolean
}
export function DropdownWrapper({
sidebarOpen,
title,
children,
icon,
src,
showContent,
isMiniView,
id,
imageSrc,
imageShape,
open = false,
}: DropdownWrapperProps) {
const ref = useRef(null)
const [isOpen, setOpen] = useState(open)
const toggle = () => setOpen(!isOpen)
const itemDropdownClass = classNames(
'n2o-sidebar__item-dropdown-label',
{
'pl-3': !isMiniView,
mini: isMiniView,
},
)
const subItemsClass = classNames(
'n2o-sidebar__subitems',
{
visible: showContent,
},
)
return (
<>
{title}
{isOpen && ({children})}
>
)
}
export default DropdownWrapper