⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
feat(web): added highlights drawer
daniel31x132a62c1ee1af1
diff --git a/apps/web/components/Announcement.tsx b/apps/web/components/Announcement.tsxindex bf7bcb8b..49f8a68d 100644--- a/apps/web/components/Announcement.tsx+++ b/apps/web/components/Announcement.tsx@@ -1,7 +1,7 @@import Link from "next/link";import React, { MouseEventHandler } from "react";import { Trans } from "next-i18next";-import { Button } from "./ui/button";+import { Button } from "@/components/ui/button";type Props = {toggleAnnouncementBar: MouseEventHandler<HTMLButtonElement>;diff --git a/apps/web/components/Drawer.tsx b/apps/web/components/Drawer.tsxindex 0e665d96..374b0b15 100644--- a/apps/web/components/Drawer.tsx+++ b/apps/web/components/Drawer.tsx@@ -8,6 +8,7 @@ type Props = {children: ReactNode;className?: string;dismissible?: boolean;+ direction?: "left" | "right";};export default function Drawer({@@ -15,6 +16,7 @@ export default function Drawer({className,children,dismissible = true,+ direction,}: Props) {const [drawerIsOpen, setDrawerIsOpen] = React.useState(true);const { width } = useWindowDimensions();@@ -62,14 +64,20 @@ export default function Drawer({onClose={() => dismissible && setDrawerIsOpen(false)}onAnimationEnd={(isOpen) => !isOpen && toggleDrawer()}dismissible={dismissible}- direction="right"+ direction={direction || "right"}><D.Portal><D.Overlay className="fixed inset-0 bg-black/10 z-20" />- <D.Content className="bg-white flex flex-col h-full w-2/5 max-w-6xl min-w-[30rem] mt-24 fixed bottom-0 right-0 z-40 !select-auto focus:outline-none">+ <D.Content+ className={clsx(+ "bg-white flex flex-col h-full w-2/5 max-w-6xl min-w-[30rem] mt-24 fixed bottom-0 z-40 !select-auto focus:outline-none",+ direction === "left" ? "left-0" : "right-0"+ )}+ ><divclassName={clsx(- "p-4 bg-base-100 flex-1 border-neutral-content border-l overflow-y-auto",+ "p-4 bg-base-100 flex-1 border-neutral-content overflow-y-auto",+ direction === "left" ? "border-r" : "border-l",className)}>diff --git a/apps/web/components/HighlightDrawer.tsx b/apps/web/components/HighlightDrawer.tsxnew file mode 100644index 00000000..a5f913e3--- /dev/null+++ b/apps/web/components/HighlightDrawer.tsx@@ -0,0 +1,75 @@+import React from "react";+import Drawer from "./Drawer";+import { useGetLinkHighlights } from "@linkwarden/router/highlights";+import { useRouter } from "next/router";+import clsx from "clsx";+import Link from "next/link";+import { useTranslation } from "next-i18next";++type Props = {+ onClose: Function;+};++const HighlightDrawer = ({ onClose }: Props) => {+ const router = useRouter();+ const { t } = useTranslation();++ const { data } = useGetLinkHighlights(Number(router.query.id));++ return (+ <Drawer+ toggleDrawer={onClose}+ className="sm:h-screen items-center relative"+ direction="left"+ >+ <div>+ <h2 className="text-lg font-semibold mb-5">{t("notes_highlights")}</h2>+ {data && data.length > 0 ? (+ data.map((highlight) => (+ <Link key={highlight.id} href={`#highlight-${highlight.id}`}>+ <div+ className={clsx(+ "p-2 mb-4 border-l-2 duration-150 cursor-pointer",+ highlight.color === "yellow"+ ? "border-yellow-500"+ : highlight.color === "green"+ ? "border-green-500"+ : highlight.color === "blue"+ ? "border-blue-500"+ : "border-red-500"+ )}+ >+ <p+ className={clsx(+ "w-fit px-2 rounded-md",+ highlight.color === "yellow"+ ? "bg-yellow-600"+ : highlight.color === "green"+ ? "bg-green-500"+ : highlight.color === "blue"+ ? "bg-blue-500"+ : "bg-red-500"+ )}+ >+ {highlight.text}+ </p>+ <span+ className="text-xs text-neutral"+ title={String(highlight.createdAt)}+ >+ {new Date(highlight.createdAt).toLocaleDateString()}+ </span>+ </div>+ </Link>+ ))+ ) : (+ <div className="text-neutral text-sm">+ No highlights found for this link.+ </div>+ )}+ </div>+ </Drawer>+ );+};++export default HighlightDrawer;diff --git a/apps/web/components/Preservation/PreservationNavbar.tsx b/apps/web/components/Preservation/PreservationNavbar.tsxindex ed3f8c09..102db6f6 100644--- a/apps/web/components/Preservation/PreservationNavbar.tsx+++ b/apps/web/components/Preservation/PreservationNavbar.tsx@@ -9,11 +9,6 @@ import {DropdownMenuCheckboxItem,DropdownMenuContent,DropdownMenuTrigger,- DropdownMenuSub,- DropdownMenuSubContent,- DropdownMenuSubTrigger,- DropdownMenuLabel,- DropdownMenuItem,} from "@/components/ui/dropdown-menu";import { Button } from "@/components/ui/button";import { useTranslation } from "next-i18next";@@ -24,13 +19,8 @@ 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";-import { useUpdateUserPreference, useUser } from "@linkwarden/router/user";-import { Caveat } from "next/font/google";-import { Bentham } from "next/font/google";--const caveat = Caveat({ subsets: ["latin"] });-const bentham = Bentham({ subsets: ["latin"], weight: "400" });+import TextStyleDropdown from "../TextStyleDropdown";+import HighlightDrawer from "../HighlightDrawer";type Props = {link: LinkIncludingShortenedCollectionAndTags;@@ -39,59 +29,8 @@ type Props = {className?: string;};-const fontSizes = [- "12px",- "14px",- "16px",- "18px",- "20px",- "22px",- "24px",- "26px",- "28px",- "30px",- "32px",- "34px",- "36px",- "38px",- "40px",- "42px",- "44px",- "46px",- "48px",- "50px",-];--const lineHeights = [- "1",- "1.1",- "1.2",- "1.3",- "1.4",- "1.5",- "1.6",- "1.7",- "1.8",- "1.9",- "2",- "2.1",- "2.2",- "2.3",- "2.4",- "2.5",- "2.6",- "2.7",- "2.8",- "2.9",- "3",-];--const lineWidth = ["narrower", "narrow", "normal", "wide", "wider", "full"];-const PreservationNavbar = ({ link, format, showNavbar, className }: Props) => {const { data: collections = [] } = useCollections();- const { data } = useUser();- const updateUserPreference = useUpdateUserPreference();const [collection, setCollection] =useState<CollectionIncludingMembersAndLinkCount>(@@ -101,6 +40,7 @@ const PreservationNavbar = ({ link, format, showNavbar, className }: Props) => {);const [linkModal, setLinkModal] = useState(false);+ const [highlightDrawer, setHighlightDrawer] = useState(false);useEffect(() => {setCollection(@@ -137,380 +77,150 @@ const PreservationNavbar = ({ link, format, showNavbar, className }: Props) => {};return (- <div- className={clsx(- "p-2 z-10 bg-base-100 flex gap-2 justify-between transform transition-transform duration-200 ease-in-out fixed top-0 left-0 right-0",- showNavbar ? "translate-y-0" : "-translate-y-full",- className- )}- >- <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" className="min-w-64">- <DropdownMenuSub>- <DropdownMenuSubTrigger>- <div className="flex items-center gap-2 justify-between w-full">- <div className="flex items-center gap-2">- <i className="bi-fonts text-lg leading-none text-neutral" />- {t("font_family")}- </div>- <p- className="text-neutral capitalize"- style={{- fontFamily:- (data?.readableFontFamily === "caveat"- ? caveat.style.fontFamily- : data?.readableFontFamily === "bentham"- ? bentham.style.fontFamily- : data?.readableFontFamily) || "sans-serif",- }}- >- {data?.readableFontFamily?.replace("-", " ")}- </p>- </div>- </DropdownMenuSubTrigger>- <DropdownMenuSubContent>- <DropdownMenuCheckboxItem- style={{ fontFamily: "sans-serif" }}- checked={- !data?.readableFontFamily ||- data?.readableFontFamily === "sans-serif"- }- onSelect={() => {- updateUserPreference.mutate({- readableFontFamily: "sans-serif",- });- }}- >- Sans Serif- </DropdownMenuCheckboxItem>- <DropdownMenuCheckboxItem- style={{ fontFamily: "serif" }}- checked={data?.readableFontFamily === "serif"}- onSelect={() => {- updateUserPreference.mutate({- readableFontFamily: "serif",- });- }}- >- Serif- </DropdownMenuCheckboxItem>- <DropdownMenuCheckboxItem- style={{ fontFamily: "monospace" }}- checked={data?.readableFontFamily === "monospace"}- onSelect={() => {- updateUserPreference.mutate({- readableFontFamily: "monospace",- });- }}- >- Monospace- </DropdownMenuCheckboxItem>- <DropdownMenuCheckboxItem- style={{ fontFamily: "cursive" }}- checked={data?.readableFontFamily === "cursive"}- onSelect={() => {- updateUserPreference.mutate({- readableFontFamily: "cursive",- });- }}- >- Cursive- </DropdownMenuCheckboxItem>- <DropdownMenuCheckboxItem- style={{ fontFamily: caveat.style.fontFamily }}- checked={data?.readableFontFamily === "caveat"}- onSelect={() => {- updateUserPreference.mutate({- readableFontFamily: "caveat",- });- }}- >- <span className={caveat.className}>Caveat</span>- </DropdownMenuCheckboxItem>- <DropdownMenuCheckboxItem- style={{ fontFamily: bentham.style.fontFamily }}- checked={data?.readableFontFamily === "bentham"}- onSelect={() => {- updateUserPreference.mutate({- readableFontFamily: "bentham",- });- }}- >- <span className={bentham.className}>Bentham</span>- </DropdownMenuCheckboxItem>- </DropdownMenuSubContent>- </DropdownMenuSub>- <DropdownMenuLabel className="flex items-center justify-between font-normal gap-2 pr-0">- <div className="flex items-center gap-2">- <FormatSize className="text-lg" />- {t("font_size")}- </div>- <div className="flex items-center gap-1">- <p className="text-neutral">- {data?.readableFontSize || "24px"}- </p>- <Button- variant="ghost"- size="icon"- onClick={() => {- const currentIndex = fontSizes.indexOf(- data?.readableFontSize || "24px"- );- if (currentIndex > 0) {- updateUserPreference.mutate({- readableFontSize: fontSizes[currentIndex - 1],- });- }- }}- >- <i className="bi-dash text-lg" />- </Button>- <Button- variant="ghost"- size="icon"- onClick={() => {- const currentIndex = fontSizes.indexOf(- data?.readableFontSize || "24px"- );- if (currentIndex < fontSizes.length - 1) {- updateUserPreference.mutate({- readableFontSize: fontSizes[currentIndex + 1],- });- }- }}- >- <i className="bi-plus text-lg" />- </Button>- </div>- </DropdownMenuLabel>- <DropdownMenuLabel className="flex items-center justify-between font-normal gap-2 pr-0">- <div className="flex items-center gap-2">- <FormatLineSpacing className="text-lg" />- {t("line_height")}- </div>- <div className="flex items-center gap-1">- <p className="text-neutral">- {data?.readableLineHeight || "1.8"}- </p>- <Button- variant="ghost"- size="icon"- onClick={() => {- const currentIndex = lineHeights.indexOf(- data?.readableLineHeight || "1.8"- );- if (currentIndex > 0) {- updateUserPreference.mutate({- readableLineHeight: lineHeights[currentIndex - 1],- });- }- }}- >- <i className="bi-dash text-lg" />- </Button>- <Button- variant="ghost"- size="icon"- onClick={() => {- const currentIndex = lineHeights.indexOf(- data?.readableLineHeight || "1.8"- );- if (currentIndex < lineHeights.length - 1) {- updateUserPreference.mutate({- readableLineHeight: lineHeights[currentIndex + 1],- });- }- }}- >- <i className="bi-plus text-lg" />- </Button>- </div>- </DropdownMenuLabel>- <DropdownMenuLabel className="flex items-center justify-between font-normal gap-2 pr-0">- <div className="flex items-center gap-2">- <FitWidth className="text-lg" />- {t("line_width")}- </div>- <div className="flex items-center gap-1">- <p className="text-neutral capitalize">- {data?.readableLineWidth || "normal"}- </p>- <Button- variant="ghost"- size="icon"- onClick={() => {- const currentIndex = lineWidth.indexOf(- data?.readableLineWidth || "normal"- );- if (currentIndex > 0) {- updateUserPreference.mutate({- readableLineWidth: lineWidth[currentIndex - 1],- });- }- }}- >- <i className="bi-dash text-lg" />- </Button>- <Button- variant="ghost"- size="icon"- onClick={() => {- const currentIndex = lineWidth.indexOf(- data?.readableLineWidth || "normal"- );- if (currentIndex < lineWidth.length - 1) {- updateUserPreference.mutate({- readableLineWidth: lineWidth[currentIndex + 1],- });- }- }}- >- <i className="bi-plus text-lg" />- </Button>- </div>- </DropdownMenuLabel>- <DropdownMenuItem- onSelect={() =>- updateUserPreference.mutate({- readableFontFamily: "sans-serif",- readableFontSize: "18px",- readableLineHeight: "1.8",- readableLineWidth: "normal",- })- }- className="w-fit mx-auto"- >- <i className="bi-arrow-counterclockwise text-neutral" />- <p className="text-center">{t("reset_defaults")}</p>- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>- ) : (- <Button variant="ghost" size="icon" onClick={handleDownload}>- <i className="bi-cloud-arrow-down text-xl text-neutral" />- </Button>+ <>+ <div+ className={clsx(+ "p-2 z-10 bg-base-100 flex gap-2 justify-between transform transition-transform duration-200 ease-in-out fixed top-0 left-0 right-0",+ showNavbar ? "translate-y-0" : "-translate-y-full",+ className)}- </div>- <DropdownMenu>- <DropdownMenuTrigger>- <Button variant="ghost" className="h-8 text-neutral">- {format === ArchivedFormat.readability- ? t("readable")- : format === ArchivedFormat.monolith- ? t("webpage")- : format === ArchivedFormat.pdf- ? t("pdf")- : t("screenshot")}- <i className="bi-chevron-down" />+ >+ <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>- </DropdownMenuTrigger>- <DropdownMenuContent>- {formatAvailable(link, "readable") && (- <DropdownMenuCheckboxItem- onSelect={() =>- router.push(- {- query: {- ...router.query,- format: ArchivedFormat.readability,- },- },- undefined,- { shallow: true }- )- }- checked={format === ArchivedFormat.readability}- >- {t("readable")}- </DropdownMenuCheckboxItem>+ {format === ArchivedFormat.readability ? (+ <TextStyleDropdown />+ ) : (+ <Button variant="ghost" size="icon" onClick={handleDownload}>+ <i className="bi-cloud-arrow-down text-xl text-neutral" />+ </Button>)}- {formatAvailable(link, "monolith") && (- <DropdownMenuCheckboxItem- onSelect={() =>- router.push(- {- query: {- ...router.query,- format: ArchivedFormat.monolith,- },- },- undefined,- { shallow: true }- )- }- checked={format === ArchivedFormat.monolith}+ {format === ArchivedFormat.readability && (+ <Button+ variant="ghost"+ size="icon"+ onClick={() => setHighlightDrawer(true)}>- {t("webpage")}- </DropdownMenuCheckboxItem>+ <i className="bi-highlighter text-xl text-neutral" />+ </Button>)}- {formatAvailable(link, "image") && (- <DropdownMenuCheckboxItem- onSelect={() =>- router.push(- {- query: {- ...router.query,- format: link?.image?.endsWith(".png")- ? ArchivedFormat.png- : ArchivedFormat.jpeg,+ </div>+ <DropdownMenu>+ <DropdownMenuTrigger>+ <Button variant="ghost" className="h-8 text-neutral">+ {format === ArchivedFormat.readability+ ? t("readable")+ : format === ArchivedFormat.monolith+ ? t("webpage")+ : format === ArchivedFormat.pdf+ ? t("pdf")+ : t("screenshot")}+ <i className="bi-chevron-down" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent>+ {formatAvailable(link, "readable") && (+ <DropdownMenuCheckboxItem+ onSelect={() =>+ router.push(+ {+ query: {+ ...router.query,+ format: ArchivedFormat.readability,+ },},- },- undefined,- { shallow: true }- )- }- checked={- format === ArchivedFormat.png || format === ArchivedFormat.jpeg- }- >- {t("screenshot")}- </DropdownMenuCheckboxItem>- )}- {formatAvailable(link, "pdf") && (- <DropdownMenuCheckboxItem- onSelect={() =>- router.push(- {- query: {- ...router.query,- format: ArchivedFormat.pdf,+ undefined,+ { shallow: true }+ )+ }+ checked={format === ArchivedFormat.readability}+ >+ {t("readable")}+ </DropdownMenuCheckboxItem>+ )}+ {formatAvailable(link, "monolith") && (+ <DropdownMenuCheckboxItem+ onSelect={() =>+ router.push(+ {+ query: {+ ...router.query,+ format: ArchivedFormat.monolith,+ },},- },- undefined,- { shallow: true }- )- }- checked={format === ArchivedFormat.pdf}- >- {t("pdf")}- </DropdownMenuCheckboxItem>- )}- </DropdownMenuContent>- </DropdownMenu>+ undefined,+ { shallow: true }+ )+ }+ checked={format === ArchivedFormat.monolith}+ >+ {t("webpage")}+ </DropdownMenuCheckboxItem>+ )}+ {formatAvailable(link, "image") && (+ <DropdownMenuCheckboxItem+ onSelect={() =>+ router.push(+ {+ query: {+ ...router.query,+ format: link?.image?.endsWith(".png")+ ? ArchivedFormat.png+ : ArchivedFormat.jpeg,+ },+ },+ undefined,+ { shallow: true }+ )+ }+ checked={+ format === ArchivedFormat.png ||+ format === ArchivedFormat.jpeg+ }+ >+ {t("screenshot")}+ </DropdownMenuCheckboxItem>+ )}+ {formatAvailable(link, "pdf") && (+ <DropdownMenuCheckboxItem+ onSelect={() =>+ router.push(+ {+ query: {+ ...router.query,+ format: ArchivedFormat.pdf,+ },+ },+ undefined,+ { shallow: true }+ )+ }+ checked={format === ArchivedFormat.pdf}+ >+ {t("pdf")}+ </DropdownMenuCheckboxItem>+ )}+ </DropdownMenuContent>+ </DropdownMenu>- <div className="flex gap-2 items-center text-neutral">- <ToggleDarkMode />- <LinkActions- link={link}- collection={collection}- linkModal={linkModal}- setLinkModal={(e) => setLinkModal(e)}- ghost- />+ <div className="flex gap-2 items-center text-neutral">+ <ToggleDarkMode />+ <LinkActions+ link={link}+ collection={collection}+ linkModal={linkModal}+ setLinkModal={(e) => setLinkModal(e)}+ ghost+ />+ </div></div>- </div>+ {highlightDrawer && (+ <HighlightDrawer onClose={() => setHighlightDrawer(false)} />+ )}+ </>);};diff --git a/apps/web/components/Preservation/ReadableView.tsx b/apps/web/components/Preservation/ReadableView.tsxindex b6e016b1..0d4fdf56 100644--- a/apps/web/components/Preservation/ReadableView.tsx+++ b/apps/web/components/Preservation/ReadableView.tsx@@ -284,6 +284,9 @@ export default function ReadableView({ link }: Props) {}const highlightWrapper = document.createElement("span");++ highlightWrapper.id = `highlight-${highlight.id}`;+highlightWrapper.dataset.highlightId = highlight.id.toString();highlightWrapper.classList.add("cursor-pointer");diff --git a/apps/web/components/TextStyleDropdown.tsx b/apps/web/components/TextStyleDropdown.tsxnew file mode 100644index 00000000..2ca4b812--- /dev/null+++ b/apps/web/components/TextStyleDropdown.tsx@@ -0,0 +1,325 @@+import React from "react";+import {+ DropdownMenu,+ DropdownMenuCheckboxItem,+ DropdownMenuContent,+ DropdownMenuTrigger,+ DropdownMenuSub,+ DropdownMenuSubContent,+ DropdownMenuSubTrigger,+ DropdownMenuLabel,+ DropdownMenuItem,+} from "@/components/ui/dropdown-menu";+import { Button } from "@/components/ui/button";+import { FitWidth, FormatLineSpacing, FormatSize } from "@/components/ui/icons";+import { useUpdateUserPreference, useUser } from "@linkwarden/router/user";+import { Caveat } from "next/font/google";+import { Bentham } from "next/font/google";+import { useTranslation } from "next-i18next";++const caveat = Caveat({ subsets: ["latin"] });+const bentham = Bentham({ subsets: ["latin"], weight: "400" });++const fontSizes = [+ "12px",+ "14px",+ "16px",+ "18px",+ "20px",+ "22px",+ "24px",+ "26px",+ "28px",+ "30px",+ "32px",+ "34px",+ "36px",+ "38px",+ "40px",+ "42px",+ "44px",+ "46px",+ "48px",+ "50px",+];++const lineHeights = [+ "1",+ "1.1",+ "1.2",+ "1.3",+ "1.4",+ "1.5",+ "1.6",+ "1.7",+ "1.8",+ "1.9",+ "2",+ "2.1",+ "2.2",+ "2.3",+ "2.4",+ "2.5",+ "2.6",+ "2.7",+ "2.8",+ "2.9",+ "3",+];++const lineWidth = ["narrower", "narrow", "normal", "wide", "wider", "full"];++type Props = {};++const TextStyleDropdown = (props: Props) => {+ const { data } = useUser();+ const updateUserPreference = useUpdateUserPreference();+ const { t } = useTranslation();++ return (+ <DropdownMenu>+ <DropdownMenuTrigger>+ <Button variant="ghost" size="icon">+ <i className="bi-type text-xl text-neutral" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="start" className="min-w-64">+ <DropdownMenuSub>+ <DropdownMenuSubTrigger>+ <div className="flex items-center gap-2 justify-between w-full">+ <div className="flex items-center gap-2">+ <i className="bi-fonts text-lg leading-none text-neutral" />+ {t("font_family")}+ </div>+ <p+ className="text-neutral capitalize"+ style={{+ fontFamily:+ (data?.readableFontFamily === "caveat"+ ? caveat.style.fontFamily+ : data?.readableFontFamily === "bentham"+ ? bentham.style.fontFamily+ : data?.readableFontFamily) || "sans-serif",+ }}+ >+ {data?.readableFontFamily?.replace("-", " ")}+ </p>+ </div>+ </DropdownMenuSubTrigger>+ <DropdownMenuSubContent>+ <DropdownMenuCheckboxItem+ style={{ fontFamily: "sans-serif" }}+ checked={+ !data?.readableFontFamily ||+ data?.readableFontFamily === "sans-serif"+ }+ onSelect={() => {+ updateUserPreference.mutate({+ readableFontFamily: "sans-serif",+ });+ }}+ >+ Sans Serif+ </DropdownMenuCheckboxItem>+ <DropdownMenuCheckboxItem+ style={{ fontFamily: "serif" }}+ checked={data?.readableFontFamily === "serif"}+ onSelect={() => {+ updateUserPreference.mutate({+ readableFontFamily: "serif",+ });+ }}+ >+ Serif+ </DropdownMenuCheckboxItem>+ <DropdownMenuCheckboxItem+ style={{ fontFamily: "monospace" }}+ checked={data?.readableFontFamily === "monospace"}+ onSelect={() => {+ updateUserPreference.mutate({+ readableFontFamily: "monospace",+ });+ }}+ >+ Monospace+ </DropdownMenuCheckboxItem>+ <DropdownMenuCheckboxItem+ style={{ fontFamily: "cursive" }}+ checked={data?.readableFontFamily === "cursive"}+ onSelect={() => {+ updateUserPreference.mutate({+ readableFontFamily: "cursive",+ });+ }}+ >+ Cursive+ </DropdownMenuCheckboxItem>+ <DropdownMenuCheckboxItem+ style={{ fontFamily: caveat.style.fontFamily }}+ checked={data?.readableFontFamily === "caveat"}+ onSelect={() => {+ updateUserPreference.mutate({+ readableFontFamily: "caveat",+ });+ }}+ >+ <span className={caveat.className}>Caveat</span>+ </DropdownMenuCheckboxItem>+ <DropdownMenuCheckboxItem+ style={{ fontFamily: bentham.style.fontFamily }}+ checked={data?.readableFontFamily === "bentham"}+ onSelect={() => {+ updateUserPreference.mutate({+ readableFontFamily: "bentham",+ });+ }}+ >+ <span className={bentham.className}>Bentham</span>+ </DropdownMenuCheckboxItem>+ </DropdownMenuSubContent>+ </DropdownMenuSub>+ <DropdownMenuLabel className="flex items-center justify-between font-normal gap-2 pr-0">+ <div className="flex items-center gap-2">+ <FormatSize className="text-lg" />+ {t("font_size")}+ </div>+ <div className="flex items-center gap-1">+ <p className="text-neutral">{data?.readableFontSize || "24px"}</p>+ <Button+ variant="ghost"+ size="icon"+ onClick={() => {+ const currentIndex = fontSizes.indexOf(+ data?.readableFontSize || "24px"+ );+ if (currentIndex > 0) {+ updateUserPreference.mutate({+ readableFontSize: fontSizes[currentIndex - 1],+ });+ }+ }}+ >+ <i className="bi-dash text-lg" />+ </Button>+ <Button+ variant="ghost"+ size="icon"+ onClick={() => {+ const currentIndex = fontSizes.indexOf(+ data?.readableFontSize || "24px"+ );+ if (currentIndex < fontSizes.length - 1) {+ updateUserPreference.mutate({+ readableFontSize: fontSizes[currentIndex + 1],+ });+ }+ }}+ >+ <i className="bi-plus text-lg" />+ </Button>+ </div>+ </DropdownMenuLabel>+ <DropdownMenuLabel className="flex items-center justify-between font-normal gap-2 pr-0">+ <div className="flex items-center gap-2">+ <FormatLineSpacing className="text-lg" />+ {t("line_height")}+ </div>+ <div className="flex items-center gap-1">+ <p className="text-neutral">{data?.readableLineHeight || "1.8"}</p>+ <Button+ variant="ghost"+ size="icon"+ onClick={() => {+ const currentIndex = lineHeights.indexOf(+ data?.readableLineHeight || "1.8"+ );+ if (currentIndex > 0) {+ updateUserPreference.mutate({+ readableLineHeight: lineHeights[currentIndex - 1],+ });+ }+ }}+ >+ <i className="bi-dash text-lg" />+ </Button>+ <Button+ variant="ghost"+ size="icon"+ onClick={() => {+ const currentIndex = lineHeights.indexOf(+ data?.readableLineHeight || "1.8"+ );+ if (currentIndex < lineHeights.length - 1) {+ updateUserPreference.mutate({+ readableLineHeight: lineHeights[currentIndex + 1],+ });+ }+ }}+ >+ <i className="bi-plus text-lg" />+ </Button>+ </div>+ </DropdownMenuLabel>+ <DropdownMenuLabel className="flex items-center justify-between font-normal gap-2 pr-0">+ <div className="flex items-center gap-2">+ <FitWidth className="text-lg" />+ {t("line_width")}+ </div>+ <div className="flex items-center gap-1">+ <p className="text-neutral capitalize">+ {data?.readableLineWidth || "normal"}+ </p>+ <Button+ variant="ghost"+ size="icon"+ onClick={() => {+ const currentIndex = lineWidth.indexOf(+ data?.readableLineWidth || "normal"+ );+ if (currentIndex > 0) {+ updateUserPreference.mutate({+ readableLineWidth: lineWidth[currentIndex - 1],+ });+ }+ }}+ >+ <i className="bi-dash text-lg" />+ </Button>+ <Button+ variant="ghost"+ size="icon"+ onClick={() => {+ const currentIndex = lineWidth.indexOf(+ data?.readableLineWidth || "normal"+ );+ if (currentIndex < lineWidth.length - 1) {+ updateUserPreference.mutate({+ readableLineWidth: lineWidth[currentIndex + 1],+ });+ }+ }}+ >+ <i className="bi-plus text-lg" />+ </Button>+ </div>+ </DropdownMenuLabel>+ <DropdownMenuItem+ onSelect={() =>+ updateUserPreference.mutate({+ readableFontFamily: "sans-serif",+ readableFontSize: "18px",+ readableLineHeight: "1.8",+ readableLineWidth: "normal",+ })+ }+ className="w-fit mx-auto"+ >+ <i className="bi-arrow-counterclockwise text-neutral" />+ <p className="text-center">{t("reset_defaults")}</p>+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ );+};++export default TextStyleDropdown;diff --git a/apps/web/public/locales/en/common.json b/apps/web/public/locales/en/common.jsonindex 83c6fc87..03be78b5 100644--- a/apps/web/public/locales/en/common.json+++ b/apps/web/public/locales/en/common.json@@ -481,5 +481,6 @@"font_family": "Font Family","font_size": "Font Size","line_height": "Line Height",- "line_width": "Line Width"+ "line_width": "Line Width",+ "notes_highlights": "Notes & Highlights"}