Skip to content

Commit

Permalink
chore : main entity setting
Browse files Browse the repository at this point in the history
  • Loading branch information
0xC0FFE2 committed Jan 17, 2025
1 parent 323817c commit d11d593
Show file tree
Hide file tree
Showing 13 changed files with 2,016 additions and 147 deletions.
1,813 changes: 1,762 additions & 51 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1"
"react-dom": "^18.3.1",
"react-router-dom": "^7.1.2"
},
"devDependencies": {
"@eslint/js": "^9.17.0",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"@vitejs/plugin-react-swc": "^3.5.0",
"autoprefixer": "^10.4.20",
"eslint": "^9.17.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.16",
"globals": "^15.14.0",
"postcss": "^8.5.1",
"postcss-cli": "^11.0.0",
"tailwindcss": "^3.4.17",
"typescript": "~5.6.2",
"typescript-eslint": "^8.18.2",
"vite": "^6.0.5"
Expand Down
7 changes: 7 additions & 0 deletions postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};

45 changes: 13 additions & 32 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'

function App() {
const [count, setCount] = useState(0)
import React from 'react';

Check failure on line 1 in src/App.tsx

View workflow job for this annotation

GitHub Actions / deploy

'React' is declared but its value is never read.
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import LoginPage from './pages/LoginPage';

const App = () => {
return (
<>
<div>
<a href="https://vite.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
)
}
<BrowserRouter>
<Routes>
<Route path="/login" element={<LoginPage />} />
<Route path="/" element={<Navigate to="/login" replace />} />
</Routes>
</BrowserRouter>
);
};

export default App
export default App
16 changes: 16 additions & 0 deletions src/components/auth/LoginBanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';

Check failure on line 1 in src/components/auth/LoginBanner.tsx

View workflow job for this annotation

GitHub Actions / deploy

'React' is declared but its value is never read.

const LoginBanner = () => {
return (
<div className="w-[600px] relative bg-cover bg-center" style={{
backgroundImage: `url('https://nanu.cc/NANU-Brand-Loader.jpg')`
}}>
<div className="absolute top-10 left-10">
<h1 className="text-xl text-white mb-2 font-bold">최대 보안. 최대 편리함.</h1>
<img src="https://nanu.cc/NANU_Brand_Logo/NANU_ID_FULL_XS.svg" alt="NAMU Logo" className="w-40" />
</div>
</div>
);
};

export default LoginBanner;
17 changes: 17 additions & 0 deletions src/components/auth/LoginContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';

interface LoginContainerProps {
children: React.ReactNode;
}

const LoginContainer: React.FC<LoginContainerProps> = ({ children }) => {
return (
<div className="min-h-screen w-full bg-gray-50 flex items-center justify-center py-8">
<div className="w-[1200px] h-[600px] bg-white shadow-lg overflow-hidden flex">
{children}
</div>
</div>
);
};

export default LoginContainer;
79 changes: 79 additions & 0 deletions src/components/auth/LoginForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React from 'react';
import { Link } from 'react-router-dom';

interface LoginFormProps {
formData: {
email: string;
password: string;
rememberMe: boolean;
};
onInputChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
onLogin: (type: 'app' | 'pin') => void;
}

