feat : 프로젝트 전반적인 커밋
SpecialSource Frontend (React) CD / deploy (push) Failing after 1m2s

This commit is contained in:
sungjin.choi committed 2026-11-17 10:21:33 +09:00
1 parent cfda95c1ba
commit a49df04adf
28 files changed
+734 -304

No files matched your search

+116
View File
@@ -0,0 +1,116 @@
"use client";
import { useEffect, useReducer, useRef, useState, useSyncExternalStore } from "react";
import { PALETTE_KEY, PALETTES } from "../constants";
import { execute, initialState } from "../lib/command";
import type { Nav, Palette } from "../types";
import MainMenu from "./MainMenu";
import PaletteSwitch from "./PaletteSwitch";
import PostDetail from "./PostDetail";
import PostList from "./PostList";
import styles from "./bbs.module.css";
const DEFAULT_PALETTE: Palette = "blue";
// localStorage를 외부 저장소로 보고 React가 구독 (다른 탭에서 바꿔도 동기화됨)
const subscribe = (onChange: () => void) => {
const handler = () => {
document.documentElement.dataset.palette = readPalette(); // 색은 CSS가 <html> 속성으로 적용
onChange(); // 버튼 활성 표시는 React가 갱신
};
window.addEventListener("storage", handler);
return () => window.removeEventListener("storage", handler);
};
const readPalette = (): Palette => {
try {
const saved = localStorage.getItem(PALETTE_KEY);
return PALETTES.find((p) => p.key === saved)?.key ?? DEFAULT_PALETTE;
} catch {
return DEFAULT_PALETTE;
}
};
export default function BbsTerminal() {
const [state, dispatch] = useReducer(execute, initialState);
const palette = useSyncExternalStore(subscribe, readPalette, () => DEFAULT_PALETTE);
const [input, setInput] = useState("");
const inputRef = useRef<HTMLInputElement>(null);
const mounted = useRef(false);
// 화면 이동을 브라우저 history에 기록 → 스와이프/뒤로가기 버튼/Alt+←가 그대로 앞뒤 이동이 됨
useEffect(() => {
const nav: Nav = { screen: state.screen, list: state.list, postId: state.postId };
if (!mounted.current) {
mounted.current = true;
history.replaceState({ bbs: nav }, ""); // 새로고침 시 이전 기록 대신 현재 화면으로 시작
} else if (JSON.stringify(history.state?.bbs) !== JSON.stringify(nav)) {
history.pushState({ bbs: nav }, "");
}
}, [state.screen, state.list, state.postId]);
useEffect(() => {
const onPop = (e: PopStateEvent) => {
if (e.state?.bbs) dispatch(e.state.bbs);
};
addEventListener("popstate", onPop);
return () => removeEventListener("popstate", onPop);
}, []);
const changePalette = (p: Palette) => {
try {
localStorage.setItem(PALETTE_KEY, p);
} catch {}
window.dispatchEvent(new StorageEvent("storage")); // 같은 탭은 storage 이벤트가 안 오므로 직접 알림
};
// 클릭 = 명령어 대리 입력: 입력창에 채운 뒤 엔터와 같은 경로로 실행
const submitFromClick = (cmd: string) => {
setInput(cmd);
// 터치 기기에서 포커스하면 가상 키보드가 튀어나와 화면을 가림 → 마우스 환경에서만
if (matchMedia("(pointer: fine)").matches) inputRef.current?.focus();
setTimeout(() => {
dispatch(cmd);
setInput("");
}, 160);
};
return (
<div className={styles.shell}>
<PaletteSwitch value={palette} onChange={changePalette} />
<div className={styles.frame}>
<div className={styles.titlebar}>
<span>SPECIALSOURCE-BBS v3.2</span>
<span>{state.loggedIn ? "ONLINE: 7 · admin 접속중" : "ONLINE: 6 · 비로그인"}</span>
</div>
<div className={styles.screen}>
{state.screen === "main" && <MainMenu readIds={state.readIds} onSelect={submitFromClick} />}
{state.screen === "list" && <PostList kind={state.list} readIds={state.readIds} onSelect={submitFromClick} />}
{state.screen === "post" && state.postId !== null && <PostDetail postId={state.postId} />}
{state.error && <div className={`${styles.sub} ${styles.error}`}>{state.error}</div>}
</div>
<div className={styles.cmdline}>
<span className={styles.prompt}>&gt;</span>
<input
ref={inputRef}
type="text"
value={input}
onChange={(e) => setInput(e.target.value)}
onKeyDown={(e) => {
if (e.key !== "Enter" || e.nativeEvent.isComposing) return;
dispatch(input);
setInput("");
}}
placeholder="번호 또는 메뉴명을 입력하세요"
aria-label="BBS 명령어 입력"
autoComplete="off"
autoFocus
/>
</div>
</div>
</div>
);
}
+33
View File
@@ -0,0 +1,33 @@
import { MENU } from "../constants";
import { POSTS } from "../mocks/posts";
import styles from "./bbs.module.css";
interface Props {
readIds: number[];
onSelect: (cmd: string) => void;
}
export default function MainMenu({ readIds, onSelect }: Props) {
const unread = POSTS.length - readIds.length;
return (
<>
<div className={styles.title}>SPECIALSOURCE.SYSTEM 메인 메뉴</div>
<div className={styles.sub}>번호나 메뉴명을 입력하거나, 줄을 클릭하세요.</div>
<hr className={styles.rule} />
{MENU.map((m) => (
<div key={m.num} className={styles.row} onClick={() => onSelect(String(m.num))}>
<span className={styles.num}>{m.num}.</span>
<span>{m.label}</span>
<span className={styles.dim}>{m.en}</span>
{m.key === "board" && <span className={styles.accent}>(안읽음 {unread})</span>}
{m.key === "viewed" && <span className={styles.accent}>({readIds.length}건)</span>}
</div>
))}
<hr className={styles.rule} />
<div className={styles.footer}>
예) <b>2</b> 또는 <b>board</b> 입력 → 자유게시판 이동
</div>
</>
);
}
@@ -0,0 +1,26 @@
import { PALETTES } from "../constants";
import type { Palette } from "../types";
import styles from "./bbs.module.css";
interface Props {
value: Palette;
onChange: (p: Palette) => void;
}
export default function PaletteSwitch({ value, onChange }: Props) {
return (
<div className={styles.paletteSwitch}>
{PALETTES.map((p) => (
<button
key={p.key}
type="button"
className={`${styles.paletteBtn} ${value === p.key ? styles.active : ""}`}
aria-pressed={value === p.key}
onClick={() => onChange(p.key)}
>
{p.label}
</button>
))}
</div>
);
}
@@ -0,0 +1,22 @@
import { POSTS } from "../mocks/posts";
import styles from "./bbs.module.css";
export default function PostDetail({ postId }: { postId: number }) {
const post = POSTS.find((p) => p.id === postId);
if (!post) return null;
return (
<>
<div className={styles.title}>{post.title}</div>
<div className={styles.sub}>
글쓴이 {post.author} · 조회 {post.views} · {post.date}
</div>
<hr className={styles.rule} />
<div className={styles.body}>{post.body}</div>
<hr className={styles.rule} />
<div className={styles.footer}>
<b>L</b>=목록으로 · <b>M</b>=메인메뉴
</div>
</>
);
}
+38
View File
@@ -0,0 +1,38 @@
import { POSTS } from "../mocks/posts";
import type { ListKind } from "../types";
import styles from "./bbs.module.css";
interface Props {
kind: ListKind;
readIds: number[];
onSelect: (cmd: string) => void;
}
export default function PostList({ kind, readIds, onSelect }: Props) {
const viewed = kind === "viewed";
const posts = POSTS.filter((p) => readIds.includes(p.id) === viewed);
return (
<>
<div className={styles.title}>
[{viewed ? 3 : 2}] {viewed ? "내가 읽은 글" : "자유게시판"}
</div>
<div className={styles.sub}>글 번호를 입력하면 읽습니다 · 총 {posts.length}건</div>
<hr className={styles.rule} />
{posts.length === 0 && <div className={styles.sub}>표시할 글이 없습니다.</div>}
{posts.map((p) => (
<div key={p.id} className={`${styles.row} ${styles.postRow}`} onClick={() => onSelect(String(p.id))}>
<span className={styles.postIdx}>{p.id}</span>
<span className={`${styles.postTitle} ${viewed ? styles.dim : ""}`}>{p.title}</span>
<span className={styles.postMeta}>
{p.author} · 조회 {p.views} · {p.date}
</span>
</div>
))}
<hr className={styles.rule} />
<div className={styles.footer}>
<b>번호</b>=글읽기 · <b>M</b>=메인 · <b>L</b>=이 목록 새로고침
</div>
</>
);
}
@@ -0,0 +1,87 @@
/* --- BBS 팔레트 (시대별 PC통신 느낌) --- */
/* <html data-palette>는 layout.tsx 인라인 스크립트가 첫 페인트 전에 설정 → 깜빡임 없음 */
.frame, :global(html[data-palette="blue"]) .frame {
--bbs-bg: #000033; --bbs-fg: #d9d9f5; --bbs-accent: #55ffff;
--bbs-highlight: #ffff55; --bbs-dim: #7d7dc4; --bbs-border: #ffffff; --bbs-glow: rgba(85, 255, 255, 0.35);
}
:global(html[data-palette="green"]) .frame {
--bbs-bg: #000d00; --bbs-fg: #cdf7cd; --bbs-accent: #4dff4d;
--bbs-highlight: #ffff55; --bbs-dim: #3f8f3f; --bbs-border: #4dff4d; --bbs-glow: rgba(77, 255, 77, 0.35);
}
:global(html[data-palette="amber"]) .frame {
--bbs-bg: #190f00; --bbs-fg: #ffe3ba; --bbs-accent: #ffb347;
--bbs-highlight: #ffffff; --bbs-dim: #a06a2c; --bbs-border: #ffb347; --bbs-glow: rgba(255, 179, 71, 0.35);
}
.shell { width: 100%; max-width: 760px; display: flex; flex-direction: column; align-items: center; }
.paletteSwitch { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.paletteBtn {
background: none; border: 1px solid #333; color: #8fae93; font-size: 11px;
padding: 6px 12px; cursor: pointer; letter-spacing: 0.02em;
}
.paletteBtn:hover, .active { border-color: #eafff0; color: #eafff0; }
.frame {
width: 100%; background: var(--bbs-bg); color: var(--bbs-fg);
border: 3px double var(--bbs-border);
box-shadow: 0 0 24px var(--bbs-glow), 0 20px 60px rgba(0, 0, 0, 0.6);
position: relative; overflow: hidden;
}
/* CRT 스캔라인 */
.frame::after {
content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
background: linear-gradient(rgba(255, 255, 255, 0) 50%, rgba(0, 0, 0, 0.12) 50%);
background-size: 100% 3px; mix-blend-mode: overlay; opacity: 0.5;
}
.frame :focus-visible { outline: 2px solid var(--bbs-accent); outline-offset: 2px; }
.titlebar {
display: flex; justify-content: space-between; align-items: center; gap: 8px;
padding: 8px 16px; border-bottom: 1px solid var(--bbs-border);
font-size: 12.5px; font-weight: 700; color: var(--bbs-accent); letter-spacing: 0.03em;
}
.screen { padding: 18px 20px; min-height: 360px; font-size: 13.5px; line-height: 1.9; }
.row { display: flex; gap: 10px; cursor: pointer; padding: 1px 4px; margin: 0 -4px; }
.row:hover { background: rgba(255, 255, 255, 0.08); }
.num { color: var(--bbs-highlight); font-weight: 700; width: 1.4em; flex-shrink: 0; text-align: right; }
.dim { color: var(--bbs-dim); }
.accent { color: var(--bbs-accent); }
.title { color: var(--bbs-accent); font-weight: 700; margin-bottom: 4px; }
.sub { color: var(--bbs-dim); font-size: 12px; margin-bottom: 10px; }
.error { color: #ff6b6b; }
.rule { border: none; border-top: 1px solid var(--bbs-dim); opacity: 0.5; margin: 8px 0 12px; }
.postRow { font-size: 13px; }
.postIdx { color: var(--bbs-highlight); width: 1.6em; flex-shrink: 0; text-align: right; }
.postTitle { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.postMeta { color: var(--bbs-dim); font-size: 11.5px; flex-shrink: 0; white-space: nowrap; }
.body { white-space: pre-wrap; margin-bottom: 14px; }
.footer { color: var(--bbs-dim); font-size: 11.5px; }
.footer b { color: var(--bbs-highlight); }
.cmdline {
display: flex; align-items: center; gap: 8px; padding: 10px 16px;
border-top: 1px solid var(--bbs-border); background: rgba(0, 0, 0, 0.25);
}
.prompt { color: var(--bbs-highlight); font-size: 13px; font-weight: 700; flex-shrink: 0; }
.cmdline input {
flex: 1; min-width: 0; background: none; border: none; outline: none; color: var(--bbs-fg);
font-size: 13.5px; caret-color: var(--bbs-highlight);
}
.cmdline input::placeholder { color: var(--bbs-dim); }
@media (max-width: 560px) {
.postMeta { display: none; }
.screen { padding: 14px; }
.titlebar { padding: 8px 12px; font-size: 11.5px; }
}
/* iOS는 16px 미만 input에 포커스하면 화면을 확대함 */
@media (pointer: coarse) {
.cmdline input { font-size: 16px; }
.row { padding: 4px; } /* 손가락 터치 영역 확보 */
}