This commit is contained in:
Виталий Лавшонок
2025-10-29 10:37:37 +03:00
parent 34a404f147
commit 5ef7933446
2 changed files with 126 additions and 57 deletions

View File

@@ -6,43 +6,50 @@ import { IconError, IconSuccess } from "../../../assets/icons/problems";
export interface ArticleItemProps { export interface ArticleItemProps {
id: number; id: number;
authorId: number;
name: string; name: string;
tags: string[]; tags: string[];
createdAt: string;
updatedAt: string;
} }
export function formatMilliseconds(ms: number): string { export function formatMilliseconds(ms: number): string {
const rounded = Math.round(ms) / 1000; const rounded = Math.round(ms) / 1000;
const formatted = rounded.toString().replace(/\.?0+$/, ''); const formatted = rounded.toString().replace(/\.?0+$/, '');
return `${formatted} c`; return `${formatted} c`;
} }
export function formatBytesToMB(bytes: number): string { export function formatBytesToMB(bytes: number): string {
const megabytes = Math.floor(bytes / (1024 * 1024)); const megabytes = Math.floor(bytes / (1024 * 1024));
return `${megabytes} МБ`; return `${megabytes} МБ`;
} }
const ArticleItem: React.FC<ArticleItemProps> = ({ const ArticleItem: React.FC<ArticleItemProps> = ({
id, authorId, name, tags, createdAt, updatedAt id, name, tags
}) => { }) => {
console.log(id); console.log(id);
return ( return (
<div className={cn("h-[44px] w-full relative rounded-[10px] text-liquid-white", <div className={cn("w-full relative rounded-[10px] text-liquid-white mb-[20px]",
// type == "first" ? "bg-liquid-lighter" : "bg-liquid-background", // type == "first" ? "bg-liquid-lighter" : "bg-liquid-background",
"grid grid-cols-[1fr,1fr,1fr] grid-flow-col gap-[20px] px-[20px] box-border items-center", "gap-[20px] px-[20px] py-[10px] box-border ",
"border-b-[1px] border-b-liquid-lighter",
)}> )}>
<div className="text-[18px] font-bold"> <div className="h-[23px] flex ">
#{id}
<div className="text-[18px] font-bold w-[60px] mr-[20px] flex items-center">
#{id}
</div>
<div className="text-[18px] font-bold flex items-center bg-red-400r">
{name}
</div>
</div> </div>
<div className="text-[18px] font-bold"> <div className="text-[14px] flex text-liquid-light gap-[10px] mt-[10px]">
{name} {tags.map((v, i) =>
<div key={i} className={cn(
"rounded-full px-[16px] py-[8px] bg-liquid-lighter",
v == "Sertificated" && "text-liquid-green")}>
{v}
</div>
)}
</div> </div>
<div className="text-[12px] text-right">
{/* стандартный ввод/вывод {formatMilliseconds(timeLimit)}, {formatBytesToMB(memoryLimit)} */}
</div>
</div> </div>
); );
}; };

View File

