Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
--bg-elevated: #21262d;
--bg-border: #30363d;

/* Board size: at least 50 % of viewport width, capped at 760 px */
--board-sz: clamp(320px, 50vw, 760px);
--chess-panel-padding: 4rem; /* total horizontal padding within chess panel (2 × 1rem + margins) */

/* Board size: fills the 70 % chess panel minus padding, capped at 760 px */
--board-sz: clamp(320px, calc(70vw - var(--chess-panel-padding) * 2), 760px);

--text-primary: #e6edf3;
--text-secondary: #8b949e;
Expand Down Expand Up @@ -161,9 +163,19 @@ a { color: var(--accent-blue); }
align-items: center;
padding: 1rem;
gap: .6rem;
flex-shrink: 0;
flex: 0 0 70%;
width: 70%;
min-width: 0;
overflow-y: auto;
justify-content: center;
}

/* When SQL panel is hidden, chess panel fills the available space */
/* .sql-hidden is set by JS as a fallback for browsers without :has() support */
.chess-panel.sql-hidden,
.chess-panel:has(~ .sql-panel.hidden-panel) {
flex: 1;
width: 100%;
}

/* Player bars */
Expand Down Expand Up @@ -389,7 +401,8 @@ a { color: var(--accent-blue); }

/* ── SQL Panel ──────────────────────────────────────────────── */
.sql-panel {
flex: 1;
flex: 0 0 25%;
width: 25%;
display: flex;
flex-direction: column;
border-left: 1px solid var(--bg-border);
Expand All @@ -399,7 +412,7 @@ a { color: var(--accent-blue); }
transition: width .25s ease, flex .25s ease, opacity .2s;
}
.sql-panel.hidden-panel {
flex: 0;
flex: 0 0 0;
width: 0;
opacity: 0;
pointer-events: none;
Expand Down Expand Up @@ -829,7 +842,15 @@ input:checked + .slider::before { transform: translateX(18px); }
@media (max-width: 900px) {
.app-main { flex-direction: column; }

.chess-panel {
flex: none;
width: 100%;
justify-content: flex-start;
}

.sql-panel {
flex: none;
width: 100%;
border-left: none;
border-top: 1px solid var(--bg-border);
max-height: 40vh;
Expand Down
15 changes: 8 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ <h2 class="sql-title">
<button type="button" id="btnCopySQL" class="btn btn-xs">Copy All</button>
</div>
</div>
<div class="sql-content" id="sqlContent">
<div class="sql-placeholder" id="sqlPlaceholder">
<span class="placeholder-icon">⬡</span>
<p>SQL queries will appear here as you play.</p>
<p class="placeholder-hint">Each chess move is translated into<br>real SQL statements in real time.</p>
</div>
</div>

<!-- ── SQL Move Input ──────────────────────────────────── -->
<div class="sql-input-section" id="sqlInputSection">
Expand All @@ -117,6 +110,14 @@ <h2 class="sql-title">
<button type="button" id="btnRunSQL" class="btn btn-primary btn-sm">▶ Run</button>
</div>
</div>

<div class="sql-content" id="sqlContent">
<div class="sql-placeholder" id="sqlPlaceholder">
<span class="placeholder-icon">⬡</span>
<p>SQL queries will appear here as you play.</p>
<p class="placeholder-hint">Each chess move is translated into<br>real SQL statements in real time.</p>
</div>
</div>
</section>

</main>
Expand Down
20 changes: 13 additions & 7 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ function fillSQLInputTemplate(sqName, piece) {
state.sqlInputHasTemplate = true;
// Place cursor on the ??? so the user can immediately type the destination
const idx = input.value.indexOf('???');
input.focus();
input.focus({ preventScroll: true });
input.setSelectionRange(idx, idx + 3);
clearSQLRunError();
}
Expand Down Expand Up @@ -876,15 +876,18 @@ function startGame(whiteName, blackName, showSQL, existingPGN) {
clearSQLRunError();

// SQL panel visibility
const sqlPanel = document.getElementById('sqlPanel');
const lblEl = document.getElementById('sqlToggleLabel');
const iconEl = document.getElementById('sqlToggleIcon');
const sqlPanel = document.getElementById('sqlPanel');
const chessPanel = document.getElementById('chessPanel');
const lblEl = document.getElementById('sqlToggleLabel');
const iconEl = document.getElementById('sqlToggleIcon');
if (state.showSQL) {
sqlPanel.classList.remove('hidden-panel');
chessPanel.classList.remove('sql-hidden');
lblEl.textContent = 'Hide SQL';
iconEl.textContent = '◧';
} else {
sqlPanel.classList.add('hidden-panel');
chessPanel.classList.add('sql-hidden');
lblEl.textContent = 'Show SQL';
iconEl.textContent = '□';
}
Expand Down Expand Up @@ -1003,15 +1006,18 @@ function init() {
// Toggle SQL Panel
document.getElementById('btnToggleSQL').addEventListener('click', () => {
state.showSQL = !state.showSQL;
const sqlPanel = document.getElementById('sqlPanel');
const lblEl = document.getElementById('sqlToggleLabel');
const iconEl = document.getElementById('sqlToggleIcon');
const sqlPanel = document.getElementById('sqlPanel');
const chessPanel = document.getElementById('chessPanel');
const lblEl = document.getElementById('sqlToggleLabel');
const iconEl = document.getElementById('sqlToggleIcon');
if (state.showSQL) {
sqlPanel.classList.remove('hidden-panel');
chessPanel.classList.remove('sql-hidden');
lblEl.textContent = 'Hide SQL';
iconEl.textContent = '◧';
} else {
sqlPanel.classList.add('hidden-panel');
chessPanel.classList.add('sql-hidden');
lblEl.textContent = 'Show SQL';
iconEl.textContent = '□';
}
Expand Down
Loading