536 lines
17 KiB
Plaintext
536 lines
17 KiB
Plaintext
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" language="java" %>
|
|
<%@ page import="com.pandoli365.bibimbap.game.GameCatalog" %>
|
|
<!DOCTYPE html>
|
|
<html lang="ko">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<jsp:include page="/WEB-INF/views/theme-init.jsp"/>
|
|
<title>bibimbap</title>
|
|
<style>
|
|
html {
|
|
color-scheme: light;
|
|
--surface: #faf8f5;
|
|
--card-bg: #fff;
|
|
--text: #1a1a1a;
|
|
--text-muted: #5c5c5c;
|
|
--accent: #e8a54b;
|
|
--border: rgba(0, 0, 0, 0.08);
|
|
--card-media-1: #f0ebe3;
|
|
--card-media-2: #e5ddd2;
|
|
--card-media-3: #dccfb8;
|
|
--card-shadow: rgba(0, 0, 0, 0.06);
|
|
--search-btn-text: #1a1a1a;
|
|
}
|
|
html[data-theme="dark"] {
|
|
color-scheme: dark;
|
|
--surface: #121212;
|
|
--card-bg: #1e1e1e;
|
|
--text: #ece8e1;
|
|
--text-muted: #a39e96;
|
|
--border: rgba(255, 255, 255, 0.1);
|
|
--card-media-1: #2a2620;
|
|
--card-media-2: #1f1c18;
|
|
--card-media-3: #3d3528;
|
|
--card-shadow: rgba(0, 0, 0, 0.35);
|
|
--search-btn-text: #1a1a1a;
|
|
}
|
|
body {
|
|
margin: 0;
|
|
min-height: 100vh;
|
|
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
|
|
background: var(--surface);
|
|
color: var(--text);
|
|
}
|
|
.page-main {
|
|
max-width: 72rem;
|
|
margin: 0 auto;
|
|
padding: 1rem max(1rem, env(safe-area-inset-left)) 2.5rem max(1rem, env(safe-area-inset-right));
|
|
}
|
|
@media (min-width: 640px) {
|
|
.page-main {
|
|
padding-top: 1.5rem;
|
|
}
|
|
}
|
|
|
|
/* 검색 */
|
|
.search-section {
|
|
margin-bottom: 1.25rem;
|
|
}
|
|
.search-form {
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
align-items: stretch;
|
|
}
|
|
.search-form__field {
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
.search-form__label {
|
|
position: absolute;
|
|
width: 1px;
|
|
height: 1px;
|
|
padding: 0;
|
|
margin: -1px;
|
|
overflow: hidden;
|
|
clip: rect(0, 0, 0, 0);
|
|
border: 0;
|
|
}
|
|
.search-form__input {
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
height: 3rem;
|
|
padding: 0 1rem 0 2.75rem;
|
|
font-size: 1rem;
|
|
border: 1px solid var(--border);
|
|
border-radius: 12px;
|
|
color: var(--text);
|
|
background-color: var(--card-bg);
|
|
background-repeat: no-repeat;
|
|
background-position: 0.875rem 50%;
|
|
background-size: 1.125rem;
|
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='8.5' cy='8.5' r='5.5'/%3E%3Cpath d='M12 12l5 5'/%3E%3C/svg%3E");
|
|
}
|
|
html[data-theme="dark"] .search-form__input {
|
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%23aaa' stroke-width='2'%3E%3Ccircle cx='8.5' cy='8.5' r='5.5'/%3E%3Cpath d='M12 12l5 5'/%3E%3C/svg%3E");
|
|
}
|
|
.search-form__input::placeholder {
|
|
color: var(--text-muted);
|
|
}
|
|
.search-form__input:focus {
|
|
outline: none;
|
|
border-color: var(--accent);
|
|
box-shadow: 0 0 0 3px rgba(232, 165, 75, 0.25);
|
|
}
|
|
.search-form__submit {
|
|
flex-shrink: 0;
|
|
min-width: 4.5rem;
|
|
height: 3rem;
|
|
padding: 0 1rem;
|
|
font-size: 0.9375rem;
|
|
font-weight: 600;
|
|
color: var(--search-btn-text);
|
|
background: var(--accent);
|
|
border: none;
|
|
border-radius: 12px;
|
|
cursor: pointer;
|
|
-webkit-tap-highlight-color: transparent;
|
|
}
|
|
.search-form__submit:active {
|
|
transform: scale(0.98);
|
|
}
|
|
|
|
.search-history {
|
|
margin-top: 0.75rem;
|
|
}
|
|
.search-history[hidden] {
|
|
display: none !important;
|
|
}
|
|
.search-history__head {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 0.5rem;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
.search-history__label {
|
|
font-size: 0.75rem;
|
|
font-weight: 600;
|
|
color: var(--text-muted);
|
|
letter-spacing: 0.02em;
|
|
}
|
|
.search-history__clear {
|
|
padding: 0.25rem 0.5rem;
|
|
font-size: 0.6875rem;
|
|
font-weight: 500;
|
|
color: var(--text-muted);
|
|
background: transparent;
|
|
border: none;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
-webkit-tap-highlight-color: transparent;
|
|
}
|
|
.search-history__clear:hover {
|
|
color: var(--accent);
|
|
background: rgba(232, 165, 75, 0.12);
|
|
}
|
|
.search-history__chips {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 0.375rem;
|
|
}
|
|
.search-history__chip {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.15rem;
|
|
max-width: 100%;
|
|
padding: 0.2rem 0.35rem 0.2rem 0.65rem;
|
|
font-size: 0.8125rem;
|
|
color: var(--text);
|
|
background: var(--card-bg);
|
|
border: 1px solid var(--border);
|
|
border-radius: 999px;
|
|
-webkit-tap-highlight-color: transparent;
|
|
}
|
|
.search-history__chip-text {
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
max-width: 12rem;
|
|
margin: 0;
|
|
padding: 0.15rem 0;
|
|
font: inherit;
|
|
color: inherit;
|
|
text-align: left;
|
|
background: none;
|
|
border: none;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
}
|
|
.search-history__chip-text:hover {
|
|
color: var(--accent);
|
|
}
|
|
.search-history__chip-remove {
|
|
flex-shrink: 0;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
width: 1.25rem;
|
|
height: 1.25rem;
|
|
padding: 0;
|
|
font-size: 1rem;
|
|
line-height: 1;
|
|
color: var(--text-muted);
|
|
background: transparent;
|
|
border: none;
|
|
border-radius: 50%;
|
|
cursor: pointer;
|
|
}
|
|
.search-history__chip-remove:hover {
|
|
color: var(--text);
|
|
background: rgba(0, 0, 0, 0.06);
|
|
}
|
|
html[data-theme="dark"] .search-history__chip-remove:hover {
|
|
background: rgba(255, 255, 255, 0.08);
|
|
}
|
|
|
|
/* 카드 그리드: 모바일 2열 → 태블릿 3열 → 데스크톱 4~5열 */
|
|
.card-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
gap: 0.625rem;
|
|
}
|
|
@media (min-width: 480px) {
|
|
.card-grid {
|
|
gap: 0.75rem;
|
|
}
|
|
}
|
|
@media (min-width: 640px) {
|
|
.card-grid {
|
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
gap: 1rem;
|
|
}
|
|
}
|
|
@media (min-width: 900px) {
|
|
.card-grid {
|
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
}
|
|
}
|
|
@media (min-width: 1200px) {
|
|
.card-grid {
|
|
grid-template-columns: repeat(5, minmax(0, 1fr));
|
|
}
|
|
}
|
|
|
|
a.card {
|
|
display: flex;
|
|
flex-direction: column;
|
|
border-radius: 12px;
|
|
overflow: hidden;
|
|
background: var(--card-bg);
|
|
border: 1px solid var(--border);
|
|
box-shadow: 0 2px 8px var(--card-shadow);
|
|
text-decoration: none;
|
|
color: inherit;
|
|
cursor: pointer;
|
|
transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
|
|
}
|
|
a.card:hover {
|
|
box-shadow: 0 6px 16px var(--card-shadow);
|
|
transform: translateY(-2px);
|
|
border-color: rgba(232, 165, 75, 0.35);
|
|
}
|
|
a.card:focus {
|
|
outline: none;
|
|
}
|
|
a.card:focus-visible {
|
|
outline: 2px solid var(--accent);
|
|
outline-offset: 2px;
|
|
}
|
|
/* 가로:세로 = 4:5 (포스터/썸네일에 흔한 비율, 3:5보다 덜 길쭉해 모바일 그리드에 균형 있음) */
|
|
.card__media {
|
|
position: relative;
|
|
width: 100%;
|
|
aspect-ratio: 4 / 5;
|
|
background: var(--card-media-2);
|
|
}
|
|
.card__index {
|
|
position: absolute;
|
|
top: 0.45rem;
|
|
left: 0.45rem;
|
|
z-index: 2;
|
|
padding: 0.25rem 0.5rem;
|
|
font-size: 0.6875rem;
|
|
font-weight: 800;
|
|
letter-spacing: -0.02em;
|
|
color: #1a1a1a;
|
|
background: rgba(255, 255, 255, 0.93);
|
|
border-radius: 6px;
|
|
line-height: 1;
|
|
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
|
|
}
|
|
html[data-theme="dark"] .card__index {
|
|
background: rgba(30, 30, 30, 0.93);
|
|
color: #ece8e1;
|
|
}
|
|
.card__img {
|
|
width: 100%;
|
|
height: 100%;
|
|
display: block;
|
|
object-fit: cover;
|
|
}
|
|
/* 이미지 없음: 로고만 중앙 */
|
|
.card__media-empty {
|
|
position: absolute;
|
|
inset: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 14%;
|
|
background: linear-gradient(160deg, var(--card-media-1) 0%, var(--card-media-2) 45%, var(--card-media-3) 100%);
|
|
}
|
|
.card__logo-fallback {
|
|
width: min(52%, 7.5rem);
|
|
height: auto;
|
|
max-height: 42%;
|
|
object-fit: contain;
|
|
opacity: 0.88;
|
|
filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.12));
|
|
}
|
|
html[data-theme="dark"] .card__logo-fallback {
|
|
opacity: 0.92;
|
|
filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.45));
|
|
}
|
|
.card__body {
|
|
padding: 0.5rem 0.625rem 0.625rem;
|
|
flex: 1;
|
|
min-height: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.2rem;
|
|
}
|
|
.card__game-name {
|
|
margin: 0;
|
|
font-size: 0.8125rem;
|
|
font-weight: 600;
|
|
line-height: 1.35;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 2;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
color: var(--text);
|
|
}
|
|
.card__creator {
|
|
margin: 0;
|
|
font-size: 0.6875rem;
|
|
color: var(--text-muted);
|
|
line-height: 1.35;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 1;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
}
|
|
.card__likes {
|
|
margin: 0.15rem 0 0;
|
|
font-size: 0.6875rem;
|
|
font-weight: 600;
|
|
color: var(--text);
|
|
letter-spacing: -0.01em;
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<jsp:include page="/WEB-INF/views/header.jsp"/>
|
|
<main class="page-main">
|
|
<section class="search-section" aria-label="게임·제작자 검색">
|
|
<form class="search-form" role="search" action="#" method="get">
|
|
<div class="search-form__field">
|
|
<label class="search-form__label" for="q">게임·제작자 검색</label>
|
|
<input class="search-form__input" type="search" id="q" name="q" placeholder="게임·제작자 검색" autocomplete="off" enterkeyhint="search" />
|
|
</div>
|
|
<button class="search-form__submit" type="submit">검색</button>
|
|
</form>
|
|
<div class="search-history" id="search-history" hidden>
|
|
<div class="search-history__head">
|
|
<span class="search-history__label">최근 검색</span>
|
|
<button type="button" class="search-history__clear" id="search-history-clear">전체 삭제</button>
|
|
</div>
|
|
<div class="search-history__chips" id="search-history-chips" role="list"></div>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="card-grid" aria-label="추천 목록">
|
|
<%-- 카드 데이터: GameCatalog (DB 연동 시 교체) --%>
|
|
<%
|
|
String ctx = request.getContextPath();
|
|
for (int i = 0; i < GameCatalog.COUNT; i++) {
|
|
int displayIndex = i + 1;
|
|
/* 썸네일 URL — DB 연동 시 null·빈 문자열이면 로고 폴백 */
|
|
String thumbUrl = null; // 예: list.get(i).getThumbnailUrl()
|
|
boolean hasImage = thumbUrl != null && !thumbUrl.isBlank();
|
|
%>
|
|
<a class="card" href="<%= ctx %>/game/<%= displayIndex %>" aria-labelledby="game-title-<%= i %>">
|
|
<div class="card__media">
|
|
<span class="card__index" aria-hidden="true">#<%= displayIndex %></span>
|
|
<% if (hasImage) { %>
|
|
<img class="card__img" src="<%= thumbUrl %>" alt="" loading="lazy" decoding="async" />
|
|
<% } else { %>
|
|
<div class="card__media-empty" role="presentation">
|
|
<img class="card__logo-fallback" src="<%= ctx %>/images/logo.png" alt="" width="120" height="120" />
|
|
</div>
|
|
<% } %>
|
|
</div>
|
|
<div class="card__body">
|
|
<h2 class="card__game-name" id="game-title-<%= i %>"><%= GameCatalog.NAMES[i] %></h2>
|
|
<p class="card__creator"><%= GameCatalog.CREATORS[i] %></p>
|
|
<p class="card__likes">좋아요 <%= String.format("%,d", GameCatalog.LIKE_COUNTS[i]) %></p>
|
|
</div>
|
|
</a>
|
|
<%
|
|
}
|
|
%>
|
|
</section>
|
|
</main>
|
|
<jsp:include page="/WEB-INF/views/footer.jsp"/>
|
|
<script>
|
|
(function () {
|
|
var STORAGE_KEY = 'bibimbap-search-history';
|
|
var MAX_ITEMS = 10;
|
|
|
|
function loadHistory() {
|
|
try {
|
|
var raw = localStorage.getItem(STORAGE_KEY);
|
|
if (!raw) return [];
|
|
var parsed = JSON.parse(raw);
|
|
var list = Array.isArray(parsed) ? parsed.filter(function (s) { return typeof s === 'string' && s.trim(); }) : [];
|
|
if (list.length > MAX_ITEMS) {
|
|
list = list.slice(0, MAX_ITEMS);
|
|
saveHistory(list);
|
|
}
|
|
return list;
|
|
} catch (e) {
|
|
return [];
|
|
}
|
|
}
|
|
|
|
function saveHistory(items) {
|
|
try {
|
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(items));
|
|
} catch (e) {
|
|
/* 용량 초과·비공개 모드 등 */
|
|
}
|
|
}
|
|
|
|
/** 검색어 추가: 앞에 넣고, 동일 문구(대소문자 무시)는 제거 후 최대 개수 유지 */
|
|
function addSearchQuery(query) {
|
|
var q = (query || '').trim();
|
|
if (!q) return;
|
|
var list = loadHistory();
|
|
var lower = q.toLowerCase();
|
|
list = list.filter(function (item) { return item.toLowerCase() !== lower; });
|
|
list.unshift(q);
|
|
if (list.length > MAX_ITEMS) list = list.slice(0, MAX_ITEMS);
|
|
saveHistory(list);
|
|
}
|
|
|
|
function removeSearchQuery(query) {
|
|
var lower = (query || '').toLowerCase();
|
|
var list = loadHistory().filter(function (item) { return item.toLowerCase() !== lower; });
|
|
saveHistory(list);
|
|
}
|
|
|
|
function clearHistory() {
|
|
try {
|
|
localStorage.removeItem(STORAGE_KEY);
|
|
} catch (e) {}
|
|
}
|
|
|
|
var form = document.querySelector('.search-form');
|
|
var input = document.getElementById('q');
|
|
var historyEl = document.getElementById('search-history');
|
|
var chipsEl = document.getElementById('search-history-chips');
|
|
var clearBtn = document.getElementById('search-history-clear');
|
|
|
|
function renderChips() {
|
|
var list = loadHistory();
|
|
chipsEl.innerHTML = '';
|
|
if (!list.length) {
|
|
historyEl.hidden = true;
|
|
return;
|
|
}
|
|
historyEl.hidden = false;
|
|
list.forEach(function (term) {
|
|
var chip = document.createElement('div');
|
|
chip.className = 'search-history__chip';
|
|
chip.setAttribute('role', 'listitem');
|
|
|
|
var textBtn = document.createElement('button');
|
|
textBtn.type = 'button';
|
|
textBtn.className = 'search-history__chip-text';
|
|
textBtn.textContent = term;
|
|
textBtn.title = term;
|
|
textBtn.addEventListener('click', function () {
|
|
input.value = term;
|
|
input.focus();
|
|
});
|
|
|
|
var removeBtn = document.createElement('button');
|
|
removeBtn.type = 'button';
|
|
removeBtn.className = 'search-history__chip-remove';
|
|
removeBtn.setAttribute('aria-label', '삭제: ' + term);
|
|
removeBtn.textContent = '\u00D7';
|
|
removeBtn.addEventListener('click', function (ev) {
|
|
ev.stopPropagation();
|
|
removeSearchQuery(term);
|
|
renderChips();
|
|
});
|
|
|
|
chip.appendChild(textBtn);
|
|
chip.appendChild(removeBtn);
|
|
chipsEl.appendChild(chip);
|
|
});
|
|
}
|
|
|
|
if (form && input) {
|
|
form.addEventListener('submit', function (ev) {
|
|
ev.preventDefault();
|
|
var q = input.value;
|
|
addSearchQuery(q);
|
|
renderChips();
|
|
/* 실제 검색 URL 연동 시: location.href = '...?q=' + encodeURIComponent(q.trim()); */
|
|
});
|
|
|
|
clearBtn.addEventListener('click', function () {
|
|
clearHistory();
|
|
renderChips();
|
|
});
|
|
|
|
renderChips();
|
|
}
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|