Skip to content

Commit 3565014

Browse files
authored
feat(web): 필터 계층화 — 상시 5묶음 + 팝오버·적용 칩·프리셋 3종 (PR A) (#11)
1 parent 21df869 commit 3565014

7 files changed

Lines changed: 375 additions & 56 deletions

File tree

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import { useEffect, useRef, useState } from 'react'
2+
3+
// 필터 팝오버 — 상시 노출을 5묶음으로 줄이고 나머지 조건을 여기로 모은다.
4+
// 값 한 줄이 곧 토글 한 줄이다(체크박스 없음). 값마다 지금 조건에서 남는 건수를 붙여
5+
// "0건이 되는 길"을 누르기 전에 보여준다. 폭 320px, 그림자 없음, radius 0.
6+
export default function FilterPopover({ open, onToggle, onClose, groups, presets, activePreset, onApplyPreset, appliedCount, onClear }) {
7+
const wrapRef = useRef(null)
8+
// 버튼 오른쪽에 320px이 안 남으면 오른쪽 맞춤 — 1024px 같은 폭에서 패널이 화면 밖으로 나간다
9+
const [side, setSide] = useState('left')
10+
11+
const toggle = () => onToggle()
12+
13+
// 열릴 때 위치를 정한다 — 버튼 오른쪽에 320px이 안 남으면 오른쪽 맞춤
14+
// (1024px 같은 폭에서 패널이 화면 밖으로 나갔다). 클릭이든 단축키든 같은 자리에서 처리한다.
15+
useEffect(() => {
16+
if (!open) return
17+
const r = wrapRef.current?.getBoundingClientRect()
18+
setSide(r && window.innerWidth - r.left < 344 ? 'right' : 'left')
19+
}, [open])
20+
21+
// 바깥을 누르면 닫는다. Esc 는 목록 단축키가 먼저 받지 않도록 여기서도 잡아 둔다.
22+
useEffect(() => {
23+
if (!open) return
24+
const onDown = (e) => {
25+
if (wrapRef.current && !wrapRef.current.contains(e.target)) onClose()
26+
}
27+
document.addEventListener('mousedown', onDown)
28+
return () => document.removeEventListener('mousedown', onDown)
29+
}, [open, onClose])
30+
31+
return (
32+
<div className="fpop-wrap" ref={wrapRef}>
33+
<button
34+
type="button"
35+
className={'fopt fpop-btn' + (open ? ' on' : '') + (appliedCount ? ' has' : '')}
36+
aria-expanded={open}
37+
aria-controls="fpop"
38+
aria-haspopup="dialog"
39+
title="직군·내 진행·마감 범위·조건 필터 — 값마다 남는 건수를 보여준다"
40+
onClick={toggle}
41+
>
42+
필터
43+
{appliedCount > 0 && <span className="fpop-n">{appliedCount}</span>}
44+
<span className="fpop-caret" aria-hidden="true">▾</span>
45+
</button>
46+
{open && (
47+
<>
48+
<div className="fpop-back" aria-hidden="true" onClick={onClose}></div>
49+
<div className={'fpop' + (side === 'right' ? ' right' : '')} id="fpop" role="dialog" aria-label="필터">
50+
<div className="fp-hd">
51+
<span className="fp-title">필터</span>
52+
<button type="button" className="fp-clear" onClick={onClear} disabled={appliedCount === 0}
53+
title="걸린 조건을 모두 푼다 (검색어·정렬은 그대로)">전체 해제</button>
54+
<button type="button" className="fp-x" onClick={onClose} aria-label="필터 닫기">닫기</button>
55+
</div>
56+
{groups.map((g) => (
57+
<div className="fp-g" key={g.id}>
58+
<div className="fp-gh">{g.label}</div>
59+
{g.rows.map((row) => (
60+
<button
61+
type="button"
62+
key={row.id}
63+
className={'fp-row' + (row.on ? ' on' : '')}
64+
aria-pressed={row.on}
65+
onClick={row.pick}
66+
>
67+
<span className="fp-l">{row.label}</span>
68+
<span className="fp-n">{row.count}</span>
69+
</button>
70+
))}
71+
</div>
72+
))}
73+
<div className="fp-g">
74+
<div className="fp-gh">프리셋</div>
75+
<div className="fp-presets">
76+
{presets.map((p) => (
77+
<button
78+
type="button"
79+
key={p.id}
80+
className={'fp-preset' + (activePreset === p.id ? ' on' : '')}
81+
aria-pressed={activePreset === p.id}
82+
title={p.hint}
83+
onClick={() => onApplyPreset(p)}
84+
>{p.label}</button>
85+
))}
86+
</div>
87+
</div>
88+
</div>
89+
</>
90+
)}
91+
</div>
92+
)
93+
}

‎web/src/components/ShortcutsHelp.jsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ const KEYS = [
77
{ keys: ['Enter'], desc: '선택한 행 상세 열기 / 닫기 (좁은 화면은 아코디언, 넓은 화면은 우측 패널)' },
88
{ keys: ['o'], desc: '선택한 행의 원문 공고를 새 탭으로 열기' },
99
{ keys: ['s'], desc: '선택한 행 관심(별표) 토글' },
10+
{ keys: ['f'], desc: '필터 팝오버 열기 / 닫기 (직군·내 진행·마감 범위·조건·프리셋)' },
1011
{ keys: ['/'], desc: '헤더 검색창으로 이동' },
11-
{ keys: ['Esc'], desc: '검색창 포커스 해제 / 상세 패널 닫기' },
12+
{ keys: ['Esc'], desc: '검색창 포커스 해제 / 필터 팝오버·상세 패널 닫기' },
1213
{ keys: ['?'], desc: '이 도움말 열기 / 닫기' },
1314
]
1415

‎web/src/lib/commit.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// build.mjs가 생성
2-
export default '8d28ab3'
2+
export default '21df869'

‎web/src/lib/hash.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ export function writeHash(patch) {
3333

3434
// 필터 → 해시 파라미터 (기본값은 지운다). 딥링크로 공유할 수 있는 최소 집합.
3535
const PROG_IDS = ['interested', 'in_progress', 'submitted']
36+
// 마감 범위(일) — 프리셋 'D-3 임박'도 이 키 하나로 공유된다
37+
export const DD_WITHIN = ['3', '7']
3638

3739
export function filterPatch(s) {
3840
return {
3941
policy: s.policy === 'all' ? null : s.policy,
4042
jobfam: s.jobfam === 'fe' ? 'fe' : null,
4143
status: s.status === 'open' ? null : s.status,
4244
prog: PROG_IDS.includes(s.prog) ? s.prog : null,
45+
dd: DD_WITHIN.includes(s.dd) ? s.dd : null,
4346
hiring: s.hiringOnly ? '1' : null,
4447
changed: s.changedOnly ? '1' : null,
4548
starred: s.starredOnly ? '1' : null,
@@ -54,6 +57,7 @@ export function filtersFromHash(h) {
5457
jobfam: h.jobfam === 'fe' ? 'fe' : 'all',
5558
status: h.status === 'all' ? 'all' : 'open',
5659
prog: PROG_IDS.includes(h.prog) ? h.prog : '',
60+
dd: DD_WITHIN.includes(h.dd) ? h.dd : '',
5761
hiringOnly: h.hiring === '1',
5862
changedOnly: h.changed === '1',
5963
starredOnly: h.starred === '1',

‎web/src/lib/presets.js‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// 필터 프리셋 — 이름 붙은 조건 조합 3종.
2+
//
3+
// 저장소를 따로 만들지 않는다: 적용은 언제나 지금의 필터 상태(=URL 해시)로 흘러가므로
4+
// 프리셋을 눌러도 location.hash 만 바뀌고, 그 링크를 열면 같은 화면이 그대로 재현된다.
5+
// localStorage 에는 "정의"만 둔다 (기본 3종을 처음 한 번 써 두고, 이후에는 저장된 정의를 읽는다).
6+
const KEY = 'am-filter-presets'
7+
8+
export const DEFAULT_PRESETS = [
9+
{
10+
id: 'd3',
11+
label: 'D-3 임박',
12+
hint: '진행중이면서 마감이 3일 이내인 건',
13+
filters: { policy: 'all', jobfam: 'all', status: 'open', prog: '', dd: '3', hiringOnly: false, changedOnly: false, starredOnly: false },
14+
},
15+
{
16+
id: 'ai-required',
17+
label: 'AI 필수',
18+
hint: '과제에 AI 활용을 요구하는 건',
19+
filters: { policy: 'required', jobfam: 'all', status: 'open', prog: '', dd: '', hiringOnly: false, changedOnly: false, starredOnly: false },
20+
},
21+
{
22+
id: 'starred',
23+
label: '관심',
24+
hint: '별표해 둔 건',
25+
filters: { policy: 'all', jobfam: 'all', status: 'open', prog: '', dd: '', hiringOnly: false, changedOnly: false, starredOnly: true },
26+
},
27+
]
28+
29+
const FILTER_KEYS = ['policy', 'jobfam', 'status', 'prog', 'dd', 'hiringOnly', 'changedOnly', 'starredOnly']
30+
31+
// 저장된 정의를 기본값 위에 덮는다. 깨진 값은 버리고 기본값을 쓴다.
32+
export function loadPresets() {
33+
let stored = null
34+
try { stored = JSON.parse(localStorage.getItem(KEY) || 'null') } catch { stored = null }
35+
if (!Array.isArray(stored)) {
36+
savePresets(DEFAULT_PRESETS)
37+
return DEFAULT_PRESETS
38+
}
39+
const byId = new Map()
40+
for (const p of stored) {
41+
if (!p || typeof p.id !== 'string' || typeof p.label !== 'string' || !p.filters) continue
42+
const filters = {}
43+
for (const k of FILTER_KEYS) if (k in p.filters) filters[k] = p.filters[k]
44+
byId.set(p.id, { id: p.id, label: p.label, hint: typeof p.hint === 'string' ? p.hint : '', filters })
45+
}
46+
// 기본 3종은 항상 남는다 — 저장소가 비었거나 일부만 남아도 프리셋 줄이 비지 않는다
47+
return DEFAULT_PRESETS.map((d) => {
48+
const s = byId.get(d.id)
49+
return { ...d, ...(s || {}), filters: { ...d.filters, ...((s && s.filters) || {}) } }
50+
})
51+
}
52+
53+
export function savePresets(list) {
54+
try { localStorage.setItem(KEY, JSON.stringify(list)) } catch { /* 사생활 모드 */ }
55+
}
56+
57+
// 지금 필터 상태가 어느 프리셋과 같은지 (없으면 빈 문자열)
58+
export function matchPreset(presets, state) {
59+
const key = (f) => FILTER_KEYS.map((k) => JSON.stringify(f[k] ?? DEFAULT_PRESETS[0].filters[k])).join('|')
60+
const now = key(state)
61+
const hit = presets.find((p) => key(p.filters) === now)
62+
return hit ? hit.id : ''
63+
}

‎web/src/styles.css‎

Lines changed: 67 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
:root {
22
--bg: #0B0E14; --panel: #0F131B; --panel2: #0D111A; --border: #1A2130; --border2: #12161F;
3-
--fg: #C9D4E3; --fg-hi: #E8EEF6; --mut: #8B98AD; --dim: #82909F; --faint: #6E7B90;
3+
--fg: #C9D4E3; --fg-hi: #E8EEF6; --mut: #8B98AD; --dim: #82909F;
4+
/* 보조 텍스트 하한 — 패널 배경(#0F131B)에서 5.04:1, 본문 배경(#0B0E14)에서 5.23:1.
5+
예전 #6E7B90 은 4.34:1 로 AA(4.5:1) 미달이었다 (2026-11-17 대비 보정).
6+
--mut(6.37:1) 로 바꾸는 대신 토큰을 올렸다: 도구 줄·메타가 조건 버튼과 같은 밝기가 되면
7+
"목록을 좁히는 조건"과 "표시 도구"의 위계가 사라진다. */
8+
--faint: #78869C;
49
--red: #FF5C5C; --blue: #5CA8FF; --green: #34D399; --yellow: #E5C07B;
510
--mono: "JetBrains Mono", "SF Mono", Menlo, monospace;
611
/* 한글 산문용 — 숫자·D-Day·단축키·터미널 메타는 --mono 그대로 */
@@ -67,22 +72,25 @@ a:hover { text-decoration: underline; text-underline-offset: 3px; }
6772
.band .dl-btn { padding: 0 7px; }
6873
.band .dl-empty { padding: 3px 10px; }
6974

70-
/* filter row — 압축: 4px 패딩 (높이 24px). 두 계층: 조건(fr-q) + 도구(fr-t) */
75+
/* filter row — 28px 행, 버튼 최소 타깃 28×24 (WCAG 2.2 SC 2.5.8). 두 계층: 조건(fr-q) + 도구(fr-t) */
7176
.fr { display: flex; border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: stretch; }
7277
.fr-q { display: flex; flex-wrap: wrap; align-items: stretch; min-width: 0; }
7378
.fr-t { display: flex; flex-wrap: wrap; align-items: stretch; margin-left: auto; border-left: 1px solid var(--border2); }
74-
.fl { display: flex; align-items: center; padding: 0 9px; font-size: 10.5px; color: var(--faint); border-right: 1px solid var(--border); }
75-
.fopt { display: inline-flex; align-items: center; padding: 4px 8px; font-size: 11px; color: var(--mut); background: none; border: 0; border-right: 1px solid var(--border2); cursor: pointer; font-family: inherit; }
79+
.fl { display: flex; align-items: center; min-height: 28px; padding: 0 9px; font-size: 10.5px; color: var(--mut); border-right: 1px solid var(--border); }
80+
.fopt { display: inline-flex; align-items: center; min-height: 28px; min-width: 24px; padding: 0 9px; font-size: 11px; color: var(--mut); background: none; border: 0; border-right: 1px solid var(--border2); cursor: pointer; font-family: inherit; }
7681
.fr-q .fl { padding: 0 8px; }
82+
/* 값 옆 건수 — 지금 조건에서 그 값이 몇 건인지 (값이 0이면 누르기 전에 보인다) */
83+
.fct { margin-left: 6px; color: var(--faint); font-size: 10px; font-variant-numeric: tabular-nums; }
84+
.fopt.on .fct, .fopt:hover .fct { color: var(--fg); }
7785
/* 도구 줄 — 조건과 같은 버튼이 아니라 보조 도구로 읽히게: 옅은 글자 + 밑줄 선택 표시 */
7886
.fr-t .fl { border-right: 0; padding: 0 8px 0 12px; }
7987
.fr-t .fl:first-child { padding-left: 10px; }
80-
.fr-t .fopt { color: var(--faint); font-size: 10.5px; padding: 4px 8px; }
88+
.fr-t .fopt { color: var(--faint); font-size: 10.5px; padding: 0 8px; }
8189
.fr-t .fopt:hover { color: var(--fg-hi); }
8290
.fr-t .fopt.on { color: var(--fg-hi); background: none; box-shadow: inset 0 -2px 0 var(--blue); }
8391
.fr-t .fopt.ics { color: var(--blue); }
84-
.fr-t .fopt.ics:disabled { color: #46505F; }
85-
.fopt-reset { margin: 4px 8px; align-self: center; padding: 1px 8px; border: 1px solid var(--border); color: var(--mut); }
92+
.fr-t .fopt.ics:disabled { color: var(--faint); }
93+
.fopt-reset { margin: 0 8px; align-self: center; padding: 0 8px; min-height: 24px; border: 1px solid var(--border); color: var(--mut); }
8694
.fopt-reset:hover { color: var(--fg-hi); border-color: var(--blue); }
8795
.fopt:hover { color: var(--fg-hi); }
8896
.fopt.on { color: var(--fg-hi); background: #11151C; }
@@ -91,6 +99,54 @@ a:hover { text-decoration: underline; text-underline-offset: 3px; }
9199
.fopt.p-ok.on { background: #0F1A15; color: var(--green); }
92100
.fopt.p-rev.on { background: #1B1710; color: var(--yellow); }
93101

102+
/* 필터 팝오버 — 상시 5묶음 밖의 조건이 여기 모인다. 값 한 줄이 토글 한 줄이고,
103+
오른쪽 숫자는 이 값을 골랐을 때 남는 건수다. 그림자 없음·radius 0 (DESIGN.md). */
104+
.fpop-wrap { position: relative; display: inline-flex; align-items: stretch; }
105+
.fpop-n { margin-left: 5px; padding: 0 3px; border: 1px solid #24303F; color: var(--blue); font-size: 9.5px; line-height: 1.4; font-variant-numeric: tabular-nums; }
106+
.fpop-btn.has { color: var(--fg-hi); }
107+
.fpop-caret { margin-left: 4px; color: var(--dim); font-size: 9px; }
108+
/* 바깥 클릭 레이어 — 화면 전체를 덮고, 누르면 닫힌다 */
109+
.fpop-back { position: fixed; inset: 0; z-index: 40; }
110+
.fpop { position: absolute; top: calc(100% + 1px); left: 0; z-index: 41; width: 320px; max-width: calc(100vw - 24px); max-height: min(74vh, 540px); overflow-y: auto; background: var(--panel); border: 1px solid var(--border); }
111+
/* 버튼이 화면 오른쪽에 가까우면 오른쪽 맞춤 — 패널이 화면 밖으로 나가지 않게 (열 때 JavaScript가 판단) */
112+
.fpop.right { left: auto; right: 0; }
113+
.fp-hd { position: sticky; top: 0; display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 10px; background: var(--panel); border-bottom: 1px solid var(--border); }
114+
.fp-title { color: var(--fg-hi); font-size: 11px; font-weight: 600; }
115+
.fp-clear { margin-left: auto; background: none; border: 1px solid var(--border); color: var(--mut); font: 10px var(--mono); min-height: 24px; padding: 0 7px; cursor: pointer; }
116+
.fp-clear:hover:not(:disabled) { color: var(--fg-hi); border-color: var(--blue); }
117+
.fp-clear:disabled { color: var(--faint); cursor: default; }
118+
.fp-x { background: none; border: 1px solid var(--border); color: var(--mut); font: 10px var(--mono); min-height: 24px; padding: 0 7px; cursor: pointer; }
119+
.fp-x:hover { color: var(--fg-hi); border-color: var(--blue); }
120+
.fp-g { padding: 6px 0 7px; border-top: 1px solid var(--border2); }
121+
.fp-g:first-of-type { border-top: 0; }
122+
.fp-gh { padding: 0 10px 3px; color: var(--dim); font-size: 10px; }
123+
.fp-row { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 26px; padding: 0 10px; background: none; border: 0; color: var(--mut); font: 11px var(--mono); text-align: left; cursor: pointer; }
124+
.fp-row:hover { color: var(--fg-hi); background: #11151C; }
125+
.fp-row.on { color: var(--fg-hi); background: #11151C; box-shadow: inset 2px 0 0 var(--blue); }
126+
.fp-l { flex: 1 1 auto; min-width: 0; }
127+
.fp-n { color: var(--dim); font-size: 10px; font-variant-numeric: tabular-nums; }
128+
.fp-row.on .fp-n { color: var(--fg); }
129+
.fp-presets { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px; }
130+
.fp-preset { min-height: 24px; padding: 0 8px; background: none; border: 1px solid var(--border); color: var(--mut); font: 10.5px var(--mono); cursor: pointer; }
131+
.fp-preset:hover { color: var(--fg-hi); border-color: #2A4A73; }
132+
.fp-preset.on { color: #DCE9FF; border-color: #2A4A73; background: #101826; }
133+
/* 좁은 화면은 바닥 트레이 — 목록을 완전히 가리지 않고, 행은 손가락 크기로 */
134+
@media (max-width: 760px) {
135+
.fpop, .fpop.right { position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: auto; max-width: none; max-height: 72vh; border-left: 0; border-right: 0; border-bottom: 0; }
136+
.fp-row { min-height: 32px; }
137+
.fchip, .fchip-clear { min-height: 28px; }
138+
}
139+
140+
/* 적용 필터 칩 줄 — 칩 하나가 곧 제거 버튼이다. 검색어·정렬은 칩이 아니라 도구라 여기 없다 */
141+
.fr-chips { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; flex: 0 0 auto; padding: 3px 10px 4px; background: var(--panel2); border-bottom: 1px solid var(--border); }
142+
.fchip { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 0 7px; background: none; border: 1px solid var(--border); color: var(--fg); font: 10.5px var(--mono); cursor: pointer; }
143+
.fchip:hover { color: var(--fg-hi); border-color: var(--blue); }
144+
.fchip .k { color: var(--faint); font-size: 10px; }
145+
.fchip .x { color: var(--dim); font-size: 11px; line-height: 1; }
146+
.fchip:hover .x { color: var(--fg-hi); }
147+
.fchip-clear { min-height: 24px; padding: 0 7px; background: none; border: 0; color: var(--faint); font: 10.5px var(--mono); cursor: pointer; }
148+
.fchip-clear:hover { color: var(--fg-hi); text-decoration: underline; text-underline-offset: 3px; }
149+
94150
/* table */
95151
.twrap { overflow: auto; flex: 1 1 0; min-height: 0; }
96152
table { width: 100%; border-collapse: collapse; font-size: 11.5px; min-width: 680px; }
@@ -201,7 +257,7 @@ tr.cur td { background: #111726; box-shadow: inset 2px 0 0 var(--blue); }
201257

202258
/* 밀도 (AG Grid spacing 토큰 / MUI 토글) */
203259
.dens { display: flex; align-self: center; }
204-
.dens button { background: none; border: 1px solid var(--border); color: var(--faint); font: 10px var(--mono); padding: 3px 8px; cursor: pointer; }
260+
.dens button { display: inline-flex; align-items: center; min-height: 28px; background: none; border: 1px solid var(--border); color: var(--faint); font: 10px var(--mono); padding: 0 8px; cursor: pointer; }
205261
.dens button.on { color: var(--fg-hi); background: #11151C; }
206262
[data-density="compact"] td { padding: 2px 8px; font-size: 11px; }
207263
[data-density="compact"] th { padding: 4px 8px; }
@@ -299,7 +355,7 @@ td.ev { white-space: nowrap; color: var(--mut); }
299355
.ics.act.primary { color: #DCE9FF; border-color: #2A4A73; background: #101826; font-weight: 700; padding: 4px 12px; }
300356
.ics.act.primary:hover { color: #fff; border-color: var(--blue); background: #14203A; }
301357
.dp-acts-top .ics.act { padding-top: 4px; padding-bottom: 4px; }
302-
.dp-foot { padding: 7px 12px 0; color: #5A6577; font-size: 10px; }
358+
.dp-foot { padding: 7px 12px 0; color: var(--faint); font-size: 10px; }
303359

304360
/* 관련 공고 — 패널(.rel .dp-sec)과 모바일 아코디언(.rel-in)이 같은 목록을 쓴다 */
305361
.rel-list { list-style: none; margin: 2px 0 4px; padding: 0; }
@@ -420,8 +476,8 @@ td.ev { white-space: nowrap; color: var(--mut); }
420476
.fopt.tog-chg.on { color: var(--red); background: #1C1113; }
421477
.fopt.ics { color: var(--blue); border-right: 1px solid var(--border); }
422478
.fopt.ics:hover { color: var(--fg-hi); }
423-
.fopt:disabled { color: #46505F; cursor: default; }
424-
.fopt:disabled:hover { color: #46505F; }
479+
.fopt:disabled { color: var(--faint); cursor: default; }
480+
.fopt:disabled:hover { color: var(--faint); }
425481

426482
/* 정책 변경 배지 — 정책 이야기는 빨강 */
427483
.badge.chg { color: var(--red); }

0 commit comments

Comments
 (0)