Skip to content

Commit cca07be

Browse files
committed
Add coordinate toggle feature and enhance UI
- Added a toggle switch in index.html to show/hide board coordinates. - Updated CSS for improved styling of the chessboard and pieces, including animations for moves and last moves. - Enhanced game.js and board.js to support visual updates for last moves and piece movement animations. - Updated README.md with new repository link and minor adjustments.
1 parent 7484ed6 commit cca07be

File tree

8 files changed

+444
-78
lines changed

8 files changed

+444
-78
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ It is designed to be simple, lightweight, and easily deployable on static hostin
2727

2828
1. **Clone the repository:**
2929
```bash
30-
git clone https://github.com/your-username/Static_Chess.git
30+
git clone https://github.com/TMHSDigital/Static_Chess.git
3131
cd Static_Chess
3232
```
3333
2. **Open `index.html`:** Simply open the `index.html` file in your web browser.
@@ -77,7 +77,7 @@ Since this is a purely static website (HTML, CSS, JS files only), it can be easi
7777
5. Choose the branch you want to deploy from (e.g., `main` or `master`).
7878
6. Ensure the folder is set to `/ (root)`.
7979
7. Click "Save".
80-
8. GitHub will build and deploy your site. The URL will be displayed in the Pages settings (usually `https://your-username.github.io/repository-name/`). It might take a minute or two for the site to become live.
80+
8. GitHub will build and deploy your site. The URL will be displayed in the Pages settings (usually `https://tmhsdigital.github.io/Static_Chess/`). It might take a minute or two for the site to become live.
8181
8282
## Potential Future Enhancements (Bonus Features)
8383

css/board.css

Lines changed: 80 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,59 @@
44
display: grid;
55
grid-template-columns: repeat(8, 1fr);
66
grid-template-rows: repeat(8, 1fr);
7-
border: 1px solid #000;
8-
box-shadow: 0 5px 15px rgba(0,0,0,0.5);
7+
border: 2px solid #111;
8+
box-shadow: 0 8px 24px rgba(0,0,0,0.5);
9+
position: relative;
910
}
1011

12+
/* Add board coordinates */
13+
.chess-board::before,
14+
.chess-board::after,
15+
.square::before,
16+
.square::after {
17+
position: absolute;
18+
color: rgba(255, 255, 255, 0.7);
19+
font-size: 0.8rem;
20+
z-index: 2;
21+
pointer-events: none;
22+
}
23+
24+
/* File coordinates (a-h) */
25+
.square[data-col="0"]::before {
26+
content: 'a';
27+
bottom: 2px;
28+
left: 2px;
29+
display: var(--show-coords, none);
30+
}
31+
.square[data-col="1"]::before { content: 'b'; bottom: 2px; left: 2px; display: var(--show-coords, none); }
32+
.square[data-col="2"]::before { content: 'c'; bottom: 2px; left: 2px; display: var(--show-coords, none); }
33+
.square[data-col="3"]::before { content: 'd'; bottom: 2px; left: 2px; display: var(--show-coords, none); }
34+
.square[data-col="4"]::before { content: 'e'; bottom: 2px; left: 2px; display: var(--show-coords, none); }
35+
.square[data-col="5"]::before { content: 'f'; bottom: 2px; left: 2px; display: var(--show-coords, none); }
36+
.square[data-col="6"]::before { content: 'g'; bottom: 2px; left: 2px; display: var(--show-coords, none); }
37+
.square[data-col="7"]::before { content: 'h'; bottom: 2px; left: 2px; display: var(--show-coords, none); }
38+
39+
/* Rank coordinates (1-8) */
40+
.square[data-row="7"][data-col="7"]::after { content: '1'; top: 2px; right: 2px; display: var(--show-coords, none); }
41+
.square[data-row="6"][data-col="7"]::after { content: '2'; top: 2px; right: 2px; display: var(--show-coords, none); }
42+
.square[data-row="5"][data-col="7"]::after { content: '3'; top: 2px; right: 2px; display: var(--show-coords, none); }
43+
.square[data-row="4"][data-col="7"]::after { content: '4'; top: 2px; right: 2px; display: var(--show-coords, none); }
44+
.square[data-row="3"][data-col="7"]::after { content: '5'; top: 2px; right: 2px; display: var(--show-coords, none); }
45+
.square[data-row="2"][data-col="7"]::after { content: '6'; top: 2px; right: 2px; display: var(--show-coords, none); }
46+
.square[data-row="1"][data-col="7"]::after { content: '7'; top: 2px; right: 2px; display: var(--show-coords, none); }
47+
.square[data-row="0"][data-col="7"]::after { content: '8'; top: 2px; right: 2px; display: var(--show-coords, none); }
48+
1149
.square {
1250
display: flex;
1351
justify-content: center;
1452
align-items: center;
15-
position: relative; /* For positioning highlights/markers */
53+
position: relative;
54+
cursor: pointer;
55+
transition: all 0.15s ease;
56+
}
57+
58+
.square:hover {
59+
filter: brightness(1.1);
1660
}
1761

