Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
fdd77e3
init
BSmick6 May 4, 2024
713afe1
create toggle and necessary props for ctrl obj
BSmick6 May 4, 2024
8e60c25
i18n and more config
BSmick6 May 4, 2024
683f4e3
comment out errors for now
BSmick6 May 4, 2024
6daa322
Merge branch 'master' into opt-coords-every-sq
ornicar May 5, 2024
e2de3ac
Merge branch 'master' into opt-coords-every-sq
ornicar May 6, 2024
dfb3985
Merge branch 'master' into opt-coords-every-sq
ornicar May 6, 2024
d1ac4ef
upgrade to chessground 9.1.1 to get coordinatesOnSquares
ornicar May 6, 2024
fd194cb
fix chessground setting name
ornicar May 6, 2024
bf6479b
Merge branch 'opt-coords-every-sq' of https://github.com/BSmick6/lila…
ornicar May 6, 2024
d19f50c
Merge branch 'master' into opt-coords-every-sq
BSmick6 May 6, 2024
61cddb9
minor text update
BSmick6 May 6, 2024
fac1607
disable when show coordinates is disabled
BSmick6 May 6, 2024
dc4a887
Merge branch 'master' into opt-coords-every-sq
BSmick6 May 6, 2024
53b6950
prettified
BSmick6 May 6, 2024
c80a720
Merge branch 'master' into opt-coords-every-sq
BSmick6 May 6, 2024
5431ef1
Merge branch 'master' into opt-coords-every-sq
BSmick6 May 7, 2024
65b293d
hard coded style fix
BSmick6 May 7, 2024
2cc3ff9
Merge branch 'master' into opt-coords-every-sq
BSmick6 May 8, 2024
f959c7b
pnpm fix
BSmick6 May 8, 2024
f6fa9c9
major css fixes
BSmick6 May 8, 2024
e7caf99
move coord text color css to proper file
BSmick6 May 9, 2024
b2107e3
clarify white orientation ranks
BSmick6 May 9, 2024
9f74fd7
cleaner css
BSmick6 May 9, 2024
2f2236e
Merge branch 'master' into opt-coords-every-sq
BSmick6 May 9, 2024
33e7393
align new css with old code
BSmick6 May 9, 2024
2fe4f91
condense css
BSmick6 May 9, 2024
47d92db
rank and file
BSmick6 May 9, 2024
296405e
Merge branch 'master' into opt-coords-every-sq
BSmick6 May 14, 2024
d8c35f8
Merge branch 'master' into opt-coords-every-sq
ornicar Jun 11, 2024
c007a8d
scala code golf
ornicar Jun 11, 2024
e817388
fix coordinate trainer layout
ornicar Jun 11, 2024
fe07fdf
remove unnecessary styles
ornicar Jun 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions app/controllers/Coordinate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ final class Coordinate(env: Env) extends LilaController(env):

private def serveHome(using ctx: Context): Fu[Result] =
ctx.userId
.so { userId =>
.so: userId =>
env.coordinate.api.getScore(userId).map(_.some)
}
.flatMap { score =>
.flatMap: score =>
Ok.page(views.coordinate.show(score))
}

