mirror of
https://github.com/headporter81/ss-front-react.git
synced 2026-12-06 07:41:11 +09:00
feat : 알림 메시지를 TUI 스타일 팝업(<dialog>)으로 표시
SpecialSource Frontend (React) CD / deploy (push) Successful in 13s
SpecialSource Frontend (React) CD / deploy (push) Successful in 13s
- 이중선 테두리·그림자·[ 확인 ] 버튼의 DOS 대화상자 스타일, 팔레트 색 따라감 - Enter·Esc·클릭으로 닫으면 명령 입력창으로 포커스 복귀 - 입력창 Enter에서 preventDefault: 같은 Enter로 팝업이 바로 닫히던 문제 방지 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4bbf5c1ba4
commit
ca4df3e9a3
2 files changed
+36
-1
No files matched your search
@@ -97,6 +97,14 @@ export default function BbsTerminal() {
|
|||||||
};
|
};
|
||||||
}, [feedKind, feedBoard, state.token, state.rev]);
|
}, [feedKind, feedBoard, state.token, state.rev]);
|
||||||
|
|
||||||
|
// 오류·안내 메시지가 생기면 팝업으로 띄우고, 다른 경로로 지워지면 닫음
|
||||||
|
const dialogRef = useRef<HTMLDialogElement>(null);
|
||||||
|
useEffect(() => {
|
||||||
|
const d = dialogRef.current;
|
||||||
|
if (state.error && !d?.open) d?.showModal();
|
||||||
|
else if (!state.error && d?.open) d.close();
|
||||||
|
}, [state.error]);
|
||||||
|
|
||||||
// 무한 스크롤: 목록 맨 아래가 보이면 다음 페이지를 불러와 이어 붙임 (붙일지 말지는 execute가 판단)
|
// 무한 스크롤: 목록 맨 아래가 보이면 다음 페이지를 불러와 이어 붙임 (붙일지 말지는 execute가 판단)
|
||||||
const loadMore = () => {
|
const loadMore = () => {
|
||||||
const f = state.feed;
|
const f = state.feed;
|
||||||
@@ -244,10 +252,18 @@ export default function BbsTerminal() {
|
|||||||
{state.screen === "post" && state.token && (
|
{state.screen === "post" && state.token && (
|
||||||
<PostDetail post={state.feed?.posts.find((p) => p.id === state.postId)} token={state.token} />
|
<PostDetail post={state.feed?.posts.find((p) => p.id === state.postId)} token={state.token} />
|
||||||
)}
|
)}
|
||||||
{state.error && <div className={`${styles.full} ${styles.error}`}>{state.error}</div>}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* 알림 팝업: <dialog>.showModal()이 화면 맨 위에 띄우고 뒤를 막음. Esc·확인으로 닫으면 입력창으로 포커스가 돌아감 */}
|
||||||
|
<dialog ref={dialogRef} className={styles.dialog} onClose={() => dispatch({ error: null })}>
|
||||||
|
<span className={styles.cap}>═ 알림 ═</span>
|
||||||
|
<p>{state.error}</p>
|
||||||
|
<form method="dialog">
|
||||||
|
<button autoFocus>확인</button>
|
||||||
|
</form>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
<div className={styles.cmdline}>
|
<div className={styles.cmdline}>
|
||||||
<label htmlFor="bbs-cmd" className={styles.prompt}>
|
<label htmlFor="bbs-cmd" className={styles.prompt}>
|
||||||
선택 >
|
선택 >
|
||||||
@@ -260,6 +276,8 @@ export default function BbsTerminal() {
|
|||||||
onChange={(e) => setInput(e.target.value)}
|
onChange={(e) => setInput(e.target.value)}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key !== "Enter" || e.nativeEvent.isComposing) return;
|
if (e.key !== "Enter" || e.nativeEvent.isComposing) return;
|
||||||
|
// 기본 동작을 막아야 이어지는 keypress가 안 생김. 안 막으면 명령 실행으로 뜬 알림 팝업의 [확인]이 같은 Enter로 바로 눌림
|
||||||
|
e.preventDefault();
|
||||||
dispatch(input);
|
dispatch(input);
|
||||||
setInput("");
|
setInput("");
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -117,6 +117,23 @@
|
|||||||
}
|
}
|
||||||
.loginForm button:disabled { opacity: 0.5; cursor: wait; }
|
.loginForm button:disabled { opacity: 0.5; cursor: wait; }
|
||||||
|
|
||||||
|
/* 알림 팝업 (DOS 대화상자: 이중선 + 검은 그림자, 반전색 버튼) */
|
||||||
|
.dialog {
|
||||||
|
max-width: min(46ch, calc(100vw - 4ch)); padding: 1.3em 2ch 0.9em; overflow: visible;
|
||||||
|
background: var(--bbs-bg); color: var(--bbs-hi); font: inherit; line-height: 1.55;
|
||||||
|
border: 4px double var(--bbs-hi); box-shadow: 1.5ch 0.9em 0 #000;
|
||||||
|
}
|
||||||
|
.dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
|
||||||
|
.dialog p { margin: 0 0 1em; }
|
||||||
|
.dialog form { text-align: center; }
|
||||||
|
.dialog button {
|
||||||
|
background: var(--bbs-bar); color: var(--bbs-bar-fg); border: none; font: inherit; font-weight: 700;
|
||||||
|
padding: 0 2ch; cursor: pointer;
|
||||||
|
}
|
||||||
|
.dialog button::before { content: "[ "; }
|
||||||
|
.dialog button::after { content: " ]"; }
|
||||||
|
.dialog button:focus-visible, .dialog button:hover { background: var(--bbs-highlight); outline: none; }
|
||||||
|
|
||||||
/* 명령줄 */
|
/* 명령줄 */
|
||||||
.cmdline { display: flex; align-items: center; gap: 1ch; padding: 0.3em 16px; border-top: 1px solid var(--bbs-dim); }
|
.cmdline { display: flex; align-items: center; gap: 1ch; padding: 0.3em 16px; border-top: 1px solid var(--bbs-dim); }
|
||||||
.prompt { color: var(--bbs-highlight); font-weight: 700; white-space: nowrap; }
|
.prompt { color: var(--bbs-highlight); font-weight: 700; white-space: nowrap; }
|
||||||
|
|||||||
Reference in new issue
Block a user