diff --git a/enshi/src/Pages/RandomPostsPage/PostCard/PostCard.tsx b/enshi/src/Pages/RandomPostsPage/PostCard/PostCard.tsx index edb7c9d..ee66e59 100644 --- a/enshi/src/Pages/RandomPostsPage/PostCard/PostCard.tsx +++ b/enshi/src/Pages/RandomPostsPage/PostCard/PostCard.tsx @@ -1,21 +1,25 @@ import { CalendarIcon } from "@radix-ui/react-icons"; import { - Box, - Card, - Flex, - Heading, - Inset, - Text, - Tooltip, + Card, + Flex, + Heading, + Inset, + Text, + Tooltip } from "@radix-ui/themes"; import dayjs from "dayjs"; import "dayjs/locale/ru"; -import { useMemo } from "react"; +import { useEffect, useMemo, useRef, useState } from "react"; import { useNavigate } from "react-router-dom"; import { Post } from "../../../@types/PostTypes"; export default function PostCard(props: Post) { const navigate = useNavigate(); + const ref = useRef(null); + + const [windowWidth, setWindowWidth] = useState(window.innerWidth); + const [isImageLoaded, setIsImageLoaded] = useState(false); + const [isHovered, setIsHovered] = useState(false); const parsedDate = dayjs(props.created_at) .locale("ru") @@ -25,24 +29,55 @@ export default function PostCard(props: Post) { navigate(`/posts/${props.post_id.toString()}`); }; - const seed = useMemo(() => { - return Math.floor(Math.random() * (1 + Math.random()) * 100000); - }, []); + const seed = useMemo(() => { + return Math.floor(Math.random() * (1 + Math.random()) * 100000); + }, []); + + useEffect(() => { + const f = () => { + setWindowWidth(window.innerWidth); + console.log(`Window width: ${window.innerWidth} px`); + + } + + f() + + window.addEventListener('resize', f); + return () => window.removeEventListener('resize', f); + }, []); return ( setIsHovered(true)} + onMouseLeave={() => setIsHovered(false)} > - - + Bold typography setIsImageLoaded(true)} /> - - + {data?.pages.map((post, i) => { return ( - + {post.selected_posts.map((post, j) => { - return ( -
- -
- ); + return ; })}
);