1862
.square.light {
@@ -25,9 +69,8 @@
2569

2670
.square.selected {
2771
background-color: var(--selected-square);
28-
/* Or use an outline/border */
29-
/* outline: 3px solid yellow; */
30-
/* outline-offset: -3px; */
72+
box-shadow: inset 0 0 20px rgba(255, 217, 0, 0.3);
73+
z-index: 1;
3174
}
3275

3376
.square.possible-move::after {
@@ -37,10 +80,40 @@
3780
height: 30%;
3881
background-color: var(--possible-move-square);
3982
border-radius: 50%;
40-
pointer-events: none; /* Allows clicking through the marker */
83+
pointer-events: none;
84+
animation: pulse 1.5s infinite;
85+
}
86+
87+
@keyframes pulse {
88+
0% { transform: scale(0.9); opacity: 0.7; }
89+
50% { transform: scale(1.1); opacity: 1; }
90+
100% { transform: scale(0.9); opacity: 0.7; }
91+
}
92+
93+
.square.possible-move.light::after {
94+
box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
95+
}
96+
97+
.square.possible-move.dark::after {
98+
box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
4199
}
42100

43101
/* Highlight for the king in check */
44102
.square.in-check {
45103
background-color: var(--check-square);
104+
animation: check-pulse 1s ease infinite alternate;
105+
}
106+
107+
@keyframes check-pulse {
108+
from { box-shadow: inset 0 0 5px rgba(255, 0, 0, 0.5); }
109+
to { box-shadow: inset 0 0 20px rgba(255, 0, 0, 0.8); }
110+
}
111+
112+
/* Last move indication */
113+
.square.last-move-from {
114+
background-color: rgba(173, 216, 230, 0.3);
115+
}
116+
117+
.square.last-move-to {
118+
background-color: rgba(173, 216, 230, 0.5);
46119
}

css/pieces.css

Lines changed: 105 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,128 @@
11
.piece {
2-
font-size: calc(var(--board-size) / 10); /* Adjust size relative to board */
2+
font-size: calc(var(--board-size) / 9);
33
cursor: grab;
4-
user-select: none; /* Prevent text selection */
5-
text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
4+
user-select: none;
5+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
6+
height: 80%;
7+
width: 80%;
8+
display: flex;
9+
justify-content: center;
10+
align-items: center;
11+
transition: transform 0.2s ease;
12+
position: relative;
13+
}
14+
15+
.piece:hover {
16+
transform: scale(1.1);
17+
}
18+
19+
.piece:active {
20+
cursor: grabbing;
21+
transform: scale(1.15);
622
}
723

824
.piece.dragging {
925
cursor: grabbing;
10-
opacity: 0.7;
26+
opacity: 0.8;
27+
z-index: 100;
1128
}
1229

13-
/* === Placeholder Unicode Pieces === */
14-
/* Replace these with background-image rules targeting your SVGs */
30+
/* === Enhanced Unicode Pieces === */
1531

1632
/* White Pieces */
17-
.piece.w.p::before { content: '\2659'; } /* White Pawn */
18-
.piece.w.r::before { content: '\2656'; } /* White Rook */
19-
.piece.w.n::before { content: '\2658'; } /* White Knight */
20-
.piece.w.b::before { content: '\2657'; } /* White Bishop */
21-
.piece.w.q::before { content: '\2655'; } /* White Queen */
22-
.piece.w.k::before { content: '\2654'; } /* White King */
33+
.piece.w.p::before {
34+
content: '\2659';
35+
color: #fff;
36+
filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.5));
37+
}
38+
.piece.w.r::before {
39+
content: '\2656';
40+
color: #fff;
41+
filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.5));
42+
}
43+
.piece.w.n::before {
44+
content: '\2658';
45+
color: #fff;
46+
filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.5));
47+
}
48+
.piece.w.b::before {
49+
content: '\2657';
50+
color: #fff;
51+
filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.5));
52+
}
53+
.piece.w.q::before {
54+
content: '\2655';
55+
color: #fff;
56+
filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.5));
57+
}
58+
.piece.w.k::before {
59+
content: '\2654';
60+
color: #fff;
61+
filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.5));
62+
}
2363

