-
Notifications
You must be signed in to change notification settings - Fork 0
/
chessboard.css
326 lines (278 loc) · 8.24 KB
/
chessboard.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
/**
* CSS codes of Chessboard.
* @see For more information, check file: src\Chess\Board\Chessboard.ts
*/
:root{
/**
* All sizes are will be calculated based on the board size.
* For example, if the board size is 800px, the square size will be 100px(1/8 of the board size),
* font size will be 16px(1/50 of the board size), and the piece size will be 80px(1/10 of the board size).
*/
--board-size: 70vh;
/* Colors */
--white-square-color: #859884;
--white-coordinate-color: #a2b9a1;
--black-square-color: #667c67;
--black-coordinate-color: #637263;
--square-shadow-color: none;
--clicked-color: #000;
/* Promotion Menu */
--promotion-option-color: #D3D3D3;
--promotion-option-hover-color: #808080;
/* Result Screen */
--result-screen-bg-color: #111111;
--result-screen-border-color: #2a2a2a;
--result-screen-color: #fff;
/* Effects */
--playable-color: #57CE92;
--killable-color: #57CE92;
--checked-color: #DF3030;
--disabled-color: #000;
--selected-color: rgba(87, 206, 146, 0.25);
--from-color: rgba(69, 201, 255, 0.39);
--to-color: rgba(69, 201, 255, 0.39);
/* White Pieces */
--white-pawn-image: url("../images/pawn_white.png");
--white-rook-image: url("../images/rook_white.png");
--white-knight-image: url("../images/knight_white.png");
--white-bishop-image: url("../images/bishop_white.png");
--white-queen-image: url("../images/queen_white.png");
--white-king-image: url("../images/king_white.png");
/* Black Pieces */
--black-pawn-image: url("../images/pawn_black.png");
--black-rook-image: url("../images/rook_black.png");
--black-knight-image: url("../images/knight_black.png");
--black-bishop-image: url("../images/bishop_black.png");
--black-queen-image: url("../images/queen_black.png");
--black-king-image: url("../images/king_black.png");
/* For animation of piece movement */
--move-from-left: 0;
--move-from-top: 0;
--move-to-left: 0;
--move-to-top: 0;
}
/* -------------- Chessboard -------------- */
#chessboard {
width: var(--board-size);
height: var(--board-size);
min-width: var(--board-size);
min-height: var(--board-size);
border:1px solid black;
display:flex;
flex-wrap: wrap;
cursor: pointer!important;
-webkit-tap-highlight-color: transparent;
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
position:relative;
}
/* -------------- Promotion Menu -------------- */
#chessboard {
& .promotion-option{
z-index:999!important;
position:inherit;
background-color: var(--promotion-option-color);
border-radius: 50%;
margin-left:0;
&:hover{
background-color: var(--promotion-option-hover-color);
}
}
}
/* -------------- Board Styles -------------- */
#chessboard {
/* Individual square styles */
& .square{
position: relative;
width:calc(var(--board-size) / 8);
height:calc(var(--board-size) / 8);
box-shadow: inset 0 0 0 1px var(--square-shadow-color);
text-align: center;
margin:0!important;
}
/* Black squares */
& .square--black{
background-color:var(--black-square-color);
}
/* White squares */
& .square--white{
background-color:var(--white-square-color);
}
/* Row coordinates display styles */
& .row-coordinate{
position:absolute;
right:0;
margin-right:0.4vw;
font-size:calc(var(--board-size) / 50);
margin-top:0.3vw;
font-weight: bold;
}
/* Row coordinates that on black squares */
& .row-coordinate--black{
color:var(--white-coordinate-color);
}
/* Row coordinates that on white squares */
& .row-coordinate--white{
color:var(--black-coordinate-color);
}
/* Column coordinates display styles */
& .column-coordinate{
position:absolute;
bottom:0;
font-size:calc(var(--board-size) / 50);
margin-left:0.4vw;
margin-bottom:0.2vw;
font-weight: bold;
}
/* Column coordinates that on black squares */
& .column-coordinate--black{
color:var(--white-coordinate-color);
}
/* Column coordinates that on white squares */
& .column-coordinate--white{
color:var(--black-coordinate-color);
}
}
/* -------------- Piece Styles -------------- */
/* Generic piece style */
.piece{
background-position: center;
background-size:cover;
background-repeat: no-repeat;
width:calc(var(--board-size) / 9);
height:calc(var(--board-size) / 10);
position: absolute;
z-index:99;
left:5%;
top:10%;
&.dragging {
opacity: 0.5;
}
}
/* Animation for piece movement, don't change this */
@keyframes move{
0% {
left:var(--move-from-left);
top:var(--move-from-top);
}
100% {
left:var(--move-to-left);
top:var(--move-to-top);
}
}
/* White pieces */
[data-piece="Rook"][data-color="White"]{
background-image:var(--white-rook-image);
}
[data-piece="Knight"][data-color="White"]{
background-image:var(--white-knight-image);
}
[data-piece="Bishop"][data-color="White"]{
background-image:var(--white-bishop-image);
}
[data-piece="Queen"][data-color="White"]{
background-image:var(--white-queen-image);
}
[data-piece="King"][data-color="White"]{
background-image:var(--white-king-image);
}
[data-piece="Pawn"][data-color="White"]{
background-image:var(--white-pawn-image);
}
/* Black pieces */
[data-piece="Rook"][data-color="Black"]{
background-image:var(--black-rook-image);
}
[data-piece="Knight"][data-color="Black"]{
background-image:var(--black-knight-image);
}
[data-piece="Bishop"][data-color="Black"]{
background-image:var(--black-bishop-image);
}
[data-piece="Queen"][data-color="Black"]{
background-image:var(--black-queen-image);
}
[data-piece="King"][data-color="Black"]{
background-image:var(--black-king-image);
}
[data-piece="Pawn"][data-color="Black"]{
background-image:var(--black-pawn-image);
}
/* -------------- Effects Styles -------------- */
#chessboard {
/* Clicked square effect */
& .square-effect--clicked{
box-shadow:inset 0 0 15px var(--clicked-color)!important;
}
/* Playable square effect */
& .square-effect--playable{
box-shadow:inset 0 0 15px var(--playable-color)!important;
}
/* Killable square effect */
& .square-effect--killable{
box-shadow:inset 0 0 15px var(--killable-color)!important;
}
/* Checked square effect */
& .square-effect--checked{
box-shadow:inset 0 0 15px var(--checked-color)!important;
}
/* Selected square effect */
& .square-effect--selected{
box-shadow:inset 0 0 100px var(--selected-color)!important;
}
/* Disabled square effect */
& .square-effect--disabled{
box-shadow:inset 0 0 100px var(--disabled-color)!important;
}
/* Move from effect */
& .square-effect--from{
box-shadow:inset 0 0 100px var(--from-color);
}
/* Move to effect */
& .square-effect--to{
box-shadow:inset 0 0 100px var(--to-color);
}
/* Opacity for disabled pieces */
& .square-effect--disabled div.piece{
opacity: 0.4;
}
/* Opacity for disabled elements other than pieces */
& .square-effect--disabled span{
opacity: 0.2;
}
}
/* -------------- Result Message -------------- */
.result-message{
box-shadow: 0 0 5px #000;
padding-top:60px;
background-color: var(--result-screen-bg-color);
color: var(--result-screen-color);
font-size: 30px;
font-weight: bold;
width: 250px;
height:100px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
border:1px solid var(--result-screen-border-color);
z-index:9999!important;
}
/**
* ------------------ Responsive -------------------
* 700px - 900px - 1250px
*/
@media screen and (max-width: 900px) {
:root{
--board-size: calc(100vw - 5rem);
}
}
@media screen and (max-width: 700px) {
:root{
--board-size: calc(100vw - 1.1rem);
}
}