feat(ReleaseOverview): add ability to change view modes for releases pages

This commit is contained in:
Kentai Radiquum 2024-05-11 07:53:20 +05:00
parent 10397b2b6a
commit e079fa3a93
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
5 changed files with 97 additions and 27 deletions

View file

@ -8,6 +8,5 @@
## Идеи ## Идеи
- Изменение вида списка релизов
- уведомления - уведомления
- метатеги - метатеги

View file

@ -1,15 +1,29 @@
import { ReleaseCard } from "@/app/components/ReleaseCard/ReleaseCard"; import { ReleaseCard } from "@/app/components/ReleaseCard/ReleaseCard";
import { ReleaseList } from "@/app/components/ReleaseList/ReleaseList";
export const CardList = (props) => { export const CardList = (props) => {
return props.data.map((item) => { return props.data.map((item) => {
return ( if (props.view == "grid") {
<ReleaseCard return (
key={item.id} <ReleaseCard
id={item.id} key={item.id}
title={item.title_ru} id={item.id}
poster={item.image} title={item.title_ru}
description={item.description} poster={item.image}
/> description={item.description}
); />
);
}
if (props.view == "list") {
return (
<ReleaseList
key={item.id}
id={item.id}
title={item.title_ru}
poster={item.image}
description={item.description}
/>
);
}
}); });
}; };

View file

@ -105,7 +105,7 @@ export const NavigationRail = (props) => {
<button className="circle transparent" onClick={() => copyToClipboard()}> <button className="circle transparent" onClick={() => copyToClipboard()}>
<i>{isCopied ? "done" : "content_copy"}</i> <i>{isCopied ? "done" : "content_copy"}</i>
<div class="tooltip right"> <div className="tooltip right">
{isCopied ? "Ссылка скопирована" : "Скопировать ссылку"} {isCopied ? "Ссылка скопирована" : "Скопировать ссылку"}
</div> </div>
</button> </button>

View file

@ -0,0 +1,33 @@
import Link from "next/link";
import Image from "next/legacy/image";
export const ReleaseList = (props) => {
return (
<Link
href={`/release/${props.id}`}
className={
props.className
? props.className
: "s12 round fill row padding surface-container"
}
>
<Image
className="round"
style={{ aspectRatio: "1/1" }}
width="128px"
height="128px"
src={props.poster}
alt=""
/>
<div className="max">
<h5 className="small">{`${props.title.substring(0, 90)}${
[...props.title].length > 90 ? "..." : ""
}`}</h5>
<p>{`${props.description.substring(0, 170)}${
[...props.description].length > 170 ? "..." : ""
}`}</p>
</div>
</Link>
);
};

View file

@ -1,30 +1,54 @@
import { CardList } from "@/app/components/CardList/CardList"; import { CardList } from "@/app/components/CardList/CardList";
import { useState } from "react";
export default function ReleasesOverview(props) { export default function ReleasesOverview(props) {
const [view, setView] = useState("grid");
return ( return (
<> <>
{props.chips && ( <div style={{ display: "flex", justifyContent: "space-between" }}>
{props.chips && (
<div>
{props.chips.map((item) => {
return (
<button
key={item.list}
className={`chip ${props.list == item.list ? "fill" : ""}`}
onClick={() => {
props.setList(item.list);
}}
>
<span>{item.title}</span>
</button>
);
})}
</div>
)}
<div> <div>
{props.chips.map((item) => { <button
return ( className="circle transparent"
<button onClick={() => {
key={item.list} setView("list");
className={`chip ${props.list == item.list ? "fill" : ""}`} }}
onClick={() => { >
props.setList(item.list); <i className={view == "list" ? "fill" : ""}>view_agenda</i>
}} </button>
> <button
<span>{item.title}</span> className="circle transparent"
</button> onClick={() => {
); setView("grid");
})} }}
>
<i className={view == "grid" ? "fill" : ""}>cards</i>
</button>
</div> </div>
)} </div>
{props.releases ? ( {props.releases ? (
<> <>
<div className="grid"> <div className="grid">
<CardList data={props.releases} /> <CardList data={props.releases} view={view} />
</div> </div>
{props.isNextPage && ( {props.isNextPage && (