mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 17:28:29 +02:00
Sidebar item dropdown
This commit is contained in:
@@ -9,6 +9,8 @@ import { useTheme } from '../hooks/useTheme';
|
|||||||
import { useUpdateRequest } from '../hooks/useUpdateRequest';
|
import { useUpdateRequest } from '../hooks/useUpdateRequest';
|
||||||
import type { HttpRequest } from '../lib/models';
|
import type { HttpRequest } from '../lib/models';
|
||||||
import { Button } from './core/Button';
|
import { Button } from './core/Button';
|
||||||
|
import { Dropdown, DropdownMenuTrigger } from './core/Dropdown';
|
||||||
|
import { Icon } from './core/Icon';
|
||||||
import { IconButton } from './core/IconButton';
|
import { IconButton } from './core/IconButton';
|
||||||
import { HStack, VStack } from './core/Stacks';
|
import { HStack, VStack } from './core/Stacks';
|
||||||
import { WindowDragRegion } from './core/WindowDragRegion';
|
import { WindowDragRegion } from './core/WindowDragRegion';
|
||||||
@@ -124,15 +126,6 @@ function SidebarItem({ request, active }: { request: HttpRequest; active: boolea
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<li className="group/item relative">
|
<li className="group/item relative">
|
||||||
<IconButton
|
|
||||||
size="sm"
|
|
||||||
color="custom"
|
|
||||||
iconSize="sm"
|
|
||||||
title="Delete request"
|
|
||||||
icon="trash"
|
|
||||||
className="absolute right-0 transition-opacity opacity-0 group-hover/item:opacity-100"
|
|
||||||
onClick={() => deleteRequest.mutate()}
|
|
||||||
/>
|
|
||||||
<Button
|
<Button
|
||||||
color="custom"
|
color="custom"
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -140,10 +133,10 @@ function SidebarItem({ request, active }: { request: HttpRequest; active: boolea
|
|||||||
editing && 'focus-within:border-blue-400/40',
|
editing && 'focus-within:border-blue-400/40',
|
||||||
active
|
active
|
||||||
? 'bg-gray-200/70 text-gray-900'
|
? 'bg-gray-200/70 text-gray-900'
|
||||||
: 'text-gray-600 hover:text-gray-800 active:bg-gray-200/30',
|
: 'text-gray-600 group-hover/item:text-gray-800 active:bg-gray-200/30',
|
||||||
|
|
||||||
// Move out of the way when trash is shown
|
// Move out of the way when trash is shown
|
||||||
'group-hover/item:pr-6',
|
'group-hover/item:pr-7',
|
||||||
)}
|
)}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
// Hitting enter on active request during keyboard nav will start edit
|
// Hitting enter on active request during keyboard nav will start edit
|
||||||
@@ -177,6 +170,19 @@ function SidebarItem({ request, active }: { request: HttpRequest; active: boolea
|
|||||||
<span className="truncate">{request.name || request.url}</span>
|
<span className="truncate">{request.name || request.url}</span>
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
|
<Dropdown
|
||||||
|
items={[
|
||||||
|
{
|
||||||
|
label: 'Delete Request',
|
||||||
|
onSelect: deleteRequest.mutate,
|
||||||
|
leftSlot: <Icon icon="trash" />,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<DropdownMenuTrigger className="absolute right-0 top-0 transition-opacity opacity-0 group-hover/item:opacity-100 focus-visible:opacity-100">
|
||||||
|
<IconButton color="custom" size="sm" iconSize="sm" title="Delete request" icon="dotsH" />
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
</Dropdown>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,24 +6,26 @@ import {
|
|||||||
CodeIcon,
|
CodeIcon,
|
||||||
ColorWheelIcon,
|
ColorWheelIcon,
|
||||||
Cross2Icon,
|
Cross2Icon,
|
||||||
|
DotsHorizontalIcon,
|
||||||
|
DotsVerticalIcon,
|
||||||
EyeOpenIcon,
|
EyeOpenIcon,
|
||||||
GearIcon,
|
GearIcon,
|
||||||
HomeIcon,
|
HomeIcon,
|
||||||
MoonIcon,
|
|
||||||
ListBulletIcon,
|
ListBulletIcon,
|
||||||
|
MagicWandIcon,
|
||||||
|
MagnifyingGlassIcon,
|
||||||
|
MoonIcon,
|
||||||
PaperPlaneIcon,
|
PaperPlaneIcon,
|
||||||
PlusCircledIcon,
|
PlusCircledIcon,
|
||||||
PlusIcon,
|
PlusIcon,
|
||||||
QuestionMarkIcon,
|
QuestionMarkIcon,
|
||||||
|
RowsIcon,
|
||||||
SunIcon,
|
SunIcon,
|
||||||
TrashIcon,
|
TrashIcon,
|
||||||
TriangleDownIcon,
|
TriangleDownIcon,
|
||||||
TriangleLeftIcon,
|
TriangleLeftIcon,
|
||||||
TriangleRightIcon,
|
TriangleRightIcon,
|
||||||
UpdateIcon,
|
UpdateIcon,
|
||||||
RowsIcon,
|
|
||||||
MagicWandIcon,
|
|
||||||
MagnifyingGlassIcon,
|
|
||||||
} from '@radix-ui/react-icons';
|
} from '@radix-ui/react-icons';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
|
||||||
@@ -34,10 +36,14 @@ const icons = {
|
|||||||
clock: ClockIcon,
|
clock: ClockIcon,
|
||||||
code: CodeIcon,
|
code: CodeIcon,
|
||||||
colorWheel: ColorWheelIcon,
|
colorWheel: ColorWheelIcon,
|
||||||
|
dotsH: DotsHorizontalIcon,
|
||||||
|
dotsV: DotsVerticalIcon,
|
||||||
eye: EyeOpenIcon,
|
eye: EyeOpenIcon,
|
||||||
gear: GearIcon,
|
gear: GearIcon,
|
||||||
home: HomeIcon,
|
home: HomeIcon,
|
||||||
listBullet: ListBulletIcon,
|
listBullet: ListBulletIcon,
|
||||||
|
magicWand: MagicWandIcon,
|
||||||
|
magnifyingGlass: MagnifyingGlassIcon,
|
||||||
moon: MoonIcon,
|
moon: MoonIcon,
|
||||||
paperPlane: PaperPlaneIcon,
|
paperPlane: PaperPlaneIcon,
|
||||||
plus: PlusIcon,
|
plus: PlusIcon,
|
||||||
@@ -50,8 +56,6 @@ const icons = {
|
|||||||
triangleLeft: TriangleLeftIcon,
|
triangleLeft: TriangleLeftIcon,
|
||||||
triangleRight: TriangleRightIcon,
|
triangleRight: TriangleRightIcon,
|
||||||
update: UpdateIcon,
|
update: UpdateIcon,
|
||||||
magicWand: MagicWandIcon,
|
|
||||||
magnifyingGlass: MagnifyingGlassIcon,
|
|
||||||
x: Cross2Icon,
|
x: Cross2Icon,
|
||||||
empty: () => <span />,
|
empty: () => <span />,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user