From 89e7524b15bd3037d328e91636e8365d3b4be367 Mon Sep 17 00:00:00 2001 From: Haziq Khairi Date: Fri, 12 Jan 2024 02:40:02 +0800 Subject: [PATCH] refactor: arts card for homepage --- src/pages/MoreArt.jsx | 315 +++++++++++++++++++++++------------------- 1 file changed, 173 insertions(+), 142 deletions(-) diff --git a/src/pages/MoreArt.jsx b/src/pages/MoreArt.jsx index 406f7c9..8092e48 100644 --- a/src/pages/MoreArt.jsx +++ b/src/pages/MoreArt.jsx @@ -1,35 +1,44 @@ -import React from 'react'; -import { Card, CardHeader, Image, Button, CardFooter } from '@nextui-org/react'; +import { useState } from 'react'; +import { useNavigate } from 'react-router-dom'; import { + Card, + CardHeader, + Image, + Button, + CardFooter, + Tooltip, Dropdown, DropdownTrigger, DropdownMenu, DropdownItem, } from '@nextui-org/react'; import { - FacebookIcon, FacebookShareButton, - XIcon, - TwitterShareButton, WhatsappShareButton, - WhatsappIcon, + TwitterShareButton, RedditShareButton, - RedditIcon, EmailShareButton, + FacebookIcon, + WhatsappIcon, + TwitterIcon, + RedditIcon, EmailIcon, } from 'react-share'; import { allLists } from '../data/list'; -import { MdIosShare } from 'react-icons/md'; -import { TbDots } from 'react-icons/tb'; -import { GoDownload } from 'react-icons/go'; -import { MdOutlineReport } from 'react-icons/md'; +import { + FaDownload, + FaExclamationTriangle, + FaShareAlt, + FaEllipsisV, +} from 'react-icons/fa'; -export default function MoreArt() { +const MoreArt = () => { + const navigate = useNavigate(); + const [savedStates, setSavedStates] = useState({}); + const shareUrl = 'https://kyziq.github.io/artistry-hub/'; + const title = 'Artistry-Hub'; const fixedWidth = '250px'; - const shareUrl = 'http://github.com'; - const title = 'GitHub'; - const [savedStates, setSavedStates] = React.useState({}); const toggleSaveState = (index) => { setSavedStates((prevState) => ({ ...prevState, @@ -37,164 +46,186 @@ export default function MoreArt() { })); }; - const handleDownload = (imageUrl, imageName) => { - // Create an anchor element + const handleDownload = (imageUrl, imageName = 'download') => { const anchor = document.createElement('a'); anchor.href = imageUrl; - anchor.download = imageName || 'download'; + anchor.download = imageName; anchor.click(); }; + const handleImageClick = (itemId) => navigate(`/art/${itemId}`); + return (
{Object.values(allLists).map((categoryList, categoryIndex) => (
{categoryList.map((item, index) => ( - - {/* Card Header */} - -
- - Header Tumblr - + handleImageClick(item.id)} + className="relative overflow-hidden inline-block group transition-opacity duration-300 hover:opacity-90" + style={{ + margin: '0 0 1.5em', + width: fixedWidth, + height: '100%', + }} + > + {/* Card Header */} + -
-
- {/* Image Component */} - {item.name} + + {/* Image Component */} + {item.name} - {/* Card Footer */} - -
- - - - - - - +
+ + + + + + - - Whatsapp - - + + + Facebook + + - - - - Twitter - - + + + Whatsapp + + - - - - Reddit - - - - - - Email - - - - + + + + Twitter + + - - - - - - handleDownload(item.img, item.name)} - startContent={ - - } - > - Download - - } + + + + Reddit + + + + + + Email + + + + + + + + + + - Report - - - -
- - + handleDownload(item.img, item.name)} + startContent={ + + } + > + Download + + } + > + Report + +
+
+
+
+
+ ))}
))}
); -} +}; + +export default MoreArt;