-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from always97/fe-user-ui
[FE] feat#76#84#224 λ‘κ·ΈμΈ/νμκ°μ , λ§μ΄νμ΄μ§ ui, μ±ν μ€ν¬λ‘€ κ°μ
- Loading branch information
Showing
6 changed files
with
348 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import { HeaderBar } from '@/components/HeaderBar'; | ||
import { useState } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
export const LoginPage = () => { | ||
const [isSignUp, setIsSignUp] = useState(false); | ||
const navigate = useNavigate(); | ||
|
||
const handleLogin = () => { | ||
navigate('/mypage'); | ||
}; | ||
|
||
return ( | ||
<div className="min-h-screen bg-gray-900 text-gray-300 flex flex-col"> | ||
<HeaderBar /> | ||
|
||
<div className="flex-grow flex items-center justify-center"> | ||
<div className="w-full max-w-md"> | ||
<div className="text-center mb-6"> | ||
<h6 className="text-lg font-bold"> | ||
<span | ||
className={`px-4 ${!isSignUp ? 'text-yellow-400' : 'text-gray-400'} cursor-pointer`} | ||
onClick={() => setIsSignUp(false)} | ||
> | ||
λ‘κ·ΈμΈ | ||
</span> | ||
<span | ||
className={`px-4 ${isSignUp ? 'text-yellow-400' : 'text-gray-400'} cursor-pointer`} | ||
onClick={() => setIsSignUp(true)} | ||
> | ||
νμκ°μ | ||
</span> | ||
</h6> | ||
<div | ||
className="relative w-16 h-4 mx-auto bg-yellow-400 rounded-full cursor-pointer" | ||
onClick={() => setIsSignUp(!isSignUp)} | ||
> | ||
<div | ||
className={`absolute w-9 h-9 bg-blue-800 rounded-full transition-transform duration-500 ${ | ||
isSignUp ? 'translate-x-8' : '' | ||
}`} | ||
></div> | ||
</div> | ||
</div> | ||
|
||
<div | ||
className="bg-gray-800 rounded-md p-8 transition-all duration-500" | ||
style={{ minHeight: '400px' }} | ||
> | ||
{isSignUp ? <SignUpForm /> : <LoginForm handleLogin={handleLogin} />} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
type LoginFormProps = { | ||
handleLogin: () => void; | ||
}; | ||
|
||
const LoginForm: React.FC<LoginFormProps> = ({ handleLogin }) => ( | ||
<div> | ||
<h4 className="mb-4 text-xl font-bold text-gray-100">λ‘κ·ΈμΈ</h4> | ||
<div className="mb-4"> | ||
<input | ||
type="email" | ||
placeholder="μ΄λ©μΌ" | ||
className="w-full px-4 py-3 text-sm text-gray-300 bg-gray-700 rounded-md focus:ring-2 focus:ring-yellow-400 focus:outline-none" | ||
/> | ||
</div> | ||
<div className="mb-4"> | ||
<input | ||
type="password" | ||
placeholder="λΉλ°λ²νΈ" | ||
className="w-full px-4 py-3 text-sm text-gray-300 bg-gray-700 rounded-md focus:ring-2 focus:ring-yellow-400 focus:outline-none" | ||
/> | ||
</div> | ||
<button | ||
className="w-full px-4 py-3 mt-4 text-sm font-semibold text-blue-900 bg-yellow-400 rounded-md hover:bg-yellow-500" | ||
onClick={handleLogin} | ||
> | ||
λ‘κ·ΈμΈ | ||
</button> | ||
<p className="mt-4 text-sm"> | ||
<a href="#" className="text-yellow-400 hover:underline"> | ||
λΉλ°λ²νΈλ₯Ό μμΌμ ¨λμ? | ||
</a> | ||
</p> | ||
</div> | ||
); | ||
|
||
const SignUpForm = () => ( | ||
<div> | ||
<h4 className="mb-4 text-xl font-bold text-gray-100">νμκ°μ </h4> | ||
<div className="mb-4"> | ||
<input | ||
type="text" | ||
placeholder="λλ€μ" | ||
className="w-full px-4 py-3 text-sm text-gray-300 bg-gray-700 rounded-md focus:ring-2 focus:ring-yellow-400 focus:outline-none" | ||
/> | ||
</div> | ||
<div className="mb-4"> | ||
<input | ||
type="email" | ||
placeholder="μ΄λ©μΌ" | ||
className="w-full px-4 py-3 text-sm text-gray-300 bg-gray-700 rounded-md focus:ring-2 focus:ring-yellow-400 focus:outline-none" | ||
/> | ||
</div> | ||
<div className="mb-4"> | ||
<input | ||
type="password" | ||
placeholder="λΉλ°λ²νΈ" | ||
className="w-full px-4 py-3 text-sm text-gray-300 bg-gray-700 rounded-md focus:ring-2 focus:ring-yellow-400 focus:outline-none" | ||
/> | ||
</div> | ||
<button className="w-full px-4 py-3 mt-4 text-sm font-semibold text-blue-900 bg-yellow-400 rounded-md hover:bg-yellow-500"> | ||
νμκ°μ | ||
</button> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import { HeaderBar } from '@/components/HeaderBar'; | ||
import { useState } from 'react'; | ||
|
||
type QuizListProps = { | ||
title: string; | ||
quizzes: string[]; | ||
activeTab: string; | ||
}; | ||
|
||
export const MyPage: React.FC = () => { | ||
const [activeTab, setActiveTab] = useState<'myQuizzes' | 'solvedQuizzes'>('myQuizzes'); | ||
|
||
const myQuizzes = ['ν΄μ¦ 1', 'ν΄μ¦ 2', 'ν΄μ¦ 3', 'ν΄μ¦ 4']; // μμ λ°μ΄ν° | ||
const solvedQuizzes = ['ν΄μ¦ A', 'ν΄μ¦ B', 'ν΄μ¦ C', 'ν΄μ¦ D']; // μμ λ°μ΄ν° | ||
|
||
return ( | ||
<div className="min-h-screen bg-gray-100 text-gray-800"> | ||
<HeaderBar /> | ||
|
||
<div className="flex flex-col items-center mt-8"> | ||
<div className="w-24 h-24 rounded-full bg-gray-300 overflow-hidden mb-4"> | ||
<img | ||
src="https://via.placeholder.com/100" // μμ νλ‘ν μ΄λ―Έμ§ | ||
alt="Profile" | ||
className="w-full h-full object-cover" | ||
/> | ||
</div> | ||
<h2 className="text-lg font-bold">λλ€μ</h2> | ||
</div> | ||
|
||
<div className="mt-8 px-4"> | ||
<div className="flex justify-center space-x-4 border-b border-gray-300 pb-2"> | ||
<button | ||
className={`px-4 py-2 font-medium ${ | ||
activeTab === 'myQuizzes' | ||
? 'text-blue-500 border-b-2 border-blue-500' | ||
: 'text-gray-500' | ||
}`} | ||
onClick={() => setActiveTab('myQuizzes')} | ||
> | ||
λ΄κ° λ§λ ν΄μ¦ | ||
</button> | ||
<button | ||
className={`px-4 py-2 font-medium ${ | ||
activeTab === 'solvedQuizzes' | ||
? 'text-blue-500 border-b-2 border-blue-500' | ||
: 'text-gray-500' | ||
}`} | ||
onClick={() => setActiveTab('solvedQuizzes')} | ||
> | ||
λ΄κ° νμ΄ν ν΄μ¦ | ||
</button> | ||
</div> | ||
|
||
{/* 리μ€νΈ */} | ||
<div className="mt-4"> | ||
{activeTab === 'myQuizzes' ? ( | ||
<QuizList title="λ΄κ° λ§λ ν΄μ¦" quizzes={myQuizzes} activeTab={activeTab} /> | ||
) : ( | ||
<QuizList title="λ΄κ° νμ΄ν ν΄μ¦" quizzes={solvedQuizzes} activeTab={activeTab} /> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
// ν΄μ¦ 리μ€νΈ μ»΄ν¬λνΈ | ||
const QuizList: React.FC<QuizListProps> = ({ title, quizzes, activeTab }) => { | ||
const handleEdit = (index: number) => { | ||
console.log(index + 'μμ ν΄λ¦'); | ||
}; | ||
const handleDelete = (index: number) => { | ||
console.log(index + 'μμ ν΄λ¦'); | ||
}; | ||
return ( | ||
<div className="max-w-lg mx-auto p-4 bg-white shadow-md rounded-md overflow-y-auto max-h-90"> | ||
<h3 className="text-lg font-bold mb-4">{title}</h3> | ||
<ul className="space-y-2"> | ||
{quizzes.map((quiz, index) => ( | ||
<li key={index} className="p-2 border-b flex justify-between items-center"> | ||
<span>{quiz}</span> | ||
<div className="flex gap-2"> | ||
{activeTab === 'myQuizzes' && ( | ||
<button | ||
onClick={() => handleEdit(index)} | ||
className="px-2 py-1 bg-blue-500 text-white rounded hover:bg-blue-600" | ||
> | ||
μμ | ||
</button> | ||
)} | ||
<button | ||
onClick={() => handleDelete(index)} | ||
className="px-2 py-1 bg-red-500 text-white rounded hover:bg-red-600" | ||
> | ||
μμ | ||
</button> | ||
</div> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.