);
});
diff --git a/src-web/components/WorkspaceDropdown.tsx b/src-web/components/WorkspaceDropdown.tsx
index cb6a90f7..f08246f7 100644
--- a/src-web/components/WorkspaceDropdown.tsx
+++ b/src-web/components/WorkspaceDropdown.tsx
@@ -1,8 +1,6 @@
import classnames from 'classnames';
import { memo, useMemo } from 'react';
-import { act } from 'react-dom/test-utils';
import { useActiveWorkspace } from '../hooks/useActiveWorkspace';
-import { useActiveWorkspaceId } from '../hooks/useActiveWorkspaceId';
import { useCreateWorkspace } from '../hooks/useCreateWorkspace';
import { useDeleteWorkspace } from '../hooks/useDeleteWorkspace';
import { useRoutes } from '../hooks/useRoutes';
@@ -36,17 +34,24 @@ export const WorkspaceDropdown = memo(function WorkspaceDropdown({ className }:
return [
...workspaceItems,
- '-----',
+ {
+ type: 'separator',
+ label: activeWorkspace?.name,
+ },
+ {
+ label: 'Delete',
+ leftSlot:
,
+ onSelect: () => deleteWorkspace.mutate(),
+ },
+ {
+ type: 'separator',
+ label: 'Actions',
+ },
{
label: 'New Workspace',
leftSlot:
,
onSelect: () => createWorkspace.mutate({ name: 'New Workspace' }),
},
- {
- label: 'Delete Workspace',
- leftSlot:
,
- onSelect: () => deleteWorkspace.mutate(),
- },
];
}, [workspaces, activeWorkspaceId]);
diff --git a/src-web/components/core/Dropdown.tsx b/src-web/components/core/Dropdown.tsx
index 02c65763..c01340b4 100644
--- a/src-web/components/core/Dropdown.tsx
+++ b/src-web/components/core/Dropdown.tsx
@@ -8,6 +8,7 @@ import { VStack } from './Stacks';
export type DropdownItem =
| {
+ type?: 'default';
label: string;
disabled?: boolean;
hidden?: boolean;
@@ -15,7 +16,10 @@ export type DropdownItem =
rightSlot?: ReactNode;
onSelect?: () => void;
}
- | '-----';
+ | {
+ type: 'separator';
+ label?: string;
+ };
export interface DropdownProps {
children: ReactElement
>;
@@ -93,7 +97,7 @@ function Menu({ className, items, onClose, triggerRect }: MenuProps) {
let nextIndex = (currIndex ?? 0) - 1;
const maxTries = items.length;
for (let i = 0; i < maxTries; i++) {
- if (items[nextIndex] === '-----') {
+ if (items[nextIndex]?.type === 'separator') {
nextIndex--;
} else if (nextIndex < 0) {
nextIndex = items.length - 1;
@@ -110,7 +114,7 @@ function Menu({ className, items, onClose, triggerRect }: MenuProps) {
let nextIndex = (currIndex ?? -1) + 1;
const maxTries = items.length;
for (let i = 0; i < maxTries; i++) {
- if (items[nextIndex] === '-----') {
+ if (items[nextIndex]?.type === 'separator') {
nextIndex++;
} else if (nextIndex >= items.length) {
nextIndex = 0;
@@ -122,26 +126,29 @@ function Menu({ className, items, onClose, triggerRect }: MenuProps) {
});
});
- const containerStyles: CSSProperties = useMemo(() => {
+ const { containerStyles, triangleStyles } = useMemo<{
+ containerStyles: CSSProperties;
+ triangleStyles: CSSProperties;
+ }>(() => {
const docWidth = document.documentElement.getBoundingClientRect().width;
const spaceRemaining = docWidth - triggerRect.left;
- if (spaceRemaining < 200) {
- return {
- top: triggerRect?.bottom,
- right: 0,
- };
- }
- return {
- top: triggerRect?.bottom,
- left: triggerRect?.left,
- };
+ const top = triggerRect?.bottom + 5;
+ const onRight = spaceRemaining < 200;
+ const containerStyles = onRight
+ ? { top, right: docWidth - triggerRect?.right }
+ : { top, left: triggerRect?.left };
+ const size = { top: '-0.2rem', width: '0.4rem', height: '0.4rem' };
+ const triangleStyles = onRight
+ ? { right: triggerRect.width / 2, marginRight: '-0.2rem', ...size }
+ : { left: triggerRect.width / 2, marginLeft: '-0.2rem', ...size };
+ return { containerStyles, triangleStyles };
}, [triggerRect]);
const handleSelect = useCallback(
(i: DropdownItem) => {
onClose();
setSelectedIndex(null);
- if (i !== '-----') {
+ if (i.type !== 'separator') {
i.onSelect?.();
}
},
@@ -160,6 +167,11 @@ function Menu({ className, items, onClose, triggerRect }: MenuProps) {
style={containerStyles}
className={classnames(className, 'pointer-events-auto fixed z-50')}
>
+
{containerStyles && (
{items.map((item, i) => {
- if (item === '-----') return ;
+ if (item.type === 'separator')
+ return ;
if (item.hidden) return null;
return (
;
+ if (item.type === 'separator') return ;
return (
+
);
}
diff --git a/tailwind.config.cjs b/tailwind.config.cjs
index 935ef399..1bd38959 100644
--- a/tailwind.config.cjs
+++ b/tailwind.config.cjs
@@ -10,6 +10,9 @@ module.exports = {
opacity: {
"disabled": "0.3"
},
+ fontSize: {
+ "xs": "0.8rem"
+ },
height: {
"xs": "1.5rem",
"sm": "2.00rem",