def score = AuthBody { ctx ?=> me ?=>
bindForm(env.coordinate.forms.score)(
Expand Down
1 change: 1 addition & 0 deletions modules/coordinate/src/main/CoordinateUi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ final class CoordinateUi(helpers: Helpers):
trans.coordinates.findSquare,
trans.coordinates.nameSquare,
trans.coordinates.showCoordinates,
trans.coordinates.showCoordsOnAllSquares,
trans.coordinates.showPieces,
trans.storm.score,
trans.study.back,
Expand Down
1 change: 1 addition & 0 deletions modules/coreI18n/src/main/key.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,7 @@ object I18nKey:
val `youHaveThirtySeconds`: I18nKey = "coordinates:youHaveThirtySeconds"
val `goAsLongAsYouWant`: I18nKey = "coordinates:goAsLongAsYouWant"
val `showCoordinates`: I18nKey = "coordinates:showCoordinates"
val `showCoordsOnAllSquares`: I18nKey = "coordinates:showCoordsOnAllSquares"
val `showPieces`: I18nKey = "coordinates:showPieces"
val `startTraining`: I18nKey = "coordinates:startTraining"
val `findSquare`: I18nKey = "coordinates:findSquare"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"ab": "github:lichess-org/ab-stub",
"chessground": "^9.0.5",
"chessground": "^9.1.1",
"eslint": "^8.57.0",
"lint-staged": "^15.2.2",
"onchange": "^7.1.0",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions translation/source/coordinates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<string name="youHaveThirtySeconds">You have 30 seconds to correctly map as many squares as possible!</string>
<string name="goAsLongAsYouWant">Go as long as you want, there is no time limit!</string>
<string name="showCoordinates">Show coordinates</string>
<string name="showCoordsOnAllSquares">Coordinates on every square</string>
<string name="showPieces">Show pieces</string>
<string name="startTraining">Start training</string>
<string name="findSquare">Find square</string>
Expand Down
48 changes: 48 additions & 0 deletions ui/common/css/theme/board/_chessground.scss
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,51 @@ html.transp body:not(.simple-board) cg-board {
//filter: hue-rotate(calc(var(---board-hue) * 3.6deg));
}
}

coords.squares {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the .squares class name. Squares are referenced very often in chess. For example, chessground already uses a <square> element. I anticipate conflicts one day, but for now, we can just specify the <coords> element to mitigate that risk.

text-transform: uppercase;
text-align: right;
flex-flow: column-reverse;
height: 100%;
width: 12.5%;

&.black {
flex-flow: column;
}

&.left {
text-align: left;
}

coord {
padding: 6% 4%;
}

&.rank2 {
transform: translateX(100%);
}

&.rank3 {
transform: translateX(200%);
}

&.rank4 {
transform: translateX(300%);
}

&.rank5 {
transform: translateX(400%);
}

&.rank6 {
transform: translateX(500%);
}

&.rank7 {
transform: translateX(600%);
}

&.rank8 {
transform: translateX(700%);
}
}
21 changes: 13 additions & 8 deletions ui/common/css/theme/board/_coords-colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ coords {
text-shadow: var(---cg-cs, $coord-shadow-default);
}

.orientation-white .files coord:nth-child(2n + 1),
.orientation-white .ranks coord:nth-child(2n),
.orientation-black .files coord:nth-child(2n),
.orientation-black .ranks coord:nth-child(2n + 1) {
/** Alternating colors in rank/file/square labels */
.orientation-white .ranks :nth-child(even),
.orientation-white .files :nth-child(odd),
.orientation-black .ranks :nth-child(odd),
.orientation-black .files :nth-child(even),
coords.squares:nth-of-type(odd) :nth-child(odd),
coords.squares:nth-of-type(even) :nth-child(even) {
color: var(---cg-ccw, $coord-color-default);
}

.orientation-white .files coord:nth-child(2n),
.orientation-white .ranks coord:nth-child(2n + 1),
.orientation-black .files coord:nth-child(2n + 1),
.orientation-black .ranks coord:nth-child(2n) {
.orientation-white .ranks :nth-child(odd),
.orientation-white .files :nth-child(even),
.orientation-black .ranks :nth-child(even),
.orientation-black .files :nth-child(odd),
coords.squares:nth-of-type(odd) :nth-child(even),
coords.squares:nth-of-type(even) :nth-child(odd) {
color: var(---cg-ccb, $coord-color-default);
}
5 changes: 2 additions & 3 deletions ui/coordinateTrainer/css/_coordinateTrainer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@
}

h1 {
font-size: 1.5em;
padding: 0 !important;
text-align: center;
margin-bottom: 1rem;
}
}

Expand Down Expand Up @@ -136,6 +134,7 @@
@extend %flex-column;
align-items: center;
justify-content: space-around;
gap: 1em;
}

