Skip to content

Commit dba09f8

Browse files
CopilotDevn913
andauthored
redesign right SQL panel: responsive layout, larger query editor, scroll isolation, Playwright tests
Agent-Logs-Url: https://github.com/Devn913/SQL_Chess/sessions/eb41956a-9637-482d-a220-c795c0d325b3 Co-authored-by: Devn913 <56478595+Devn913@users.noreply.github.com>
1 parent a0d451a commit dba09f8

7 files changed

Lines changed: 512 additions & 19 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,40 @@ jobs:
2929
- name: Validate HTML
3030
run: html-validate index.html
3131

32+
# ── Playwright responsive / layout tests ─────────────────────
33+
test:
34+
name: Responsive Layout Tests
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
40+
- name: Setup Node.js
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: '20'
44+
45+
- name: Install dependencies
46+
run: npm ci
47+
48+
- name: Install Playwright browsers
49+
run: npx playwright install chromium --with-deps
50+
51+
- name: Run Playwright tests
52+
run: npx playwright test --reporter=list
53+
54+
- name: Upload Playwright report on failure
55+
if: failure()
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: playwright-report
59+
path: playwright-report/
60+
retention-days: 7
61+
3262
# ── Deploy (only on push to main) ────────────────────────────
3363
deploy:
3464
name: Deploy to GitHub Pages
35-
needs: validate
65+
needs: [validate, test]
3666
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
3767
runs-on: ubuntu-latest
3868

@@ -61,3 +91,4 @@ jobs:
6191
- name: Deploy to GitHub Pages
6292
id: deployment
6393
uses: actions/deploy-pages@v4
94+

css/style.css

Lines changed: 148 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
--chess-panel-padding: 4rem; /* total horizontal padding within chess panel (2 × 1rem + margins) */
1414

15-
/* Board size: fills the 70 % chess panel minus padding, capped at 720 px.
15+
/* Board size: fills the 68 % chess panel minus padding, capped at 720 px.
1616
Also constrained by viewport height (subtracting ~280px for header 56px +
1717
player bars ~80px + controls ~40px + move history ~100px + gaps ~4px). */
18-
--board-sz: clamp(300px, min(calc(70vw - var(--chess-panel-padding) * 2), calc(100vh - 280px)), 720px);
18+
--board-sz: clamp(300px, min(calc(68vw - var(--chess-panel-padding) * 2), calc(100vh - 280px)), 720px);
1919

2020
--text-primary: #e6edf3;
2121
--text-secondary: #8b949e;
@@ -166,8 +166,8 @@ a { color: var(--accent-blue); }
166166
align-items: center;
167167
padding: 1rem;
168168
gap: .6rem;
169-
flex: 0 0 70%;
170-
width: 70%;
169+
flex: 0 0 68%;
170+
width: 68%;
171171
min-width: 0;
172172
overflow-y: auto;
173173
scrollbar-width: thin;
@@ -405,22 +405,25 @@ a { color: var(--accent-blue); }
405405

406406
/* ── SQL Panel ──────────────────────────────────────────────── */
407407
.sql-panel {
408-
flex: 0 0 30%;
409-
width: 30%;
408+
flex: 0 0 32%;
409+
width: 32%;
410+
min-width: 300px;
410411
display: flex;
411412
flex-direction: column;
412413
border-left: 1px solid var(--bg-border);
413414
background: var(--sql-bg);
414415
overflow: hidden;
415-
min-width: 0;
416416
transition: width .25s ease, flex .25s ease, opacity .2s;
417417
}
418418
.sql-panel.hidden-panel {
419419
flex: 0 0 0;
420420
width: 0;
421+
/* Override the base min-width (300 px) so the panel collapses fully */
422+
min-width: 0;
421423
opacity: 0;
422424
pointer-events: none;
423425
border-left: none;
426+
overflow: hidden;
424427
}
425428

426429
.sql-panel-header {
@@ -459,13 +462,16 @@ a { color: var(--accent-blue); }
459462
/* SQL content area */
460463
.sql-content {
461464
flex: 1;
465+
min-height: 0;
462466
overflow-y: auto;
467+
overflow-x: hidden;
463468
padding: .75rem 1rem;
464469
display: flex;
465470
flex-direction: column;
466471
gap: .75rem;
467472
scroll-behavior: smooth;
468473
scrollbar-width: thin;
474+
scrollbar-color: var(--bg-border) transparent;
469475
}
470476

471477
.sql-placeholder {
@@ -782,7 +788,9 @@ input:checked + .slider::before { transform: translateX(18px); }
782788
font-size: .78rem;
783789
line-height: 1.6;
784790
padding: .6rem .75rem;
785-
resize: none;
791+
resize: vertical;
792+
min-height: 7.5rem;
793+
max-height: 20rem;
786794
outline: none;
787795
transition: background .15s;
788796
}
@@ -845,41 +853,164 @@ input:checked + .slider::before { transform: translateX(18px); }
845853
.sql-input-section { display: flex; }
846854
}
847855