@@ -1,9 +1,5 @@
import { Logo } from "../../../assets/logos";
import { Account, Clipboard, Cup, Home, Openbook, Users } from "../../../assets/icons/menu";
// import MenuItem from "./MenuItem";
import { useAppSelector } from "../../../redux/hooks";
// import ProblemItem from "./ProblemItem";
import { SecondaryButton } from "../../../components/button/SecondaryButton"; import { SecondaryButton } from "../../../components/button/SecondaryButton";
import ArticleItem, { ArticleItemProps } from "./ArticleItem";
export interface Problem { export interface Problem {
@@ -21,50 +17,116 @@ export interface Problem {
const Articles = () => { const Articles = () => {
const problems: Problem[] = [ const articles: ArticleItemProps[] = [
{ {
"id": 1, "id": 1,
"authorId": 1,
"name": "Todo List App", "name": "Todo List App",
"difficulty": "Easy", "tags": ["Sertificated", "state", "list"],
"tags": ["react", "state", "list"],
"timeLimit": 1000,
"memoryLimit": 268435456,
"createdAt": "2025-10-28T13:23:13.000Z",
"updatedAt": "2025-10-28T13:23:13.000Z"
}, },
{ {
"id": 2, "id": 2,
"authorId": 1,
"name": "Search Filter Component", "name": "Search Filter Component",
"difficulty": "Medium",
"tags": ["filter", "props", "hooks"], "tags": ["filter", "props", "hooks"],
"timeLimit": 1000,
"memoryLimit": 268435456,
"createdAt": "2025-10-28T13:23:14.000Z",
"updatedAt": "2025-10-28T13:23:14.000Z"
}, },
{ {
"id": 3, "id": 3,
"authorId": 1,
"name": "User Card List", "name": "User Card List",
"difficulty": "Easy",
"tags": ["components", "props", "array"], "tags": ["components", "props", "array"],
"timeLimit": 1000,
"memoryLimit": 268435456,
"createdAt": "2025-10-28T13:23:15.000Z",
"updatedAt": "2025-10-28T13:23:15.000Z"
}, },
{ {
"id": 4, "id": 4,
"authorId": 1,
"name": "Theme Switcher", "name": "Theme Switcher",
"difficulty": "Medium", "tags": ["Sertificated", "theme", "hooks"],
"tags": ["context", "theme", "hooks"], },
"timeLimit": 1000, {
"memoryLimit": 268435456, "id": 2,
"createdAt": "2025-10-28T13:23:16.000Z", "name": "Search Filter Component",
"updatedAt": "2025-10-28T13:23:16.000Z" "tags": ["filter", "props", "hooks"],
},
{
"id": 3,
"name": "User Card List",
"tags": ["components", "props", "array"],
},
{
"id": 4,
"name": "Theme Switcher",
"tags": ["Sertificated", "theme", "hooks"],
},
{
"id": 2,
"name": "Search Filter Component",
"tags": ["filter", "props", "hooks"],
},
{
"id": 3,
"name": "User Card List",
"tags": ["components", "props", "array"],
},
{
"id": 4,
"name": "Theme Switcher",
"tags": ["Sertificated", "theme", "hooks"],
},
{
"id": 2,
"name": "Search Filter Component",
"tags": ["filter", "props", "hooks"],
},
{
"id": 3,
"name": "User Card List",
"tags": ["components", "props", "array"],
},
{
"id": 4,
"name": "Theme Switcher",
"tags": ["Sertificated", "theme", "hooks"],
},
{
"id": 2,
"name": "Search Filter Component",
"tags": ["filter", "props", "hooks"],
},
{
"id": 3,
"name": "User Card List",
"tags": ["components", "props", "array"],
},
{
"id": 4,
"name": "Theme Switcher",
"tags": ["Sertificated", "theme", "hooks"],
},
{
"id": 2,
"name": "Search Filter Component",
"tags": ["filter", "props", "hooks"],
},
{
"id": 3,
"name": "User Card List",
"tags": ["components", "props", "array"],
},
{
"id": 4,
"name": "Theme Switcher",
"tags": ["Sertificated", "theme", "hooks"],
},
{
"id": 2,
"name": "Search Filter Component",
"tags": ["filter", "props", "hooks"],
},
{
"id": 3,
"name": "User Card List",
"tags": ["components", "props", "array"],
},
{
"id": 4,
"name": "Theme Switcher",
"tags": ["Sertificated", "theme", "hooks"],
} }
]; ];
@@ -77,8 +139,8 @@ const Articles = () => {
<div className="h-[50px] text-[40px] font-bold text-liquid-white flex items-center"> <div className="h-[50px] text-[40px] font-bold text-liquid-white flex items-center">
База статей База статей
</div> </div>
<SecondaryButton <SecondaryButton
onClick={() => {}} onClick={() => { }}
text="Создать статью" text="Создать статью"
className="absolute right-0" className="absolute right-0"
/> />
@@ -90,12 +152,12 @@ const Articles = () => {
<div> <div>
{/* {problems.map((v, i) => ( {articles.map((v, i) => (
<ProblemItem key={i} {...v} type={i % 2 == 0 ? "first" : "second"} status={i == 0 || i == 3 || i == 7 ? "success" : (i == 2 || i == 4 || i == 9 ? "error" : "empty")}/> <ArticleItem key={i} {...v} />
))} */} ))}
</div> </div>
<div> <div>
pages pages
</div> </div>