.explanation {
Expand Down
1 change: 1 addition & 0 deletions ui/coordinateTrainer/src/chessground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function makeConfig(ctrl: CoordinateTrainerCtrl): CgConfig {
orientation: ctrl.orientation,
blockTouchScroll: true,
coordinates: ctrl.showCoordinates(),
coordinatesOnSquares: ctrl.showCoordsOnAllSquares(),
addPieceZIndex: ctrl.config.is3d,
movable: { free: false, color: undefined },
drawable: { enabled: false },
Expand Down
10 changes: 10 additions & 0 deletions ui/coordinateTrainer/src/ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ export default class CoordinateTrainerCtrl {
this.chessground?.redrawAll();
};

showCoordsOnAllSquares = withEffect<boolean>(
storedBooleanProp('coordinateTrainer.showCoordsOnAllSquares', document.body.classList.contains('kid')),
(show: boolean) => this.onShowCoordsOnAllSquaresChange(show),
);

onShowCoordsOnAllSquaresChange = (show: boolean) => {
this.chessground?.set({ coordinatesOnSquares: show });
this.chessground?.redrawAll();
};

showPieces = withEffect<boolean>(storedBooleanProp('coordinateTrainer.showPieces', true), () =>
this.onShowPiecesChange(),
);
Expand Down
23 changes: 17 additions & 6 deletions ui/coordinateTrainer/src/side.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ const backButton = (ctrl: CoordinateTrainerCtrl): VNode =>
h('div.back', h('a.back-button', { hook: bind('click', ctrl.stop) }, `« ${ctrl.trans('back')}`));

const settings = (ctrl: CoordinateTrainerCtrl): VNode => {
const { trans, redraw, showCoordinates, showPieces } = ctrl;
const { trans, redraw, showCoordinates, showCoordsOnAllSquares, showPieces } = ctrl;
return h('div.settings', [
ctrl.mode() === 'findSquare'
? toggle(
Expand All @@ -245,6 +245,17 @@ const settings = (ctrl: CoordinateTrainerCtrl): VNode => {
trans,
redraw,
),
toggle(
{
name: 'showCoordsOnAllSquares',
id: 'showCoordsOnAllSquares',
checked: showCoordsOnAllSquares(),
change: showCoordsOnAllSquares,
disabled: !ctrl.showCoordinates(),
},
trans,
redraw,
),
toggle(
{ name: 'showPieces', id: 'showPieces', checked: showPieces(), change: showPieces },
trans,
Expand All @@ -264,9 +275,9 @@ const playingAs = (ctrl: CoordinateTrainerCtrl): VNode => {
};

const side = (ctrl: CoordinateTrainerCtrl): VNode =>
h('div.side', [
h('div.box', h('h1', ctrl.trans('coordinates'))),
...(ctrl.playing
h(
'div.side',
ctrl.playing
? [
scoreBox(ctrl),
!ctrl.timeDisabled() ? timeBox(ctrl) : null,
Expand All @@ -279,7 +290,7 @@ const side = (ctrl: CoordinateTrainerCtrl): VNode =>
...configurationButtons(ctrl),
ctrl.isAuth && ctrl.hasModeScores() ? scoreCharts(ctrl) : null,
settings(ctrl),
]),
]);
],
);

export default side;
3 changes: 2 additions & 1 deletion ui/coordinateTrainer/src/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const textOverlay = (ctrl: CoordinateTrainerCtrl): VNode | false => {

const explanation = (ctrl: CoordinateTrainerCtrl): VNode => {
const { trans } = ctrl;
return h('div.explanation', [
return h('div.explanation.box', [
h('h1', trans('coordinates')),
h('p', trans('knowingTheChessBoard')),
h('ul', [
h('li', trans('mostChessCourses')),
Expand Down