Skip to content

Commit

Permalink
refactor towards menu bar with extra item
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed Sep 26, 2024
1 parent e8f6950 commit 9f1ee6f
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 134 deletions.
7 changes: 4 additions & 3 deletions client/components/menu/Audio.tsx
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>
);
}
48 changes: 24 additions & 24 deletions client/finder-admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ $active-rectangle: rgb(210, 210, 112);

.search-realm {
[role="combobox"] {
width: 225px;
li:nth-child(2) {
padding-bottom: 4px;
border-bottom: 1px solid lightgrey;
Expand All @@ -143,24 +142,11 @@ $active-rectangle: rgb(210, 210, 112);
margin-left: auto;
margin-right: auto;
width: auto;
}

&::after {
right: -12px;
}

[role="combobox"] {
width: 150px;

svg {
color: grey;
}
span {
margin-left: 40px;
}
svg + span {
margin-left: 10px;
}
}
&:last-of-type [role="combobox"] {
right: 0;
margin-inline-end: inherit;
}

svg {
Expand All @@ -169,13 +155,12 @@ $active-rectangle: rgb(210, 210, 112);
height: 30px;
margin: 1px;
}

}

[aria-haspopup="true"] {
[aria-haspopup="true"]:has([role="combobox"]) {
position: relative;
display: flex;
&::after {
&.with-caret::after {
content: " ";
align-self: center;
border: 5px solid transparent;
Expand All @@ -189,14 +174,19 @@ $active-rectangle: rgb(210, 210, 112);
z-index: 1;
background-color: white;
top: 100%;
left: calc(32px - 150px / 2);
left: -250px;
right:-250px;
margin-inline: auto;
border: 1px solid rgb(192, 192, 192);
border-radius: 4px;
box-shadow: 0 0 8px rgb(192, 192, 192);
display: flex;
flex-direction: column;
margin: 0;
padding: 3px 0;
width: max-content;
padding-top: 3px;
padding-bottom: 3px;
padding-inline-start: 3px;
padding-inline-end: 30px;

&[aria-expanded="false"] {
display: none;
Expand All @@ -216,6 +206,16 @@ $active-rectangle: rgb(210, 210, 112);
right: 10px;
}
}

svg {
color: grey;
}
span {
margin-left: 40px;
}
svg + span {
margin-left: 10px;
}
}
}
}
Expand Down
36 changes: 36 additions & 0 deletions client/finder/DropDownMenu.tsx
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>
)
}
Loading

0 comments on commit 9f1ee6f

Please sign in to comment.