Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update folder-dropdown.tsx

Steven Teyfac8ed5fb6da
diff --git a/apps/web/ui/folders/folder-dropdown.tsx b/apps/web/ui/folders/folder-dropdown.tsx
index 5b6cc792c3..3516ea9b3c 100644
--- a/apps/web/ui/folders/folder-dropdown.tsx
+++ b/apps/web/ui/folders/folder-dropdown.tsx
@@ -13,14 +13,12 @@ import { FolderIcon } from "./folder-icon";
interface FolderDropdownProps {
onFolderSelect: (folder: FolderSummary) => void;
- hideViewAll?: boolean;
hideFolderIcon?: boolean;
textClassName?: string;
}
export const FolderDropdown = ({
onFolderSelect,
- hideViewAll = false,
hideFolderIcon = false,
textClassName,
}: FolderDropdownProps) => {
@@ -60,93 +58,88 @@ export const FolderDropdown = ({
<AddFolderModal />
<Popover
content={
- folders && (
- <div className="relative mt-1 max-h-80 w-full space-y-0.5 overflow-auto rounded-md bg-white p-2 text-base sm:w-60 sm:text-sm sm:shadow-lg">
- <div className="flex items-center justify-between px-2 pb-1">
- <p className="text-xs font-medium text-neutral-500">Folders</p>
- {!hideViewAll && folders.length > 0 && (
- <Link
- href={`/${slug}/settings/library/folders`}
- onClick={() => setOpenPopover(false)}
- className="rounded-md border border-neutral-200 px-2 py-1 text-xs transition-colors hover:bg-neutral-100"
- >
- View All
- </Link>
- )}
- </div>
+ <div className="relative mt-1 max-h-80 w-full space-y-0.5 overflow-auto rounded-md bg-white p-2 text-base sm:w-60 sm:text-sm sm:shadow-lg">
+ <div className="flex items-center justify-between px-2 pb-1">
+ <p className="text-xs font-medium text-neutral-500">Folders</p>
+ <Link
+ href={`/${slug}/settings/library/folders`}
+ onClick={() => setOpenPopover(false)}
+ className="rounded-md border border-neutral-200 px-2 py-1 text-xs transition-colors hover:bg-neutral-100"
+ >
+ View All
+ </Link>
+ </div>
- {[unsortedLinks, ...folders].map((folder) => {
- return (
- <Link
- key={folder.id}
- href={`/${slug}?folderId=${folder.id}`}
- className={cn(
- "relative flex w-full items-center gap-x-2 rounded-md px-2 py-1.5 transition-all duration-75 hover:bg-neutral-100 active:bg-neutral-200",
- {
- "font-medium": selectedFolder?.id === folder.id,
- },
- )}
- onClick={() => {
- setOpenPopover(false);
- setSelectedFolder(folder);
- onFolderSelect?.(folder);
- }}
+ {[unsortedLinks, ...(folders || [])].map((folder) => {
+ return (
+ <Link
+ key={folder.id}
+ href={`/${slug}?folderId=${folder.id}`}
+ className={cn(
+ "relative flex w-full items-center gap-x-2 rounded-md px-2 py-1.5 transition-all duration-75 hover:bg-neutral-100 active:bg-neutral-200",
+ {
+ "font-medium": selectedFolder?.id === folder.id,
+ },
+ )}
+ onClick={() => {
+ setOpenPopover(false);
+ onFolderSelect?.(folder);
+ }}
+ >
+ <FolderIcon folder={folder} shape="square" />
+ <span
+ className={`flex items-center justify-start gap-1.5 text-sm sm:max-w-[140px] ${
+ selectedFolder?.id === folder.id
+ ? "font-medium"
+ : "font-normal"
+ }`}
>
- <FolderIcon folder={folder} shape="square" />
- <span
- className={`flex items-center justify-start gap-1.5 text-sm sm:max-w-[140px] ${
- selectedFolder?.id === folder.id
- ? "font-medium"
- : "font-normal"
- }`}
- >
- <span className="truncate">{folder.name}</span>
+ <span className="truncate">{folder.name}</span>
- {folder.id === "unsorted" && (
- <div className="rounded bg-neutral-100 p-1">
- <div className="text-xs font-normal text-black">
- Unsorted
- </div>
+ {folder.id === "unsorted" && (
+ <div className="rounded bg-neutral-100 p-1">
+ <div className="text-xs font-normal text-black">
+ Unsorted
</div>
- )}
- </span>
-
- {selectedFolder?.id === folder.id && (
- <span className="absolute inset-y-0 right-0 flex items-center pr-3 text-black">
- <Tick className="size-5" aria-hidden="true" />
- </span>
+ </div>
)}
- </Link>
- );
- })}
+ </span>
+
+ {selectedFolder?.id === folder.id && (
+ <span className="absolute inset-y-0 right-0 flex items-center pr-3 text-black">
+ <Tick className="size-5" aria-hidden="true" />
+ </span>
+ )}
+ </Link>
+ );
+ })}
- <Button
- key="add-folder"
- variant="outline"
- icon={
- <FolderIcon
- folder={{ id: "new", accessLevel: null }}
- shape="square"
+ <Button
+ key="add-folder"
+ variant="outline"
+ icon={
+ <FolderIcon
+ folder={{ id: "new", accessLevel: null }}
+ shape="square"
+ />
+ }
+ text="Create new folder"
+ className="justify-start px-2"
+ onClick={() => {
+ setOpenPopover(false);
+ setShowAddFolderModal(true);
+ }}
+ disabledTooltip={
+ plan === "free" && (
+ <TooltipContent
+ title="You can only use Link Folders on a Pro plan and above. Upgrade to Pro to continue."
+ cta="Upgrade to Pro"
+ href={`/${slug}/upgrade`}
/>
- }
- text="Create new folder"
- className="justify-start px-2"
- onClick={() => {
- setOpenPopover(false);
- setShowAddFolderModal(true);
- }}
- disabledTooltip={
- plan === "free" && (
- <TooltipContent
- title="You can only use Link Folders on a Pro plan and above. Upgrade to Pro to continue."
- cta="Upgrade to Pro"
- href={`/${slug}/upgrade`}
- />
- )
- }
- />
- </div>
- )
+ )
+ }
+ />
+ </div>
}
openPopover={openPopover}
setOpenPopover={setOpenPopover}
@@ -156,11 +149,8 @@ export const FolderDropdown = ({
<button
className={cn(
"group flex max-w-60 items-center gap-2 rounded-lg px-2 py-1",
- isLoading
- ? "cursor-not-allowed"
- : "transition-colors hover:bg-neutral-100 active:bg-neutral-200 data-[state=open]:bg-neutral-100",
+ "transition-colors hover:bg-neutral-100 active:bg-neutral-200 data-[state=open]:bg-neutral-100",
)}
- disabled={isLoading}
>
{!hideFolderIcon && selectedFolder && (
<FolderIcon folder={selectedFolder} shape="square" />