add resource table separate icon component
This commit is contained in:
parent
4dbc46c1c0
commit
0e311b0aa2
@ -9,12 +9,50 @@ import { ClipboardDocumentListIcon } from "@heroicons/react/24/outline";
|
|||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { translateEnumPlatform, translateEnumSkill } from "~/utils/enumWordLut";
|
import { translateEnumPlatform, translateEnumSkill } from "~/utils/enumWordLut";
|
||||||
import { type ChangeEvent } from "react";
|
import { useEffect, type ChangeEvent, useState } from "react";
|
||||||
import { ChevronDownIcon } from "@heroicons/react/24/outline";
|
import { ChevronDownIcon } from "@heroicons/react/24/outline";
|
||||||
import { type ParsedUrlQuery, type ParsedUrlQueryInput } from "querystring";
|
import { type ParsedUrlQuery, type ParsedUrlQueryInput } from "querystring";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { PriceIcon } from "~/prices/Icons";
|
import { PriceIcon } from "~/prices/Icons";
|
||||||
|
|
||||||
|
export const ResourcePhoto = ({ resource }: { resource: AuditoryResource }) => {
|
||||||
|
const [blobSrc, setBlobSrc] = useState<string | undefined>(undefined);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!resource.photo?.data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const blob = new Blob([resource.photo.data], { type: "image/png" });
|
||||||
|
setBlobSrc(URL.createObjectURL(blob));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const commonProps = {
|
||||||
|
width: 512,
|
||||||
|
height: 512,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (resource.photo?.data) {
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
className="w-full rounded-xl border border-neutral-400 bg-white drop-shadow-lg"
|
||||||
|
src={blobSrc}
|
||||||
|
alt={`${resource.name} logo`}
|
||||||
|
{...commonProps}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Image
|
||||||
|
className="w-full rounded-xl border border-neutral-400 bg-white drop-shadow-lg"
|
||||||
|
src={`/resource_logos/${resource.icon}`}
|
||||||
|
alt={`${resource.name} logo`}
|
||||||
|
{...commonProps}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const ResourceInfo = ({
|
export const ResourceInfo = ({
|
||||||
resource,
|
resource,
|
||||||
showMoreInfo,
|
showMoreInfo,
|
||||||
@ -46,13 +84,7 @@ export const ResourceInfo = ({
|
|||||||
{showMoreInfo ? (
|
{showMoreInfo ? (
|
||||||
<Link href={`resources/${resource.id}`}>
|
<Link href={`resources/${resource.id}`}>
|
||||||
<div className="flex w-20 flex-col justify-center space-y-2 sm:w-28">
|
<div className="flex w-20 flex-col justify-center space-y-2 sm:w-28">
|
||||||
<Image
|
<ResourcePhoto resource={resource} />
|
||||||
className="w-full rounded-xl border border-neutral-400 bg-white drop-shadow-lg"
|
|
||||||
src={`/resource_logos/${resource.icon}`}
|
|
||||||
alt={`${resource.name} logo`}
|
|
||||||
width={512}
|
|
||||||
height={512}
|
|
||||||
/>
|
|
||||||
<span className="block rounded-lg border border-neutral-900 bg-neutral-900 py-[1px] text-center text-white hover:bg-neutral-500 print:hidden">
|
<span className="block rounded-lg border border-neutral-900 bg-neutral-900 py-[1px] text-center text-white hover:bg-neutral-500 print:hidden">
|
||||||
more info
|
more info
|
||||||
</span>
|
</span>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user