856+
/* ── Responsive: Tablet (≤ 1024 px) ────────────────────────── */
857+
@media (max-width: 1024px) {
858+
.sql-panel {
859+
flex: 0 0 36%;
860+
width: 36%;
861+
min-width: 260px;
862+
}
863+
.chess-panel {
864+
flex: 0 0 64%;
865+
width: 64%;
866+
}
867+
:root {
868+
--board-sz: clamp(280px,
869+
min(calc(64vw - var(--chess-panel-padding) * 2), calc(100vh - 280px)),
870+
640px);
871+
}
872+
}
873+
874+
/* ── Responsive: Mobile landscape / narrow (≤ 900 px) ──────── */
848875
@media (max-width: 900px) {
849-
.app-main { flex-direction: column; overflow-y: auto; overflow-x: hidden; }
876+
.app-main {
877+
flex-direction: column;
878+
overflow: hidden;
879+
}
850880

851881
.chess-panel {
852-
flex: none;
882+
flex: 0 0 auto;
853883
width: 100%;
884+
max-height: 58vh;
854885
min-height: auto;
855-
overflow-y: visible;
886+
overflow-y: auto;
887+
scrollbar-width: thin;
856888
}
857889

858890
.sql-panel {
859-
flex: none;
891+
flex: 1 1 auto;
860892
width: 100%;
893+
min-width: 0;
894+
min-height: 40vh;
861895
border-left: none;
862896
border-top: 1px solid var(--bg-border);
863-
height: 45vh;
864-
min-height: 260px;
897+
overflow: hidden;
865898
}
866899
.sql-panel.hidden-panel {
867-
height: 0;
900+
flex: 0 0 0;
868901
min-height: 0;
902+
height: 0;
869903
border-top: none;
904+
overflow: hidden;
905+
}
906+
907+
.sql-move-input {
908+
min-height: 5.5rem;
870909
}
871910

872911
/* Mobile: limit by both viewport width and height to handle short screens */
873912
:root { --board-sz: min(90vw, 440px, calc(55vh)); }
874913
}
875914

