Commit abb81a75 authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Remove arrow from menus

parent 90a6adb8
...@@ -98,11 +98,6 @@ function AnnotationPublishControl({ ...@@ -98,11 +98,6 @@ function AnnotationPublishControl({
style={buttonStyle} style={buttonStyle}
> >
<Menu <Menu
arrowClass={classnames(
// Position up-pointing menu caret aligned beneath the
// down-pointing menu-open button icon
'right-[10px]',
)}
containerPositioned={false} containerPositioned={false}
contentClass={classnames( contentClass={classnames(
// Ensure the menu is wide enough to "reach" the right-aligned // Ensure the menu is wide enough to "reach" the right-aligned
......
...@@ -81,21 +81,28 @@ function GroupList({ settings }: GroupListProps) { ...@@ -81,21 +81,28 @@ function GroupList({ settings }: GroupListProps) {
label = ( label = (
<span <span
className={classnames( className={classnames(
// Don't allow this label to shrink (wrap to next line) // Add some vertical padding so that the dropdown has some space
'shrink-0 flex items-center gap-x-1 text-md text-color-text font-bold', 'py-1',
)} )}
> >
{icon && ( <span
<img className={classnames(
className={classnames( // Don't allow this label to shrink (wrap to next line)
// Tiny adjustment to make H logo align better with group name 'shrink-0 flex items-center gap-x-1 text-md text-color-text font-bold',
'relative top-[1px] w-4 h-4', )}
)} >
src={icon} {icon && (
alt={altName} <img
/> className={classnames(
)} // Tiny adjustment to make H logo align better with group name
{focusedGroup.name} 'relative top-[1px] w-4 h-4',
)}
src={icon}
alt={altName}
/>
)}
{focusedGroup.name}
</span>
</span> </span>
); );
} else { } else {
......
...@@ -4,7 +4,6 @@ import classnames from 'classnames'; ...@@ -4,7 +4,6 @@ import classnames from 'classnames';
import type { ComponentChildren } from 'preact'; import type { ComponentChildren } from 'preact';
import { useCallback, useEffect, useRef, useState } from 'preact/hooks'; import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
import MenuArrow from './MenuArrow';
import MenuKeyboardNavigation from './MenuKeyboardNavigation'; import MenuKeyboardNavigation from './MenuKeyboardNavigation';
/** /**
...@@ -21,13 +20,6 @@ export type MenuProps = { ...@@ -21,13 +20,6 @@ export type MenuProps = {
*/ */
align?: 'left' | 'right'; align?: 'left' | 'right';
/**
* Additional CSS class for the arrow caret at the edge of the menu content
* that "points" toward the menu's toggle button. This can be used to adjust
* the position of that caret respective to the toggle button.
*/
arrowClass?: string;
/** /**
* Label element or string for the toggle button that hides and shows the menu * Label element or string for the toggle button that hides and shows the menu
*/ */
...@@ -95,7 +87,6 @@ const noop = () => {}; ...@@ -95,7 +87,6 @@ const noop = () => {};
*/ */
export default function Menu({ export default function Menu({
align = 'left', align = 'left',
arrowClass = '',
children, children,
containerPositioned = true, containerPositioned = true,
contentClass, contentClass,
...@@ -227,40 +218,28 @@ export default function Menu({ ...@@ -227,40 +218,28 @@ export default function Menu({
</span> </span>
</button> </button>
{isOpen && ( {isOpen && (
<> <div
<MenuArrow className={classnames(
direction="up" 'focus-visible-ring',
classes={classnames( // Position menu content near bottom of menu label/toggle control
// Position menu-arrow caret near bottom right of menu label/toggle control 'absolute top-[calc(100%+3px)] z-1',
'right-1 top-[calc(100%-3px)] w-[15px]', 'border shadow rounded-lg overflow-hidden bg-white text-md',
arrowClass, {
)} 'left-0': align === 'left',
/> 'right-0': align === 'right',
<div },
className={classnames( contentClass,
'focus-visible-ring', )}
// Position menu content near bottom of menu label/toggle control data-testid="menu-content"
'absolute top-[calc(100%+5px)] z-1', role="menu"
'border shadow rounded-lg overflow-hidden bg-white text-md', tabIndex={-1}
{ onClick={closeMenu}
'left-0': align === 'left', onKeyDown={handleMenuKeyDown}
// Adding negative right distance so that the menu arrow does >
// not overlap with the top-right corner when it's rounded <MenuKeyboardNavigation visible={true}>
'-right-1': align === 'right', {children}
}, </MenuKeyboardNavigation>
contentClass, </div>
)}
data-testid="menu-content"
role="menu"
tabIndex={-1}
onClick={closeMenu}
onKeyDown={handleMenuKeyDown}
>
<MenuKeyboardNavigation visible={true}>
{children}
</MenuKeyboardNavigation>
</div>
</>
)} )}
</div> </div>
); );
......
...@@ -217,7 +217,7 @@ describe('Menu', () => { ...@@ -217,7 +217,7 @@ describe('Menu', () => {
assert.isTrue(wrapper.find(contentSelector).hasClass('left-0')); assert.isTrue(wrapper.find(contentSelector).hasClass('left-0'));
wrapper.setProps({ align: 'right' }); wrapper.setProps({ align: 'right' });
assert.isTrue(wrapper.find(contentSelector).hasClass('-right-1')); assert.isTrue(wrapper.find(contentSelector).hasClass('right-0'));
}); });
it('applies custom content class', () => { it('applies custom content class', () => {
...@@ -229,16 +229,6 @@ describe('Menu', () => { ...@@ -229,16 +229,6 @@ describe('Menu', () => {
assert.isTrue(content.hasClass('special-menu')); assert.isTrue(content.hasClass('special-menu'));
}); });
it('applies custom arrow class', () => {
const wrapper = createMenu({
arrowClass: 'my-arrow-class',
defaultOpen: true,
});
const arrow = wrapper.find('MenuArrow');
assert.include(arrow.props().classes, 'my-arrow-class');
});
it('has relative positioning if `containerPositioned` is `true`', () => { it('has relative positioning if `containerPositioned` is `true`', () => {
const wrapper = createMenu({ const wrapper = createMenu({
containerPositioned: true, // default containerPositioned: true, // default
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment