-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor towards menu bar with extra item
- Loading branch information
Showing
6 changed files
with
216 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import React, {useEffect, useState} from 'react'; | ||
import React from 'react'; | ||
import ArchiveIcon from 'icons/archive.svg'; | ||
|
||
|
||
export default function Audio(props) { | ||
console.log(props); | ||
|
||
function archiveSelectedIcons() { | ||
console.log("archiveSelectedIcons", props); | ||
} | ||
|
||
return ( | ||
<li onClick={() => archiveSelectedIcons()} className={props.numSelectedInodes ? null : "disabled"} data-tooltip-id="django-finder-tooltip" data-tooltip-content={gettext("Create archive from selection")}> | ||
<ArchiveIcon /> | ||
<li className={props.numSelectedInodes ? null : "disabled"} onClick={archiveSelectedIcons}> | ||
<ArchiveIcon/><span>{gettext("Create archive from selection")}</span> | ||
</li> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React, {useEffect, useRef} from 'react'; | ||
|
||
|
||
export default function DropDownMenu(props) { | ||
const ref = useRef(null); | ||
const Wrapper = props.wrapperElement ?? 'li'; | ||
|
||
useEffect(() => { | ||
const closeSubmenu = (event) => { | ||
if (!ref.current?.parentElement?.contains(event.target)) { | ||
ref.current.setAttribute('aria-expanded', 'false'); | ||
} | ||
}; | ||
window.addEventListener('click', closeSubmenu); | ||
return () => window.removeEventListener('click', closeSubmenu); | ||
}, []); | ||
|
||
function toggleSubmenu() { | ||
ref.current.setAttribute('aria-expanded', ref.current.ariaExpanded === 'true' ? 'false': 'true'); | ||
} | ||
|
||
return ( | ||
<Wrapper | ||
aria-haspopup="true" | ||
onClick={toggleSubmenu} | ||
className={`dropdown-menu ${props.className}`} | ||
data-tooltip-id="django-finder-tooltip" | ||
data-tooltip-content={props.tooltip} | ||
> | ||
{props.icon} | ||
<ul ref={ref} role="combobox" aria-expanded="false"> | ||
{props.children} | ||
</ul> | ||
</Wrapper> | ||
) | ||
} |
Oops, something went wrong.