⚡️⚡️⚡️ 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
added translation to icon picker component + other fixes and improvements
daniel31x136df2e44213ce
diff --git a/components/IconGrid.tsx b/components/IconGrid.tsxnew file mode 100644index 00000000..edb2362d--- /dev/null+++ b/components/IconGrid.tsx@@ -0,0 +1,45 @@+import { icons } from "@/lib/client/icons";+import Fuse from "fuse.js";+import { useMemo } from "react";++const fuse = new Fuse(icons, {+ keys: [{ name: "name", weight: 4 }, "tags", "categories"],+ threshold: 0.2,+ useExtendedSearch: true,+});++type Props = {+ query: string;+ color: string;+ weight: "light" | "regular" | "bold" | "fill" | "duotone" | "thin";+ iconName?: string;+ setIconName: Function;+};++const IconGrid = ({ query, color, weight, iconName, setIconName }: Props) => {+ const filteredQueryResultsSelector = useMemo(() => {+ if (!query) {+ return icons;+ }+ return fuse.search(query).map((result) => result.item);+ }, [query]);++ return filteredQueryResultsSelector.map((icon) => {+ const IconComponent = icon.Icon;+ return (+ <div+ key={icon.pascal_name}+ onClick={() => setIconName(icon.pascal_name)}+ className={`cursor-pointer btn p-1 box-border bg-base-100 border-none w-full ${+ icon.pascal_name === iconName+ ? "outline outline-1 outline-primary"+ : ""+ }`}+ >+ <IconComponent size={32} weight={weight} color={color} />+ </div>+ );+ });+};++export default IconGrid;diff --git a/components/IconPicker.tsx b/components/IconPicker.tsxindex 513da2c2..a7122623 100644--- a/components/IconPicker.tsx+++ b/components/IconPicker.tsx@@ -1,12 +1,11 @@-import { icons } from "@/lib/client/icons";-import React, { useMemo, useState, lazy, Suspense } from "react";-import Fuse from "fuse.js";+import React, { useState } from "react";import TextInput from "./TextInput";import Popover from "./Popover";import { HexColorPicker } from "react-colorful";import { useTranslation } from "next-i18next";import Icon from "./Icon";import { IconWeight } from "@phosphor-icons/react";+import IconGrid from "./IconGrid";type Props = {alignment?: "left" | "right";@@ -31,23 +30,10 @@ const IconPicker = ({className,reset,}: Props) => {- const fuse = new Fuse(icons, {- keys: [{ name: "name", weight: 4 }, "tags", "categories"],- threshold: 0.2,- useExtendedSearch: true,- });-const { t } = useTranslation();const [query, setQuery] = useState("");const [iconPicker, setIconPicker] = useState(false);- const filteredQueryResultsSelector = useMemo(() => {- if (!query) {- return icons;- }- return fuse.search(query).map((result) => result.item);- }, [query]);-return (<div className="relative"><div@@ -89,41 +75,32 @@ const IconPicker = ({value={weight}onChange={(e) => setWeight(e.target.value)}>- <option value="regular">Regular</option>- <option value="thin">Thin</option>- <option value="light">Light</option>- <option value="bold">Bold</option>- <option value="fill">Fill</option>- <option value="duotone">Duotone</option>+ <option value="regular">{t("regular")}</option>+ <option value="thin">{t("thin")}</option>+ <option value="light">{t("light_icon")}</option>+ <option value="bold">{t("bold")}</option>+ <option value="fill">{t("fill")}</option>+ <option value="duotone">{t("duotone")}</option></select><HexColorPicker color={color} onChange={(e) => setColor(e)} /></div>- <div className="flex flex-col gap-2 w-fit">+ <div className="flex flex-col gap-2 w-full"><TextInputclassName="p-2 rounded w-full h-7 text-sm"- placeholder="Search icons"+ placeholder={t("search")}value={query}onChange={(e) => setQuery(e.target.value)}/><div className="grid grid-cols-4 gap-1 w-full overflow-y-auto h-32 border border-neutral-content bg-base-100 rounded-md p-2">- {filteredQueryResultsSelector.map((icon) => {- const IconComponent = icon.Icon;- return (- <div- key={icon.pascal_name}- onClick={() => setIconName(icon.pascal_name)}- className={`cursor-pointer btn p-1 box-border bg-base-100 border-none aspect-square ${- icon.pascal_name === iconName- ? "outline outline-1 outline-primary"- : ""- }`}- >- <IconComponent size={32} weight={weight} color={color} />- </div>- );- })}+ <IconGrid+ query={query}+ color={color}+ weight={weight}+ iconName={iconName}+ setIconName={setIconName}+ /></div></div></div>diff --git a/public/locales/en/common.json b/public/locales/en/common.jsonindex c2e9a82b..61658069 100644--- a/public/locales/en/common.json+++ b/public/locales/en/common.json@@ -372,5 +372,12 @@"demo_desc": "This is only a demo instance of Linkwarden and uploads are disabled.","demo_desc_2": "If you want to try out the full version, you can sign up for a free trial at:","demo_button": "Login as demo user",- "notes": "Notes"+ "notes": "Notes",+ "regular": "Regular",+ "thin": "Thin",+ "bold": "Bold",+ "fill": "Fill",+ "duotone": "Duotone",+ "light_icon": "Light",+ "search": "Search"}\ No newline at end of file