nextjs-tailwindcss-headless.../app/components/card/page.tsx

49 lines
1.5 KiB
TypeScript
Raw Permalink Normal View History

2023-09-14 09:21:45 +08:00
"use client";
2023-08-25 21:53:07 +08:00
import { useHover } from "usehooks-ts";
import { useRef } from "react";
import Image from "next/image";
2023-08-25 21:53:07 +08:00
export default function Page() {
2023-09-14 09:21:45 +08:00
const ref = useRef(null);
const isHover = useHover(ref);
2023-08-25 21:53:07 +08:00
2023-09-14 09:21:45 +08:00
return (
<div className="bg-white rounded-lg cursor-pointer w-64">
<div className="relative w-full h-auto" ref={ref}>
<Image
width={500}
height={250}
className={"object-cover w-full rounded-t-lg"}
src={
!isHover
? "https://res-academy.cache.wpscdn.com/static/cover/xls_v2.png"
: "https://res-academy.cache.wpscdn.com/youtube-gif/20220419/144426_H3Ns3Os0zqE_72_10.gif"
}
alt={"img"}
/>
<div
className={`absolute bottom-2 right-2
2023-08-25 21:53:07 +08:00
bg-gray-600 text-white text-xs
px-1 py-0.5 rounded-md
2023-09-14 09:21:45 +08:00
${isHover ? "hidden" : "flex"}`}
>
03:14
2023-08-25 21:53:07 +08:00
</div>
2023-09-14 09:21:45 +08:00
</div>
<div className="flex justify-between text-xs mt-2 text-gray-500 px-2">
<div className="flex items-center gap-1 my-1">
<Image
width={32}
height={38}
alt={""}
src="https://res-academy.cache.wpscdn.com/static/images/icon_excel.png"
/>
<span>Spread</span>
</div>
<div>18.0K views</div>
</div>
<h1 className="text-md font-semibold mt-2 px-2 pb-3">How use WPS</h1>
</div>
);
2023-08-25 21:53:07 +08:00
}