custom preview initial commit

This commit is contained in:
daniel31x13 2024-08-26 21:04:52 -04:00
parent 0371695eb3
commit 6498ae794b
8 changed files with 61 additions and 29 deletions

View File

@ -40,7 +40,7 @@ export default function Drawer({
<ClickAwayHandler <ClickAwayHandler
onClickOutside={() => dismissible && setDrawerIsOpen(false)} onClickOutside={() => dismissible && setDrawerIsOpen(false)}
> >
<D.Content className="flex flex-col rounded-t-2xl min-h-max mt-24 fixed bottom-0 left-0 right-0 z-30 h-[90%]"> <D.Content className="flex flex-col rounded-t-2xl mt-24 fixed bottom-0 left-0 right-0 z-30 h-[90%]">
<div <div
className="p-4 bg-base-100 rounded-t-2xl flex-1 border-neutral-content border-t overflow-y-auto" className="p-4 bg-base-100 rounded-t-2xl flex-1 border-neutral-content border-t overflow-y-auto"
data-testid="mobile-modal-container" data-testid="mobile-modal-container"

View File

@ -40,7 +40,7 @@ export default function Modal({
<ClickAwayHandler <ClickAwayHandler
onClickOutside={() => dismissible && setDrawerIsOpen(false)} onClickOutside={() => dismissible && setDrawerIsOpen(false)}
> >
<Drawer.Content className="flex flex-col rounded-t-2xl min-h-max mt-24 fixed bottom-0 left-0 right-0 z-30"> <Drawer.Content className="flex flex-col rounded-t-2xl h-[90%] mt-24 fixed bottom-0 left-0 right-0 z-30">
<div <div
className="p-4 bg-base-100 rounded-t-2xl flex-1 border-neutral-content border-t overflow-y-auto" className="p-4 bg-base-100 rounded-t-2xl flex-1 border-neutral-content border-t overflow-y-auto"
data-testid="mobile-modal-container" data-testid="mobile-modal-container"

View File

@ -97,7 +97,7 @@ export default function EditCollectionModal({
<div className="w-full"> <div className="w-full">
<p className="mb-2">{t("description")}</p> <p className="mb-2">{t("description")}</p>
<textarea <textarea
className="w-full h-[13rem] resize-none border rounded-md duration-100 bg-base-200 p-2 outline-none border-neutral-content focus:border-primary" className="w-full h-32 resize-none border rounded-md duration-100 bg-base-200 p-2 outline-none border-neutral-content focus:border-primary"
placeholder={t("collection_description_placeholder")} placeholder={t("collection_description_placeholder")}
value={collection.description} value={collection.description}
onChange={(e) => onChange={(e) =>

View File

@ -3,7 +3,10 @@ import CollectionSelection from "@/components/InputSelect/CollectionSelection";
import TagSelection from "@/components/InputSelect/TagSelection"; import TagSelection from "@/components/InputSelect/TagSelection";
import TextInput from "@/components/TextInput"; import TextInput from "@/components/TextInput";
import unescapeString from "@/lib/client/unescapeString"; import unescapeString from "@/lib/client/unescapeString";
import { LinkIncludingShortenedCollectionAndTags } from "@/types/global"; import {
ArchivedFormat,
LinkIncludingShortenedCollectionAndTags,
} from "@/types/global";
import Link from "next/link"; import Link from "next/link";
import Modal from "../Modal"; import Modal from "../Modal";
import { useTranslation } from "next-i18next"; import { useTranslation } from "next-i18next";
@ -11,6 +14,8 @@ import { useUpdateLink } from "@/hooks/store/links";
import toast from "react-hot-toast"; import toast from "react-hot-toast";
import IconPicker from "../IconPicker"; import IconPicker from "../IconPicker";
import { IconWeight } from "@phosphor-icons/react"; import { IconWeight } from "@phosphor-icons/react";
import Image from "next/image";
import { previewAvailable } from "@/lib/shared/getArchiveValidity";
type Props = { type Props = {
onClose: Function; onClose: Function;
@ -137,31 +142,56 @@ export default function EditLinkModal({ onClose, activeLink }: Props) {
setLink({ ...link, description: e.target.value }) setLink({ ...link, description: e.target.value })
} }
placeholder={t("link_description_placeholder")} placeholder={t("link_description_placeholder")}
className="resize-none w-full rounded-md p-2 border-neutral-content bg-base-200 focus:border-sky-300 dark:focus:border-sky-600 border-solid border outline-none duration-100" className="resize-none w-full rounded-md p-2 h-32 border-neutral-content bg-base-200 focus:border-primary border-solid border outline-none duration-100"
/> />
</div> </div>
<div> <div>
<IconPicker <p className="mb-2">{t("icon_and_preview")}</p>
hideDefaultIcon <div className="flex gap-3">
color={link.color || "#0ea5e9"} <IconPicker
setColor={(color: string) => setLink({ ...link, color })} hideDefaultIcon
weight={(link.iconWeight || "regular") as IconWeight} color={link.color || "#0ea5e9"}
setWeight={(iconWeight: string) => setColor={(color: string) => setLink({ ...link, color })}
setLink({ ...link, iconWeight }) weight={(link.iconWeight || "regular") as IconWeight}
} setWeight={(iconWeight: string) =>
iconName={link.icon as string} setLink({ ...link, iconWeight })
setIconName={(icon: string) => setLink({ ...link, icon })} }
reset={() => iconName={link.icon as string}
setLink({ setIconName={(icon: string) => setLink({ ...link, icon })}
...link, reset={() =>
color: "", setLink({
icon: "", ...link,
iconWeight: "", color: "",
}) icon: "",
} iconWeight: "",
alignment="-top-10 translate-x-20" })
/> }
alignment="-top-10 translate-x-20"
/>
{previewAvailable(link) ? (
<Image
src={`/api/v1/archives/${link.id}?format=${ArchivedFormat.jpeg}&preview=true`}
width={1280}
height={720}
alt=""
className="object-cover h-20 w-32 rounded-lg opacity-80"
onError={(e) => {
const target = e.target as HTMLElement;
target.style.display = "none";
}}
/>
) : link.preview === "unavailable" ? (
<div className="bg-gray-50 duration-100 h-20 w-32 bg-opacity-80 rounded-lg flex flex-col justify-center">
<p className="text-black text-sm text-center">
{t("preview_unavailable")}
</p>
</div>
) : (
<div className="duration-100 h-20 w-32 bg-opacity-80 skeleton rounded-lg"></div>
)}
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -113,7 +113,7 @@ export default function NewCollectionModal({ onClose, parent }: Props) {
<div className="w-full"> <div className="w-full">
<p className="mb-2">{t("description")}</p> <p className="mb-2">{t("description")}</p>
<textarea <textarea
className="w-full h-[13rem] resize-none border rounded-md duration-100 bg-base-200 p-2 outline-none border-neutral-content focus:border-primary" className="w-full h-32 resize-none border rounded-md duration-100 bg-base-200 p-2 outline-none border-neutral-content focus:border-primary"
placeholder={t("collection_description_placeholder")} placeholder={t("collection_description_placeholder")}
value={collection.description} value={collection.description}
onChange={(e) => onChange={(e) =>

View File

@ -169,7 +169,7 @@ export default function NewLinkModal({ onClose }: Props) {
setLink({ ...link, description: e.target.value }) setLink({ ...link, description: e.target.value })
} }
placeholder={t("link_description_placeholder")} placeholder={t("link_description_placeholder")}
className="resize-none w-full rounded-md p-2 border-neutral-content bg-base-200 focus:border-primary border-solid border outline-none duration-100" className="resize-none w-full h-32 rounded-md p-2 border-neutral-content bg-base-200 focus:border-primary border-solid border outline-none duration-100"
/> />
</div> </div>
</div> </div>

View File

@ -207,7 +207,7 @@ export default function UploadFileModal({ onClose }: Props) {
setLink({ ...link, description: e.target.value }) setLink({ ...link, description: e.target.value })
} }
placeholder={t("description_placeholder")} placeholder={t("description_placeholder")}
className="resize-none w-full rounded-md p-2 border-neutral-content bg-base-200 focus:border-sky-300 dark:focus:border-sky-600 border-solid border outline-none duration-100" className="resize-none w-full h-32 rounded-md p-2 border-neutral-content bg-base-200 focus:border-primary border-solid border outline-none duration-100"
/> />
</div> </div>
</div> </div>

View File

@ -385,5 +385,7 @@
"show": "Show", "show": "Show",
"image": "Image", "image": "Image",
"icon": "Icon", "icon": "Icon",
"date": "Date" "date": "Date",
"preview_unavailable": "Preview Unavailable",
"icon_and_preview": "Icon & Preview"
} }