Skip to content

Commit c59d4e9

Browse files
CopilotDevn913
andauthored
feat: UI improvements - fix scroll on click, move execute query up, 70/25 layout
Agent-Logs-Url: https://github.com/Devn913/SQL_Chess/sessions/7d3e44cc-57ba-4831-bcfb-922e5b045efe Co-authored-by: Devn913 <56478595+Devn913@users.noreply.github.com>
1 parent 320374f commit c59d4e9

3 files changed

Lines changed: 47 additions & 19 deletions

File tree

css/style.css

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
--bg-elevated: #21262d;
1111
--bg-border: #30363d;
1212

13-
/* Board size: at least 50 % of viewport width, capped at 760 px */
14-
--board-sz: clamp(320px, 50vw, 760px);
13+
--chess-panel-padding: 4rem; /* total horizontal padding within chess panel (2 × 1rem + margins) */
14+
15+
/* Board size: fills the 70 % chess panel minus padding, capped at 760 px */
16+
--board-sz: clamp(320px, calc(70vw - var(--chess-panel-padding) * 2), 760px);
1517

1618
--text-primary: #e6edf3;
1719
--text-secondary: #8b949e;
@@ -161,9 +163,19 @@ a { color: var(--accent-blue); }
161163
align-items: center;
162164
padding: 1rem;
163165
gap: .6rem;
164-
flex-shrink: 0;
166+
flex: 0 0 70%;
167+
width: 70%;
165168
min-width: 0;
166169
overflow-y: auto;
170+
justify-content: center;
171+
}
172+
173+
/* When SQL panel is hidden, chess panel fills the available space */
174+
/* .sql-hidden is set by JS as a fallback for browsers without :has() support */
175+
.chess-panel.sql-hidden,
176+
.chess-panel:has(~ .sql-panel.hidden-panel) {
177+
flex: 1;
178+
width: 100%;
167179
}
168180

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

390402
/* ── SQL Panel ──────────────────────────────────────────────── */
391403
.sql-panel {
392-
flex: 1;
404+
flex: 0 0 25%;
405+
width: 25%;
393406
display: flex;
394407
flex-direction: column;
395408
border-left: 1px solid var(--bg-border);
@@ -399,7 +412,7 @@ a { color: var(--accent-blue); }
399412
transition: width .25s ease, flex .25s ease, opacity .2s;
400413
}
401414
.sql-panel.hidden-panel {
402-
flex: 0;
415+
flex: 0 0 0;
403416
width: 0;
404417
opacity: 0;
405418
pointer-events: none;
@@ -829,7 +842,15 @@ input:checked + .slider::before { transform: translateX(18px); }
829842
@media (max-width: 900px) {
830843
.app-main { flex-direction: column; }
831844

845+
.chess-panel {
846+
flex: none;
847+
width: 100%;
848+
justify-content: flex-start;
849+
}
850+
832851
.sql-panel {
852+
flex: none;
853+
width: 100%;
833854
border-left: none;
834855
border-top: 1px solid var(--bg-border);
835856
max-height: 40vh;

index.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@ <h2 class="sql-title">
9090
<button type="button" id="btnCopySQL" class="btn btn-xs">Copy All</button>
9191
</div>
9292
</div>
93-
<div class="sql-content" id="sqlContent">
94-
<div class="sql-placeholder" id="sqlPlaceholder">
95-
<span class="placeholder-icon"></span>
96-
<p>SQL queries will appear here as you play.</p>
97-
<p class="placeholder-hint">Each chess move is translated into<br>real SQL statements in real time.</p>
98-
</div>
99-
</div>
10093

10194
<!-- ── SQL Move Input ──────────────────────────────────── -->
10295
<div class="sql-input-section" id="sqlInputSection">
@@ -117,6 +110,14 @@ <h2 class="sql-title">
117110
<button type="button" id="btnRunSQL" class="btn btn-primary btn-sm">▶ Run</button>
118111
</div>
119112
</div>
113+
114+
<div class="sql-content" id="sqlContent">
115+
<div class="sql-placeholder" id="sqlPlaceholder">
116+
<span class="placeholder-icon"></span>
117+
<p>SQL queries will appear here as you play.</p>
118+
<p class="placeholder-hint">Each chess move is translated into<br>real SQL statements in real time.</p>
119+
</div>
120+
</div>
120121
</section>
121122

122123
</main>

js/app.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ function fillSQLInputTemplate(sqName, piece) {
292292
state.sqlInputHasTemplate = true;
293293
// Place cursor on the ??? so the user can immediately type the destination
294294
const idx = input.value.indexOf('???');
295-
input.focus();
295+
input.focus({ preventScroll: true });
296296
input.setSelectionRange(idx, idx + 3);
297297
clearSQLRunError();
298298
}
@@ -876,15 +876,18 @@ function startGame(whiteName, blackName, showSQL, existingPGN) {
876876
clearSQLRunError();
877877

878878
// SQL panel visibility
879-
const sqlPanel = document.getElementById('sqlPanel');
880-
const lblEl = document.getElementById('sqlToggleLabel');
881-
const iconEl = document.getElementById('sqlToggleIcon');
879+
const sqlPanel = document.getElementById('sqlPanel');
880+
const chessPanel = document.getElementById('chessPanel');
881+
const lblEl = document.getElementById('sqlToggleLabel');
882+
const iconEl = document.getElementById('sqlToggleIcon');
882883
if (state.showSQL) {
883884
sqlPanel.classList.remove('hidden-panel');
885+
chessPanel.classList.remove('sql-hidden');
884886
lblEl.textContent = 'Hide SQL';
885887
iconEl.textContent = '◧';
886888
} else {
887889
sqlPanel.classList.add('hidden-panel');
890+
chessPanel.classList.add('sql-hidden');
888891
lblEl.textContent = 'Show SQL';
889892
iconEl.textContent = '□';
890893
}
@@ -1003,15 +1006,18 @@ function init() {
10031006
// Toggle SQL Panel
10041007
document.getElementById('btnToggleSQL').addEventListener('click', () => {
10051008
state.showSQL = !state.showSQL;
1006-
const sqlPanel = document.getElementById('sqlPanel');
1007-
const lblEl = document.getElementById('sqlToggleLabel');
1008-
const iconEl = document.getElementById('sqlToggleIcon');
1009+
const sqlPanel = document.getElementById('sqlPanel');
1010+
const chessPanel = document.getElementById('chessPanel');
1011+
const lblEl = document.getElementById('sqlToggleLabel');
1012+
const iconEl = document.getElementById('sqlToggleIcon');
10091013
if (state.showSQL) {
10101014
sqlPanel.classList.remove('hidden-panel');
1015+
chessPanel.classList.remove('sql-hidden');
10111016
lblEl.textContent = 'Hide SQL';
10121017
iconEl.textContent = '◧';
10131018
} else {
10141019
sqlPanel.classList.add('hidden-panel');
1020+
chessPanel.classList.add('sql-hidden');
10151021
lblEl.textContent = 'Show SQL';
10161022
iconEl.textContent = '□';
10171023
}

0 commit comments

Comments
 (0)