Skip to content

Commit

Permalink
Merge pull request #58 from 9oormDari/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
karpitony authored Sep 28, 2024
2 parents 6aeba97 + 6a015e7 commit 7ae457f
Show file tree
Hide file tree
Showing 26 changed files with 638 additions and 326 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BrowserRouter } from 'react-router-dom';
import { Analytics } from '@vercel/analytics/react';
import { BrowserRouter } from 'react-router-dom';

function App() {
return (
Expand Down
Binary file added src/assets/loading/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/loading/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/loading/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
157 changes: 94 additions & 63 deletions src/components/Goalpage/GoormScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';
import cn from '../../lib/cn';
import BlueCloud from '../../assets/GoalPage/BlueCloud.svg';
import ColorCloud from '../../assets/GoalPage/ColorCloud.svg';
import Rainbow1 from '../../assets/GoalPage/Rainbow1.svg';
import Rainbow2 from '../../assets/GoalPage/Rainbow2.svg';
import CloudComponent from './GoormScreen/CloudComponent';
import { API } from '../../lib/api/index.ts';

interface Cloud {
cloudType: string;
Expand All @@ -15,98 +16,128 @@ interface Cloud {

export default function GoormScreen() {
const [stage, setStage] = useState<number>(0);
const [myId, setMyId] = useState<string>('');
const [clouds, setClouds] = useState<Cloud[]>([]);

const clouds: Cloud[] = [
{
cloudType: stage === 1 ? ColorCloud : BlueCloud,
colStart: 1,
rowStart: 1,
hidden: stage === 0,
},
{
cloudType: stage === 2 ? ColorCloud : BlueCloud,
colStart: 2,
rowStart: 2,
hidden: stage < 2,
},
{
cloudType: stage === 3 ? ColorCloud : BlueCloud,
colStart: 3,
rowStart: 1,
hidden: stage < 3,
},
{
cloudType: stage === 4 ? ColorCloud : BlueCloud,
colStart: 4,
rowStart: 2,
hidden: stage < 4,
},
];
useEffect(() => {
const fetchMyData = async () => {
try {
const response = await API.User.getMyInfo();

if (response.status === 'OK' && response.data) {
// ์‚ฌ์šฉ์ž ID ์„ค์ •
setMyId(response.data.id);

// 'data' ๋ฐฐ์—ด์ด ์กด์žฌํ•˜๊ณ  ๋ฐฐ์—ด์ธ์ง€ ํ™•์ธ ํ›„ ๊ธธ์ด ์„ค์ •
if (response.data.data && Array.isArray(response.data.data)) {
const dataCount = response.data.data.length;
setStage(dataCount);
} else {
// 'data' ๋ฐฐ์—ด์ด ์—†๊ฑฐ๋‚˜ ๋ฐฐ์—ด์ด ์•„๋‹Œ ๊ฒฝ์šฐ 0์œผ๋กœ ์„ค์ •
setStage(0);
}
} else {
console.error('์‘๋‹ต ์ƒํƒœ๊ฐ€ OK๊ฐ€ ์•„๋‹ˆ๊ฑฐ๋‚˜ ๋ฐ์ดํ„ฐ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.');
setStage(0);
}
} catch (error) {
console.error('๋‚ด ์ •๋ณด๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค:', error);
setStage(0);
}
};

fetchMyData();
}, []);

useEffect(() => {
const newClouds: Cloud[] = [
{
cloudType: stage === 1 ? ColorCloud : BlueCloud,
colStart: 1,
rowStart: 1,
hidden: stage < 1,
},
{
cloudType: stage === 2 ? ColorCloud : BlueCloud,
colStart: 2,
rowStart: 2,
hidden: stage < 2,
},
{
cloudType: stage === 3 ? ColorCloud : BlueCloud,
colStart: 3,
rowStart: 1,
hidden: stage < 3,
},
{
cloudType: stage === 4 ? ColorCloud : BlueCloud,
colStart: 4,
rowStart: 2,
hidden: stage < 4,
},
];

setClouds(newClouds); // ์ƒˆ๋กœ์šด clouds ๋ฐฐ์—ด๋กœ ์—…๋ฐ์ดํŠธ
}, [stage]); // stage๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ๋งˆ๋‹ค ์‹คํ–‰

// ์ž„์‹œ๋กœ ์ง‘์–ด๋„ฃ์€ ๊ตฌ๋ฆ„ ๋‹จ๊ณ„ ์ฆ๊ฐ€ ํ•จ์ˆ˜
const increaseStage = () => {
setStage((prev) => (prev < 4 ? prev + 1 : prev));
};

// ์ž„์‹œ๋กœ ์ง‘์–ด๋„ฃ์€ ๊ตฌ๋ฆ„ ๋‹จ๊ณ„ ๊ฐ์†Œ ํ•จ์ˆ˜
const decreaseStage = () => {
setStage((prev) => (prev > 0 ? prev - 1 : prev));
};
// ๊ตฌ๋ฆ„ ์ฆ๊ฐ€์‹œํ‚ค๋Š”๋ฐ ์ฒœ์ฒœํžˆ ์ฆ๊ฐ€ํ•˜๋„๋ก ์„ค์ •
useEffect(() => {
if (stage < 4) { // ์ตœ๋Œ€ ์Šคํ…Œ์ด์ง€๊ฐ€ 4๋ผ๋ฉด
const timer = setTimeout(() => {
increaseStage();
}, 1000);

return () => clearTimeout(timer);
}
}, [stage]);

return (
<div
className={cn(
'flex flex-col items-center justify-center w-full',
'relative bg-gradient-to-b from-[#5A82F1] to-[#DAE4FF]',
'p-2 md:p-10 h-[30vh] md:h-[60vh]'
'p-2 md:p-10 h-[30vh] md:h-[75vh]'
)}
>
{/* ๋‹จ๊ณ„ ์กฐ์ ˆ ๋ฒ„ํŠผ */}
<div className="absolute top-4 right-4 flex space-x-2">
<button
onClick={decreaseStage}
className="px-4 py-2 bg-white rounded shadow"
disabled={stage === 0}
>
๋‹จ๊ณ„ ๊ฐ์†Œ
</button>
<button
onClick={increaseStage}
className="px-4 py-2 bg-white rounded shadow"
disabled={stage === 4}
>
๋‹จ๊ณ„ ์ฆ๊ฐ€
</button>
</div>

<div className="relative grid grid-cols-4 grid-rows-2 gap-2 md:gap-4 mt-8">
{clouds.map((cloud, index) => (
<CloudComponent
key={index}
cloudType={cloud.cloudType}
colStart={cloud.colStart}
rowStart={cloud.rowStart}
hidden={cloud.hidden}
/>
))}
{clouds.map((cloud, index) => (
<CloudComponent
key={index}
cloudType={cloud.cloudType}
colStart={cloud.colStart}
rowStart={cloud.rowStart}
hidden={cloud.hidden}
/>
))}

{/* ๋ฌด์ง€๊ฐœ ์ด๋ฏธ์ง€๋ฅผ ์ ˆ๋Œ€ ์œ„์น˜๋กœ ๋ฐฐ์น˜ */}
<div className="absolute inset-x-0 top-[90px] md:top-[242px] flex justify-center transform -translate-y-1/2">
{/* ๋ฌด์ง€๊ฐœ ์ด๋ฏธ์ง€ */}
<img
src={Rainbow1}
alt="์ฒซ ๋ฒˆ์งธ ๋ฌด์ง€๊ฐœ"
className={`w-1/4 ${stage >= 2 ? "" : "invisible"}`}
className={`w-1/4 transition-opacity duration-500 ${
stage >= 2 ? 'opacity-100 delay-100' : 'opacity-0'
}`}
/>
<img
src={Rainbow2}
alt="๋‘ ๋ฒˆ์งธ ๋ฌด์ง€๊ฐœ"
className={`w-1/4 ${stage >= 3 ? "" : "invisible"}`}
className={`w-1/4 transition-opacity duration-500 ${
stage >= 3 ? 'opacity-100 delay-200' : 'opacity-0'
}`}
/>
<img
src={Rainbow1}
alt="์„ธ ๋ฒˆ์งธ ๋ฌด์ง€๊ฐœ"
className={`w-1/4 ${stage >= 4 ? "" : "invisible"}`}
className={`w-1/4 transition-opacity duration-500 ${
stage >= 4 ? 'opacity-100 delay-300' : 'opacity-0'
}`}
/>
</div>
</div>
Expand Down
19 changes: 11 additions & 8 deletions src/components/Goalpage/GoormScreen/CloudComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React, { useEffect } from 'react';
import cn from '../../../lib/cn';
import CloudDisk from '../../../assets/GoalPage/CloudDisk.svg';
import ColorCloud from '../../../assets/GoalPage/ColorCloud.svg';
Expand All @@ -9,17 +10,17 @@ interface CloudComponentProps {
hidden: boolean;
}

export default function CloudComponent({
const CloudComponent: React.FC<CloudComponentProps> = ({
cloudType,
colStart,
rowStart,
hidden,
}: CloudComponentProps) {
}) => {
return (
<div
className={cn(
'flex justify-center flex-col items-center',
`${hidden ? 'hidden' : ''}`
'flex justify-center flex-col items-center transition-opacity duration-500',
hidden ? 'opacity-0' : 'opacity-100'
)}
style={{
gridColumnStart: colStart,
Expand All @@ -37,11 +38,13 @@ export default function CloudComponent({
alt="๋ฐ›์นจ"
className={cn(
'w-1/4 h-1/4 md:w-[288px] md:h-[156px]',
'absolute mt-20 md:mt-[200px]',
`${cloudType === ColorCloud ? '' : 'hidden'}`
'absolute mt-20 md:mt-[200px] transition-opacity duration-500',
cloudType === ColorCloud ? 'opacity-100' : 'opacity-0'
)}
style={{ zIndex: 1 }}
style={{ zIndex: 0 }}
/>
</div>
);
}
};

export default CloudComponent;
1 change: 0 additions & 1 deletion src/components/Goalpage/MemberList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ interface Member {
username: string;
}


export default function MemberList() {
const [members, setMembers] = useState<Member[]>([
{ id: '1', username: '๊น€' },
Expand Down
36 changes: 22 additions & 14 deletions src/components/Goalpage/MemberList/ShowImageModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ interface ImageData {
alt: string; // ์ด๋ฏธ์ง€ ๋Œ€์ฒด ํ…์ŠคํŠธ
}

export default function ShowImageModal({ memberId, memberName, onClose }: ShowImageModalProps) {
export default function ShowImageModal({
memberId,
memberName,
onClose,
}: ShowImageModalProps) {
// ๋ฐฑ์—”๋“œ์—์„œ ๊ฐ€์ ธ์˜จ ์ด๋ฏธ์ง€๋“ค์„ ์ €์žฅํ•  ์ƒํƒœ
const [images, setImages] = useState<ImageData[]>([]);

Expand Down Expand Up @@ -53,11 +57,14 @@ export default function ShowImageModal({ memberId, memberName, onClose }: ShowIm
}, []);

// ๊ฐ€์ ธ์˜จ ์ด๋ฏธ์ง€์™€ ๊ธฐ๋ณธ ์ด๋ฏธ์ง€๋ฅผ ๊ฒฐํ•ฉํ•˜์—ฌ ์ตœ๋Œ€ 4๊ฐœ์˜ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑ
const displayImages = [...images, ...Array(4 - images.length).fill({
id: 'no-image', // ID ๋Œ€์‹  'no-image'๋กœ ์ฑ„์›€
url: NoImage, // ๊ธฐ๋ณธ ์ด๋ฏธ์ง€ URL
alt: 'No Image Available', // ๋Œ€์ฒด ํ…์ŠคํŠธ
})].slice(0, 4); // ์ตœ๋Œ€ 4๊ฐœ๊นŒ์ง€ ํ‘œ์‹œ
const displayImages = [
...images,
...Array(4 - images.length).fill({
id: 'no-image', // ID ๋Œ€์‹  'no-image'๋กœ ์ฑ„์›€
url: NoImage, // ๊ธฐ๋ณธ ์ด๋ฏธ์ง€ URL
alt: 'No Image Available', // ๋Œ€์ฒด ํ…์ŠคํŠธ
}),
].slice(0, 4); // ์ตœ๋Œ€ 4๊ฐœ๊นŒ์ง€ ํ‘œ์‹œ

return (
<div
Expand All @@ -74,22 +81,23 @@ export default function ShowImageModal({ memberId, memberName, onClose }: ShowIm
</h1>
<div className="mt-8 grid grid-cols-1 sm:grid-cols-2 gap-4">
{displayImages.map((image, index) => (
<div
key={`${image.id}-${index}`}
className="h-32 md:h-48 bg-gray-200 flex justify-center items-center rounded"
>
<img
key={`${image.id}-${index}`} // ๊ณ ์œ ํ•œ key ์„ค์ •
src={image.url} // ์ด๋ฏธ์ง€ URL ์„ค์ •
alt={image.alt} // ๋Œ€์ฒด ํ…์ŠคํŠธ ์„ค์ •
className={cn(
"flex justify-center items-center w-[80vp] md:w-[80vp]",
"h-32 md:h-48 object-cover rounded" // ์ด๋ฏธ์ง€ ์Šคํƒ€์ผ๋ง
)}
src={image.url}
alt={image.alt}
className="w-full h-full object-contain"
/>
</div>
))}
</div>
<div className="flex items-center justify-center p-2">
<button
className={cn(
'w-32 md:w-64 h-10 bg-blue-400 text-white text-2xl',
'rounded-lg hover:bg-blue-500 transition-colors',
'rounded-lg hover:bg-blue-500 transition-colors'
)}
onClick={onClose}
aria-label="Close Modal" // ์ ‘๊ทผ์„ฑ์„ ์œ„ํ•œ aria-label
Expand Down
5 changes: 3 additions & 2 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export default function Header() {
className={cn(
'bg-white flex items-center justify-between',
'h-[75px] md:h-[150px] p-2 md:px-20',
'border-b-2 border-[#DBDBDB] relative'
'border-b-2 border-[#DBDBDB] fixed top-0 left-0 w-full z-50',
'shadow-md' // ์ถ”๊ฐ€: ๊ทธ๋ฆผ์ž ํšจ๊ณผ
)}
>
{/* ๋กœ๊ณ  ์˜์—ญ */}
Expand Down Expand Up @@ -88,7 +89,7 @@ export default function Header() {
<div
ref={menuRef}
className={cn(
'fixed top-0 right-0 h-full w-64 bg-white shadow-lg z-50',
'fixed top-0 right-0 h-full w-64 bg-white shadow-lg z-50',
'transform transition-transform duration-300',
isMenuOpen ? 'translate-x-0' : 'translate-x-full'
)}
Expand Down
16 changes: 11 additions & 5 deletions src/components/Header/NavLink.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useLocation, useNavigate } from 'react-router-dom';

import cn from '../../lib/cn.ts';
import { useLocation } from 'react-router-dom';

interface NavLinkProps {
href: string;
Expand All @@ -8,17 +9,22 @@ interface NavLinkProps {

export default function NavLink({ href, label }: NavLinkProps) {
const location = useLocation();
const navigate = useNavigate(); // useNavigate ํ›… ์‚ฌ์šฉ
const isActive = location.pathname === href;

const handleClick = () => {
navigate(href); // ํŽ˜์ด์ง€ ์ด๋™
};

return (
<a
href={href}
<div
onClick={handleClick}
className={cn(
'text-base md:text-2xl transition md:p-4',
'text-xl md:text-2xl p-1 md:p-4',
`${isActive ? 'text-black font-bold' : 'text-gray-400 hover:text-gray-600'}`
)}
>
{label}
</a>
</div>
);
}
2 changes: 1 addition & 1 deletion src/components/Mypage/Goals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Goals: React.FC = () => {
const isSetting = sector === 'setting';

return (
<div className="w-full max-w-lg">
<div className="w-full max-w-2xl">
{/* ๋ชฉํ‘œ ์ ๊ฒ€ ๋ฐ ์„ค์ • ๋ฒ„ํŠผ */}
<div className="flex w-full">
{/* ๋ชฉํ‘œ ์ ๊ฒ€ (maintenance) ๋ฒ„ํŠผ */}
Expand Down
Loading

0 comments on commit 7ae457f

Please sign in to comment.