Merge pull request #579 from codingmatty/main
Add link actions to readable view
This commit is contained in:
commit
db446d450f
|
@ -200,7 +200,7 @@ export default function LinkCard({ link, flipDropdown, editMode }: Props) {
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
{link.tags[0] && (
|
{link.tags && link.tags[0] && (
|
||||||
<>
|
<>
|
||||||
<p className="text-neutral text-lg mt-3 font-semibold">Tags</p>
|
<p className="text-neutral text-lg mt-3 font-semibold">Tags</p>
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ type Props = {
|
||||||
position?: string;
|
position?: string;
|
||||||
toggleShowInfo?: () => void;
|
toggleShowInfo?: () => void;
|
||||||
linkInfo?: boolean;
|
linkInfo?: boolean;
|
||||||
|
alignToTop?: boolean;
|
||||||
flipDropdown?: boolean;
|
flipDropdown?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ export default function LinkActions({
|
||||||
toggleShowInfo,
|
toggleShowInfo,
|
||||||
position,
|
position,
|
||||||
linkInfo,
|
linkInfo,
|
||||||
|
alignToTop,
|
||||||
flipDropdown,
|
flipDropdown,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const permissions = usePermissions(link.collection.id as number);
|
const permissions = usePermissions(link.collection.id as number);
|
||||||
|
@ -67,9 +69,9 @@ export default function LinkActions({
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
className={`dropdown dropdown-left dropdown-end absolute ${
|
className={`dropdown dropdown-left absolute ${
|
||||||
position || "top-3 right-3"
|
position || "top-3 right-3"
|
||||||
} z-20`}
|
} ${alignToTop ? "" : "dropdown-end"} z-20`}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
|
@ -79,7 +81,11 @@ export default function LinkActions({
|
||||||
>
|
>
|
||||||
<i title="More" className="bi-three-dots text-xl" />
|
<i title="More" className="bi-three-dots text-xl" />
|
||||||
</div>
|
</div>
|
||||||
<ul className="dropdown-content z-[20] menu shadow bg-base-200 border border-neutral-content rounded-box w-44 mr-1 translate-y-10">
|
<ul
|
||||||
|
className={`dropdown-content z-[20] menu shadow bg-base-200 border border-neutral-content rounded-box w-44 mr-1 ${
|
||||||
|
alignToTop ? "" : "translate-y-10"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
<li>
|
<li>
|
||||||
<div
|
<div
|
||||||
role="button"
|
role="button"
|
||||||
|
|
|
@ -4,6 +4,7 @@ import isValidUrl from "@/lib/shared/isValidUrl";
|
||||||
import useLinkStore from "@/store/links";
|
import useLinkStore from "@/store/links";
|
||||||
import {
|
import {
|
||||||
ArchivedFormat,
|
ArchivedFormat,
|
||||||
|
CollectionIncludingMembersAndLinkCount,
|
||||||
LinkIncludingShortenedCollectionAndTags,
|
LinkIncludingShortenedCollectionAndTags,
|
||||||
} from "@/types/global";
|
} from "@/types/global";
|
||||||
import ColorThief, { RGBColor } from "colorthief";
|
import ColorThief, { RGBColor } from "colorthief";
|
||||||
|
@ -11,7 +12,9 @@ import DOMPurify from "dompurify";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useMemo, useState } from "react";
|
||||||
|
import LinkActions from "./LinkViews/LinkComponents/LinkActions";
|
||||||
|
import useCollectionStore from "@/store/collections";
|
||||||
|
|
||||||
type LinkContent = {
|
type LinkContent = {
|
||||||
title: string;
|
title: string;
|
||||||
|
@ -40,7 +43,14 @@ export default function ReadableView({ link }: Props) {
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const { links, getLink } = useLinkStore();
|
const { getLink } = useLinkStore();
|
||||||
|
const { collections } = useCollectionStore();
|
||||||
|
|
||||||
|
const collection = useMemo(() => {
|
||||||
|
return collections.find(
|
||||||
|
(e) => e.id === link.collection.id
|
||||||
|
) as CollectionIncludingMembersAndLinkCount;
|
||||||
|
}, [collections, link]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchLinkContent = async () => {
|
const fetchLinkContent = async () => {
|
||||||
|
@ -128,10 +138,10 @@ export default function ReadableView({ link }: Props) {
|
||||||
}, [colorPalette]);
|
}, [colorPalette]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`flex flex-col max-w-screen-md h-full mx-auto py-5`}>
|
<div className={`flex flex-col max-w-screen-md h-full mx-auto p-5`}>
|
||||||
<div
|
<div
|
||||||
id="link-banner"
|
id="link-banner"
|
||||||
className="link-banner bg-opacity-10 border-neutral-content p-3 border mb-3"
|
className="link-banner relative bg-opacity-10 border-neutral-content p-3 border mb-3"
|
||||||
>
|
>
|
||||||
<div id="link-banner-inner" className="link-banner-inner"></div>
|
<div id="link-banner-inner" className="link-banner-inner"></div>
|
||||||
|
|
||||||
|
@ -164,7 +174,7 @@ export default function ReadableView({ link }: Props) {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<p className="text-xl">
|
<p className="text-xl pr-10">
|
||||||
{unescapeString(
|
{unescapeString(
|
||||||
link?.name || link?.description || link?.url || ""
|
link?.name || link?.description || link?.url || ""
|
||||||
)}
|
)}
|
||||||
|
@ -202,7 +212,7 @@ export default function ReadableView({ link }: Props) {
|
||||||
{link?.collection.name}
|
{link?.collection.name}
|
||||||
</p>
|
</p>
|
||||||
</Link>
|
</Link>
|
||||||
{link?.tags.map((e, i) => (
|
{link?.tags?.map((e, i) => (
|
||||||
<Link key={i} href={`/tags/${e.id}`} className="z-10">
|
<Link key={i} href={`/tags/${e.id}`} className="z-10">
|
||||||
<p
|
<p
|
||||||
title={e.name}
|
title={e.name}
|
||||||
|
@ -226,6 +236,13 @@ export default function ReadableView({ link }: Props) {
|
||||||
|
|
||||||
{link?.name ? <p>{unescapeString(link?.description)}</p> : undefined}
|
{link?.name ? <p>{unescapeString(link?.description)}</p> : undefined}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<LinkActions
|
||||||
|
link={link}
|
||||||
|
collection={collection}
|
||||||
|
position="top-3 right-3"
|
||||||
|
alignToTop
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col gap-5 h-full">
|
<div className="flex flex-col gap-5 h-full">
|
||||||
|
|
Ŝarĝante…
Reference in New Issue