Allowed to combine contents
This commit is contained in:
parent
fc0512fc91
commit
be7c508aaa
|
@ -28,6 +28,7 @@ interface Props {
|
||||||
topChips?: string[];
|
topChips?: string[];
|
||||||
bottomChips?: string[];
|
bottomChips?: string[];
|
||||||
keepInfoVisible?: boolean;
|
keepInfoVisible?: boolean;
|
||||||
|
stackEffect?: boolean;
|
||||||
metadata?: {
|
metadata?: {
|
||||||
currencies?: AppStaticProps["currencies"];
|
currencies?: AppStaticProps["currencies"];
|
||||||
release_date?: DatePickerFragment | null;
|
release_date?: DatePickerFragment | null;
|
||||||
|
@ -52,6 +53,7 @@ export default function PreviewCard(props: Immutable<Props>): JSX.Element {
|
||||||
title,
|
title,
|
||||||
subtitle,
|
subtitle,
|
||||||
description,
|
description,
|
||||||
|
stackEffect = false,
|
||||||
topChips,
|
topChips,
|
||||||
bottomChips,
|
bottomChips,
|
||||||
keepInfoVisible,
|
keepInfoVisible,
|
||||||
|
@ -112,8 +114,26 @@ export default function PreviewCard(props: Immutable<Props>): JSX.Element {
|
||||||
className="drop-shadow-shade-xl cursor-pointer grid items-end
|
className="drop-shadow-shade-xl cursor-pointer grid items-end
|
||||||
fine:[--cover-opacity:0] hover:[--cover-opacity:1] hover:scale-[1.02]
|
fine:[--cover-opacity:0] hover:[--cover-opacity:1] hover:scale-[1.02]
|
||||||
[--bg-opacity:0] hover:[--bg-opacity:0.5] [--play-opacity:0]
|
[--bg-opacity:0] hover:[--bg-opacity:0.5] [--play-opacity:0]
|
||||||
hover:[--play-opacity:100] transition-transform"
|
hover:[--play-opacity:100] transition-transform
|
||||||
|
[--stacked-top:0] hover:[--stacked-top:1]"
|
||||||
>
|
>
|
||||||
|
{thumbnail && stackEffect && (
|
||||||
|
<>
|
||||||
|
<Img
|
||||||
|
className={`rounded-t-md absolute -top-[var(--stacked-top)*1.3rem]
|
||||||
|
opacity-30 scale-[0.88] transition-[top]`}
|
||||||
|
image={thumbnail}
|
||||||
|
quality={ImageQuality.Medium}
|
||||||
|
/>
|
||||||
|
<Img
|
||||||
|
className={`rounded-t-md absolute -top-[var(--stacked-top)*0.6rem]
|
||||||
|
opacity-60 scale-95 transition-[top]`}
|
||||||
|
image={thumbnail}
|
||||||
|
quality={ImageQuality.Medium}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
{thumbnail ? (
|
{thumbnail ? (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<Img
|
<Img
|
||||||
|
@ -174,9 +194,13 @@ export default function PreviewCard(props: Immutable<Props>): JSX.Element {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="my-1">
|
<div className="my-1">
|
||||||
{pre_title && <p className="leading-none mb-1 break-words">{pre_title}</p>}
|
{pre_title && (
|
||||||
|
<p className="leading-none mb-1 break-words">{pre_title}</p>
|
||||||
|
)}
|
||||||
{title && (
|
{title && (
|
||||||
<p className="font-headers text-lg leading-none break-words">{title}</p>
|
<p className="font-headers text-lg leading-none break-words">
|
||||||
|
{title}
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
{subtitle && <p className="leading-none break-words">{subtitle}</p>}
|
{subtitle && <p className="leading-none break-words">{subtitle}</p>}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,7 +4,7 @@ query getContents($language_code: String) {
|
||||||
id
|
id
|
||||||
attributes {
|
attributes {
|
||||||
slug
|
slug
|
||||||
titles(filters: { language: { code: { eq: $language_code } } }) {
|
titles {
|
||||||
pre_title
|
pre_title
|
||||||
title
|
title
|
||||||
subtitle
|
subtitle
|
||||||
|
@ -55,6 +55,16 @@ query getContents($language_code: String) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
next_recommended {
|
||||||
|
data {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
previous_recommended {
|
||||||
|
data {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
text_set {
|
text_set {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,13 +28,23 @@ export default function Contents(props: Immutable<Props>): JSX.Element {
|
||||||
const [groupingMethod, setGroupingMethod] = useState<number>(-1);
|
const [groupingMethod, setGroupingMethod] = useState<number>(-1);
|
||||||
const [keepInfoVisible, setKeepInfoVisible] = useState(false);
|
const [keepInfoVisible, setKeepInfoVisible] = useState(false);
|
||||||
|
|
||||||
|
const [combineRelatedContent, setCombineRelatedContent] = useState(true);
|
||||||
|
|
||||||
|
const [filteredItems, setFilteredItems] = useState(
|
||||||
|
filterContents(combineRelatedContent, contents)
|
||||||
|
);
|
||||||
|
|
||||||
const [groups, setGroups] = useState<GroupContentItems>(
|
const [groups, setGroups] = useState<GroupContentItems>(
|
||||||
getGroups(langui, groupingMethod, contents)
|
getGroups(langui, groupingMethod, filteredItems)
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setGroups(getGroups(langui, groupingMethod, contents));
|
setFilteredItems(filterContents(combineRelatedContent, contents));
|
||||||
}, [langui, groupingMethod, contents]);
|
}, [combineRelatedContent, contents]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setGroups(getGroups(langui, groupingMethod, filteredItems));
|
||||||
|
}, [langui, groupingMethod, filteredItems]);
|
||||||
|
|
||||||
const subPanel = (
|
const subPanel = (
|
||||||
<SubPanel>
|
<SubPanel>
|
||||||
|
@ -55,6 +65,14 @@ export default function Contents(props: Immutable<Props>): JSX.Element {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="flex flex-row gap-2 place-items-center coarse:hidden">
|
||||||
|
<p className="flex-shrink-0">{"Combine related contents"}:</p>
|
||||||
|
<Switch
|
||||||
|
setState={setCombineRelatedContent}
|
||||||
|
state={combineRelatedContent}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-row gap-2 place-items-center coarse:hidden">
|
<div className="flex flex-row gap-2 place-items-center coarse:hidden">
|
||||||
<p className="flex-shrink-0">{"Always show info"}:</p>
|
<p className="flex-shrink-0">{"Always show info"}:</p>
|
||||||
<Switch setState={setKeepInfoVisible} state={keepInfoVisible} />
|
<Switch setState={setKeepInfoVisible} state={keepInfoVisible} />
|
||||||
|
@ -100,6 +118,11 @@ export default function Contents(props: Immutable<Props>): JSX.Element {
|
||||||
subtitle={item.attributes.titles?.[0]?.subtitle}
|
subtitle={item.attributes.titles?.[0]?.subtitle}
|
||||||
thumbnail={item.attributes.thumbnail?.data?.attributes}
|
thumbnail={item.attributes.thumbnail?.data?.attributes}
|
||||||
thumbnailAspectRatio="3/2"
|
thumbnailAspectRatio="3/2"
|
||||||
|
stackEffect={
|
||||||
|
item.attributes.next_recommended?.data?.id !== null &&
|
||||||
|
item.attributes.next_recommended?.data?.id !== undefined &&
|
||||||
|
combineRelatedContent
|
||||||
|
}
|
||||||
topChips={
|
topChips={
|
||||||
item.attributes.type?.data?.attributes
|
item.attributes.type?.data?.attributes
|
||||||
? [
|
? [
|
||||||
|
@ -231,3 +254,15 @@ function getGroups(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function filterContents(
|
||||||
|
combineRelatedContent: boolean,
|
||||||
|
contents: Immutable<Props["contents"]>
|
||||||
|
): Immutable<Props["contents"]> {
|
||||||
|
if (combineRelatedContent) {
|
||||||
|
return [...contents].filter(
|
||||||
|
(content) => !content.attributes?.previous_recommended?.data?.id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return contents;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue