mirror of
https://github.com/danbee/chess
synced 2025-03-04 08:39:06 +00:00
Clean up moves display
This commit is contained in:
parent
950e7a86f1
commit
6243259d27
@ -1,13 +1,3 @@
|
|||||||
:root {
|
|
||||||
--board-size: 90vmin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-aspect-ratio: 10/11) {
|
|
||||||
:root {
|
|
||||||
--board-size: 80vmin;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@mixin move-indicator {
|
@mixin move-indicator {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
content: "";
|
content: "";
|
||||||
@ -25,6 +15,7 @@
|
|||||||
border-spacing: 1px;
|
border-spacing: 1px;
|
||||||
box-shadow: 0 calc(var(--board-size) / 200) calc(var(--board-size) / 40) $board-shadow-color;
|
box-shadow: 0 calc(var(--board-size) / 200) calc(var(--board-size) / 40) $board-shadow-color;
|
||||||
color: $white-square-color;
|
color: $white-square-color;
|
||||||
|
grid-area: board;
|
||||||
height: var(--board-size);
|
height: var(--board-size);
|
||||||
padding: calc(var(--board-size) / 20);
|
padding: calc(var(--board-size) / 20);
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|||||||
7
assets/css/_game_grid.scss
Normal file
7
assets/css/_game_grid.scss
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.game-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-gap: $base-spacing;
|
||||||
|
grid-template-areas: "board moves";
|
||||||
|
grid-template-columns: min-content 1fr;
|
||||||
|
grid-template-rows: var(--board-size);
|
||||||
|
}
|
||||||
@ -6,6 +6,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.your-turn {
|
.your-turn {
|
||||||
font-weight: bold;
|
|
||||||
background-color: $your-turn-background-color;
|
background-color: $your-turn-background-color;
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|||||||
6
assets/css/_headings.scss
Normal file
6
assets/css/_headings.scss
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.heading {
|
||||||
|
font-family: $heading-font-family;
|
||||||
|
font-size: modular-scale(1);
|
||||||
|
line-height: $heading-line-height;
|
||||||
|
margin: 0 0 $small-spacing;
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
html {
|
html {
|
||||||
background: $background-color;
|
background: $background-color;
|
||||||
color: mix($background-color, $foreground-color, 20%);
|
color: mix($background-color, $foreground-color, 20%);
|
||||||
|
font-weight: 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
@ -11,7 +12,6 @@ h1,
|
|||||||
h2,
|
h2,
|
||||||
h3,
|
h3,
|
||||||
h4 {
|
h4 {
|
||||||
font-variant: small-caps;
|
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
assets/css/_move_list.scss
Normal file
16
assets/css/_move_list.scss
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
.move-list {
|
||||||
|
grid-area: moves;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.move-list__line-number {
|
||||||
|
color: mix($background-color, $foreground-color);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
font-feature-settings: "tnum";
|
||||||
|
}
|
||||||
|
|
||||||
|
.move-list__header--white,
|
||||||
|
.move-list__move--white,
|
||||||
|
.move-list__line-number {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
16
assets/css/_tables.scss
Normal file
16
assets/css/_tables.scss
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
.table--condensed {
|
||||||
|
width: auto;
|
||||||
|
|
||||||
|
caption {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr {
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
padding: 0 $base-spacing 0 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
3
assets/css/_utilities.scss
Normal file
3
assets/css/_utilities.scss
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.visually-hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
@ -28,3 +28,14 @@ $available-outline-color: rgba(lighten($available-square-color, 20%), 0.5);
|
|||||||
|
|
||||||
$colours: "black" "white";
|
$colours: "black" "white";
|
||||||
$pieces: king queen bishop knight rook pawn;
|
$pieces: king queen bishop knight rook pawn;
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--board-size: 90vmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-aspect-ratio: 10/11) {
|
||||||
|
:root {
|
||||||
|
--board-size: 80vmin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,18 @@
|
|||||||
@import "bourbon/bourbon";
|
@import "bourbon/bourbon";
|
||||||
@import "base/base";
|
|
||||||
@import "vendor/family";
|
@import "vendor/family";
|
||||||
|
@import "base/base";
|
||||||
|
|
||||||
@import "variables";
|
@import "variables";
|
||||||
|
|
||||||
|
@import "utilities";
|
||||||
|
|
||||||
|
@import "tables";
|
||||||
|
@import "headings";
|
||||||
|
|
||||||
@import "layout";
|
@import "layout";
|
||||||
@import "nav";
|
@import "nav";
|
||||||
|
|
||||||
@import "game_list";
|
@import "game_list";
|
||||||
@import "board";
|
@import "board";
|
||||||
|
@import "move_list";
|
||||||
|
@import "game_grid";
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
table {
|
table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
margin: $base-spacing 0;
|
|
||||||
table-layout: fixed;
|
table-layout: fixed;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class App extends React.Component {
|
|||||||
const { store, gameId } = this.props;
|
const { store, gameId } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="game-grid">
|
||||||
<ChessBoard
|
<ChessBoard
|
||||||
gameId={gameId}
|
gameId={gameId}
|
||||||
store={store}
|
store={store}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
import classNames from "classnames";
|
||||||
|
|
||||||
const pieceToNotation = (piece) => {
|
const pieceToNotation = (piece) => {
|
||||||
const pieces = {
|
const pieces = {
|
||||||
@ -15,10 +16,14 @@ const pieceToNotation = (piece) => {
|
|||||||
return pieces[piece.type];
|
return pieces[piece.type];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const moveClass = (move) => {
|
||||||
|
return classNames("move-list__move", "move-list__move--" + move.piece.colour);
|
||||||
|
}
|
||||||
|
|
||||||
const renderMove = (move) => {
|
const renderMove = (move) => {
|
||||||
if (move != undefined) {
|
if (move != undefined) {
|
||||||
return (
|
return (
|
||||||
<td className="move">
|
<td className={moveClass(move)}>
|
||||||
{pieceToNotation(move.piece)}
|
{pieceToNotation(move.piece)}
|
||||||
{move.piece_captured ? "x" : ""}
|
{move.piece_captured ? "x" : ""}
|
||||||
{move.to}
|
{move.to}
|
||||||
@ -28,9 +33,12 @@ const renderMove = (move) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const renderMoves = (moves) => {
|
const renderMoves = (moves) => {
|
||||||
|
let lineNumber = 1;
|
||||||
|
|
||||||
return _.map(moves, (move) => {
|
return _.map(moves, (move) => {
|
||||||
return (
|
return (
|
||||||
<tr key={move[0].id}>
|
<tr key={move[0].id}>
|
||||||
|
<th scope="row" className="move-list__line-number">{lineNumber++}.</th>
|
||||||
{renderMove(move[0])}
|
{renderMove(move[0])}
|
||||||
{renderMove(move[1])}
|
{renderMove(move[1])}
|
||||||
</tr>
|
</tr>
|
||||||
@ -40,17 +48,26 @@ const renderMoves = (moves) => {
|
|||||||
|
|
||||||
const MoveList = (props) => {
|
const MoveList = (props) => {
|
||||||
return (
|
return (
|
||||||
<table className="move-list">
|
<div className="move-list">
|
||||||
|
<table className="table table--condensed">
|
||||||
|
<caption className="heading">Moves</caption>
|
||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>White</th>
|
<th className="move-list__line-number">
|
||||||
<th>Black</th>
|
<span className="visually-hidden">Move no.</span>
|
||||||
|
</th>
|
||||||
|
|
||||||
|
<th className="move-list__header--white">White</th>
|
||||||
|
<th className="move-list__header--black">Black</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
{renderMoves(props.moves)}
|
{renderMoves(props.moves)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<h2><%= gettext "Listing games" %></h2>
|
<h2><%= gettext "Listing games" %></h2>
|
||||||
|
|
||||||
<table class="table">
|
<table class="table table--games-list">
|
||||||
<tbody>
|
<tbody>
|
||||||
<%= for game <- @games do %>
|
<%= for game <- @games do %>
|
||||||
<tr class="<%= turn_class(@conn, game) %>">
|
<tr class="<%= turn_class(@conn, game) %>">
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
<p><%= link gettext("Back to games"), to: game_path(@conn, :index) %></p>
|
|
||||||
|
|
||||||
<h2><%= gettext "Game with %{name}", name: opponent(@conn, @game).name %></h2>
|
<h2><%= gettext "Game with %{name}", name: opponent(@conn, @game).name %></h2>
|
||||||
|
|
||||||
<div id="app" data-game-id="<%= @game.id %>">
|
<div id="app" data-game-id="<%= @game.id %>">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user