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.

fix folder icon

Kiran K9f97ca19a83b
diff --git a/apps/web/lib/folder/types.ts b/apps/web/lib/folder/types.ts
index 0092135bca..ec2cbbdccb 100644
--- a/apps/web/lib/folder/types.ts
+++ b/apps/web/lib/folder/types.ts
@@ -26,6 +26,6 @@ export type FolderSummary = Pick<
export const unsortedLinks: FolderSummary = {
id: "unsorted",
name: "Links",
- accessLevel: "edit",
+ accessLevel: null,
linkCount: -1,
};
diff --git a/apps/web/ui/analytics/toggle.tsx b/apps/web/ui/analytics/toggle.tsx
index 16f98a6800..3ccf859fef 100644
--- a/apps/web/ui/analytics/toggle.tsx
+++ b/apps/web/ui/analytics/toggle.tsx
@@ -418,22 +418,14 @@ export default function Toggle({
const folder = folders?.find(({ name }) => name === folderName);
return folder ? (
- <FolderSquareIcon
- folder={folder}
- className="p-1"
- iconSize="size-3"
- />
+ <FolderSquareIcon folder={folder} iconClassName="size-3" />
) : null;
},
options:
folders?.map((folder) => ({
value: folder.id,
icon: (
- <FolderSquareIcon
- folder={folder}
- className="p-1"
- iconSize="size-3"
- />
+ <FolderSquareIcon folder={folder} iconClassName="size-3" />
),
label: folder.name,
})) ?? null,
diff --git a/apps/web/ui/folders/folder-dropdown.tsx b/apps/web/ui/folders/folder-dropdown.tsx
index b511c773bc..8eac7f2640 100644
--- a/apps/web/ui/folders/folder-dropdown.tsx
+++ b/apps/web/ui/folders/folder-dropdown.tsx
@@ -90,7 +90,7 @@ export const FolderDropdown = ({
setSelectedFolder(folder);
}}
>
- <FolderSquareIcon folder={folder} />
+ <FolderSquareIcon folder={folder} iconClassName="size-4" />
<span
className={`flex items-center justify-start gap-1.5 text-sm sm:max-w-[140px] ${
selectedFolder?.id === folder.id
@@ -126,7 +126,10 @@ export const FolderDropdown = ({
setShowAddFolderModal(true);
}}
>
- <FolderSquareIcon folder={{ id: "new", accessLevel: null }} />
+ <FolderSquareIcon
+ folder={{ id: "new", accessLevel: null }}
+ iconClassName="size-4"
+ />
<span className="block truncate">Create new folder</span>
</button>
</div>
@@ -137,7 +140,9 @@ export const FolderDropdown = ({
popoverContentClassName="-ml-1"
>
<button className="group flex w-36 min-w-0 items-center gap-2 rounded-lg transition-colors duration-75 hover:bg-gray-100 data-[state=open]:bg-gray-200">
- {selectedFolder && <FolderSquareIcon folder={selectedFolder} />}
+ {selectedFolder && (
+ <FolderSquareIcon folder={selectedFolder} iconClassName="size-4" />
+ )}
<h1 className="min-w-0 truncate text-left text-lg font-medium leading-7 text-neutral-900">
{selectedFolder?.name}
</h1>
diff --git a/apps/web/ui/folders/folder-icon.tsx b/apps/web/ui/folders/folder-icon.tsx
index cdbba44a9d..6c098a5e71 100644
--- a/apps/web/ui/folders/folder-icon.tsx
+++ b/apps/web/ui/folders/folder-icon.tsx
@@ -8,9 +8,6 @@ import {
} from "@dub/ui/icons";
import { cn } from "@dub/utils";
-// TODO:
-// Cleanup the icons and make them more consistent
-
const FolderOpen = ({ className }: { className: string }) => {
return <Folder className={cn("text-blue-800", className)} />;
};
@@ -51,6 +48,9 @@ const accessLevelMap = {
edit: "open",
} as const;
+// TODO:
+// Combine with FolderSquareIcon with FolderAccessIcon
+
export const FolderAccessIcon = ({
folder,
circlePadding = "p-2.5",
@@ -70,27 +70,6 @@ export const FolderAccessIcon = ({
return null;
}
- return (
- <FolderIcon
- type={type}
- circlePadding={circlePadding}
- withBorder={withBorder}
- className={className}
- />
- );
-};
-
-const FolderIcon = ({
- type = "open",
- circlePadding = "p-2.5",
- withBorder = true,
- className = "rounded-full",
-}: {
- type: "unsorted" | "private" | "restricted" | "open";
- circlePadding?: string;
- withBorder?: boolean;
- className?: string;
-}) => {
const { borderColor, bgColor, IconComponent } = folderIconsMap[type];
if (!withBorder) {
@@ -112,27 +91,25 @@ const FolderIcon = ({
export const FolderSquareIcon = ({
folder,
- className,
- iconSize = "size-4",
+ iconClassName,
}: {
folder: Pick<FolderProps, "id" | "accessLevel">;
- className?: string;
- iconSize?: string;
+ iconClassName?: string;
}) => {
- const type =
+ const folderType =
accessLevelMap[folder.id] ||
accessLevelMap[folder.accessLevel || "private"];
- if (!type) {
+ if (!folderType) {
return null;
}
- const { borderColor, bgColor, IconComponent } = folderIconsMap[type];
+ const { borderColor, bgColor, IconComponent } = folderIconsMap[folderType];
return (
<div className={cn("rounded-md border", borderColor, bgColor)}>
- <div className={className}>
- <IconComponent className={iconSize} />
+ <div className="p-1">
+ <IconComponent className={iconClassName} />
</div>
</div>
);