Skip to content

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

feat(web): add a text style dropdown to readable view

daniel31x132b8964ca64cc
diff --git a/apps/web/components/Modal.tsx b/apps/web/components/Modal.tsx
index 224e1e07..7544ef43 100644
--- a/apps/web/components/Modal.tsx
+++ b/apps/web/components/Modal.tsx
@@ -1,4 +1,5 @@
import React, { MouseEventHandler, ReactNode, useEffect } from "react";
+import ReactDOM from "react-dom";
import ClickAwayHandler from "@/components/ClickAwayHandler";
import { Drawer } from "vaul";
import useWindowDimensions from "@/hooks/useWindowDimensions";
@@ -58,7 +59,7 @@ export default function Modal({
</Drawer.Root>
);
} else {
- return (
+ return ReactDOM.createPortal(
<div
className="overflow-y-auto pt-2 sm:py-2 fixed top-0 bottom-0 right-0 left-0 bg-black bg-opacity-10 backdrop-blur-sm flex justify-center items-center fade-in z-40"
data-testid="modal-outer"
@@ -89,7 +90,8 @@ export default function Modal({
{children}
</div>
</ClickAwayHandler>
- </div>
+ </div>,
+ document.body
);
}
}
diff --git a/apps/web/components/Preservation/PreservationNavbar.tsx b/apps/web/components/Preservation/PreservationNavbar.tsx
index 56978cc6..3e1d72c3 100644
--- a/apps/web/components/Preservation/PreservationNavbar.tsx
+++ b/apps/web/components/Preservation/PreservationNavbar.tsx
@@ -9,6 +9,12 @@ import {
DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuTrigger,
+ DropdownMenuItem,
+ DropdownMenuSub,
+ DropdownMenuSubContent,
+ DropdownMenuSubTrigger,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
} from "@/components/ui/dropdown-menu";
import { Button } from "@/components/ui/button";
import { useTranslation } from "next-i18next";
@@ -18,6 +24,8 @@ import { formatAvailable } from "@linkwarden/lib/formatStats";
import LinkActions from "../LinkViews/LinkComponents/LinkActions";
import { useCollections } from "@linkwarden/router/collections";
import clsx from "clsx";
+import ToggleDarkMode from "../ToggleDarkMode";
+import { FitWidth, FormatLineSpacing, FormatSize } from "../ui/icons";
type Props = {
link: LinkIncludingShortenedCollectionAndTags;
@@ -74,11 +82,77 @@ const PreservationNavbar = ({ link, format, className }: Props) => {
return (
<div className={clsx("p-2 z-10 bg-base-100", className)}>
<div className="max-w-6xl flex gap-2 justify-between mx-auto">
- <Button variant="ghost" size="icon" asChild>
- <Link href={`/dashboard`}>
- <i className="bi-chevron-left text-xl text-neutral" />
- </Link>
- </Button>
+ <div className="flex items-center gap-2">
+ <Button variant="ghost" size="icon" asChild>
+ <Link href={`/dashboard`}>
+ <i className="bi-chevron-left text-lg text-neutral" />
+ </Link>
+ </Button>
+ {format === ArchivedFormat.readability ? (
+ <DropdownMenu>
+ <DropdownMenuTrigger>
+ <Button variant="ghost" size="icon">
+ <i className="bi-type text-xl text-neutral" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start">
+ <DropdownMenuLabel className="flex items-center justify-between font-normal">
+ {t("theme")}
+ <ToggleDarkMode />
+ </DropdownMenuLabel>
+ <DropdownMenuSeparator />
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger>
+ <i className="bi-fonts text-lg leading-none text-neutral" />
+ {t("font_family")}
+ </DropdownMenuSubTrigger>
+ <DropdownMenuSubContent>
+ <DropdownMenuItem>a</DropdownMenuItem>
+ <DropdownMenuItem>b</DropdownMenuItem>
+ <DropdownMenuItem>c</DropdownMenuItem>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger>
+ <FormatSize className="text-lg" />
+ {t("font_size")}
+ </DropdownMenuSubTrigger>
+ <DropdownMenuSubContent>
+ <DropdownMenuItem>a</DropdownMenuItem>
+ <DropdownMenuItem>b</DropdownMenuItem>
+ <DropdownMenuItem>c</DropdownMenuItem>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger>
+ <FormatLineSpacing className="text-lg" />
+ {t("line_height")}
+ </DropdownMenuSubTrigger>
+ <DropdownMenuSubContent>
+ <DropdownMenuItem>a</DropdownMenuItem>
+ <DropdownMenuItem>b</DropdownMenuItem>
+ <DropdownMenuItem>c</DropdownMenuItem>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger>
+ <FitWidth className="text-lg" />
+ {t("line_width")}
+ </DropdownMenuSubTrigger>
+ <DropdownMenuSubContent>
+ <DropdownMenuItem>a</DropdownMenuItem>
+ <DropdownMenuItem>b</DropdownMenuItem>
+ <DropdownMenuItem>c</DropdownMenuItem>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ ) : (
+ <Button variant="ghost" size="icon" onClick={handleDownload}>
+ <i className="bi-cloud-arrow-down text-xl text-neutral" />
+ </Button>
+ )}
+ </div>
<DropdownMenu>
<DropdownMenuTrigger>
<Button variant="ghost" className="h-8 text-neutral">
@@ -178,19 +252,6 @@ const PreservationNavbar = ({ link, format, className }: Props) => {
</DropdownMenu>
<div className="flex gap-2 items-center text-neutral">
- {format === ArchivedFormat.readability ? (
- <Button
- variant="ghost"
- size="icon"
- className="font-extralight text-lg"
- >
- Aa
- </Button>
- ) : (
- <Button variant="ghost" size="icon" onClick={handleDownload}>
- <i className="bi-cloud-arrow-down text-xl" />
- </Button>
- )}
<LinkActions
link={link}
collection={collection}
diff --git a/apps/web/components/Preservation/PreservationPageContent.tsx b/apps/web/components/Preservation/PreservationPageContent.tsx
index 7988ecb3..ab086f25 100644
--- a/apps/web/components/Preservation/PreservationPageContent.tsx
+++ b/apps/web/components/Preservation/PreservationPageContent.tsx
@@ -63,7 +63,7 @@ export default function PreservationPageContent() {
}, [router.query.format]);
return (
- <div>
+ <div className="relative">
{link?.id && (
<PreservationNavbar
link={link}
diff --git a/apps/web/components/ui/icons.tsx b/apps/web/components/ui/icons.tsx
new file mode 100644
index 00000000..c37d60e4
--- /dev/null
+++ b/apps/web/components/ui/icons.tsx
@@ -0,0 +1,44 @@
+import clsx from "clsx";
+
+type Props = {
+ className?: string;
+};
+
+export const FormatSize = ({ className }: Props) => (
+ <svg
+ className={clsx("text-neutral", className)}
+ fill="currentColor"
+ width="1em"
+ height="1em"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 -960 960 960"
+ >
+ <path d="M560-160v-520H360v-120h520v120H680v520H560Zm-360 0v-320H80v-120h360v120H320v320H200Z" />
+ </svg>
+);
+
+export const FormatLineSpacing = ({ className }: Props) => (
+ <svg
+ className={clsx("text-neutral", className)}
+ fill="currentColor"
+ width="1em"
+ height="1em"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 -960 960 960"
+ >
+ <path d="M240-160 80-320l56-56 64 62v-332l-64 62-56-56 160-160 160 160-56 56-64-62v332l64-62 56 56-160 160Zm240-40v-80h400v80H480Zm0-240v-80h400v80H480Zm0-240v-80h400v80H480Z" />
+ </svg>
+);
+
+export const FitWidth = ({ className }: Props) => (
+ <svg
+ className={clsx("text-neutral", className)}
+ fill="currentColor"
+ width="1em"
+ height="1em"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 -960 960 960"
+ >
+ <path d="M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z" />
+ </svg>
+);
diff --git a/apps/web/public/locales/en/common.json b/apps/web/public/locales/en/common.json
index e8671cb9..cecef692 100644
--- a/apps/web/public/locales/en/common.json
+++ b/apps/web/public/locales/en/common.json
@@ -475,5 +475,10 @@
"links_are_being_represerved": "Links are being re-preserved...",
"cancel": "Cancel",
"preservation_rules": "Preservation rules:",
- "links_being_archived": "Links are being archived..."
+ "links_being_archived": "Links are being archived...",
+ "theme": "Theme",
+ "font_family": "Font Family",
+ "font_size": "Font Size",
+ "line_height": "Line Height",
+ "line_width": "Line Width"
}