const LoginForm: React.FC<LoginFormProps> = ({ formData, onInputChange, onLogin }) => {
return (
<div className="flex-1 flex items-center justify-center p-8">
<div className="w-[360px]">
<h1 className="text-2xl font-bold mb-8">로그인</h1>
<form className="space-y-6">
<div className="space-y-4">
<input
type="email"
name="email"
placeholder="Enter Email"
className="w-full px-0 py-2 border-b border-gray-300 focus:border-blue-500 focus:outline-none transition-colors"
value={formData.email}
onChange={onInputChange}
/>
<input
type="password"
name="password"
placeholder="Enter Password"
className="w-full px-0 py-2 border-b border-gray-300 focus:border-blue-500 focus:outline-none transition-colors"
value={formData.password}
onChange={onInputChange}
/>
</div>

<div className="flex items-center">
<input
type="checkbox"
name="rememberMe"
id="rememberMe"
checked={formData.rememberMe}
onChange={onInputChange}
className="h-4 w-4 text-blue-600 rounded border-gray-300"
/>
<label htmlFor="rememberMe" className="ml-2 text-sm text-gray-600">
로그인 정보 저장하기
</label>
</div>

<div className="space-y-3 pt-4">
<button
type="button"
onClick={() => onLogin('app')}
className="w-full bg-blue-600 text-white py-3 rounded hover:bg-blue-700 transition-colors"
>
APP 인증 로그인하기
</button>
<button
type="button"
onClick={() => onLogin('pin')}
className="w-full bg-blue-600 text-white py-3 rounded hover:bg-blue-700 transition-colors"
>
PIN 인증 로그인하기
</button>
</div>
</form>

<div className="mt-8 text-center text-sm text-gray-600">
계정이 없으신가요? <Link to="/signup" className="text-blue-600 hover:underline">NAMU ID 생성하기</Link>
</div>
</div>
</div>
);
};

export default LoginForm;
80 changes: 19 additions & 61 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,68 +1,26 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
@tailwind base;
@tailwind components;
@tailwind utilities;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
@font-face {
font-family: 'Paperlogy-8Regular';
src: url('https://fastly.jsdelivr.net/gh/projectnoonnu/[email protected]/Paperlogy-8Regular.woff2') format('woff2');
font-weight: 300;
font-style: normal;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
@font-face {
font-family: 'Paperlogy-8ExtraBold';
src: url('https://fastly.jsdelivr.net/gh/projectnoonnu/[email protected]/Paperlogy-8ExtraBold.woff2') format('woff2');
font-weight: 800;
font-style: normal;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
* {
font-family: 'Paperlogy-8Regular';
font-weight: 300;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
.font-bold {
font-family: 'Paperlogy-8ExtraBold';
}
47 changes: 47 additions & 0 deletions src/pages/LoginPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import LoginContainer from '../components/auth/LoginContainer';
import LoginBanner from '../components/auth/LoginBanner';
import LoginForm from '../components/auth/LoginForm';

interface LoginFormData {
email: string;
password: string;
rememberMe: boolean;
}

const LoginPage = () => {
const [formData, setFormData] = useState<LoginFormData>({
email: '',
password: '',
rememberMe: false
});

const navigate = useNavigate();

Check failure on line 20 in src/pages/LoginPage.tsx

View workflow job for this annotation

GitHub Actions / deploy

'navigate' is declared but its value is never read.

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { name, value, type, checked } = e.target;
setFormData(prev => ({
...prev,
[name]: type === 'checkbox' ? checked : value
}));
};

const handleLogin = (type: 'app' | 'pin') => {
// TODO: Implement login logic
console.log(`Logging in with ${type}`, formData);
};

return (
<LoginContainer>
<LoginBanner />
<LoginForm
formData={formData}
onInputChange={handleInputChange}
onLogin={handleLogin}
/>
</LoginContainer>
);
};

export default LoginPage;
23 changes: 23 additions & 0 deletions src/services/AuthService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { LoginFormData, AuthResponse } from '../types/Auth';

export const authService = {
async login(credentials: LoginFormData): Promise<AuthResponse> {
try {
const response = await fetch('/api/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(credentials),
});

if (!response.ok) {
throw new Error('Login failed');
}

return response.json();
} catch (error) {
throw error;
}
},
};
13 changes: 13 additions & 0 deletions src/types/Auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export interface LoginFormData {
email: string;
password: string;
rememberMe: boolean;
}

export interface AuthResponse {
token: string;
user: {
id: string;
email: string;
};
}
12 changes: 12 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}

Loading

0 comments on commit d11d593

Please sign in to comment.