915+
/* ── Responsive: Mobile portrait (≤ 600 px) ────────────────── */
916+
@media (max-width: 600px) {
917+
.chess-panel {
918+
max-height: 54vh;
919+
padding: .6rem;
920+
}
921+
922+
.sql-panel {
923+
min-height: 44vh;
924+
}
925+
926+
.sql-move-input {
927+
min-height: 5rem;
928+
font-size: .75rem;
929+
}
930+
931+
.sql-panel-header {
932+
padding: .4rem .75rem;
933+
}
934+
935+
.sql-input-bar {
936+
padding: .45rem .75rem;
937+
}
938+
939+
:root { --board-sz: min(90vw, 380px, calc(50vh)); }
940+
}
941+
942+
/* ── Responsive: Small phone (≤ 480 px) ────────────────────── */
876943
@media (max-width: 480px) {
877944
.app-header { padding: 0 .75rem; }
878945
.header-logo .logo-text { display: none; }
879-
.chess-panel { padding: .5rem; }
946+
.chess-panel { padding: .5rem; gap: .4rem; max-height: 52vh; }
880947
.header-controls { gap: .3rem; }
881948

882-
:root { --board-sz: min(92vw, 360px); }
949+
.sql-panel { min-height: 46vh; }
950+
951+
.sql-move-input { min-height: 4.5rem; }
952+
953+
:root { --board-sz: min(92vw, 340px, calc(48vh)); }
883954

884955
#btnToggleSQL #sqlToggleLabel { display: none; }
885956
}
957+
958+
/* ── Responsive: Wide screens (≥ 1440 px) ──────────────────── */
959+
@media (min-width: 1440px) {
960+
.sql-panel {
961+
flex: 0 0 28%;
962+
width: 28%;
963+
min-width: 340px;
964+
}
965+
.chess-panel {
966+
flex: 0 0 72%;
967+
width: 72%;
968+
}
969+
:root {
970+
--board-sz: clamp(400px,
971+
min(calc(72vw - var(--chess-panel-padding) * 2), calc(100vh - 280px)),
972+
760px);
973+
}
974+
}
975+
976+
/* ── Responsive: Very wide screens (≥ 1920 px) ─────────────── */
977+
@media (min-width: 1920px) {
978+
.sql-panel {
979+
flex: 0 0 26%;
980+
width: 26%;
981+
min-width: 400px;
982+
}
983+
.chess-panel {
984+
flex: 0 0 74%;
985+
width: 74%;
986+
}
987+
.sql-move-input {
988+
min-height: 9rem;
989+
}
990+
}
991+
992+
/* ── Responsive: Short landscape (height < 500 px) ─────────── */
993+
/* e.g. phones in landscape orientation */
994+
@media (max-height: 500px) {
995+
.chess-panel {
996+
max-height: 50vh;
997+
}
998+
.sql-panel {
999+
min-height: 48vh;
1000+
}
1001+
.sql-move-input {
1002+
min-height: 3rem;
1003+
max-height: 6rem;
1004+
}
1005+
.sql-input-bar {
1006+
min-height: 36px;
1007+
padding: .25rem .75rem;
1008+
}
1009+
.sql-input-actions {
1010+
padding: .25rem .5rem;
1011+
}
1012+
.sql-panel-header {
1013+
padding: .35rem .75rem;
1014+
}
1015+
}
1016+

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ <h2 class="sql-title">
101101
id="sqlMoveInput"
102102
class="sql-move-input"
103103
spellcheck="false"
104-
rows="3"
104+
rows="6"
105105
placeholder="UPDATE chess_piece&#10;SET position = 'e4'&#10;WHERE position = 'e2';&#10;&#10;-- or shorthand: e2 e4"></textarea>
106106
<div class="sql-input-actions">
107107
<span class="sql-run-error hidden" id="sqlRunError"></span>

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
22
"dependencies": {
33
"chess.js": "^0.10.3"
4+
},
5+
"devDependencies": {
6+
"@playwright/test": "^1.59.1"
7+
},
8+
"scripts": {
9+
"test": "playwright test",
10+
"test:report": "playwright show-report"
411
}
512
}

playwright.config.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// @ts-check
2+
const { defineConfig, devices } = require('@playwright/test');
3+
const path = require('path');
4+
5+
module.exports = defineConfig({
6+
testDir: './tests',
7+
timeout: 30_000,
8+
retries: 0,
9+
reporter: [['list'], ['html', { open: 'never' }]],
10+
11+
use: {
12+
/* Serve index.html directly via file:// so no server is needed */
13+
baseURL: 'file://' + path.resolve(__dirname, 'index.html'),
14+
headless: true,
15+
screenshot: 'only-on-failure',
16+
video: 'off',
17+
},
18+
19+
projects: [
20+
/* Desktop sizes */
21+
{
22+
name: 'desktop-1920x1080',
23+
use: { ...devices['Desktop Chrome'], viewport: { width: 1920, height: 1080 } },
24+
},
25+
{
26+
name: 'desktop-1440x900',
27+
use: { ...devices['Desktop Chrome'], viewport: { width: 1440, height: 900 } },
28+
},
29+
{
30+
name: 'desktop-1280x800',
31+
use: { ...devices['Desktop Chrome'], viewport: { width: 1280, height: 800 } },
32+
},
33+
/* Tablet sizes */
34+
{
35+
name: 'tablet-1024x768',
36+
use: { ...devices['Desktop Chrome'], viewport: { width: 1024, height: 768 } },
37+
},
38+
{
39+
name: 'tablet-portrait-768x1024',
40+
use: { ...devices['Desktop Chrome'], viewport: { width: 768, height: 1024 } },
41+
},
42+
/* Mobile sizes */
43+
{
44+
name: 'mobile-portrait-390x844',
45+
use: { ...devices['Desktop Chrome'], viewport: { width: 390, height: 844 } },
46+
},
47+
{
48+
name: 'mobile-landscape-844x390',
49+
use: { ...devices['Desktop Chrome'], viewport: { width: 844, height: 390 } },
50+
},
51+
{
52+
name: 'mobile-small-360x640',
53+
use: { ...devices['Desktop Chrome'], viewport: { width: 360, height: 640 } },
54+
},
55+
/* Ultrawide */
56+
{
57+
name: 'ultrawide-2560x1080',
58+
use: { ...devices['Desktop Chrome'], viewport: { width: 2560, height: 1080 } },
59+
},
60+
],
61+
});

test-results/.last-run.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"status": "passed",
3+
"failedTests": []
4+
}

0 commit comments

Comments
 (0)