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 icons

Kiran K2d50e2b391c9
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/library/folders/[folderId]/members/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/library/folders/[folderId]/members/page-client.tsx
index 2ad95339d1..dcb9649cc0 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/library/folders/[folderId]/members/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/library/folders/[folderId]/members/page-client.tsx
@@ -11,7 +11,7 @@ import {
} from "@/lib/swr/use-folder-permissions";
import useWorkspace from "@/lib/swr/use-workspace";
import { Folder, FolderUser } from "@/lib/types";
-import { FolderAccessIcon } from "@/ui/folders/folder-icon";
+import { FolderIcon } from "@/ui/folders/folder-icon";
import { RequestFolderEditAccessButton } from "@/ui/folders/request-edit-button";
import { FolderUserRole } from "@dub/prisma/client";
import { Avatar, BlurImage, Globe } from "@dub/ui";
@@ -106,7 +106,7 @@ export const FolderUsersPageClient = ({ folderId }: { folderId: string }) => {
{folder ? (
<>
<div className="flex items-center gap-x-6">
- <FolderAccessIcon folder={folder} />
+ <FolderIcon folder={folder} />
<div className="flex flex-col gap-2">
<span className="text-sm font-semibold leading-none text-gray-900">
{folder.name}
diff --git a/apps/web/ui/analytics/toggle.tsx b/apps/web/ui/analytics/toggle.tsx
index 2b3d3a6c94..df81bf23b3 100644
--- a/apps/web/ui/analytics/toggle.tsx
+++ b/apps/web/ui/analytics/toggle.tsx
@@ -78,7 +78,7 @@ import {
} from "react";
import useSWR from "swr";
import { useDebounce } from "use-debounce";
-import { FolderSquareIcon } from "../folders/folder-icon";
+import { FolderIcon } from "../folders/folder-icon";
import TagBadge from "../links/tag-badge";
import AnalyticsOptions from "./analytics-options";
import { AnalyticsContext } from "./analytics-provider";
@@ -423,21 +423,13 @@ export default function Toggle({
);
return folder ? (
- <FolderSquareIcon
- folder={folder}
- iconClassName="size-3"
- />
+ <FolderIcon folder={folder} shape="square" />
) : null;
},
options:
folders?.map((folder) => ({
value: folder.id,
- icon: (
- <FolderSquareIcon
- folder={folder}
- iconClassName="size-3"
- />
- ),
+ icon: <FolderIcon folder={folder} shape="square" />,
label: folder.name,
})) ?? null,
},
diff --git a/apps/web/ui/folders/folder-card.tsx b/apps/web/ui/folders/folder-card.tsx
index b2b68b86e4..67f49679a5 100644
--- a/apps/web/ui/folders/folder-card.tsx
+++ b/apps/web/ui/folders/folder-card.tsx
@@ -22,7 +22,7 @@ import { toast } from "sonner";
import { useDeleteFolderModal } from "../modals/delete-folder-modal";
import { useRenameFolderModal } from "../modals/rename-folder-modal";
import { Chart, Delete, ThreeDots } from "../shared/icons";
-import { FolderAccessIcon } from "./folder-icon";
+import { FolderIcon } from "./folder-icon";
import { useFolderPermissionsPanel } from "./folder-permissions-panel";
import { RequestFolderEditAccessButton } from "./request-edit-button";
@@ -48,7 +48,7 @@ export const FolderCard = ({ folder }: { folder: Folder }) => {
const { folderPermissionsPanel, setShowFolderPermissionsPanel } =
useFolderPermissionsPanel(folder);
- const isAllLinksFolder = folder.id === "unsorted";
+ const unsortedLinks = folder.id === "unsorted";
useKeyboardShortcut(
["r", "m", "x", "a", "i"],
@@ -77,7 +77,7 @@ export const FolderCard = ({ folder }: { folder: Folder }) => {
}
},
{
- enabled: openPopover || (isHovering && !isAllLinksFolder),
+ enabled: openPopover || (isHovering && !unsortedLinks),
},
);
@@ -100,10 +100,10 @@ export const FolderCard = ({ folder }: { folder: Folder }) => {
onMouseLeave={() => setIsHovering(false)}
>
<div className="flex items-center justify-between">
- <FolderAccessIcon folder={folder} />
+ <FolderIcon folder={folder} />
- {!isAllLinksFolder && (
- <div className="flex items-center justify-end gap-2">
+ {!unsortedLinks && (
+ <div className="flex items-center justify-end gap-1">
{!isPermissionsLoading && !canCreateLinks && (
<RequestFolderEditAccessButton
folderId={folder.id}
diff --git a/apps/web/ui/folders/folder-dropdown.tsx b/apps/web/ui/folders/folder-dropdown.tsx
index 1c1c9438fa..912cbce2d2 100644
--- a/apps/web/ui/folders/folder-dropdown.tsx
+++ b/apps/web/ui/folders/folder-dropdown.tsx
@@ -8,7 +8,7 @@ import Link from "next/link";
import { useSearchParams } from "next/navigation";
import { useEffect, useState } from "react";
import { useAddFolderModal } from "../modals/add-folder-modal";
-import { FolderSquareIcon } from "./folder-icon";
+import { FolderIcon } from "./folder-icon";
interface FolderDropdownProps {
onFolderSelect: (folder: FolderSummary) => void;
@@ -77,7 +77,7 @@ export const FolderDropdown = ({
setSelectedFolder(folder);
}}
>
- <FolderSquareIcon folder={folder} iconClassName="size-4" />
+ <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
@@ -113,10 +113,8 @@ export const FolderDropdown = ({
setShowAddFolderModal(true);
}}
>
- <FolderSquareIcon
- folder={{ id: "new", accessLevel: null }}
- iconClassName="size-4"
- />
+
+ <FolderIcon folder={{ id: "new", accessLevel: null }} shape="square" />
<span className="block truncate">Create new folder</span>
</button>
</div>
@@ -128,7 +126,7 @@ export const FolderDropdown = ({
>
<button className="group flex w-32 min-w-0 items-center gap-2 rounded-lg transition-colors duration-75">
{!hideFolderIcon && selectedFolder && (
- <FolderSquareIcon folder={selectedFolder} iconClassName="size-4" />
+ <FolderIcon folder={selectedFolder} shape="square" />
)}
<h1 className="min-w-0 truncate text-left text-lg font-medium leading-7 text-neutral-900">
diff --git a/apps/web/ui/folders/folder-icon.tsx b/apps/web/ui/folders/folder-icon.tsx
index 4ffdb94bcf..2685d19f3c 100644
--- a/apps/web/ui/folders/folder-icon.tsx
+++ b/apps/web/ui/folders/folder-icon.tsx
@@ -17,37 +17,37 @@ const folderIconsMap: Record<
{
borderColor: string;
bgColor: string;
- IconComponent: React.ElementType;
+ icon: React.ElementType;
}
> = {
- new: {
- borderColor: "border-gray-200",
- bgColor: "bg-gray-100",
- IconComponent: FolderPlus,
- },
- unsorted: {
- borderColor: "border-green-200",
- bgColor: "bg-green-100",
- IconComponent: FolderBookmark,
+ read: {
+ borderColor: "border-indigo-200",
+ bgColor: "bg-indigo-100",
+ icon: FolderShield,
},
write: {
borderColor: "border-blue-200",
bgColor: "bg-blue-100",
- IconComponent: FolderOpen,
- },
- read: {
- borderColor: "border-indigo-200",
- bgColor: "bg-indigo-100",
- IconComponent: FolderShield,
+ icon: FolderOpen,
},
none: {
borderColor: "border-orange-200",
bgColor: "bg-orange-100",
- IconComponent: FolderLock,
+ icon: FolderLock,
+ },
+ new: {
+ borderColor: "border-gray-200",
+ bgColor: "bg-gray-100",
+ icon: FolderPlus,
+ },
+ unsorted: {
+ borderColor: "border-green-200",
+ bgColor: "bg-green-100",
+ icon: FolderBookmark,
},
} as const;
-const findIconIdentifier = (
+const determineFolderIcon = (
folder: Pick<FolderProps, "id" | "accessLevel">,
) => {
if (["new", "unsorted"].includes(folder.id)) {
@@ -61,55 +61,44 @@ const findIconIdentifier = (
return "none";
};
-// TODO:
-// Combine with FolderSquareIcon with FolderAccessIcon
-
-export const FolderAccessIcon = ({
+export const FolderIcon = ({
folder,
circlePadding = "p-2.5",
- withBorder = true,
- className,
+ shape = "rounded",
}: {
folder: Pick<FolderProps, "id" | "accessLevel">;
circlePadding?: string;
- withBorder?: boolean;
- className?: string;
+ shape?: "rounded" | "square";
}) => {
- const { borderColor, bgColor, IconComponent } =
- folderIconsMap[findIconIdentifier(folder)];
+ const iconType = determineFolderIcon(folder);
+ const { borderColor, bgColor, icon: Icon } = folderIconsMap[iconType];
- if (!withBorder) {
- return (
- <div className={`${className} p-1.5 ${bgColor}`}>
- <IconComponent className="size-4" />
- </div>
- );
- }
+ const shapeClasses = shape === "rounded" ? "rounded-full" : "rounded-md";
return (
- <div className={cn("border", className, borderColor, bgColor)}>
- <div className={cn(circlePadding)}>
- <IconComponent className="size-4" />
+ <div className={cn(shapeClasses, "border", borderColor, bgColor)}>
+ <div className={cn(shape === "rounded" ? circlePadding : "p-1")}>
+ <Icon className={"size-4"} />
</div>
</div>
);
};
-export const FolderSquareIcon = ({
- folder,
- iconClassName,
-}: {
- folder: Pick<FolderProps, "id" | "accessLevel">;
- iconClassName?: string;
-}) => {
- const { borderColor, bgColor, IconComponent } =
- folderIconsMap[findIconIdentifier(folder)];
+// export const FolderSquareIcon = ({
+// folder,
+// iconClassName,
+// }: {
+// folder: Pick<FolderProps, "id" | "accessLevel">;
+// iconClassName?: string;
+// }) => {
+// const iconType = determineFolderIcon(folder);
+// const { borderColor, bgColor, icon: Icon } = folderIconsMap[iconType];
- return (
- <div className={cn("rounded-md border", borderColor, bgColor)}>
- <div className="p-1">
- <IconComponent className={iconClassName} />
- </div>
- </div>
- );
-};
+// return (
+// <div className={cn("rounded-md border", borderColor, bgColor)}>
+// <div className="p-1">
+// <Icon className={iconClassName} />
+// </div>
+// </div>
+// );
+// };
diff --git a/apps/web/ui/folders/folder-permissions-panel.tsx b/apps/web/ui/folders/folder-permissions-panel.tsx
index b993e1840d..9d2aa8b67d 100644
--- a/apps/web/ui/folders/folder-permissions-panel.tsx
+++ b/apps/web/ui/folders/folder-permissions-panel.tsx
@@ -20,7 +20,7 @@ import { toast } from "sonner";
import useSWR, { mutate } from "swr";
import { Drawer } from "vaul";
import { X } from "../shared/icons";
-import { FolderAccessIcon } from "./folder-icon";
+import { FolderIcon } from "./folder-icon";
import { RequestFolderEditAccessButton } from "./request-edit-button";
// TODO
@@ -124,7 +124,7 @@ const FolderPermissionsPanel = ({
<div className="px-8 py-6">
<div className="flex flex-col justify-between rounded-xl border border-gray-200 bg-white px-5 py-4 sm:h-36">
<div className="flex items-start justify-between">
- <FolderAccessIcon folder={folder} />
+ <FolderIcon folder={folder} />
{!isLoadingPermissions && !canCreateLinks && (
<RequestFolderEditAccessButton
folderId={folder.id}