2464
/* Black Pieces */
25-
.piece.b.p::before { content: '\265F'; } /* Black Pawn */
26-
.piece.b.r::before { content: '\265C'; } /* Black Rook */
27-
.piece.b.n::before { content: '\265E'; } /* Black Knight */
28-
.piece.b.b::before { content: '\265D'; } /* Black Bishop */
29-
.piece.b.q::before { content: '\265B'; } /* Black Queen */
30-
.piece.b.k::before { content: '\265A'; } /* Black King */
31-
32-
/* Example for SVG (assuming you have assets/wp.svg etc.) */
65+
.piece.b.p::before {
66+
content: '\265F';
67+
color: #000;
68+
text-shadow: 0 0 2px rgba(255,255,255,0.8);
69+
}
70+
.piece.b.r::before {
71+
content: '\265C';
72+
color: #000;
73+
text-shadow: 0 0 2px rgba(255,255,255,0.8);
74+
}
75+
.piece.b.n::before {
76+
content: '\265E';
77+
color: #000;
78+
text-shadow: 0 0 2px rgba(255,255,255,0.8);
79+
}
80+
.piece.b.b::before {
81+
content: '\265D';
82+
color: #000;
83+
text-shadow: 0 0 2px rgba(255,255,255,0.8);
84+
}
85+
.piece.b.q::before {
86+
content: '\265B';
87+
color: #000;
88+
text-shadow: 0 0 2px rgba(255,255,255,0.8);
89+
}
90+
.piece.b.k::before {
91+
content: '\265A';
92+
color: #000;
93+
text-shadow: 0 0 2px rgba(255,255,255,0.8);
94+
}
95+
96+
/* Move animations */
97+
@keyframes move-piece {
98+
0% { transform: scale(1); }
99+
50% { transform: scale(1.2); }
100+
100% { transform: scale(1); }
101+
}
102+
103+
.piece.moved {
104+
animation: move-piece 0.3s ease;
105+
}
106+
107+
/* Optional: CSS for SVG pieces (uncomment and add SVGs to the assets folder) */
108+
/*
109+
.piece::before {
110+
display: none; /* Hide Unicode when using SVG */
33111
/*
112+
}
113+
34114
.piece.w.p {
35115
background-image: url('../assets/wp.svg');
36116
background-size: contain;
37117
background-repeat: no-repeat;
38-
width: 80%;
39-
height: 80%;
118+
background-position: center;
40119
}
120+
41121
.piece.b.p {
42122
background-image: url('../assets/bp.svg');
43123
background-size: contain;
44124
background-repeat: no-repeat;
45-
width: 80%;
46-
height: 80%;
125+
background-position: center;
47126
}
48-
Add similar rules for other pieces
49-
*/
127+
128+
/* Add other pieces similarly */

0 commit comments

Comments
 (0)