Renamed ThumbnailPreview to PreviewCard + removed Next/Image
This commit is contained in:
parent
16891dfad1
commit
a82bc74baa
|
@ -1,16 +1,13 @@
|
||||||
import { UploadImageFragment } from "graphql/generated";
|
import { UploadImageFragment } from "graphql/generated";
|
||||||
import { getAssetURL, getImgSizesByQuality, ImageQuality } from "helpers/img";
|
import { getAssetURL, getImgSizesByQuality, ImageQuality } from "helpers/img";
|
||||||
import { Immutable } from "helpers/types";
|
import { Immutable } from "helpers/types";
|
||||||
import Image, { ImageProps } from "next/image";
|
import { ImageProps } from "next/image";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
image?: UploadImageFragment | string;
|
image?: UploadImageFragment | string;
|
||||||
quality?: ImageQuality;
|
quality?: ImageQuality;
|
||||||
alt?: ImageProps["alt"];
|
alt?: ImageProps["alt"];
|
||||||
layout?: ImageProps["layout"];
|
|
||||||
objectFit?: ImageProps["objectFit"];
|
|
||||||
priority?: ImageProps["priority"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Img(props: Immutable<Props>): JSX.Element {
|
export default function Img(props: Immutable<Props>): JSX.Element {
|
||||||
|
@ -20,6 +17,7 @@ export default function Img(props: Immutable<Props>): JSX.Element {
|
||||||
className={props.className}
|
className={props.className}
|
||||||
src={props.image}
|
src={props.image}
|
||||||
alt={props.alt ?? ""}
|
alt={props.alt ?? ""}
|
||||||
|
loading="lazy"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (props.image?.width && props.image.height) {
|
} else if (props.image?.width && props.image.height) {
|
||||||
|
@ -29,19 +27,16 @@ export default function Img(props: Immutable<Props>): JSX.Element {
|
||||||
props.quality ?? ImageQuality.Small
|
props.quality ?? ImageQuality.Small
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<Image
|
<img
|
||||||
className={props.className}
|
className={props.className}
|
||||||
src={getAssetURL(
|
src={getAssetURL(
|
||||||
props.image.url,
|
props.image.url,
|
||||||
props.quality ? props.quality : ImageQuality.Small
|
props.quality ? props.quality : ImageQuality.Small
|
||||||
)}
|
)}
|
||||||
alt={props.alt ?? props.image.alternativeText ?? ""}
|
alt={props.alt ?? props.image.alternativeText ?? ""}
|
||||||
width={props.layout === "fill" ? undefined : imgSize.width}
|
width={imgSize.width}
|
||||||
height={props.layout === "fill" ? undefined : imgSize.height}
|
height={imgSize.height}
|
||||||
layout={props.layout}
|
loading="lazy"
|
||||||
objectFit={props.objectFit}
|
|
||||||
priority={props.priority}
|
|
||||||
unoptimized
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,8 +270,6 @@ export default function Markdawn(props: Immutable<Props>): JSX.Element {
|
||||||
? getAssetURL(compProps.src, ImageQuality.Small)
|
? getAssetURL(compProps.src, ImageQuality.Small)
|
||||||
: compProps.src
|
: compProps.src
|
||||||
}
|
}
|
||||||
layout="fill"
|
|
||||||
objectFit="contain"
|
|
||||||
quality={ImageQuality.Medium}
|
quality={ImageQuality.Medium}
|
||||||
></Img>
|
></Img>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -44,7 +44,7 @@ interface Props {
|
||||||
| { __typename: "anotherHoverlayName" };
|
| { __typename: "anotherHoverlayName" };
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ThumbnailPreview(props: Immutable<Props>): JSX.Element {
|
export default function PreviewCard(props: Immutable<Props>): JSX.Element {
|
||||||
const {
|
const {
|
||||||
href,
|
href,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
|
@ -160,9 +160,8 @@ export default function ThumbnailPreview(props: Immutable<Props>): JSX.Element {
|
||||||
)}
|
)}
|
||||||
<div
|
<div
|
||||||
className={`linearbg-obi ${
|
className={`linearbg-obi ${
|
||||||
keepInfoVisible
|
!keepInfoVisible &&
|
||||||
? "-mt-[0.3333em]"
|
`fine:drop-shadow-shade-lg fine:absolute coarse:rounded-b-md
|
||||||
: `fine:drop-shadow-shade-lg fine:absolute coarse:rounded-b-md
|
|
||||||
bottom-2 -inset-x-0.5 opacity-[var(--cover-opacity)]`
|
bottom-2 -inset-x-0.5 opacity-[var(--cover-opacity)]`
|
||||||
} transition-opacity z-20 grid p-4 gap-2`}
|
} transition-opacity z-20 grid p-4 gap-2`}
|
||||||
>
|
>
|
||||||
|
|
|
@ -54,7 +54,6 @@ export default function ThumbnailHeader(props: Immutable<Props>): JSX.Element {
|
||||||
className=" rounded-xl"
|
className=" rounded-xl"
|
||||||
image={thumbnail}
|
image={thumbnail}
|
||||||
quality={ImageQuality.Medium}
|
quality={ImageQuality.Medium}
|
||||||
priority
|
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="w-96 aspect-[4/3] bg-light rounded-xl"></div>
|
<div className="w-96 aspect-[4/3] bg-light rounded-xl"></div>
|
||||||
|
|
|
@ -8,7 +8,7 @@ import ContentPanel, {
|
||||||
ContentPanelWidthSizes,
|
ContentPanelWidthSizes,
|
||||||
} from "components/Panels/ContentPanel";
|
} from "components/Panels/ContentPanel";
|
||||||
import SubPanel from "components/Panels/SubPanel";
|
import SubPanel from "components/Panels/SubPanel";
|
||||||
import ThumbnailPreview from "components/PreviewCard";
|
import PreviewCard from "components/PreviewCard";
|
||||||
import { GetVideoChannelQuery } from "graphql/generated";
|
import { GetVideoChannelQuery } from "graphql/generated";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getReadySdk } from "graphql/sdk";
|
import { getReadySdk } from "graphql/sdk";
|
||||||
|
@ -68,7 +68,7 @@ export default function Channel(props: Props): JSX.Element {
|
||||||
{channel?.videos?.data.map((video) => (
|
{channel?.videos?.data.map((video) => (
|
||||||
<>
|
<>
|
||||||
{video.attributes && (
|
{video.attributes && (
|
||||||
<ThumbnailPreview
|
<PreviewCard
|
||||||
key={video.id}
|
key={video.id}
|
||||||
href={`/archives/videos/v/${video.attributes.uid}`}
|
href={`/archives/videos/v/${video.attributes.uid}`}
|
||||||
title={video.attributes.title}
|
title={video.attributes.title}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import ContentPanel, {
|
||||||
ContentPanelWidthSizes,
|
ContentPanelWidthSizes,
|
||||||
} from "components/Panels/ContentPanel";
|
} from "components/Panels/ContentPanel";
|
||||||
import SubPanel from "components/Panels/SubPanel";
|
import SubPanel from "components/Panels/SubPanel";
|
||||||
import ThumbnailPreview from "components/PreviewCard";
|
import PreviewCard from "components/PreviewCard";
|
||||||
import { GetVideosPreviewQuery } from "graphql/generated";
|
import { GetVideosPreviewQuery } from "graphql/generated";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getReadySdk } from "graphql/sdk";
|
import { getReadySdk } from "graphql/sdk";
|
||||||
|
@ -88,7 +88,7 @@ export default function Videos(props: Props): JSX.Element {
|
||||||
{paginatedVideos[page].map((video) => (
|
{paginatedVideos[page].map((video) => (
|
||||||
<>
|
<>
|
||||||
{video.attributes && (
|
{video.attributes && (
|
||||||
<ThumbnailPreview
|
<PreviewCard
|
||||||
key={video.id}
|
key={video.id}
|
||||||
href={`/archives/videos/v/${video.attributes.uid}`}
|
href={`/archives/videos/v/${video.attributes.uid}`}
|
||||||
title={video.attributes.title}
|
title={video.attributes.title}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import ContentPanel, {
|
||||||
ContentPanelWidthSizes,
|
ContentPanelWidthSizes,
|
||||||
} from "components/Panels/ContentPanel";
|
} from "components/Panels/ContentPanel";
|
||||||
import SubPanel from "components/Panels/SubPanel";
|
import SubPanel from "components/Panels/SubPanel";
|
||||||
import ThumbnailPreview from "components/PreviewCard";
|
import PreviewCard from "components/PreviewCard";
|
||||||
import { GetContentsQuery } from "graphql/generated";
|
import { GetContentsQuery } from "graphql/generated";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getReadySdk } from "graphql/sdk";
|
import { getReadySdk } from "graphql/sdk";
|
||||||
|
@ -89,7 +89,7 @@ export default function Contents(props: Immutable<Props>): JSX.Element {
|
||||||
{items.map((item) => (
|
{items.map((item) => (
|
||||||
<>
|
<>
|
||||||
{item.attributes && (
|
{item.attributes && (
|
||||||
<ThumbnailPreview
|
<PreviewCard
|
||||||
key={item.id}
|
key={item.id}
|
||||||
href={`/contents/${item.attributes.slug}`}
|
href={`/contents/${item.attributes.slug}`}
|
||||||
pre_title={item.attributes.titles?.[0]?.pre_title}
|
pre_title={item.attributes.titles?.[0]?.pre_title}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import ContentPanel, {
|
||||||
ContentPanelWidthSizes,
|
ContentPanelWidthSizes,
|
||||||
} from "components/Panels/ContentPanel";
|
} from "components/Panels/ContentPanel";
|
||||||
import SubPanel from "components/Panels/SubPanel";
|
import SubPanel from "components/Panels/SubPanel";
|
||||||
import ThumbnailPreview from "components/PreviewCard";
|
import PreviewCard from "components/PreviewCard";
|
||||||
import { useAppLayout } from "contexts/AppLayoutContext";
|
import { useAppLayout } from "contexts/AppLayoutContext";
|
||||||
import {
|
import {
|
||||||
Enum_Componentmetadatabooks_Binding_Type,
|
Enum_Componentmetadatabooks_Binding_Type,
|
||||||
|
@ -172,9 +172,7 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
|
||||||
<Img
|
<Img
|
||||||
image={item.thumbnail.data.attributes}
|
image={item.thumbnail.data.attributes}
|
||||||
quality={ImageQuality.Large}
|
quality={ImageQuality.Large}
|
||||||
layout="fill"
|
className="w-full h-full object-contain"
|
||||||
objectFit="contain"
|
|
||||||
priority
|
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="w-full aspect-[21/29.7] bg-light rounded-xl"></div>
|
<div className="w-full aspect-[21/29.7] bg-light rounded-xl"></div>
|
||||||
|
@ -270,15 +268,10 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
|
||||||
className="bg-light absolute inset-0
|
|
||||||
rounded-lg drop-shadow-shade-md"
|
|
||||||
></div>
|
|
||||||
<Img
|
<Img
|
||||||
className="rounded-lg"
|
className="bg-light rounded-lg drop-shadow-shade-md
|
||||||
|
w-full h-full object-cover"
|
||||||
image={galleryItem.attributes}
|
image={galleryItem.attributes}
|
||||||
layout="fill"
|
|
||||||
objectFit="cover"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -445,7 +438,7 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
|
||||||
{item.subitems.data.map((subitem) => (
|
{item.subitems.data.map((subitem) => (
|
||||||
<>
|
<>
|
||||||
{subitem.attributes && (
|
{subitem.attributes && (
|
||||||
<ThumbnailPreview
|
<PreviewCard
|
||||||
key={subitem.id}
|
key={subitem.id}
|
||||||
href={`/library/${subitem.attributes.slug}`}
|
href={`/library/${subitem.attributes.slug}`}
|
||||||
title={subitem.attributes.title}
|
title={subitem.attributes.title}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import ContentPanel, {
|
||||||
ContentPanelWidthSizes,
|
ContentPanelWidthSizes,
|
||||||
} from "components/Panels/ContentPanel";
|
} from "components/Panels/ContentPanel";
|
||||||
import SubPanel from "components/Panels/SubPanel";
|
import SubPanel from "components/Panels/SubPanel";
|
||||||
import ThumbnailPreview from "components/PreviewCard";
|
import PreviewCard from "components/PreviewCard";
|
||||||
import { GetPostsPreviewQuery } from "graphql/generated";
|
import { GetPostsPreviewQuery } from "graphql/generated";
|
||||||
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
import { AppStaticProps, getAppStaticProps } from "graphql/getAppStaticProps";
|
||||||
import { getReadySdk } from "graphql/sdk";
|
import { getReadySdk } from "graphql/sdk";
|
||||||
|
@ -48,7 +48,7 @@ export default function News(props: Immutable<Props>): JSX.Element {
|
||||||
{posts.map((post) => (
|
{posts.map((post) => (
|
||||||
<>
|
<>
|
||||||
{post.attributes && (
|
{post.attributes && (
|
||||||
<ThumbnailPreview
|
<PreviewCard
|
||||||
key={post.id}
|
key={post.id}
|
||||||
href={`/news/${post.attributes.slug}`}
|
href={`/news/${post.attributes.slug}`}
|
||||||
title={
|
title={
|
||||||
|
|
Loading…
Reference in New Issue