Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

refactored the design into a more modern look by removing the navbar and consolidating everything into the sidebar + improved UX

daniel31x139fc5fa278087
diff --git a/apps/mobile/components/ActionSheets/AddLinkSheet.tsx b/apps/mobile/components/ActionSheets/AddLinkSheet.tsx
index d0b91d38..4cc5c815 100644
--- a/apps/mobile/components/ActionSheets/AddLinkSheet.tsx
+++ b/apps/mobile/components/ActionSheets/AddLinkSheet.tsx
@@ -105,9 +105,9 @@ export default function AddLinkSheet(props: SheetProps<"add-link-sheet">) {
setLink("");
}}
isLoading={addLink.isPending}
- variant="accent"
+ variant="primary"
>
- <Text className="text-white">Save to Linkwarden</Text>
+ <Text className="text-base-100">Save to Linkwarden</Text>
</Button>
</View>
</ActionSheet>
diff --git a/apps/mobile/components/ActionSheets/AddTagSheet.tsx b/apps/mobile/components/ActionSheets/AddTagSheet.tsx
index 0479dc9a..bef4dce4 100644
--- a/apps/mobile/components/ActionSheets/AddTagSheet.tsx
+++ b/apps/mobile/components/ActionSheets/AddTagSheet.tsx
@@ -65,9 +65,9 @@ export default function AddTagSheet() {
}
disabled={name.trim().length === 0}
isLoading={upsertTags.isPending}
- variant="accent"
+ variant="primary"
>
- <Text className="text-white">Save Tag</Text>
+ <Text className="text-base-100">Save Tag</Text>
</Button>
</View>
</ActionSheet>
diff --git a/apps/mobile/components/ActionSheets/EditLinkSheet.tsx b/apps/mobile/components/ActionSheets/EditLinkSheet.tsx
index 6f7967de..6e15e10d 100644
--- a/apps/mobile/components/ActionSheets/EditLinkSheet.tsx
+++ b/apps/mobile/components/ActionSheets/EditLinkSheet.tsx
@@ -240,11 +240,9 @@ const Main = (props: SheetProps<"edit-link-sheet">) => {
.catch(() => null);
if (uploaded) {
- await seedFormatCache(
- link.id,
- "preview",
- newBanner.uri
- ).catch(() => {});
+ await seedFormatCache(link.id, "preview", newBanner.uri).catch(
+ () => {}
+ );
}
}
@@ -256,9 +254,9 @@ const Main = (props: SheetProps<"edit-link-sheet">) => {
SheetManager.hide("edit-link-sheet");
}}
isLoading={updateLink.isPending || updateFile.isPending}
- variant="accent"
+ variant="primary"
>
- <Text className="text-white">Save</Text>
+ <Text className="text-base-100">Save</Text>
</Button>
</View>
</>
diff --git a/apps/mobile/components/ActionSheets/NewCollectionSheet.tsx b/apps/mobile/components/ActionSheets/NewCollectionSheet.tsx
index 8b64a801..97aaeb68 100644
--- a/apps/mobile/components/ActionSheets/NewCollectionSheet.tsx
+++ b/apps/mobile/components/ActionSheets/NewCollectionSheet.tsx
@@ -87,9 +87,9 @@ export default function NewCollectionSheet() {
)
}
isLoading={createCollection.isPending}
- variant="accent"
+ variant="primary"
>
- <Text className="text-white">Save Collection</Text>
+ <Text className="text-base-100">Save Collection</Text>
</Button>
</View>
</ActionSheet>
diff --git a/apps/mobile/components/ActionSheets/ReadableHighlightSheet.tsx b/apps/mobile/components/ActionSheets/ReadableHighlightSheet.tsx
index 9944a8c0..bea637cd 100644
--- a/apps/mobile/components/ActionSheets/ReadableHighlightSheet.tsx
+++ b/apps/mobile/components/ActionSheets/ReadableHighlightSheet.tsx
@@ -211,10 +211,10 @@ export default function ReadableHighlightSheet(
onPress={handleSave}
isLoading={saveHighlight.isPending}
disabled={!draft || deleteHighlight.isPending}
- variant="accent"
+ variant="primary"
className="mb-2"
>
- <Text className="text-white">Save</Text>
+ <Text className="text-base-100">Save</Text>
</Button>
{draft?.highlightId ? (
diff --git a/apps/mobile/components/ActionSheets/WhatsNewSheet.tsx b/apps/mobile/components/ActionSheets/WhatsNewSheet.tsx
index 332c85a4..a5acc778 100644
--- a/apps/mobile/components/ActionSheets/WhatsNewSheet.tsx
+++ b/apps/mobile/components/ActionSheets/WhatsNewSheet.tsx
@@ -72,8 +72,8 @@ export default function WhatsNewSheet() {
})}
<View className="flex-col gap-3">
- <Button variant="accent" size="lg" onPress={closeSheet}>
- <Text className="text-white text-xl">Got it</Text>
+ <Button variant="primary" size="lg" onPress={closeSheet}>
+ <Text className="text-base-100 text-xl">Got it</Text>
</Button>
{WHATS_NEW_LEARN_MORE_URL && (
diff --git a/apps/mobile/components/DashboardSection.tsx b/apps/mobile/components/DashboardSection.tsx
index 0e8a3c91..050469c2 100644
--- a/apps/mobile/components/DashboardSection.tsx
+++ b/apps/mobile/components/DashboardSection.tsx
@@ -145,7 +145,7 @@ const DashboardSection: React.FC<DashboardSectionProps> = ({
</Text>
{/* <View className="text-center w-full mt-4 flex-row flex-wrap gap-4 justify-center">
- <Button onPress={() => setNewLinkModal(true)} variant="accent">
+ <Button onPress={() => setNewLinkModal(true)} variant="primary">
<Icon name="bi-plus-lg" className="text-xl" />
<Text>{t("add_link")}</Text>
</Button>
diff --git a/apps/web/components/AdminSidebar.tsx b/apps/web/components/AdminSidebar.tsx
index b6ab5273..871e792f 100644
--- a/apps/web/components/AdminSidebar.tsx
+++ b/apps/web/components/AdminSidebar.tsx
@@ -1,125 +1,34 @@
-import Link from "next/link";
-import { useRouter } from "next/router";
-import React, { useEffect, useState } from "react";
import { useTranslation } from "next-i18next";
-import { useUser } from "@linkwarden/router/user";
-import Image from "next/image";
+import SecondarySidebar from "@/components/SecondarySidebar";
-export default function AdminSidebar({ className }: { className?: string }) {
+export default function AdminSidebar({
+ className,
+ toggleSidebar,
+ sidebarIsCollapsed,
+}: {
+ className?: string;
+ toggleSidebar?: () => void;
+ sidebarIsCollapsed?: boolean;
+}) {
const { t } = useTranslation();
- const LINKWARDEN_VERSION = process.env.version;
-
- const { data: user } = useUser();
-
- const router = useRouter();
- const [active, setActive] = useState("");
-
- useEffect(() => {
- setActive(router.asPath);
- }, [router]);
return (
- <div
- className={`bg-base-200 h-screen w-80 overflow-y-auto border-solid border border-base-200 border-r-neutral-content p-2 z-20 flex flex-col gap-5 justify-between ${
- className || ""
- }`}
- >
- <div className="flex flex-col gap-1">
- <div className="flex items-center justify-between mb-4">
- {user?.theme === "light" ? (
- <Image
- src={"/linkwarden_light.png"}
- width={640}
- height={136}
- alt="Linkwarden"
- className="h-9 w-auto cursor-pointer"
- onClick={() => router.push("/dashboard")}
- priority
- />
- ) : (
- <Image
- src={"/linkwarden_dark.png"}
- width={640}
- height={136}
- alt="Linkwarden"
- className="h-9 w-auto cursor-pointer"
- onClick={() => router.push("/dashboard")}
- priority
- />
- )}
- </div>
- <Link href="/admin/user-administration">
- <div
- className={`${
- active === "/admin/user-administration"
- ? "bg-primary/20"
- : "hover:bg-neutral/20"
- } duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-people text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">
- {t("user_administration")}
- </p>
- </div>
- </Link>
-
- <Link href="/admin/background-jobs">
- <div
- className={`${
- active === "/admin/background-jobs"
- ? "bg-primary/20"
- : "hover:bg-neutral/20"
- } duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-gear-wide-connected text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">
- {t("background_jobs")}
- </p>
- </div>
- </Link>
- </div>
-
- <div className="flex flex-col gap-1">
- <Link
- href={`https://github.com/linkwarden/linkwarden/releases`}
- target="_blank"
- className="text-neutral text-sm ml-2 hover:opacity-50 duration-100"
- >
- {t("linkwarden_version", { version: LINKWARDEN_VERSION })}
- </Link>
- <Link href="https://docs.linkwarden.app" target="_blank">
- <div
- className={`hover:bg-neutral/20 duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-question-circle text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">{t("help")}</p>
- </div>
- </Link>
- <Link href="https://github.com/linkwarden/linkwarden" target="_blank">
- <div
- className={`hover:bg-neutral/20 duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-github text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">{t("github")}</p>
- </div>
- </Link>
- <Link href="https://twitter.com/LinkwardenHQ" target="_blank">
- <div
- className={`hover:bg-neutral/20 duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-twitter-x text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">{t("twitter")}</p>
- </div>
- </Link>
- <Link href="https://fosstodon.org/@linkwarden" target="_blank">
- <div
- className={`hover:bg-neutral/20 duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-mastodon text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">{t("mastodon")}</p>
- </div>
- </Link>
- </div>
- </div>
+ <SecondarySidebar
+ className={className}
+ toggleSidebar={toggleSidebar}
+ sidebarIsCollapsed={sidebarIsCollapsed}
+ links={[
+ {
+ title: t("user_administration"),
+ href: "/admin/user-administration",
+ icon: "bi-people",
+ },
+ {
+ title: t("background_jobs"),
+ href: "/admin/background-jobs",
+ icon: "bi-gear-wide-connected",
+ },
+ ]}
+ />
);
}
diff --git a/apps/web/components/CollectionCard.tsx b/apps/web/components/CollectionCard.tsx
index 506da7e3..e12b09e1 100644
--- a/apps/web/components/CollectionCard.tsx
+++ b/apps/web/components/CollectionCard.tsx
@@ -166,7 +166,7 @@ export default function CollectionCard({
}}
className="card card-compact shadow-md hover:shadow-none duration-200 border border-neutral-content"
>
- <div className="card-body flex flex-col justify-between min-h-[12rem]">
+ <div className="card-body flex flex-col justify-between">
<div className="flex justify-between">
<p className="card-title break-words line-clamp-2 w-full">
{collection.name}
diff --git a/apps/web/components/CollectionListing.tsx b/apps/web/components/CollectionListing.tsx
index cd7488e4..117d977d 100644
--- a/apps/web/components/CollectionListing.tsx
+++ b/apps/web/components/CollectionListing.tsx
@@ -271,7 +271,7 @@ const CollectionListing = () => {
);
} else if (!tree) {
return (
- <p className="text-neutral text-xs font-semibold truncate w-full px-2 mt-5 mb-8">
+ <p className="text-neutral text-xs font-semibold truncate w-full px-2">
{t("you_have_no_collections")}
</p>
);
@@ -322,7 +322,7 @@ const renderItem = (
: droppableActive
? "select-none"
: "hover:bg-neutral/20",
- "duration-100 flex gap-1 items-center pr-2 pl-1 rounded-md"
+ "relative duration-100 flex items-center pr-2 rounded-md"
)}
>
{Dropdown(item as ExtendedTreeItem, onExpand, onCollapse)}
@@ -333,24 +333,24 @@ const renderItem = (
{...provided.dragHandleProps}
>
<div
- className={`py-1 cursor-pointer flex items-center gap-2 w-full rounded-md h-8`}
+ className={`cursor-pointer flex items-center gap-2 w-full pl-5 rounded-md`}
>
{collection.icon ? (
<Icon
icon={collection.icon}
- size={30}
+ size={28}
weight={(collection.iconWeight || "regular") as IconWeight}
color={collection.color}
className="-mr-[0.15rem]"
/>
) : (
<i
- className="bi-folder-fill text-xl"
+ className="bi-folder-fill text-lg"
style={{ color: collection.color }}
></i>
)}
- <p className="truncate w-full">{collection.name}</p>
+ <p className="truncate w-full text-xs">{collection.name}</p>
{collection.isPublic && (
<i
@@ -374,19 +374,25 @@ const Dropdown = (
onExpand: (id: ItemId) => void,
onCollapse: (id: ItemId) => void
) => {
- if (item.children && item.children.length > 0) {
- return item.isExpanded ? (
- <button onClick={() => onCollapse(item.id)}>
- <div className="bi-caret-down-fill opacity-50 hover:opacity-100 duration-200"></div>
- </button>
- ) : (
- <button onClick={() => onExpand(item.id)}>
- <div className="bi-caret-right-fill opacity-40 hover:opacity-100 duration-200"></div>
- </button>
- );
+ if (!item.children || item.children.length === 0) {
+ return null;
}
- // return <span>&bull;</span>;
- return <div></div>;
+
+ return item.isExpanded ? (
+ <button
+ onClick={() => onCollapse(item.id)}
+ className="absolute left-0.5 top-1/2 -translate-y-1/2 flex items-center justify-center"
+ >
+ <div className="bi-caret-down-fill opacity-50 hover:opacity-100 duration-200"></div>
+ </button>
+ ) : (
+ <button
+ onClick={() => onExpand(item.id)}
+ className="absolute left-0.5 top-1/2 -translate-y-1/2 flex items-center justify-center"
+ >
+ <div className="bi-caret-right-fill opacity-40 hover:opacity-100 duration-200"></div>
+ </button>
+ );
};
const buildTreeFromCollections = (
diff --git a/apps/web/components/DashboardLayoutDropdown.tsx b/apps/web/components/DashboardLayoutDropdown.tsx
index a456486f..c940b465 100644
--- a/apps/web/components/DashboardLayoutDropdown.tsx
+++ b/apps/web/components/DashboardLayoutDropdown.tsx
@@ -263,7 +263,7 @@ export default function DashboardLayoutDropdown() {
<DropdownMenu modal>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="sm" className="h-8">
- <i className="bi-sliders2-vertical text-neutral" />
+ <i className="bi-pencil text-neutral" />
{t("edit_layout")}
</Button>
</DropdownMenuTrigger>
diff --git a/apps/web/components/DragNDrop.tsx b/apps/web/components/DragNDrop.tsx
index 52759923..77f54ee4 100644
--- a/apps/web/components/DragNDrop.tsx
+++ b/apps/web/components/DragNDrop.tsx
@@ -91,6 +91,9 @@ export default function DragNDrop({
}
const { over, active } = event;
+
+ setActiveLink(null);
+
if (!over || !activeLink) return;
const overData = over.data.current;
@@ -98,8 +101,6 @@ export default function DragNDrop({
const isFromRecentSection = active.data.current?.dashboardType === "recent";
- setActiveLink(null);
-
const mutateWithToast = async (
updatedLink: LinkIncludingShortenedCollectionAndTags,
opts?: { invalidateDashboardOnError?: boolean }
@@ -242,6 +243,7 @@ export default function DragNDrop({
{!!activeLink && (
// when drag end, immediately hide the overlay
<DragOverlay
+ dropAnimation={null}
style={{
zIndex: 100,
pointerEvents: "none",
diff --git a/apps/web/components/LinkDetails.tsx b/apps/web/components/LinkDetails.tsx
index 5ed182ed..cd2c315e 100644
--- a/apps/web/components/LinkDetails.tsx
+++ b/apps/web/components/LinkDetails.tsx
@@ -628,7 +628,7 @@ export default function LinkDetails({
<br />
<div className="flex justify-end items-center">
<Button
- variant="accent"
+ variant="primary"
disabled={JSON.stringify(activeLink) === JSON.stringify(link)}
onClick={submit}
>
diff --git a/apps/web/components/MobileNavigation.tsx b/apps/web/components/MobileNavigation.tsx
deleted file mode 100644
index d220721f..00000000
--- a/apps/web/components/MobileNavigation.tsx
+++ /dev/null
@@ -1,84 +0,0 @@
-import { isIphone, isPWA } from "@/lib/utils";
-import React from "react";
-import { useState } from "react";
-import NewLinkModal from "./ModalContent/NewLinkModal";
-import NewCollectionModal from "./ModalContent/NewCollectionModal";
-import UploadFileModal from "./ModalContent/UploadFileModal";
-import MobileNavigationButton from "./MobileNavigationButton";
-import { useTranslation } from "next-i18next";
-import {
- DropdownMenu,
- DropdownMenuTrigger,
- DropdownMenuContent,
- DropdownMenuItem,
-} from "@/components/ui/dropdown-menu";
-import { Button } from "./ui/button";
-
-type Props = {};
-
-export default function MobileNavigation({}: Props) {
- const { t } = useTranslation();
- const [newLinkModal, setNewLinkModal] = useState(false);
- const [newCollectionModal, setNewCollectionModal] = useState(false);
- const [uploadFileModal, setUploadFileModal] = useState(false);
-
- return (
- <>
- <div
- className={`fixed bottom-0 left-0 right-0 z-30 duration-200 sm:hidden`}
- >
- <div
- className={`w-full flex bg-base-100 ${
- isIphone() && isPWA() ? "pb-5" : ""
- } border-solid border-t-neutral-content border-t`}
- >
- <MobileNavigationButton href={`/dashboard`} icon={"bi-house"} />
- <MobileNavigationButton
- href={`/links/pinned`}
- icon={"bi-pin-angle"}
- />
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- className="-mt-4 flex items-center w-20 h-20 aspect-square px-2 relative rounded-full"
- variant="accent"
- >
- <i className="bi-plus text-5xl pointer-events-none"></i>
- </Button>
- </DropdownMenuTrigger>
-
- <DropdownMenuContent>
- <DropdownMenuItem onSelect={() => setNewLinkModal(true)}>
- <i className="bi-link-45deg"></i>
- {t("new_link")}
- </DropdownMenuItem>
- <DropdownMenuItem onSelect={() => setUploadFileModal(true)}>
- <i className="bi-file-earmark-arrow-up"></i>
- {t("upload_file")}
- </DropdownMenuItem>
- <DropdownMenuItem onSelect={() => setNewCollectionModal(true)}>
- <i className="bi-folder"></i>
- {t("new_collection")}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- <MobileNavigationButton href={`/links`} icon={"bi-link-45deg"} />
- <MobileNavigationButton href={`/collections`} icon={"bi-folder"} />
- </div>
- </div>
- {newLinkModal && (
- <NewLinkModal
- onClose={() => {
- setNewLinkModal(false);
- }}
- />
- )}
- {newCollectionModal && (
- <NewCollectionModal onClose={() => setNewCollectionModal(false)} />
- )}
- {uploadFileModal && (
- <UploadFileModal onClose={() => setUploadFileModal(false)} />
- )}
- </>
- );
-}
diff --git a/apps/web/components/MobileNavigationButton.tsx b/apps/web/components/MobileNavigationButton.tsx
deleted file mode 100644
index 4369c585..00000000
--- a/apps/web/components/MobileNavigationButton.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { isPWA } from "@/lib/utils";
-import Link from "next/link";
-import { useRouter } from "next/router";
-import { useEffect, useState } from "react";
-
-export default function MobileNavigationButton({
- href,
- icon,
-}: {
- href: string;
- icon: string;
-}) {
- const router = useRouter();
- const [active, setActive] = useState(false);
-
- useEffect(() => {
- setActive(href === router.asPath);
- }, [router]);
-
- return (
- <Link
- href={href}
- className="w-full active:scale-[80%] duration-200 select-none"
- draggable="false"
- style={{ WebkitTouchCallout: "none" }}
- onContextMenu={(e) => {
- if (isPWA()) {
- e.preventDefault();
- e.stopPropagation();
- return false;
- } else return null;
- }}
- >
- <div
- className={`py-2 cursor-pointer gap-2 w-full rounded-full capitalize flex items-center justify-center`}
- >
- <i
- className={`${icon} text-primary text-3xl drop-shadow duration-200 rounded-full w-14 h-14 text-center pt-[0.65rem] ${
- active || false ? "bg-primary/20" : ""
- }`}
- ></i>
- </div>
- </Link>
- );
-}
diff --git a/apps/web/components/Modal.tsx b/apps/web/components/Modal.tsx
index 7544ef43..448b4a9f 100644
--- a/apps/web/components/Modal.tsx
+++ b/apps/web/components/Modal.tsx
@@ -10,6 +10,7 @@ type Props = {
children: ReactNode;
className?: string;
dismissible?: boolean;
+ hideCloseButton?: boolean;
};
export default function Modal({
@@ -17,6 +18,7 @@ export default function Modal({
className,
children,
dismissible = true,
+ hideCloseButton,
}: Props) {
const [drawerIsOpen, setDrawerIsOpen] = React.useState(true);
const { width } = useWindowDimensions();
@@ -74,7 +76,7 @@ export default function Modal({
className="slide-up mt-auto sm:m-auto relative border-neutral-content rounded-t-xl sm:rounded-xl border-t sm:border shadow-xl p-5 bg-base-100 overflow-y-auto sm:overflow-y-visible"
data-testid="modal-container"
>
- {dismissible && (
+ {dismissible && !hideCloseButton && (
<Button
variant="ghost"
size="icon"
diff --git a/apps/web/components/ModalContent/BulkEditLinksModal.tsx b/apps/web/components/ModalContent/BulkEditLinksModal.tsx
index 2f153bb6..512a16b2 100644
--- a/apps/web/components/ModalContent/BulkEditLinksModal.tsx
+++ b/apps/web/components/ModalContent/BulkEditLinksModal.tsx
@@ -107,7 +107,7 @@ export default function BulkEditLinksModal({ onClose }: Props) {
</div>
<div className="flex justify-end items-center mt-5">
- <Button variant="accent" onClick={submit}>
+ <Button variant="primary" onClick={submit}>
{t("save_changes")}
</Button>
</div>
diff --git a/apps/web/components/ModalContent/EditCollectionModal.tsx b/apps/web/components/ModalContent/EditCollectionModal.tsx
index aba168bd..9ceb566b 100644
--- a/apps/web/components/ModalContent/EditCollectionModal.tsx
+++ b/apps/web/components/ModalContent/EditCollectionModal.tsx
@@ -109,7 +109,7 @@ export default function EditCollectionModal({
</div>
</div>
- <Button variant="accent" className="ml-auto" onClick={submit}>
+ <Button variant="primary" className="ml-auto" onClick={submit}>
{t("save_changes")}
</Button>
</div>
diff --git a/apps/web/components/ModalContent/EditCollectionSharingModal.tsx b/apps/web/components/ModalContent/EditCollectionSharingModal.tsx
index 3cf8b6d6..d4f11b38 100644
--- a/apps/web/components/ModalContent/EditCollectionSharingModal.tsx
+++ b/apps/web/components/ModalContent/EditCollectionSharingModal.tsx
@@ -187,7 +187,7 @@ export default function EditCollectionSharingModal({
/>
<Button
- variant="accent"
+ variant="primary"
size="icon"
className="h-10 w-10"
onClick={() =>
@@ -394,7 +394,7 @@ export default function EditCollectionSharingModal({
{permissions === true && !isPublicRoute && (
<Button
- variant="accent"
+ variant="primary"
className="w-fit ml-auto mt-3"
onClick={submit}
>
diff --git a/apps/web/components/ModalContent/EmailChangeVerificationModal.tsx b/apps/web/components/ModalContent/EmailChangeVerificationModal.tsx
index 6e181138..68fd6c1c 100644
--- a/apps/web/components/ModalContent/EmailChangeVerificationModal.tsx
+++ b/apps/web/components/ModalContent/EmailChangeVerificationModal.tsx
@@ -63,7 +63,7 @@ export default function EmailChangeVerificationModal({
</div>
<div className="flex justify-end items-center">
- <Button variant="accent" onClick={() => onSubmit(password)}>
+ <Button variant="primary" onClick={() => onSubmit(password)}>
{t("confirm")}
</Button>
</div>
diff --git a/apps/web/components/ModalContent/InviteModal.tsx b/apps/web/components/ModalContent/InviteModal.tsx
index 08636477..04594129 100644
--- a/apps/web/components/ModalContent/InviteModal.tsx
+++ b/apps/web/components/ModalContent/InviteModal.tsx
@@ -131,7 +131,7 @@ export default function InviteModal({ onClose }: Props) {
</div>
<div className="flex justify-between items-center mt-5">
- <Button variant="accent" className="ml-auto" type="submit">
+ <Button variant="primary" className="ml-auto" type="submit">
{t("send_invitation")}
</Button>
</div>
diff --git a/apps/web/components/ModalContent/MergeTagsModal.tsx b/apps/web/components/ModalContent/MergeTagsModal.tsx
index 14f258a3..52b39444 100644
--- a/apps/web/components/ModalContent/MergeTagsModal.tsx
+++ b/apps/web/components/ModalContent/MergeTagsModal.tsx
@@ -65,7 +65,7 @@ export default function MergeTagsModal({
placeholder={t("tag_name_placeholder")}
/>
- <Button className="ml-auto" variant="accent" onClick={merge}>
+ <Button className="ml-auto" variant="primary" onClick={merge}>
<i className="bi-intersect text-xl" />
{t("merge_tags")}
</Button>
diff --git a/apps/web/components/ModalContent/NewCollectionModal.tsx b/apps/web/components/ModalContent/NewCollectionModal.tsx
index de3327fe..bfaca79b 100644
--- a/apps/web/components/ModalContent/NewCollectionModal.tsx
+++ b/apps/web/components/ModalContent/NewCollectionModal.tsx
@@ -133,7 +133,7 @@ export default function NewCollectionModal({ onClose, parent }: Props) {
</div>
</div>
- <Button variant="accent" className="ml-auto" onClick={submit}>
+ <Button variant="primary" className="ml-auto" onClick={submit}>
{t("create_collection_button")}
</Button>
</div>
diff --git a/apps/web/components/ModalContent/NewLinkModal.tsx b/apps/web/components/ModalContent/NewLinkModal.tsx
index 9a4b74d7..8e07b94a 100644
--- a/apps/web/components/ModalContent/NewLinkModal.tsx
+++ b/apps/web/components/ModalContent/NewLinkModal.tsx
@@ -172,7 +172,7 @@ export default function NewLinkModal({ onClose }: Props) {
<p>{optionsExpanded ? t("hide_options") : t("more_options")}</p>
<i className={`bi-chevron-${optionsExpanded ? "up" : "down"}`} />
</Button>
- <Button variant="accent" onClick={submit}>
+ <Button variant="primary" onClick={submit}>
{t("create_link")}
</Button>
</div>
diff --git a/apps/web/components/ModalContent/NewRssSubscriptionModal.tsx b/apps/web/components/ModalContent/NewRssSubscriptionModal.tsx
index 4ab674e5..7803ba91 100644
--- a/apps/web/components/ModalContent/NewRssSubscriptionModal.tsx
+++ b/apps/web/components/ModalContent/NewRssSubscriptionModal.tsx
@@ -107,7 +107,7 @@ export default function NewRssSubscriptionModal({ onClose }: Props) {
</div>
<div className="flex justify-end items-center mt-5">
- <Button variant="accent" onClick={submit}>
+ <Button variant="primary" onClick={submit}>
{t("create_rss_subscription")}
</Button>
</div>
diff --git a/apps/web/components/ModalContent/NewTagModal.tsx b/apps/web/components/ModalContent/NewTagModal.tsx
index aae6cddf..4f76bcd0 100644
--- a/apps/web/components/ModalContent/NewTagModal.tsx
+++ b/apps/web/components/ModalContent/NewTagModal.tsx
@@ -68,7 +68,7 @@ export default function NewTagModal({ onClose }: Props) {
</div>
<div className="flex justify-end items-center mt-5">
- <Button variant="accent" onClick={submit} disabled={!tag.label.trim()}>
+ <Button variant="primary" onClick={submit} disabled={!tag.label.trim()}>
{t("create_new_tag")}
</Button>
</div>
diff --git a/apps/web/components/ModalContent/NewTokenModal.tsx b/apps/web/components/ModalContent/NewTokenModal.tsx
index 5ca60d7a..50049bc9 100644
--- a/apps/web/components/ModalContent/NewTokenModal.tsx
+++ b/apps/web/components/ModalContent/NewTokenModal.tsx
@@ -163,7 +163,7 @@ export default function NewTokenModal({ onClose }: Props) {
</div>
<div className="flex justify-end items-center mt-5">
- <Button variant="accent" onClick={submit}>
+ <Button variant="primary" onClick={submit}>
{t("create_token")}
</Button>
</div>
diff --git a/apps/web/components/ModalContent/NewUserModal.tsx b/apps/web/components/ModalContent/NewUserModal.tsx
index 3111a384..0795df9b 100644
--- a/apps/web/components/ModalContent/NewUserModal.tsx
+++ b/apps/web/components/ModalContent/NewUserModal.tsx
@@ -135,7 +135,7 @@ export default function NewUserModal({ onClose }: Props) {
</div>
<div className="flex justify-between items-center mt-5">
- <Button variant="accent" className="ml-auto" type="submit">
+ <Button variant="primary" className="ml-auto" type="submit">
{t("create_user")}
</Button>
</div>
diff --git a/apps/web/components/ModalContent/SearchModal.tsx b/apps/web/components/ModalContent/SearchModal.tsx
new file mode 100644
index 00000000..0f45b2ce
--- /dev/null
+++ b/apps/web/components/ModalContent/SearchModal.tsx
@@ -0,0 +1,179 @@
+import { useEffect, useRef, useState } from "react";
+import Link from "next/link";
+import { useRouter } from "next/router";
+import { toast } from "react-hot-toast";
+import { useTranslation } from "next-i18next";
+import Modal from "@/components/Modal";
+import { Button } from "@/components/ui/button";
+import { Kbd } from "@/components/ui/kbd";
+import { ADVANCED_SEARCH_OPERATORS } from "@/components/SearchBar";
+
+export const isAppleDevice =
+ typeof navigator !== "undefined" &&
+ /Mac|iPhone|iPad|iPod/.test(navigator.platform);
+
+const RECENT_SEARCHES_KEY = "recentSearches";
+const MAX_RECENT_SEARCHES = 5;
+
+type RecentSearch = {
+ query: string;
+ searchedAt: string;
+};
+
+const getRecentSearches = (): RecentSearch[] => {
+ try {
+ const stored = JSON.parse(
+ localStorage.getItem(RECENT_SEARCHES_KEY) || "[]"
+ );
+ if (!Array.isArray(stored)) return [];
+ return stored.filter((entry) => typeof entry?.query === "string");
+ } catch {
+ return [];
+ }
+};
+
+const setRecentSearches = (recents: RecentSearch[]) => {
+ localStorage.setItem(RECENT_SEARCHES_KEY, JSON.stringify(recents));
+};
+
+export default function SearchModal({ onClose }: { onClose: () => void }) {
+ const { t } = useTranslation();
+ const router = useRouter();
+ const inputRef = useRef<HTMLInputElement>(null);
+ const [searchQuery, setSearchQuery] = useState("");
+ const [recents, setRecents] = useState<RecentSearch[]>(getRecentSearches);
+
+ useEffect(() => {
+ const handler = (e: KeyboardEvent) => {
+ if (e.key === "Escape") onClose();
+ };
+ document.addEventListener("keydown", handler);
+ return () => document.removeEventListener("keydown", handler);
+ }, [onClose]);
+
+ const submit = (query: string) => {
+ const trimmed = query.trim();
+ if (!trimmed) return;
+
+ const updated = [
+ { query: trimmed, searchedAt: new Date().toISOString() },
+ ...recents.filter((entry) => entry.query !== trimmed),
+ ].slice(0, MAX_RECENT_SEARCHES);
+ setRecentSearches(updated);
+
+ router.push("/search?q=" + encodeURIComponent(trimmed));
+ onClose();
+ };
+
+ const removeRecent = (query: string) => {
+ const updated = recents.filter((entry) => entry.query !== query);
+ setRecentSearches(updated);
+ setRecents(updated);
+ };
+
+ const appendOperator = (operator: string) => {
+ setSearchQuery((prev) => {
+ const needsSpace = prev.length > 0 && !prev.endsWith(" ");
+ return `${prev}${needsSpace ? " " : ""}${operator}`;
+ });
+ inputRef.current?.focus();
+ };
+
+ return (
+ <Modal toggleModal={onClose} hideCloseButton>
+ <div className="flex items-center gap-3">
+ <i className="bi-search text-neutral text-lg leading-none" />
+ <input
+ type="text"
+ ref={inputRef}
+ autoFocus
+ placeholder={t("search_for_links")}
+ value={searchQuery}
+ onChange={(e) => {
+ e.target.value.includes("%") &&
+ toast.error(t("search_query_invalid_symbol"));
+ setSearchQuery(e.target.value.replace("%", ""));
+ }}
+ onKeyDown={(e) => e.key === "Enter" && submit(searchQuery)}
+ className="w-full bg-transparent outline-none text-lg"
+ />
+ <div className="hidden sm:flex items-center gap-1 shrink-0">
+ <Kbd>{isAppleDevice ? "⌘" : "Ctrl"}</Kbd>
+ <Kbd>K</Kbd>
+ </div>
+ </div>
+
+ <div className="border-t border-neutral-content -mx-4 sm:-mx-5 mt-4" />
+
+ <div className="sm:max-h-80 sm:overflow-y-auto -mx-4 sm:-mx-5 -mb-4 sm:-mb-5">
+ {recents.length > 0 && (
+ <div className="px-4 sm:px-5">
+ <p className="text-xs font-bold text-neutral mt-4">{t("recent")}</p>
+ <div className="flex flex-col gap-1 mt-2">
+ {recents.map((entry) => (
+ <div
+ key={entry.query}
+ className="flex items-center gap-3 rounded-md px-2 py-1.5 cursor-pointer hover:bg-base-200 duration-100"
+ onClick={() => submit(entry.query)}
+ >
+ <i className="bi-clock-history text-neutral" />
+ <span className="flex-1 truncate text-sm">{entry.query}</span>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="h-6 w-6"
+ aria-label={t("delete")}
+ onClick={(e) => {
+ e.stopPropagation();
+ removeRecent(entry.query);
+ }}
+ >
+ <i className="bi-x text-lg text-neutral" />
+ </Button>
+ </div>
+ ))}
+ </div>
+ <div className="border-t border-neutral-content -mx-4 sm:-mx-5 mt-4" />
+ </div>
+ )}
+
+ <div className="px-4 sm:px-5 pb-4 sm:pb-5">
+ <p className="text-xs font-bold text-neutral mt-4">
+ {t("suggested_search_operators")}
+ </p>
+ <div className="flex flex-col gap-1 mt-2">
+ {ADVANCED_SEARCH_OPERATORS.map((entry) => (
+ <button
+ key={entry.operator}
+ type="button"
+ className="flex items-center gap-2 justify-between rounded-md px-2 py-1.5 text-left hover:bg-base-200 duration-100"
+ onClick={() => appendOperator(entry.operator)}
+ >
+ <div className="flex items-center gap-3">
+ <i className={`${entry.icon} text-primary`} />
+ <span className="text-sm">{t(entry.labelKey)}</span>
+ </div>
+ <span className="font-mono text-xs px-1.5 py-0.5 rounded-md bg-base-200 border border-neutral-content text-base-content">
+ {entry.operator}
+ </span>
+ </button>
+ ))}
+ </div>
+
+ <div className="flex justify-end mt-2">
+ <Button asChild variant="ghost" size="sm" className="text-xs">
+ <Link
+ href="https://docs.linkwarden.app/Usage/advanced-search"
+ target="_blank"
+ className="flex items-center gap-1"
+ >
+ {t("learn_more")}
+ <i className="bi-box-arrow-up-right text-xs" />
+ </Link>
+ </Button>
+ </div>
+ </div>
+ </div>
+ </Modal>
+ );
+}
diff --git a/apps/web/components/ModalContent/SurveyModal.tsx b/apps/web/components/ModalContent/SurveyModal.tsx
index 3ad2ee15..cb792ed4 100644
--- a/apps/web/components/ModalContent/SurveyModal.tsx
+++ b/apps/web/components/ModalContent/SurveyModal.tsx
@@ -57,7 +57,7 @@ export default function SurveyModal({ onClose, submit }: Props) {
<Button
className="ml-auto mt-3"
- variant="accent"
+ variant="primary"
onClick={() => submit(referer, other)}
>
{t("submit")}
diff --git a/apps/web/components/ModalContent/UploadFileModal.tsx b/apps/web/components/ModalContent/UploadFileModal.tsx
index 53bff8af..9010cf0f 100644
--- a/apps/web/components/ModalContent/UploadFileModal.tsx
+++ b/apps/web/components/ModalContent/UploadFileModal.tsx
@@ -179,7 +179,7 @@ export default function UploadFileModal({ onClose }: Props) {
<p>{optionsExpanded ? t("hide_options") : t("more_options")}</p>
<i className={`bi-chevron-${optionsExpanded ? "up" : "down"}`} />
</Button>
- <Button variant="accent" onClick={submit}>
+ <Button variant="primary" onClick={submit}>
{t("upload_file")}
</Button>
</div>
diff --git a/apps/web/components/Navbar.tsx b/apps/web/components/Navbar.tsx
deleted file mode 100644
index 5daad396..00000000
--- a/apps/web/components/Navbar.tsx
+++ /dev/null
@@ -1,200 +0,0 @@
-import { useEffect, useState } from "react";
-import ClickAwayHandler from "@/components/ClickAwayHandler";
-import Sidebar from "@/components/Sidebar";
-import { useRouter } from "next/router";
-import SearchBar from "@/components/SearchBar";
-import useWindowDimensions from "@/hooks/useWindowDimensions";
-import ToggleDarkMode from "./ToggleDarkMode";
-import NewLinkModal from "./ModalContent/NewLinkModal";
-import NewCollectionModal from "./ModalContent/NewCollectionModal";
-import UploadFileModal from "./ModalContent/UploadFileModal";
-import MobileNavigation from "./MobileNavigation";
-import ProfileDropdown from "./ProfileDropdown";
-import { useTranslation } from "next-i18next";
-import {
- DropdownMenu,
- DropdownMenuTrigger,
- DropdownMenuContent,
- DropdownMenuItem,
-} from "@/components/ui/dropdown-menu";
-import { Button } from "@/components/ui/button";
-import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from "@/components/ui/tooltip";
-import { useUser } from "@linkwarden/router/user";
-import Link from "next/link";
-import SettingsSidebar from "@/components/SettingsSidebar";
-import AdminSidebar from "@/components/AdminSidebar";
-
-const STRIPE_ENABLED = process.env.NEXT_PUBLIC_STRIPE === "true";
-const TRIAL_PERIOD_DAYS =
- Number(process.env.NEXT_PUBLIC_TRIAL_PERIOD_DAYS) || 14;
-
-export default function Navbar({
- settings,
- admin,
-}: {
- settings?: boolean;
- admin?: boolean;
-}) {
- const { t } = useTranslation();
- const router = useRouter();
- const { data: user } = useUser();
-
- const [sidebar, setSidebar] = useState(false);
-
- const { width } = useWindowDimensions();
-
- useEffect(() => {
- if (sidebar) setSidebar(false);
- }, [width, router]);
-
- useEffect(() => {
- document.body.style.overflow = "auto";
- }, [sidebar]);
-
- const toggleSidebar = () => {
- setSidebar(false);
- document.body.style.overflow = "auto";
- };
-
- const [newLinkModal, setNewLinkModal] = useState(false);
- const [newCollectionModal, setNewCollectionModal] = useState(false);
- const [uploadFileModal, setUploadFileModal] = useState(false);
-
- const [daysLeft, setDaysLeft] = useState<number>(0);
- const [isTrialing, setIsTrialing] = useState<boolean>(false);
-
- useEffect(() => {
- if (user?.createdAt) {
- const trialEndTime =
- new Date(user.createdAt).getTime() +
- (1 + Number(TRIAL_PERIOD_DAYS)) * 86400000; // Add 1 to account for the current day
-
- setDaysLeft(Math.floor((trialEndTime - Date.now()) / 86400000));
- }
- }, [user]);
-
- useEffect(() => {
- const isTrialing =
- user?.id &&
- !user?.subscription?.active &&
- !user.parentSubscription?.active;
-
- setIsTrialing(Boolean(isTrialing));
- }, [user, daysLeft]);
-
- return (
- <>
- {STRIPE_ENABLED && isTrialing && (
- <Link
- href="/subscribe"
- className="w-full text-sm cursor-pointer select-none bg-base-200"
- >
- <p className="w-full text-center flex items-center justify-center gap-1 underline decoration-dotted underline-offset-4 hover:opacity-70 duration-200 py-1 px-2">
- <i className="bi-clock text-primary" />
- {daysLeft === 1
- ? t("trial_left_singular")
- : t("trial_left_plural", { count: daysLeft })}
- </p>
- </Link>
- )}
- <div className="flex justify-between gap-2 items-center pl-3 pr-4 py-2 border-solid border-b-neutral-content border-b">
- <Button
- variant="ghost"
- size="icon"
- className="text-neutral lg:hidden sm:inline-flex"
- onClick={() => {
- setSidebar(true);
- document.body.style.overflow = "hidden";
- }}
- >
- <i className="bi-list text-xl leading-none" />
- </Button>
-
- <SearchBar />
-
- <div className="flex items-center gap-2">
- <ToggleDarkMode hideInMobile />
-
- <DropdownMenu>
- <DropdownMenuTrigger className="hidden sm:inline-grid">
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger>
- <Button
- variant="accent"
- size="sm"
- className="min-w-[3.4rem] h-[2rem] relative"
- >
- <span>
- <i className="bi-plus text-4xl absolute -top-[0.3rem] left-0 pointer-events-none" />
- </span>
- <span>
- <i className="bi-caret-down-fill text-xs absolute top-[0.6rem] right-[0.4rem] pointer-events-none" />
- </span>
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p>{t("create_new")}</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </DropdownMenuTrigger>
-
- <DropdownMenuContent align="end">
- <DropdownMenuItem onSelect={() => setNewLinkModal(true)}>
- <i className="bi-link-45deg" />
- {t("new_link")}
- </DropdownMenuItem>
- <DropdownMenuItem onSelect={() => setUploadFileModal(true)}>
- <i className="bi-file-earmark-arrow-up" />
- {t("upload_file")}
- </DropdownMenuItem>
- <DropdownMenuItem onSelect={() => setNewCollectionModal(true)}>
- <i className="bi-folder" />
- {t("new_collection")}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
-
- <ProfileDropdown />
- </div>
-
- <MobileNavigation />
-
- {sidebar && (
- <div className="fixed top-0 bottom-0 right-0 left-0 bg-black bg-opacity-10 backdrop-blur-sm flex items-center fade-in z-40">
- <ClickAwayHandler className="h-full" onClickOutside={toggleSidebar}>
- <div className="slide-right h-full shadow-lg">
- {admin ? (
- <AdminSidebar />
- ) : settings ? (
- <SettingsSidebar />
- ) : (
- <Sidebar />
- )}
- </div>
- </ClickAwayHandler>
- </div>
- )}
- {newLinkModal && (
- <NewLinkModal
- onClose={() => {
- setNewLinkModal(false);
- }}
- />
- )}
- {newCollectionModal && (
- <NewCollectionModal onClose={() => setNewCollectionModal(false)} />
- )}
- {uploadFileModal && (
- <UploadFileModal onClose={() => setUploadFileModal(false)} />
- )}
- </div>
- </>
- );
-}
diff --git a/apps/web/components/NoLinksFound.tsx b/apps/web/components/NoLinksFound.tsx
index c1e7f1fa..9b085d1b 100644
--- a/apps/web/components/NoLinksFound.tsx
+++ b/apps/web/components/NoLinksFound.tsx
@@ -32,7 +32,7 @@ export default function NoLinksFound({ text }: Props) {
onClick={() => {
setNewLinkModal(true);
}}
- variant="accent"
+ variant="primary"
>
<i className="bi-plus-lg text-xl duration-100"></i>
<span className="group-hover:opacity-0 w-full duration-100">
diff --git a/apps/web/components/PageHeader.tsx b/apps/web/components/PageHeader.tsx
index 1429dad4..c7947420 100644
--- a/apps/web/components/PageHeader.tsx
+++ b/apps/web/components/PageHeader.tsx
@@ -1,4 +1,4 @@
-import clsx from "clsx";
+import { cn } from "@/lib/utils";
import React from "react";
export default function PageHeader({
@@ -6,17 +6,23 @@ export default function PageHeader({
description,
icon,
className,
+ sm,
}: {
title: string;
description?: string;
icon: string;
className?: string;
+ sm?: boolean;
}) {
return (
- <div className={clsx("flex items-center gap-3", className)}>
- <i className={`${icon} text-primary text-2xl drop-shadow`}></i>
+ <div
+ className={cn("flex items-center", className, !sm ? "gap-3" : "gap-2")}
+ >
+ <i
+ className={cn("text-primary drop-shadow", icon, !sm && "text-2xl")}
+ ></i>
<div>
- <p className="text-2xl capitalize font-thin">{title}</p>
+ <p className={cn("capitalize font-thin", !sm && "text-2xl")}>{title}</p>
<p className="text-xs sm:text-sm">{description}</p>
</div>
</div>
diff --git a/apps/web/components/ProfileDropdown.tsx b/apps/web/components/ProfileDropdown.tsx
index e4cf8a59..8e6606a5 100644
--- a/apps/web/components/ProfileDropdown.tsx
+++ b/apps/web/components/ProfileDropdown.tsx
@@ -9,13 +9,35 @@ import {
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuSub,
+ DropdownMenuSubTrigger,
+ DropdownMenuSubContent,
+ DropdownMenuPortal,
} from "@/components/ui/dropdown-menu";
import { Button } from "./ui/button";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger,
+} from "@/components/ui/tooltip";
-export default function ProfileDropdown() {
+export default function ProfileDropdown({
+ showName,
+ tooltipSide,
+ dropdownSide,
+ dropdownAlign,
+}: {
+ showName?: boolean;
+ tooltipSide?: "top" | "right" | "bottom" | "left";
+ dropdownSide?: "top" | "right" | "bottom" | "left";
+ dropdownAlign?: "center" | "start" | "end";
+}) {
const { t } = useTranslation();
const updateUserPreference = useUpdateUserPreference();
const { data: user } = useUser();
+ const LINKWARDEN_VERSION = process.env.version;
const { data: config } = useConfig();
@@ -26,17 +48,67 @@ export default function ProfileDropdown() {
updateUserPreference.mutate({ theme: newTheme });
};
- return (
- <DropdownMenu>
- <DropdownMenuTrigger>
+ const trigger = (
+ <DropdownMenuTrigger>
+ {showName ? (
+ <div className="flex items-center gap-2 rounded-full h-10 px-0 justify-start min-w-0 w-fit">
+ <ProfilePhoto
+ src={user?.image ? user?.image : undefined}
+ name={user?.name}
+ priority={true}
+ />
+ <span className="truncate text-sm max-w-48">
+ {user?.name || user?.username}
+ </span>
+ </div>
+ ) : (
<Button variant="ghost" className="rounded-full p-1">
<ProfilePhoto
src={user?.image ? user?.image : undefined}
+ name={user?.name}
priority={true}
/>
</Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="min-w-40">
+ )}
+ </DropdownMenuTrigger>
+ );
+
+ return (
+ <DropdownMenu>
+ {tooltipSide ? (
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>{trigger}</TooltipTrigger>
+ <TooltipContent side={tooltipSide} className="max-w-40 truncate">
+ {t("account")}
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ ) : (
+ trigger
+ )}
+ <DropdownMenuContent
+ align={dropdownAlign || "start"}
+ side={dropdownSide}
+ className="min-w-40"
+ >
+ <div className="flex items-center gap-2 px-2 py-1.5">
+ <ProfilePhoto
+ src={user?.image ? user?.image : undefined}
+ name={user?.name}
+ />
+ <div className="max-w-48 min-w-28">
+ <p className="text-sm font-semibold truncate">
+ {user?.name || user?.username}
+ </p>
+ <p className="text-xs text-neutral truncate">
+ {user?.email || user?.username}
+ </p>
+ </div>
+ </div>
+
+ <DropdownMenuSeparator />
+
<DropdownMenuItem asChild>
<Link href="/settings/account" className="whitespace-nowrap">
<i className="bi-gear"></i>
@@ -44,22 +116,6 @@ export default function ProfileDropdown() {
</Link>
</DropdownMenuItem>
- <DropdownMenuItem asChild>
- <div
- onClick={() => handleToggle()}
- className="whitespace-nowrap block sm:hidden"
- >
- {user?.theme === "light" ? (
- <i className="bi-moon-fill"></i>
- ) : (
- <i className="bi-sun-fill"></i>
- )}
- {t("switch_to", {
- theme: user?.theme === "light" ? t("dark") : t("light"),
- })}
- </div>
- </DropdownMenuItem>
-
{isAdmin && (
<DropdownMenuItem asChild>
<Link
@@ -73,12 +129,54 @@ export default function ProfileDropdown() {
</DropdownMenuItem>
)}
+ <DropdownMenuItem asChild>
+ <div onClick={() => handleToggle()} className="whitespace-nowrap">
+ {user?.theme === "light" ? (
+ <i className="bi-moon-fill"></i>
+ ) : (
+ <i className="bi-sun-fill"></i>
+ )}
+ {t("switch_to", {
+ theme: user?.theme === "light" ? t("dark") : t("light"),
+ })}
+ </div>
+ </DropdownMenuItem>
+
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger>
+ <i className="bi-question-circle"></i>
+ {t("need_help")}
+ </DropdownMenuSubTrigger>
+ <DropdownMenuPortal>
+ <DropdownMenuSubContent>
+ <DropdownMenuItem asChild>
+ <Link
+ href="https://docs.linkwarden.app"
+ target="_blank"
+ className="whitespace-nowrap"
+ >
+ <i className="bi-book"></i>
+ {t("documentation")}
+ </Link>
+ </DropdownMenuItem>
+ </DropdownMenuSubContent>
+ </DropdownMenuPortal>
+ </DropdownMenuSub>
+
<DropdownMenuItem asChild>
<div onClick={() => signOut()} className="whitespace-nowrap">
<i className="bi-box-arrow-left" />
{t("logout")}
</div>
</DropdownMenuItem>
+
+ <Link
+ href="https://github.com/linkwarden/linkwarden/releases"
+ target="_blank"
+ className="block px-2 py-1.5 text-xs text-neutral hover:opacity-50 duration-100"
+ >
+ {t("linkwarden_version", { version: LINKWARDEN_VERSION })}
+ </Link>
</DropdownMenuContent>
</DropdownMenu>
);
diff --git a/apps/web/components/SearchBar.tsx b/apps/web/components/SearchBar.tsx
index f981ca23..fb70cb89 100644
--- a/apps/web/components/SearchBar.tsx
+++ b/apps/web/components/SearchBar.tsx
@@ -4,13 +4,13 @@ import { useRouter } from "next/router";
import { toast } from "react-hot-toast";
import { useTranslation } from "next-i18next";
import { Button } from "@/components/ui/button";
-import { useUser } from "@linkwarden/router/user";
type Props = {
placeholder?: string;
+ fullWidth?: boolean;
};
-const ADVANCED_SEARCH_OPERATORS = [
+export const ADVANCED_SEARCH_OPERATORS = [
{
operator: "url:",
labelKey: "url",
@@ -38,15 +38,12 @@ const ADVANCED_SEARCH_OPERATORS = [
},
] as const;
-export default function SearchBar({ placeholder }: Props) {
+export default function SearchBar({ placeholder, fullWidth }: Props) {
const router = useRouter();
const { t } = useTranslation();
const [searchQuery, setSearchQuery] = useState("");
const [showSuggestions, setShowSuggestions] = useState(false);
const inputRef = useRef<HTMLInputElement>(null);
- const { data: user } = useUser();
-
- const [dismissSearchNote, setDismissSearchNote] = useState(false);
useEffect(() => {
router.query.q
@@ -64,7 +61,11 @@ export default function SearchBar({ placeholder }: Props) {
};
return (
- <div className="flex items-center relative group">
+ <div
+ className={`flex items-center relative group ${
+ fullWidth ? "w-full" : ""
+ }`}
+ >
<label
htmlFor="search-box"
className="inline-flex items-center w-fit absolute left-1 pointer-events-none rounded-md p-1 text-primary"
@@ -110,7 +111,9 @@ export default function SearchBar({ placeholder }: Props) {
}
}
}}
- className="border border-neutral-content bg-base-200 focus:border-primary py-1 rounded-md pl-9 pr-2 w-full max-w-[15rem] md:w-80 md:max-w-full outline-none"
+ className={`border border-neutral-content bg-base-100 focus:border-primary py-1 rounded-md pl-9 pr-2 outline-none ${
+ fullWidth ? "w-full" : "w-full max-w-[15rem] md:w-80 md:max-w-full"
+ }`}
/>
{showSuggestions && (
diff --git a/apps/web/components/SecondarySidebar.tsx b/apps/web/components/SecondarySidebar.tsx
new file mode 100644
index 00000000..f7eac3b4
--- /dev/null
+++ b/apps/web/components/SecondarySidebar.tsx
@@ -0,0 +1,101 @@
+import Link from "next/link";
+import { useRouter } from "next/router";
+import { useEffect, useState } from "react";
+import { useTranslation } from "next-i18next";
+import SidebarShell, { ActionIcon } from "@/components/SidebarShell";
+import SidebarScrollArea from "@/components/SidebarScrollArea";
+import SidebarHighlightLink from "@/components/SidebarHighlightLink";
+import { Button } from "./ui/button";
+import { cn } from "@/lib/utils";
+
+export type SecondarySidebarLink = {
+ title: string;
+ href: string;
+ icon: string;
+};
+
+export default function SecondarySidebar({
+ links,
+ className,
+ toggleSidebar,
+ sidebarIsCollapsed,
+}: {
+ links: SecondarySidebarLink[];
+ className?: string;
+ toggleSidebar?: () => void;
+ sidebarIsCollapsed?: boolean;
+}) {
+ const { t } = useTranslation();
+
+ const router = useRouter();
+ const [active, setActive] = useState("");
+
+ useEffect(() => {
+ setActive(router.asPath);
+ }, [router]);
+
+ return (
+ <SidebarShell
+ className={className}
+ toggleSidebar={toggleSidebar}
+ sidebarIsCollapsed={sidebarIsCollapsed}
+ >
+ {({ collapsed }) => {
+ const navLinks = (
+ <div className={cn("flex flex-col gap-2", collapsed && "gap-3")}>
+ {links.map((link) => (
+ <SidebarHighlightLink
+ key={link.href}
+ title={link.title}
+ href={link.href}
+ icon={link.icon}
+ active={active === link.href}
+ sidebarIsCollapsed={collapsed}
+ />
+ ))}
+ </div>
+ );
+
+ return (
+ <>
+ {collapsed ? (
+ <div className="flex flex-col items-center shrink-0">
+ <ActionIcon
+ icon="bi-chevron-left"
+ variant="ghost"
+ label={t("back_to_dashboard")}
+ tooltipSide="right"
+ onClick={() => router.push("/dashboard")}
+ />
+ </div>
+ ) : (
+ <div className="shrink-0 pt-1 px-1">
+ <Button
+ asChild
+ size="sm"
+ variant="ghost"
+ className="justify-start w-full h-8"
+ >
+ <Link href="/dashboard">
+ <i className="bi-chevron-left text-md" />
+ <p>{t("back_to_dashboard")}</p>
+ </Link>
+ </Button>
+ </div>
+ )}
+
+ {collapsed ? (
+ <div className="flex-1 min-h-0 flex flex-col items-center justify-center">
+ {navLinks}
+ </div>
+ ) : (
+ <div className="flex-1 min-h-0 overflow-y-auto mt-1 p-1">
+ {navLinks}
+ </div>
+ )}
+ </>
+ );
+ }}
+ </SidebarShell>
+ );
+}
diff --git a/apps/web/components/SettingsSidebar.tsx b/apps/web/components/SettingsSidebar.tsx
index 0bce09c2..ffec4f64 100644
--- a/apps/web/components/SettingsSidebar.tsx
+++ b/apps/web/components/SettingsSidebar.tsx
@@ -1,193 +1,63 @@
-import Link from "next/link";
-import { useRouter } from "next/router";
-import React, { useEffect, useState } from "react";
import { useTranslation } from "next-i18next";
import { useUser } from "@linkwarden/router/user";
-import Image from "next/image";
-
-export default function SettingsSidebar({ className }: { className?: string }) {
+import SecondarySidebar, {
+ SecondarySidebarLink,
+} from "@/components/SecondarySidebar";
+
+export default function SettingsSidebar({
+ className,
+ toggleSidebar,
+ sidebarIsCollapsed,
+}: {
+ className?: string;
+ toggleSidebar?: () => void;
+ sidebarIsCollapsed?: boolean;
+}) {
const { t } = useTranslation();
- const LINKWARDEN_VERSION = process.env.version;
-
const { data: user } = useUser();
- const router = useRouter();
- const [active, setActive] = useState("");
-
- useEffect(() => {
- setActive(router.asPath);
- }, [router]);
+ const links: SecondarySidebarLink[] = [
+ {
+ title: t("account"),
+ href: "/settings/account",
+ icon: "bi-person",
+ },
+ {
+ title: t("preference"),
+ href: "/settings/preference",
+ icon: "bi-sliders",
+ },
+ {
+ title: "RSS Subscriptions",
+ href: "/settings/rss-subscriptions",
+ icon: "bi-rss",
+ },
+ {
+ title: t("access_tokens"),
+ href: "/settings/access-tokens",
+ icon: "bi-key",
+ },
+ {
+ title: t("password"),
+ href: "/settings/password",
+ icon: "bi-lock",
+ },
+ ];
+
+ if (process.env.NEXT_PUBLIC_STRIPE && !user?.parentSubscriptionId) {
+ links.push({
+ title: t("billing"),
+ href: "/settings/billing",
+ icon: "bi-credit-card",
+ });
+ }
return (
- <div
- className={`bg-base-200 h-screen w-80 overflow-y-auto border-solid border border-base-200 border-r-neutral-content p-2 z-20 flex flex-col gap-5 justify-between ${
- className || ""
- }`}
- >
- <div className="flex flex-col gap-1">
- <div className="flex items-center justify-between mb-3">
- {user?.theme === "light" ? (
- <Image
- src={"/linkwarden_light.png"}
- width={640}
- height={136}
- alt="Linkwarden"
- className="h-9 w-auto cursor-pointer"
- onClick={() => router.push("/dashboard")}
- priority
- />
- ) : (
- <Image
- src={"/linkwarden_dark.png"}
- width={640}
- height={136}
- alt="Linkwarden"
- className="h-9 w-auto cursor-pointer"
- onClick={() => router.push("/dashboard")}
- priority
- />
- )}
- </div>
- <Link href="/settings/account">
- <div
- className={`${
- active === "/settings/account"
- ? "bg-primary/20"
- : "hover:bg-neutral/20"
- } duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-person text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">
- {t("account")}
- </p>
- </div>
- </Link>
-
- <Link href="/settings/preference">
- <div
- className={`${
- active === "/settings/preference"
- ? "bg-primary/20"
- : "hover:bg-neutral/20"
- } duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-sliders text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">
- {t("preference")}
- </p>
- </div>
- </Link>
-
- <Link href="/settings/rss-subscriptions">
- <div
- className={`${
- active === "/settings/rss-subscriptions"
- ? "bg-primary/20"
- : "hover:bg-neutral/20"
- } duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-rss text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">
- RSS Subscriptions
- </p>
- </div>
- </Link>
-
- <Link href="/settings/access-tokens">
- <div
- className={`${
- active === "/settings/access-tokens"
- ? "bg-primary/20"
- : "hover:bg-neutral/20"
- } duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-key text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">
- {t("access_tokens")}
- </p>
- </div>
- </Link>
-
- <Link href="/settings/password">
- <div
- className={`${
- active === "/settings/password"
- ? "bg-primary/20"
- : "hover:bg-neutral/20"
- } duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-lock text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">
- {t("password")}
- </p>
- </div>
- </Link>
-
- {process.env.NEXT_PUBLIC_STRIPE && !user?.parentSubscriptionId && (
- <Link href="/settings/billing">
- <div
- className={`${
- active === "/settings/billing"
- ? "bg-primary/20"
- : "hover:bg-neutral/20"
- } duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-credit-card text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">
- {t("billing")}
- </p>
- </div>
- </Link>
- )}
- </div>
-
- <div className="flex flex-col gap-1">
- <Link
- href={`https://github.com/linkwarden/linkwarden/releases`}
- target="_blank"
- className="text-neutral text-sm ml-2 hover:opacity-50 duration-100"
- >
- {t("linkwarden_version", { version: LINKWARDEN_VERSION })}
- </Link>
- <Link href="https://docs.linkwarden.app" target="_blank">
- <div
- className={`hover:bg-neutral/20 duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-question-circle text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">{t("help")}</p>
- </div>
- </Link>
- <Link href="https://github.com/linkwarden/linkwarden" target="_blank">
- <div
- className={`hover:bg-neutral/20 duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-github text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">
- {t("github")}
- </p>
- </div>
- </Link>
- <Link href="https://twitter.com/LinkwardenHQ" target="_blank">
- <div
- className={`hover:bg-neutral/20 duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-twitter-x text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">
- {t("twitter")}
- </p>
- </div>
- </Link>
- <Link href="https://fosstodon.org/@linkwarden" target="_blank">
- <div
- className={`hover:bg-neutral/20 duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}
- >
- <i className="bi-mastodon text-primary text-xl drop-shadow"></i>
- <p className="truncate w-full font-semibold text-sm">
- {t("mastodon")}
- </p>
- </div>
- </Link>
- </div>
- </div>
+ <SecondarySidebar
+ className={className}
+ toggleSidebar={toggleSidebar}
+ sidebarIsCollapsed={sidebarIsCollapsed}
+ links={links}
+ />
);
}
diff --git a/apps/web/components/Sidebar.tsx b/apps/web/components/Sidebar.tsx
index a7a0c9a6..64554a85 100644
--- a/apps/web/components/Sidebar.tsx
+++ b/apps/web/components/Sidebar.tsx
@@ -1,6 +1,6 @@
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
-import { Disclosure, Transition } from "@headlessui/react";
+import { Transition } from "@headlessui/react";
import SidebarHighlightLink from "@/components/SidebarHighlightLink";
import CollectionListing from "@/components/CollectionListing";
import { useTranslation } from "next-i18next";
@@ -8,17 +8,28 @@ import { useCollections } from "@linkwarden/router/collections";
import { useTags } from "@linkwarden/router/tags";
import TagListing from "./TagListing";
import { Button } from "./ui/button";
-import { useUser } from "@linkwarden/router/user";
-import Image from "next/image";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
+import {
+ DropdownMenu,
+ DropdownMenuTrigger,
+ DropdownMenuContent,
+ DropdownMenuItem,
+} from "@/components/ui/dropdown-menu";
import { cn } from "@/lib/utils";
import { TagSort } from "@linkwarden/types/global";
import { useInView } from "react-intersection-observer";
+import SidebarShell, { ActionIcon } from "@/components/SidebarShell";
+import SidebarScrollArea from "@/components/SidebarScrollArea";
+import NewLinkModal from "./ModalContent/NewLinkModal";
+import NewCollectionModal from "./ModalContent/NewCollectionModal";
+import NewTagModal from "./ModalContent/NewTagModal";
+import UploadFileModal from "./ModalContent/UploadFileModal";
+import SearchModal, { isAppleDevice } from "./ModalContent/SearchModal";
export default function Sidebar({
className,
@@ -43,6 +54,12 @@ export default function Sidebar({
}
);
+ const [searchModal, setSearchModal] = useState(false);
+ const [newLinkModal, setNewLinkModal] = useState(false);
+ const [newCollectionModal, setNewCollectionModal] = useState(false);
+ const [newTagModal, setNewTagModal] = useState(false);
+ const [uploadFileModal, setUploadFileModal] = useState(false);
+
const { data: collections } = useCollections();
const {
@@ -58,8 +75,6 @@ export default function Sidebar({
const router = useRouter();
- const { data: user } = useUser();
-
useEffect(() => {
localStorage.setItem("tagDisclosure", tagDisclosure ? "true" : "false");
}, [tagDisclosure]);
@@ -75,6 +90,20 @@ export default function Sidebar({
setActive(router.asPath);
}, [router, collections]);
+ useEffect(() => {
+ const handler = (e: KeyboardEvent) => {
+ if (
+ e.key.toLowerCase() === "k" &&
+ (isAppleDevice ? e.metaKey : e.ctrlKey)
+ ) {
+ e.preventDefault();
+ setSearchModal((prev) => !prev);
+ }
+ };
+ document.addEventListener("keydown", handler);
+ return () => document.removeEventListener("keydown", handler);
+ }, []);
+
useEffect(() => {
if (!inView) return;
if (!hasNextPage) return;
@@ -84,216 +113,269 @@ export default function Sidebar({
}, [inView, hasNextPage, isFetchingNextPage, fetchNextPage]);
return (
- <div
- id="sidebar"
- className={cn(
- "bg-base-200 h-screen overflow-y-auto border-solid border border-base-200 border-r-neutral-content p-2 z-20",
- className,
- sidebarIsCollapsed ? "w-14" : "w-80"
- )}
+ <SidebarShell
+ className={className}
+ toggleSidebar={toggleSidebar}
+ sidebarIsCollapsed={sidebarIsCollapsed}
>
- <div
- className={cn(
- "flex flex-col",
- sidebarIsCollapsed
- ? "my-auto h-full justify-between items-center gap-3"
- : "gap-1"
- )}
- >
- <div className="flex items-center justify-between mb-3">
- {sidebarIsCollapsed ? (
- <Image
- src={"/icon.png"}
- width={640}
- height={136}
- alt="Linkwarden Icon"
- className="h-8 w-auto cursor-pointer"
- onClick={() => router.push("/dashboard")}
- priority
+ {({ collapsed, toggle, closeMobileSidebar }) => {
+ const openModal = (setModal: (value: boolean) => void) => {
+ setModal(true);
+ closeMobileSidebar();
+ };
+
+ const navLinks = (
+ <div className={cn("flex flex-col gap-2", collapsed && "gap-3")}>
+ <SidebarHighlightLink
+ title={t("dashboard")}
+ href={`/dashboard`}
+ icon={"bi-house"}
+ active={active === `/dashboard`}
+ sidebarIsCollapsed={collapsed}
+ />
+ <SidebarHighlightLink
+ title={t("links")}
+ href={`/links`}
+ icon={"bi-link-45deg"}
+ active={active === `/links`}
+ sidebarIsCollapsed={collapsed}
+ />
+ <SidebarHighlightLink
+ title={t("pinned")}
+ href={`/links/pinned`}
+ icon={"bi-pin-angle"}
+ active={active === `/links/pinned`}
+ sidebarIsCollapsed={collapsed}
/>
- ) : user?.theme === "light" ? (
- <Image
- src={"/linkwarden_light.png"}
- width={640}
- height={136}
- alt="Linkwarden"
- className="h-9 w-auto cursor-pointer"
- onClick={() => router.push("/dashboard")}
- priority
+ <SidebarHighlightLink
+ title={t("collections")}
+ href={`/collections`}
+ icon={"bi-folder"}
+ active={active === `/collections`}
+ sidebarIsCollapsed={collapsed}
+ expanded={collectionDisclosure}
+ onToggleExpand={
+ collapsed
+ ? undefined
+ : () => setCollectionDisclosure(!collectionDisclosure)
+ }
/>
- ) : (
- <Image
- src={"/linkwarden_dark.png"}
- width={640}
- height={136}
- alt="Linkwarden"
- className="h-9 w-auto cursor-pointer"
- onClick={() => router.push("/dashboard")}
- priority
+ {!collapsed && (
+ <Transition
+ show={collectionDisclosure}
+ enter="transition duration-100 ease-out"
+ enterFrom="transform opacity-0 -translate-y-3"
+ enterTo="transform opacity-100 translate-y-0"
+ leave="transition duration-100 ease-out"
+ leaveFrom="transform opacity-100 translate-y-0"
+ leaveTo="transform opacity-0 -translate-y-3"
+ >
+ <div className="pl-4">
+ <CollectionListing />
+ </div>
+ </Transition>
+ )}
+ <SidebarHighlightLink
+ title={t("tags")}
+ href={`/tags`}
+ icon={"bi-hash"}
+ active={active === `/tags`}
+ sidebarIsCollapsed={collapsed}
+ expanded={tagDisclosure}
+ onToggleExpand={
+ collapsed ? undefined : () => setTagDisclosure(!tagDisclosure)
+ }
/>
- )}
+ {!collapsed && (
+ <Transition
+ show={tagDisclosure}
+ enter="transition duration-100 ease-out"
+ enterFrom="transform opacity-0 -translate-y-3"
+ enterTo="transform opacity-100 translate-y-0"
+ leave="transition duration-100 ease-out"
+ leaveFrom="transform opacity-100 translate-y-0"
+ leaveTo="transform opacity-0 -translate-y-3"
+ >
+ <div className="pl-4 flex flex-col gap-1">
+ {isLoading ? (
+ <div className="flex flex-col gap-4">
+ <div className="skeleton h-4 w-full"></div>
+ <div className="skeleton h-4 w-full"></div>
+ <div className="skeleton h-4 w-full"></div>
+ </div>
+ ) : (
+ <>
+ <TagListing tags={tags} active={active} />
+ {hasNextPage && <div ref={ref} className="h-1 w-full" />}
+ {isFetchingNextPage && (
+ <div className="flex flex-col gap-4 mt-3">
+ <div className="skeleton h-4 w-full"></div>
+ <div className="skeleton h-4 w-full"></div>
+ <div className="skeleton h-4 w-full"></div>
+ </div>
+ )}
+ </>
+ )}
+ </div>
+ </Transition>
+ )}
+ </div>
+ );
- {!sidebarIsCollapsed && (
- <div className="hidden lg:block">
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- onClick={toggleSidebar}
- size={"icon"}
+ return (
+ <>
+ {collapsed ? (
+ <div className="flex flex-col items-center gap-3 shrink-0">
+ <ActionIcon
+ icon="bi-search"
+ variant="default"
+ label={t("search_for_links")}
+ tooltipSide="right"
+ onClick={() => openModal(setSearchModal)}
+ />
+ <DropdownMenu>
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="primary"
+ size="icon"
+ className="h-9 w-9 shrink-0"
+ aria-label={t("create_new")}
+ >
+ <i className="bi-plus-lg text-lg leading-none" />
+ </Button>
+ </DropdownMenuTrigger>
+ </TooltipTrigger>
+ <TooltipContent side="right">
+ {t("create_new")}
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ <DropdownMenuContent side="right" align="start">
+ <DropdownMenuItem
+ onSelect={() => openModal(setNewLinkModal)}
>
- <i className={`bi-layout-sidebar`} />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- {sidebarIsCollapsed
- ? t("expand_sidebar")
- : t("shrink_sidebar")}
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
- )}
- </div>
+ <i className="bi-link-45deg" />
+ {t("new_link")}
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onSelect={() => openModal(setNewCollectionModal)}
+ >
+ <i className="bi-folder-plus" />
+ {t("new_collection")}
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onSelect={() => openModal(setNewTagModal)}
+ >
+ <i className="bi-tag" />
+ {t("new_tag")}
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onSelect={() => openModal(setUploadFileModal)}
+ >
+ <i className="bi-file-earmark-arrow-up" />
+ {t("upload_file")}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ ) : (
+ <div className="flex flex-col gap-2 shrink-0 pt-1 px-1">
+ <Button
+ size="sm"
+ variant="default"
+ className="justify-between whitespace-nowrap h-8"
+ onClick={() => openModal(setSearchModal)}
+ >
+ <div className="flex gap-2 items-center">
+ <i className="bi-search leading-none" />
+ {t("search_for_links")}
+ </div>
+ </Button>
- <div
- className={cn(
- "flex flex-col",
- sidebarIsCollapsed ? "my-auto justify-center gap-3" : "gap-1"
- )}
- >
- <SidebarHighlightLink
- title={t("dashboard")}
- href={`/dashboard`}
- icon={"bi-house"}
- active={active === `/dashboard`}
- sidebarIsCollapsed={sidebarIsCollapsed}
- />
- <SidebarHighlightLink
- title={t("links")}
- href={`/links`}
- icon={"bi-link-45deg"}
- active={active === `/links`}
- sidebarIsCollapsed={sidebarIsCollapsed}
- />
- <SidebarHighlightLink
- title={t("pinned")}
- href={`/links/pinned`}
- icon={"bi-pin-angle"}
- active={active === `/links/pinned`}
- sidebarIsCollapsed={sidebarIsCollapsed}
- />
- <SidebarHighlightLink
- title={t("collections")}
- href={`/collections`}
- icon={"bi-folder"}
- active={active === `/collections`}
- sidebarIsCollapsed={sidebarIsCollapsed}
- />
- <SidebarHighlightLink
- title={t("tags")}
- href={`/tags`}
- icon={"bi-hash"}
- active={active === `/tags`}
- sidebarIsCollapsed={sidebarIsCollapsed}
- />
- </div>
+ <div className="flex items-center gap-1.5">
+ <Button
+ variant="primary"
+ className="flex-1 min-w-0 h-9 justify-center whitespace-nowrap"
+ onClick={() => openModal(setNewLinkModal)}
+ >
+ <i className="bi-plus-lg text-lg leading-none" />
+ {t("new_link")}
+ </Button>
- {sidebarIsCollapsed && (
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button variant="ghost" onClick={toggleSidebar} size={"icon"}>
- <i className={`bi-layout-sidebar`} />
- </Button>
- </TooltipTrigger>
- <TooltipContent side="right">
- {sidebarIsCollapsed ? t("expand_sidebar") : t("shrink_sidebar")}
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- )}
- </div>
+ <ActionIcon
+ icon="bi-folder-plus"
+ variant="default"
+ label={t("new_collection")}
+ onClick={() => openModal(setNewCollectionModal)}
+ />
+ <ActionIcon
+ icon="bi-tag"
+ variant="default"
+ label={t("new_tag")}
+ onClick={() => openModal(setNewTagModal)}
+ />
- {sidebarIsCollapsed ? (
- <></>
- ) : (
- <>
- <Disclosure defaultOpen={collectionDisclosure}>
- <Disclosure.Button
- onClick={() => {
- setCollectionDisclosure(!collectionDisclosure);
- }}
- className="flex items-center justify-between w-full text-left mb-2 pl-2 font-bold text-neutral mt-4"
- >
- <p className="text-sm">{t("collections")}</p>
- <i
- className={`bi-chevron-down ${
- collectionDisclosure ? "rotate-reverse" : "rotate"
- }`}
- ></i>
- </Disclosure.Button>
- <Transition
- enter="transition duration-100 ease-out"
- enterFrom="transform opacity-0 -translate-y-3"
- enterTo="transform opacity-100 translate-y-0"
- leave="transition duration-100 ease-out"
- leaveFrom="transform opacity-100 translate-y-0"
- leaveTo="transform opacity-0 -translate-y-3"
- >
- <Disclosure.Panel>
- <CollectionListing />
- </Disclosure.Panel>
- </Transition>
- </Disclosure>
- <Disclosure defaultOpen={tagDisclosure}>
- <Disclosure.Button
- onClick={() => {
- setTagDisclosure(!tagDisclosure);
- }}
- className="flex items-center justify-between w-full text-left mb-2 pl-2 font-bold text-neutral mt-4"
- >
- <p className="text-sm">{t("tags")}</p>
- <i
- className={`bi-chevron-down ${
- tagDisclosure ? "rotate-reverse" : "rotate"
- }`}
- ></i>
- </Disclosure.Button>
- <Transition
- enter="transition duration-100 ease-out"
- enterFrom="transform opacity-0 -translate-y-3"
- enterTo="transform opacity-100 translate-y-0"
- leave="transition duration-100 ease-out"
- leaveFrom="transform opacity-100 translate-y-0"
- leaveTo="transform opacity-0 -translate-y-3"
- >
- <Disclosure.Panel className="flex flex-col gap-1">
- {isLoading ? (
- <div className="flex flex-col gap-4">
- <div className="skeleton h-4 w-full"></div>
- <div className="skeleton h-4 w-full"></div>
- <div className="skeleton h-4 w-full"></div>
- </div>
- ) : (
- <>
- <TagListing tags={tags} active={active} />
- {hasNextPage && <div ref={ref} className="h-1 w-full" />}
- {isFetchingNextPage && (
- <div className="flex flex-col gap-4 mt-3">
- <div className="skeleton h-4 w-full"></div>
- <div className="skeleton h-4 w-full"></div>
- <div className="skeleton h-4 w-full"></div>
- </div>
- )}
- </>
- )}
- </Disclosure.Panel>
- </Transition>
- </Disclosure>
- </>
- )}
- </div>
+ <DropdownMenu>
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="default"
+ size="icon"
+ className="h-9 w-9 shrink-0"
+ aria-label={t("more")}
+ >
+ <i className="bi-three-dots text-lg leading-none" />
+ </Button>
+ </DropdownMenuTrigger>
+ </TooltipTrigger>
+ <TooltipContent>{t("more")}</TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem
+ onSelect={() => openModal(setUploadFileModal)}
+ >
+ <i className="bi-file-earmark-arrow-up" />
+ {t("upload_file")}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </div>
+ )}
+
+ {collapsed ? (
+ <div className="flex-1 min-h-0 flex flex-col items-center justify-center">
+ {navLinks}
+ </div>
+ ) : (
+ <SidebarScrollArea>{navLinks}</SidebarScrollArea>
+ )}
+ {searchModal && (
+ <SearchModal onClose={() => setSearchModal(false)} />
+ )}
+ {newLinkModal && (
+ <NewLinkModal onClose={() => setNewLinkModal(false)} />
+ )}
+ {newCollectionModal && (
+ <NewCollectionModal
+ onClose={() => setNewCollectionModal(false)}
+ />
+ )}
+ {newTagModal && (
+ <NewTagModal onClose={() => setNewTagModal(false)} />
+ )}
+ {uploadFileModal && (
+ <UploadFileModal onClose={() => setUploadFileModal(false)} />
+ )}
+ </>
+ );
+ }}
+ </SidebarShell>
);
}
diff --git a/apps/web/components/SidebarHighlightLink.tsx b/apps/web/components/SidebarHighlightLink.tsx
index 94dadce2..3c780d95 100644
--- a/apps/web/components/SidebarHighlightLink.tsx
+++ b/apps/web/components/SidebarHighlightLink.tsx
@@ -12,37 +12,78 @@ export default function SidebarHighlightLink({
href,
icon,
active,
+ external,
sidebarIsCollapsed,
+ expanded,
+ onToggleExpand,
}: {
title: string;
href: string;
icon: string;
active?: boolean;
+ external?: boolean;
sidebarIsCollapsed?: boolean;
+ expanded?: boolean;
+ onToggleExpand?: () => void;
}) {
+ const showToggle = Boolean(onToggleExpand) && !sidebarIsCollapsed;
+
return (
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
- <Link href={href} title={title}>
+ <Link
+ href={href}
+ title={title}
+ target={external ? "_blank" : undefined}
+ >
<div
className={cn(
active ? "bg-primary/20" : "hover:bg-neutral/20",
- "duration-200 cursor-pointer flex items-center gap-2 capitalize",
- sidebarIsCollapsed
- ? "rounded-md h-8 w-8"
- : "rounded-lg px-3 py-1"
+ "group transition-colors cursor-pointer flex items-center gap-2 capitalize",
+ sidebarIsCollapsed ? "rounded-md h-8 w-8" : "rounded-lg px-3"
)}
>
- <i
- className={cn(
- icon,
- "text-primary text-xl drop-shadow",
- sidebarIsCollapsed && "w-full text-center"
- )}
- ></i>
+ {sidebarIsCollapsed ? (
+ <i
+ className={cn(
+ icon,
+ "text-primary text-lg drop-shadow w-full text-center"
+ )}
+ ></i>
+ ) : (
+ <span className="relative flex items-center shrink-0">
+ <i
+ className={cn(
+ icon,
+ "text-primary text-lg drop-shadow",
+ showToggle && "group-hover:opacity-0 duration-100"
+ )}
+ ></i>
+ {showToggle && (
+ <button
+ onClick={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ onToggleExpand?.();
+ }}
+ aria-expanded={expanded}
+ className="absolute inset-0 hidden group-hover:flex items-center justify-center"
+ >
+ <i
+ className={cn(
+ expanded
+ ? "bi-caret-down-fill"
+ : "bi-caret-right-fill",
+ "opacity-50 hover:opacity-100 duration-200"
+ )}
+ ></i>
+ </button>
+ )}
+ </span>
+ )}
{!sidebarIsCollapsed && (
- <p className="truncate w-full font-semibold text-sm">{title}</p>
+ <p className="truncate w-full font-bold text-xs">{title}</p>
)}
</div>
</Link>
diff --git a/apps/web/components/SidebarScrollArea.tsx b/apps/web/components/SidebarScrollArea.tsx
new file mode 100644
index 00000000..28423333
--- /dev/null
+++ b/apps/web/components/SidebarScrollArea.tsx
@@ -0,0 +1,146 @@
+import { ReactNode, useEffect, useRef, useState } from "react";
+import { cn } from "@/lib/utils";
+
+const SCROLLBAR_HIDE_DELAY = 1000;
+const MIN_THUMB_HEIGHT = 24;
+
+export default function SidebarScrollArea({
+ children,
+}: {
+ children: ReactNode;
+}) {
+ const scrollRef = useRef<HTMLDivElement>(null);
+ const contentRef = useRef<HTMLDivElement>(null);
+ const hideTimeout = useRef<ReturnType<typeof setTimeout> | undefined>(
+ undefined
+ );
+ const drag = useRef<{ startY: number; startScrollTop: number } | null>(null);
+
+ const [showTopFade, setShowTopFade] = useState(false);
+ const [showBottomFade, setShowBottomFade] = useState(false);
+ const [thumb, setThumb] = useState({ top: 0, height: 0 });
+ const [scrolling, setScrolling] = useState(false);
+ const [thumbHovered, setThumbHovered] = useState(false);
+ const [dragging, setDragging] = useState(false);
+
+ const updateScrollState = () => {
+ const el = scrollRef.current;
+ if (!el) return;
+
+ setShowTopFade(el.scrollTop > 0);
+ setShowBottomFade(el.scrollHeight - el.clientHeight - el.scrollTop > 1);
+
+ if (el.scrollHeight <= el.clientHeight) {
+ setThumb({ top: 0, height: 0 });
+ return;
+ }
+
+ const height = Math.max(
+ (el.clientHeight / el.scrollHeight) * el.clientHeight,
+ MIN_THUMB_HEIGHT
+ );
+
+ const maxScrollTop = el.scrollHeight - el.clientHeight;
+ const scrollTop = Math.min(Math.max(el.scrollTop, 0), maxScrollTop);
+ const top = (scrollTop / maxScrollTop) * (el.clientHeight - height);
+
+ setThumb({ top, height });
+ };
+
+ const showScrollbar = () => {
+ setScrolling(true);
+ if (hideTimeout.current) clearTimeout(hideTimeout.current);
+ hideTimeout.current = setTimeout(
+ () => setScrolling(false),
+ SCROLLBAR_HIDE_DELAY
+ );
+ };
+
+ const handleScroll = () => {
+ updateScrollState();
+ showScrollbar();
+ };
+
+ useEffect(() => {
+ updateScrollState();
+
+ const observer = new ResizeObserver(updateScrollState);
+ if (scrollRef.current) observer.observe(scrollRef.current);
+ if (contentRef.current) observer.observe(contentRef.current);
+
+ return () => {
+ observer.disconnect();
+ if (hideTimeout.current) clearTimeout(hideTimeout.current);
+ };
+ }, []);
+
+ const onThumbPointerDown = (e: React.PointerEvent<HTMLDivElement>) => {
+ const el = scrollRef.current;
+ if (!el) return;
+
+ e.preventDefault();
+ e.currentTarget.setPointerCapture(e.pointerId);
+ drag.current = { startY: e.clientY, startScrollTop: el.scrollTop };
+ setDragging(true);
+ };
+
+ const onThumbPointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
+ const el = scrollRef.current;
+ if (!el || !drag.current) return;
+
+ const trackRange = el.clientHeight - thumb.height;
+ if (trackRange <= 0) return;
+
+ const scrollRange = el.scrollHeight - el.clientHeight;
+ el.scrollTop =
+ drag.current.startScrollTop +
+ ((e.clientY - drag.current.startY) * scrollRange) / trackRange;
+ };
+
+ const onThumbPointerUp = () => {
+ drag.current = null;
+ setDragging(false);
+ showScrollbar();
+ };
+
+ const thumbVisible =
+ thumb.height > 0 && (scrolling || thumbHovered || dragging);
+
+ return (
+ <div className="flex-1 min-h-0 relative mt-1">
+ <div
+ ref={scrollRef}
+ onScroll={handleScroll}
+ className="h-full overflow-y-auto p-1 hide-scrollbar"
+ >
+ <div ref={contentRef}>{children}</div>
+ </div>
+ <div
+ className={cn(
+ "absolute top-0 inset-x-0 h-6 bg-gradient-to-b from-base-200 to-transparent pointer-events-none transition-opacity duration-200",
+ showTopFade ? "opacity-100" : "opacity-0"
+ )}
+ />
+ <div
+ className={cn(
+ "absolute bottom-0 inset-x-0 h-6 bg-gradient-to-t from-base-200 to-transparent pointer-events-none transition-opacity duration-200",
+ showBottomFade ? "opacity-100" : "opacity-0"
+ )}
+ />
+ {thumb.height > 0 && (
+ <div
+ onPointerDown={onThumbPointerDown}
+ onPointerMove={onThumbPointerMove}
+ onPointerUp={onThumbPointerUp}
+ onPointerEnter={() => setThumbHovered(true)}
+ onPointerLeave={() => setThumbHovered(false)}
+ className={cn(
+ "absolute right-0.5 w-1.5 rounded-full bg-base-content/30 hover:bg-base-content/50 touch-none transition-opacity duration-300",
+ thumbVisible ? "opacity-100" : "opacity-0 pointer-events-none"
+ )}
+ style={{ top: thumb.top, height: thumb.height }}
+ />
+ )}
+ </div>
+ );
+}
diff --git a/apps/web/components/SidebarShell.tsx b/apps/web/components/SidebarShell.tsx
new file mode 100644
index 00000000..429a17c2
--- /dev/null
+++ b/apps/web/components/SidebarShell.tsx
@@ -0,0 +1,155 @@
+import { ReactNode, useEffect, useState } from "react";
+import { useRouter } from "next/router";
+import { useTranslation } from "next-i18next";
+import useWindowDimensions from "@/hooks/useWindowDimensions";
+import ProfileDropdown from "@/components/ProfileDropdown";
+import { Button } from "./ui/button";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger,
+} from "@/components/ui/tooltip";
+import { cn } from "@/lib/utils";
+
+export function ActionIcon({
+ icon,
+ label,
+ onClick,
+ variant = "metal",
+ tooltipSide,
+}: {
+ icon: string;
+ label: string;
+ onClick: () => void;
+ variant?:
+ | "metal"
+ | "link"
+ | "default"
+ | "primary"
+ | "accent"
+ | "destructive"
+ | "outline"
+ | "secondary"
+ | "ghost"
+ | "simple";
+ tooltipSide?: "top" | "right" | "bottom" | "left";
+}) {
+ return (
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant={variant}
+ size="icon"
+ className="h-9 w-9 shrink-0"
+ onClick={onClick}
+ aria-label={label}
+ >
+ <i className={cn(icon, "text-lg leading-none")} />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent side={tooltipSide}>{label}</TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ );
+}
+
+type SidebarShellContext = {
+ collapsed?: boolean;
+ toggle?: () => void;
+ closeMobileSidebar: () => void;
+};
+
+export default function SidebarShell({
+ className,
+ toggleSidebar,
+ sidebarIsCollapsed,
+ children,
+}: {
+ className?: string;
+ toggleSidebar?: () => void;
+ sidebarIsCollapsed?: boolean;
+ children: (ctx: SidebarShellContext) => ReactNode;
+}) {
+ const { t } = useTranslation();
+ const router = useRouter();
+
+ const { width } = useWindowDimensions();
+ const isMobile = width < 1024;
+ const [mobileExpanded, setMobileExpanded] = useState(false);
+
+ useEffect(() => {
+ setMobileExpanded(false);
+ }, [router.asPath]);
+
+ const collapsed = isMobile ? !mobileExpanded : sidebarIsCollapsed;
+ const toggle = isMobile
+ ? () => setMobileExpanded(!mobileExpanded)
+ : toggleSidebar;
+
+ return (
+ <>
+ {isMobile && mobileExpanded && (
+ <>
+ <div className="w-14 shrink-0" />
+ <div
+ className="fixed inset-0 bg-black bg-opacity-10 backdrop-blur-sm z-30 fade-in"
+ onClick={() => setMobileExpanded(false)}
+ />
+ </>
+ )}
+ <div
+ id="sidebar"
+ className={cn(
+ "bg-base-200 h-screen flex flex-col border-solid border border-base-200 border-r-neutral-content z-20",
+ className,
+ collapsed ? "p-2 w-14" : "p-1 w-72",
+ isMobile &&
+ mobileExpanded &&
+ "p-2 fixed inset-y-0 left-0 z-40 shadow-lg"
+ )}
+ >
+ {children({
+ collapsed,
+ toggle,
+ closeMobileSidebar: () => setMobileExpanded(false),
+ })}
+
+ <div
+ className={cn(
+ "shrink-0 flex items-center gap-2 p-1 mt-1",
+ collapsed ? "flex-col" : "justify-between relative"
+ )}
+ >
+ {collapsed ? (
+ <ProfileDropdown
+ tooltipSide="right"
+ dropdownSide="right"
+ dropdownAlign="end"
+ />
+ ) : (
+ <div className="min-w-0 flex-1">
+ <ProfileDropdown showName />
+ </div>
+ )}
+
+ {toggle && (
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button variant="ghost" onClick={toggle} size="icon">
+ <i className="bi-layout-sidebar" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent side={collapsed ? "right" : "top"}>
+ {collapsed ? t("expand_sidebar") : t("shrink_sidebar")}
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ )}
+ </div>
+ </div>
+ </>
+ );
+}
diff --git a/apps/web/components/TagListing.tsx b/apps/web/components/TagListing.tsx
index b8ed2f28..a45636fe 100644
--- a/apps/web/components/TagListing.tsx
+++ b/apps/web/components/TagListing.tsx
@@ -16,13 +16,9 @@ export default function TagListing({ tags, active }: TagListingProps) {
if (!tags[0]) {
return (
- <div
- className={`duration-100 py-1 px-2 flex items-center gap-2 w-full rounded-md h-8 capitalize`}
- >
- <p className="text-neutral text-xs font-semibold truncate w-full pr-7">
- {t("you_have_no_tags")}
- </p>
- </div>
+ <p className="text-neutral text-xs font-semibold truncate w-full px-2">
+ {t("you_have_no_tags")}
+ </p>
);
}
@@ -46,11 +42,11 @@ export default function TagListing({ tags, active }: TagListingProps) {
: droppableActive
? "select-none"
: "hover:bg-neutral/20",
- "duration-100 py-1 px-2 cursor-pointer flex items-center gap-2 w-full rounded-md h-8"
+ "duration-100 px-2 cursor-pointer flex items-center gap-2 w-full rounded-md"
)}
>
- <i className="bi-hash text-xl text-primary drop-shadow"></i>
- <p className="truncate w-full pr-7">{e.name}</p>
+ <i className="bi-hash text-lg text-primary drop-shadow"></i>
+ <p className="truncate w-full pr-7 text-sm">{e.name}</p>
<div className="drop-shadow text-neutral text-xs">
{e._count?.links}
</div>
diff --git a/apps/web/components/TrialBanner.tsx b/apps/web/components/TrialBanner.tsx
new file mode 100644
index 00000000..388c0f11
--- /dev/null
+++ b/apps/web/components/TrialBanner.tsx
@@ -0,0 +1,51 @@
+import { useEffect, useState } from "react";
+import Link from "next/link";
+import { useTranslation } from "next-i18next";
+import { useUser } from "@linkwarden/router/user";
+
+const STRIPE_ENABLED = process.env.NEXT_PUBLIC_STRIPE === "true";
+const TRIAL_PERIOD_DAYS =
+ Number(process.env.NEXT_PUBLIC_TRIAL_PERIOD_DAYS) || 14;
+
+export default function TrialBanner() {
+ const { t } = useTranslation();
+ const { data: user } = useUser();
+
+ const [daysLeft, setDaysLeft] = useState<number>(0);
+ const [isTrialing, setIsTrialing] = useState<boolean>(false);
+
+ useEffect(() => {
+ if (user?.createdAt) {
+ const trialEndTime =
+ new Date(user.createdAt).getTime() +
+ (1 + Number(TRIAL_PERIOD_DAYS)) * 86400000; // Add 1 to account for the current day
+
+ setDaysLeft(Math.floor((trialEndTime - Date.now()) / 86400000));
+ }
+ }, [user]);
+
+ useEffect(() => {
+ const isTrialing =
+ user?.id &&
+ !user?.subscription?.active &&
+ !user.parentSubscription?.active;
+
+ setIsTrialing(Boolean(isTrialing));
+ }, [user, daysLeft]);
+
+ if (!STRIPE_ENABLED || !isTrialing) return null;
+
+ return (
+ <Link
+ href="/subscribe"
+ className="w-full text-sm cursor-pointer select-none bg-base-200"
+ >
+ <p className="w-full text-center flex items-center justify-center gap-1 underline decoration-dotted underline-offset-4 hover:opacity-70 duration-200 py-1 px-2">
+ <i className="bi-clock text-primary" />
+ {daysLeft === 1
+ ? t("trial_left_singular")
+ : t("trial_left_plural", { count: daysLeft })}
+ </p>
+ </Link>
+ );
+}
diff --git a/apps/web/components/ui/kbd.tsx b/apps/web/components/ui/kbd.tsx
new file mode 100644
index 00000000..ae002929
--- /dev/null
+++ b/apps/web/components/ui/kbd.tsx
@@ -0,0 +1,19 @@
+import * as React from "react";
+
+import { cn } from "@/lib/utils";
+
+const Kbd = React.forwardRef<HTMLElement, React.HTMLAttributes<HTMLElement>>(
+ ({ className, ...props }, ref) => (
+ <kbd
+ ref={ref}
+ className={cn(
+ "font-mono text-xs px-1.5 py-0.5 rounded-md bg-base-200 border border-neutral-content text-neutral",
+ className
+ )}
+ {...props}
+ />
+ )
+);
+Kbd.displayName = "Kbd";
+
+export { Kbd };
diff --git a/apps/web/hooks/useSidebarCollapse.ts b/apps/web/hooks/useSidebarCollapse.ts
new file mode 100644
index 00000000..490e2171
--- /dev/null
+++ b/apps/web/hooks/useSidebarCollapse.ts
@@ -0,0 +1,18 @@
+import { useEffect, useState } from "react";
+
+export default function useSidebarCollapse() {
+ const [sidebarIsCollapsed, setSidebarIsCollapsed] = useState<boolean>(
+ () => localStorage.getItem("sidebarIsCollapsed") === "true"
+ );
+
+ useEffect(() => {
+ localStorage.setItem(
+ "sidebarIsCollapsed",
+ sidebarIsCollapsed ? "true" : "false"
+ );
+ }, [sidebarIsCollapsed]);
+
+ const toggleSidebar = () => setSidebarIsCollapsed(!sidebarIsCollapsed);
+
+ return { sidebarIsCollapsed, toggleSidebar };
+}
diff --git a/apps/web/layouts/AdminLayout.tsx b/apps/web/layouts/AdminLayout.tsx
index e8b95e5d..207cbe3f 100644
--- a/apps/web/layouts/AdminLayout.tsx
+++ b/apps/web/layouts/AdminLayout.tsx
@@ -1,37 +1,28 @@
import AdminSidebar from "@/components/AdminSidebar";
-import Navbar from "@/components/Navbar";
import React, { ReactNode } from "react";
-import Link from "next/link";
-import { Button } from "@/components/ui/button";
-import { useTranslation } from "next-i18next";
+import useSidebarCollapse from "@/hooks/useSidebarCollapse";
interface Props {
children: ReactNode;
}
export default function AdminLayout({ children }: Props) {
- const { t } = useTranslation();
+ const { sidebarIsCollapsed, toggleSidebar } = useSidebarCollapse();
return (
<div className="flex" data-testid="admin-wrapper">
- <div className="hidden lg:block">
- <AdminSidebar />
- </div>
-
- <div className="lg:w-[calc(100%-320px)] w-full sm:pb-0 pb-20 flex flex-col h-screen overflow-y-auto">
- <Navbar admin />
- <div className="p-5 mx-auto w-full max-w-7xl">
- <div className="gap-2 mb-3">
- <Button asChild variant="ghost" size="sm" className="text-neutral">
- <Link href="/dashboard">
- <i className="bi-chevron-left text-md" />
- <p>{t("back_to_dashboard")}</p>
- </Link>
- </Button>
- </div>
+ <AdminSidebar
+ toggleSidebar={toggleSidebar}
+ sidebarIsCollapsed={sidebarIsCollapsed}
+ />
- {children}
- </div>
+ <div
+ className={`${
+ sidebarIsCollapsed ? "" : "lg:w-[calc(100%-288px)]"
+ } w-[calc(100%-56px)] sm:pb-0 pb-20 flex flex-col h-screen overflow-y-auto`}
+ >
+ {/* <TrialBanner /> */}
+ <div className="p-5 mx-auto w-full max-w-7xl">{children}</div>
</div>
</div>
);
diff --git a/apps/web/layouts/MainLayout.tsx b/apps/web/layouts/MainLayout.tsx
index a5bb360d..1aaeeb7f 100644
--- a/apps/web/layouts/MainLayout.tsx
+++ b/apps/web/layouts/MainLayout.tsx
@@ -1,10 +1,10 @@
-import Navbar from "@/components/Navbar";
import Announcement from "@/components/Announcement";
import Sidebar from "@/components/Sidebar";
import { ReactNode, useEffect, useState } from "react";
import getLatestVersion from "@/lib/client/getLatestVersion";
import DragNDrop from "@/components/DragNDrop";
import { LinkIncludingShortenedCollectionAndTags } from "@linkwarden/types/global";
+import useSidebarCollapse from "@/hooks/useSidebarCollapse";
interface Props {
children: ReactNode;
@@ -12,14 +12,11 @@ interface Props {
export default function MainLayout({ children }: Props) {
const showAnnouncementBar = localStorage.getItem("showAnnouncementBar");
- const sidebarState = localStorage.getItem("sidebarIsCollapsed");
const [showAnnouncement, setShowAnnouncement] = useState(
showAnnouncementBar ? showAnnouncementBar === "true" : true
);
- const [sidebarIsCollapsed, setSidebarIsCollapsed] = useState(
- sidebarState ? sidebarState === "true" : false
- );
+ const { sidebarIsCollapsed, toggleSidebar } = useSidebarCollapse();
useEffect(() => {
getLatestVersion(setShowAnnouncement);
@@ -32,15 +29,7 @@ export default function MainLayout({ children }: Props) {
);
}, [showAnnouncement]);
- useEffect(() => {
- localStorage.setItem(
- "sidebarIsCollapsed",
- sidebarIsCollapsed ? "true" : "false"
- );
- }, [sidebarIsCollapsed]);
-
const toggleAnnouncementBar = () => setShowAnnouncement(!showAnnouncement);
- const toggleSidebar = () => setSidebarIsCollapsed(!sidebarIsCollapsed);
const [activeLink, setActiveLink] =
useState<LinkIncludingShortenedCollectionAndTags | null>(null);
@@ -51,22 +40,16 @@ export default function MainLayout({ children }: Props) {
{showAnnouncement && (
<Announcement toggleAnnouncementBar={toggleAnnouncementBar} />
)}
- <div className="hidden lg:block">
- <Sidebar
- className={`${sidebarIsCollapsed ? "w-14" : "w-80"}`}
- toggleSidebar={toggleSidebar}
- sidebarIsCollapsed={sidebarIsCollapsed}
- />
- </div>
+ <Sidebar
+ toggleSidebar={toggleSidebar}
+ sidebarIsCollapsed={sidebarIsCollapsed}
+ />
<div
className={`${
- sidebarIsCollapsed
- ? "lg:w-[calc(100%-56px)]"
- : "lg:w-[calc(100%-320px)]"
- } w-full sm:pb-0 pb-20 flex flex-col h-screen overflow-y-auto`}
+ sidebarIsCollapsed ? "" : "lg:w-[calc(100%-288px)]"
+ } w-[calc(100%-56px)] sm:pb-0 pb-20 flex flex-col h-screen overflow-y-auto`}
>
- <Navbar />
{children}
</div>
</div>
diff --git a/apps/web/layouts/SettingsLayout.tsx b/apps/web/layouts/SettingsLayout.tsx
index a66571ed..a94510c9 100644
--- a/apps/web/layouts/SettingsLayout.tsx
+++ b/apps/web/layouts/SettingsLayout.tsx
@@ -1,35 +1,28 @@
import SettingsSidebar from "@/components/SettingsSidebar";
-import Navbar from "@/components/Navbar";
import React, { ReactNode } from "react";
-import Link from "next/link";
-import { Button } from "@/components/ui/button";
-import { useTranslation } from "next-i18next";
+import useSidebarCollapse from "@/hooks/useSidebarCollapse";
interface Props {
children: ReactNode;
}
export default function SettingsLayout({ children }: Props) {
- const { t } = useTranslation();
+ const { sidebarIsCollapsed, toggleSidebar } = useSidebarCollapse();
return (
<div className="flex" data-testid="settings-wrapper">
- <div className="hidden lg:block">
- <SettingsSidebar />
- </div>
+ <SettingsSidebar
+ toggleSidebar={toggleSidebar}
+ sidebarIsCollapsed={sidebarIsCollapsed}
+ />
- <div className="lg:w-[calc(100%-320px)] w-full sm:pb-0 pb-20 flex flex-col h-screen overflow-y-auto">
- <Navbar settings />
+ <div
+ className={`${
+ sidebarIsCollapsed ? "" : "lg:w-[calc(100%-288px)]"
+ } w-[calc(100%-56px)] sm:pb-0 pb-20 flex flex-col h-screen overflow-y-auto`}
+ >
+ {/* <TrialBanner /> */}
<div className="p-3 mx-auto w-full max-w-3xl min-[2000px]:max-w-6xl">
- <div className="gap-2 mb-3">
- <Button asChild variant="ghost" size="sm" className="text-neutral">
- <Link href="/dashboard">
- <i className="bi-chevron-left text-md" />
- <p>{t("back_to_dashboard")}</p>
- </Link>
- </Button>
- </div>
-
{children}
</div>
</div>
diff --git a/apps/web/pages/admin/user-administration.tsx b/apps/web/pages/admin/user-administration.tsx
index 76f71863..8e306db4 100644
--- a/apps/web/pages/admin/user-administration.tsx
+++ b/apps/web/pages/admin/user-administration.tsx
@@ -93,7 +93,7 @@ const Page: NextPageWithLayout = () => {
<Button
onClick={() => setNewUserModal(true)}
- variant="accent"
+ variant="primary"
size="icon"
className="flex items-center px-2 aspect-square relative"
>
diff --git a/apps/web/pages/collections/index.tsx b/apps/web/pages/collections/index.tsx
index a3f9e7a8..00d049c7 100644
--- a/apps/web/pages/collections/index.tsx
+++ b/apps/web/pages/collections/index.tsx
@@ -99,7 +99,7 @@ const Page: NextPageWithLayout = () => {
</p>
<Button
className="mx-auto mt-5"
- variant={"accent"}
+ variant="primary"
onClick={() => setNewCollectionModal(true)}
>
<i className="bi-plus-lg text-xl mr-2" />
@@ -113,16 +113,6 @@ const Page: NextPageWithLayout = () => {
.map((e) => (
<CollectionCard key={e.id} collection={e} />
))}
-
- <div
- className="card card-compact shadow-md hover:shadow-none duration-200 border border-neutral-content p-5 bg-base-200 self-stretch min-h-[12rem] rounded-xl cursor-pointer flex flex-col gap-4 justify-center items-center group"
- onClick={() => setNewCollectionModal(true)}
- >
- <p className="group-hover:opacity-0 duration-100">
- {t("new_collection")}
- </p>
- <i className="bi-plus-lg text-5xl group-hover:text-7xl group-hover:-mt-10 text-primary drop-shadow duration-100"></i>
- </div>
</div>
)}
diff --git a/apps/web/pages/dashboard.tsx b/apps/web/pages/dashboard.tsx
index 4bb13f5f..dace7452 100644
--- a/apps/web/pages/dashboard.tsx
+++ b/apps/web/pages/dashboard.tsx
@@ -132,9 +132,9 @@ const Page: NextPageWithLayout = () => {
return (
<>
- <div className="p-3 flex flex-col gap-3">
+ <div className="p-3 flex flex-col gap-3 grow">
<div className="flex items-center justify-between">
- <div className="flex items-center gap-2">
+ <div className="flex items-center gap-2 text-2xl drop-shadow">
<i className="bi-house-fill text-primary" />
<p className="font-thin">{t("dashboard")}</p>
</div>
@@ -273,7 +273,11 @@ const Section = ({
<>
<div className="flex justify-between items-center">
<div className="flex gap-2 items-center">
- <PageHeader icon={"bi-clock-history"} title={t("recent_links")} />
+ <PageHeader
+ icon={"bi-clock-history"}
+ title={t("recent_links")}
+ sm
+ />
</div>
<Link
href="/links"
@@ -292,7 +296,7 @@ const Section = ({
isLoading={dashboardData.isLoading}
/>
) : (
- <div className="flex flex-col gap-2 justify-center h-full border border-solid border-neutral-content w-full mx-auto p-10 rounded-xl bg-base-200 bg-gradient-to-tr from-neutral-content/70 to-50% to-base-200">
+ <div className="grow flex flex-col gap-2 justify-center border border-solid border-neutral-content w-full mx-auto p-10 rounded-xl bg-base-200 bg-gradient-to-tr from-neutral-content/70 to-50% to-base-200">
<p className="text-center text-xl">
{t("view_added_links_here")}
</p>
@@ -305,7 +309,7 @@ const Section = ({
onClick={() => {
setNewLinkModal(true);
}}
- variant="accent"
+ variant="primary"
>
<i className="bi-plus-lg text-xl"></i>
{t("add_link")}
@@ -317,12 +321,16 @@ const Section = ({
)}
</>
);
- case DashboardSectionType.PINNED_LINKS:
+ case DashboardSectionType.PINNED_LINKS: {
+ const hasPinnedLinks = links?.some(
+ (e: any) => e.pinnedBy && e.pinnedBy[0]
+ );
+
return (
<>
<div className="flex justify-between items-center">
<div className="flex gap-2 items-center">
- <PageHeader icon={"bi-pin-angle"} title={t("pinned_links")} />
+ <PageHeader icon={"bi-pin-angle"} title={t("pinned_links")} sm />
</div>
<Link
href="/links/pinned"
@@ -337,15 +345,19 @@ const Section = ({
data={{
name: "pinned-links",
}}
+ className={clsx(
+ !dashboardData.isLoading &&
+ !hasPinnedLinks &&
+ "grow flex flex-col"
+ )}
>
- {dashboardData.isLoading ||
- links?.some((e: any) => e.pinnedBy && e.pinnedBy[0]) ? (
+ {dashboardData.isLoading || hasPinnedLinks ? (
<DashboardLinks
links={links.filter((e: any) => e.pinnedBy && e.pinnedBy[0])}
isLoading={dashboardData.isLoading}
/>
) : (
- <div className="flex flex-col gap-2 justify-center h-full border border-solid border-neutral-content w-full mx-auto p-10 rounded-xl bg-base-200 bg-gradient-to-tr from-neutral-content/70 to-50% to-base-200">
+ <div className="grow flex flex-col gap-2 justify-center border border-solid border-neutral-content w-full mx-auto p-10 rounded-xl bg-base-200 bg-gradient-to-tr from-neutral-content/70 to-50% to-base-200">
<i className="bi-pin mx-auto text-6xl text-primary"></i>
<p className="text-center text-xl">
{t("pin_favorite_links_here")}
@@ -358,18 +370,20 @@ const Section = ({
</Droppable>
</>
);
- case DashboardSectionType.COLLECTION:
+ }
+ case DashboardSectionType.COLLECTION: {
+ const hasCollectionLinks = collectionLinks?.length > 0;
+
return (
collection?.id && (
<>
<div className="flex justify-between items-center">
<div className="flex gap-2 items-center">
- <div className={clsx("flex items-center gap-3")}>
+ <div className={clsx("flex items-center gap-2")}>
{collection.icon ? (
<Icon
icon={collection.icon}
color={collection.color || "#0ea5e9"}
- className="text-2xl"
/>
) : (
<i
@@ -378,9 +392,7 @@ const Section = ({
></i>
)}
<div>
- <p className="text-2xl capitalize font-thin">
- {collection.name}
- </p>
+ <p className="capitalize font-thin">{collection.name}</p>
</div>
</div>
</div>
@@ -400,15 +412,20 @@ const Section = ({
ownerId: collection.ownerId,
type: "collection",
}}
+ className={clsx(
+ !dashboardData.isLoading &&
+ !hasCollectionLinks &&
+ "grow flex flex-col"
+ )}
>
- {dashboardData.isLoading || collectionLinks?.length > 0 ? (
+ {dashboardData.isLoading || hasCollectionLinks ? (
<DashboardLinks
type="collection"
links={collectionLinks}
isLoading={dashboardData.isLoading}
/>
) : (
- <div className="flex flex-col gap-2 justify-center h-full border border-solid border-neutral-content w-full mx-auto p-10 rounded-xl bg-base-200 bg-gradient-to-tr from-neutral-content/70 to-50% to-base-200 min-h-72">
+ <div className="grow flex flex-col gap-2 justify-center border border-solid border-neutral-content w-full mx-auto p-10 rounded-xl bg-base-200 bg-gradient-to-tr from-neutral-content/70 to-50% to-base-200 min-h-72">
<i className="bi-folder mx-auto text-6xl text-primary"></i>
<p className="text-center text-xl">
{t("no_link_in_collection")}
@@ -422,6 +439,7 @@ const Section = ({
</>
)
);
+ }
default:
return null;
}
diff --git a/apps/web/pages/search.tsx b/apps/web/pages/search.tsx
index 4f3b830d..8f509e76 100644
--- a/apps/web/pages/search.tsx
+++ b/apps/web/pages/search.tsx
@@ -28,8 +28,6 @@ const Page: NextPageWithLayout = () => {
);
const [editMode, setEditMode] = useState(false);
- const [activeLink, setActiveLink] =
- useState<LinkIncludingShortenedCollectionAndTags | null>(null);
useEffect(() => {
if (editMode) return setEditMode(false);
@@ -52,7 +50,13 @@ const Page: NextPageWithLayout = () => {
setEditMode={setEditMode}
links={links}
>
- <PageHeader icon={"bi-search"} title={t("search_results")} />
+ <PageHeader
+ icon={"bi-search"}
+ title={t("search_results")}
+ description={`${t("results_for")} "${decodeURIComponent(
+ router.query.q as string
+ )}"`}
+ />
</LinkListOptions>
{!data.isLoading && links && !links[0] && <p>{t("nothing_found")}</p>}
diff --git a/apps/web/pages/settings/access-tokens.tsx b/apps/web/pages/settings/access-tokens.tsx
index 46cc5a0f..0843e5c1 100644
--- a/apps/web/pages/settings/access-tokens.tsx
+++ b/apps/web/pages/settings/access-tokens.tsx
@@ -45,7 +45,7 @@ const Page: NextPageWithLayout = () => {
<Button
className="ml-auto"
- variant="accent"
+ variant="primary"
onClick={() => {
setNewTokenModal(true);
}}
diff --git a/apps/web/pages/settings/account.tsx b/apps/web/pages/settings/account.tsx
index fa27c507..0c218783 100644
--- a/apps/web/pages/settings/account.tsx
+++ b/apps/web/pages/settings/account.tsx
@@ -285,7 +285,7 @@ const Page: NextPageWithLayout = () => {
</div>
<Button
- variant="accent"
+ variant="primary"
onClick={() => {
if (account?.email !== user.email) {
setEmailChangeVerificationModal(true);
diff --git a/apps/web/pages/settings/billing.tsx b/apps/web/pages/settings/billing.tsx
index b505c777..24faa836 100644
--- a/apps/web/pages/settings/billing.tsx
+++ b/apps/web/pages/settings/billing.tsx
@@ -163,7 +163,7 @@ const Page: NextPageWithLayout = () => {
<div className="flex gap-3">
<Button
- variant="accent"
+ variant="primary"
onClick={() => setInviteModal(true)}
className="flex items-center px-2 h-[2.15rem] relative"
>
diff --git a/apps/web/pages/settings/password.tsx b/apps/web/pages/settings/password.tsx
index 669c6ab1..a6b48098 100644
--- a/apps/web/pages/settings/password.tsx
+++ b/apps/web/pages/settings/password.tsx
@@ -103,7 +103,7 @@ const Page: NextPageWithLayout = () => {
disabled={
submitLoader || !newPassword || (!canCreatePassword && !oldPassword)
}
- variant="accent"
+ variant="primary"
className="mt-3 w-full sm:w-fit"
>
{t("save_changes")}
diff --git a/apps/web/pages/settings/preference.tsx b/apps/web/pages/settings/preference.tsx
index 1d38784c..5e827471 100644
--- a/apps/web/pages/settings/preference.tsx
+++ b/apps/web/pages/settings/preference.tsx
@@ -438,7 +438,7 @@ const Page: NextPageWithLayout = () => {
onClick={saveAiSection}
disabled={aiSubmitLoader || !hasAiChanges}
className="mt-2 w-full sm:w-fit"
- variant="accent"
+ variant="primary"
>
{t("save_changes")}
</Button>
@@ -556,7 +556,7 @@ const Page: NextPageWithLayout = () => {
onClick={saveArchiveSection}
disabled={archiveSubmitLoader || !hasArchiveChanges}
className="mt-2 w-full sm:w-fit"
- variant="accent"
+ variant="primary"
>
{t("save_changes")}
</Button>
@@ -687,7 +687,7 @@ const Page: NextPageWithLayout = () => {
onClick={saveLinkSection}
disabled={linkSubmitLoader || !hasLinkChanges}
className="mt-2 w-full sm:w-fit"
- variant="accent"
+ variant="primary"
>
{t("save_changes")}
</Button>
diff --git a/apps/web/pages/settings/rss-subscriptions.tsx b/apps/web/pages/settings/rss-subscriptions.tsx
index 587be977..54e44ee6 100644
--- a/apps/web/pages/settings/rss-subscriptions.tsx
+++ b/apps/web/pages/settings/rss-subscriptions.tsx
@@ -46,7 +46,7 @@ const Page: NextPageWithLayout = () => {
</p>
<Button
- variant="accent"
+ variant="primary"
className="ml-auto"
onClick={() => {
setNewSubscriptionModal(true);
diff --git a/apps/web/pages/tags/index.tsx b/apps/web/pages/tags/index.tsx
index b740d20d..117b8790 100644
--- a/apps/web/pages/tags/index.tsx
+++ b/apps/web/pages/tags/index.tsx
@@ -237,7 +237,7 @@ const Page: NextPageWithLayout = () => {
</p>
<Button
className="mx-auto mt-5"
- variant={"accent"}
+ variant="primary"
onClick={() => setNewTagModal(true)}
>
<i className="bi-plus-lg text-xl mr-2" />
diff --git a/apps/web/public/locales/en/common.json b/apps/web/public/locales/en/common.json
index 3c3f9318..703a0adc 100644
--- a/apps/web/public/locales/en/common.json
+++ b/apps/web/public/locales/en/common.json
@@ -65,6 +65,7 @@
"display_name": "Display Name",
"sign_up_agreement": "By signing up, you agree to our <0>Terms of Service</0> and <1>Privacy Policy</1>.",
"need_help": "Need help?",
+ "documentation": "Documentation",
"get_in_touch": "Get in touch",
"already_registered": "Already have an account?",
"deleting_selections": "Deleting selections...",
@@ -467,6 +468,7 @@
"pinned_links": "Pinned Links",
"recent_links": "Recent Links",
"search_results": "Search Results",
+ "results_for": "Results for",
"linkwarden_icon": "Linkwarden Icon",
"permanent_session": "This is a permanent session",
"locale": "en-US",