Skip to content

Commit

Permalink
Merge pull request #75 from LikeLionHGU/eunju_feat/#74
Browse files Browse the repository at this point in the history
feat: 목표 썸네일 랜덤 이미지 넣어주기
  • Loading branch information
ejPark43 authored Aug 3, 2024
2 parents 40c3424 + 55de273 commit 65f13a6
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 2 deletions.
23 changes: 23 additions & 0 deletions src/asset/Random/random1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions src/asset/Random/random2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 21 additions & 2 deletions src/homepage/component/goals/Goals.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import { tokenState } from "../../../atom/atom";
import { useRecoilState } from "recoil";
import GoalDoesNotExistImg from "../../../asset/Icon/GoalDoesNotExist.svg";

import img1 from "../../../asset/Random/random1.svg";
import img2 from "../../../asset/Random/random2.svg";
const backgroundArr = [img1, img2];
// const randomIndex = Math.floor(Math.random() * backgroundArr.length);
// const backgroundImg = backgroundArr[randomIndex];

function Goals() {
const [isModalOpen, setIsModalOpen] = useState(false);
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
Expand Down Expand Up @@ -148,14 +154,27 @@ function Goals() {
)}
<TransitionGroup component={null}>
{filteredGoals.map((goal) => {
const randomIndex = Math.floor(
Math.random() * backgroundArr.length
);
const backgroundImg = backgroundArr[randomIndex];
const daysLeft = getDaysLeft(goal.endDate);
return (
<CSSTransition key={goal.id} timeout={500} classNames="goal">
<GoalWrapper onClick={() => handleClickGoal(goal.goalId)}>
<ImageContainer>
<Image
{goal.thumbnail ? (
<Image
style={{ backgroundImage: `url(${goal.thumbnail})` }}
/>
) : (
<Image
style={{ backgroundImage: `url(${backgroundImg})` }}
/>
)}
{/* <Image
style={{ backgroundImage: `url(${goal.thumbnail})` }}
/>
/> */}
<GoalEditDropdown
setIsDeleteModalOpen={setIsDeleteModalOpen}
/>
Expand Down

0 comments on commit 65f13a6

Please sign in to comment.