Skip to content

Commit 46eb988

Browse files
authored
feat(545): Add close Collection Button and closing Logic (#570)
* 545-Add close collection button and closing logic Adding the closing button with the given close icon. Use same functionallity as not found collections to close a collection To ensure proper updates the collections state is filtered. With these changes, collections can be removed from the collections dropdown menu without deleting them from the system. * 545- Adapt button style to fit the overall style Changing the text style, adding a hover functionality. Fixing the centering of text by changing the span to p. * 545-Fixing alignment to the right side of the dropdown menu The close button is now aligned to the right side of the dropdown menu to fit the overall style. * 545-Removing closing button for first collection The closing button is removed for the first collection as this collection is required for proper execution.
1 parent 1108e63 commit 46eb988

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/renderer/components/sidebar/CollectionDropdown.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { RendererEventService } from '@/services/event/renderer-event-service';
1515
import { useCallback, useEffect, useState } from 'react';
1616
import { CollectionBase } from 'shim/objects/collection';
1717
import { FolderOpen, FolderPlus, Upload } from 'lucide-react';
18+
import { CloseIcon } from '@/components/icons';
19+
import { cn } from '@/lib/utils';
1820

1921
const eventService = RendererEventService.instance;
2022

@@ -71,7 +73,22 @@ export default function CollectionDropdown() {
7173
() =>
7274
collections.map(({ title, dirPath }, i) => (
7375
<DropdownMenuRadioItem key={i} value={dirPath}>
74-
{title}
76+
<p className="flex-1 pr-2">{title}</p>
77+
{i !== 0 && (
78+
<button
79+
onClick={async (e) => {
80+
e.stopPropagation();
81+
await eventService.closeCollection(dirPath);
82+
setCollections((prev) => prev.filter((c) => c.dirPath !== dirPath));
83+
}}
84+
className={cn(
85+
'text-popover-foreground flex h-6 w-6 items-center justify-center rounded-md opacity-0',
86+
'hover:text-popover-foreground hover:bg-popover hover:opacity-100'
87+
)}
88+
>
89+
<CloseIcon size={24} />
90+
</button>
91+
)}
7592
</DropdownMenuRadioItem>
7693
)),
7794
[collections]

0 commit comments

Comments
 (0)