Skip to content

Commit

Permalink
use proper css for language direction
Browse files Browse the repository at this point in the history
  • Loading branch information
schlawg committed Mar 23, 2024
1 parent 775b145 commit 7afc998
Show file tree
Hide file tree
Showing 1,415 changed files with 1,635 additions and 3,139 deletions.
14 changes: 7 additions & 7 deletions app/templating/AssetHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ trait AssetHelper extends HasEnv:
def flairSrc(flair: Flair) = staticAssetUrl(s"$flairVersion/flair/img/$flair.webp")

def cssTag(name: String)(using ctx: Context): Frag =
cssTagWithDirAndTheme(name, isRTL, ctx.pref.currentBg)
cssTagWithTheme(name, isRTL, ctx.pref.currentBg)

def cssTagWithDirAndTheme(name: String, isRTL: Boolean, theme: String): Frag =
def cssTagWithTheme(name: String, isRTL: Boolean, theme: String): Frag =
if theme == "system" then
frag(
cssTagWithDirAndSimpleTheme(name, isRTL, "light")(media := "(prefers-color-scheme: light)"),
cssTagWithDirAndSimpleTheme(name, isRTL, "dark")(media := "(prefers-color-scheme: dark)")
cssTagWithSimpleTheme(name, isRTL, "light")(media := "(prefers-color-scheme: light)"),
cssTagWithSimpleTheme(name, isRTL, "dark")(media := "(prefers-color-scheme: dark)")
)
else cssTagWithDirAndSimpleTheme(name, isRTL, theme)
else cssTagWithSimpleTheme(name, isRTL, theme)

private def cssTagWithDirAndSimpleTheme(name: String, isRTL: Boolean, theme: String): Tag =
private def cssTagWithSimpleTheme(name: String, isRTL: Boolean, theme: String): Tag =
cssAt:
s"css/$name.${if isRTL then "rtl" else "ltr"}.$theme.${if minifiedAssets then "min" else "dev"}.css"
s"css/$name.$theme.${if minifiedAssets then "min" else "dev"}.css"

def cssTagNoTheme(name: String): Frag =
cssAt(s"css/$name.${if minifiedAssets then "min" else "dev"}.css")
Expand Down
2 changes: 1 addition & 1 deletion app/views/base/embed.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object embed:
layout.bits.metaCsp(basicCsp.withNonce(ctx.nonce).withInlineIconFont),
st.headTitle(title),
layout.bits.pieceSprite(ctx.pieceSet),
cssTagWithDirAndTheme(cssModule, isRTL = lila.i18n.LangList.isRTL(ctx.lang), ctx.bg),
cssTagWithTheme(cssModule, isRTL = lila.i18n.LangList.isRTL(ctx.lang), ctx.bg),
(ctx.bg == "system").option(embedJsUnsafe(systemThemePolyfillJs, ctx.nonce))
),
st.body(cls := s"${ctx.bg} highlight ${ctx.boardClass}")(
Expand Down
9 changes: 5 additions & 4 deletions app/views/base/layout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import lila.common.base.StringUtils.escapeHtmlRaw
object layout:

object bits:
val doctype = raw("<!DOCTYPE html>")
def htmlTag(using lang: Lang) = html(st.lang := lang.code, dir := isRTL.option("rtl"))
val topComment = raw("""<!-- Lichess is open source! See https://lichess.org/source -->""")
val charset = raw("""<meta charset="utf-8">""")
val doctype = raw("<!DOCTYPE html>")
def htmlTag(using lang: Lang) =
html(st.lang := lang.code, dir := isRTL.option("rtl"), cls := isRTL.option("rtl"))
val topComment = raw("""<!-- Lichess is open source! See https://lichess.org/source -->""")
val charset = raw("""<meta charset="utf-8">""")
val viewport = raw:
"""<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">"""
def metaCsp(csp: ContentSecurityPolicy): Frag = raw:
Expand Down
25 changes: 10 additions & 15 deletions ui/.build/src/sass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,16 @@ async function buildThemedScss() {
const path = match[1];
const partial = match[2];
fs.mkdirSync(`${path}/gen`, { recursive: true });
for (const direction of ['ltr', 'rtl']) {
for (const theme of ['light', 'dark', 'transp']) {
const themed = `${path}/gen/${partial}.${direction}.${theme}.scss`;
if (fs.existsSync(themed)) {
continue;
}
const code =
`@import '../../../../common/css/dir/${direction}';\n` +
`@import '../../../../common/css/theme/${theme}';\n` +
`@import '../${partial}';\n`;
try {
await fs.promises.writeFile(themed, code);
} catch (e) {
env.log(e, { error: true });
}
for (const theme of ['light', 'dark', 'transp']) {
const themed = `${path}/gen/${partial}.${theme}.scss`;
if (fs.existsSync(themed)) {
continue;
}
const code = `@import '../../../../common/css/theme/${theme}';\n` + `@import '../${partial}';\n`;
try {
await fs.promises.writeFile(themed, code);
} catch (e) {
env.log(e, { error: true });
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions ui/analyse/css/_action-menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@
}

&:before {
#{$end-direction}: 8px;
@include pos-end(8px);
}

&:after {
#{$start-direction}: 8px;
@include pos-start(8px);
}
}
}

.action-menu {
&__tools {
display: grid;
gap: 0 1em;
Expand All @@ -51,7 +53,7 @@
min-height: 3em;

&::before {
padding-#{$end-direction}: 8px;
padding-inline-end: 8px;
font-size: 1.7em;
}

Expand Down Expand Up @@ -97,7 +99,7 @@
}

.switch + label {
margin-#{$start-direction}: 1ch;
margin-inline-start: 1ch;
}

input[type='range'] {
Expand Down
2 changes: 1 addition & 1 deletion ui/analyse/css/_analyse.free.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@extend %box-radius-bottom;

position: absolute;
#{$end-direction}: 0;
@include pos-end(0);
top: 100%;
text-align: right;
visibility: hidden;
Expand Down
6 changes: 3 additions & 3 deletions ui/analyse/css/_chart-loader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
span {
@extend %nowrap-hidden;

margin-#{$start-direction}: 7px;
margin-inline-start: 7px;
opacity: 1;
transition: 0.5s;
width: 100px;
display: block;

.analyse__underboard:hover & {
margin-#{$start-direction}: 0;
margin-inline-start: 0;
width: 0;
opacity: 0;
}
Expand All @@ -35,6 +35,6 @@
width: 32px;
height: 32px;
display: inline-block;
margin-#{$start-direction}: 10px;
margin-inline-start: 10px;
}
}
10 changes: 5 additions & 5 deletions ui/analyse/css/_forecast.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@

@include padding-direction(0.7em, 0.1em, 0.7em, 0.6em);

margin-#{$start-direction}: -0.1em;
margin-inline-start: -0.1em;

@include transition;

position: relative;
border-bottom: $border;

&::before {
margin-#{$start-direction}: -0.6em;
margin-inline-start: -0.6em;
opacity: 0.4;
}

Expand All @@ -54,7 +54,7 @@
@extend %button-none;

position: absolute;
#{$end-direction}: 8px;
@include pos-end(8px);
width: 1.5em;
height: 1.5em;
line-height: 1;
Expand All @@ -63,7 +63,7 @@
display: flex;
justify-content: center;
align-items: center;
padding-#{$end-direction}: 0.5px;
padding-inline-end: 0.5px;

@include transition;

Expand Down Expand Up @@ -141,7 +141,7 @@

sans > * {
display: inline-block;
margin-#{$end-direction}: 0.2em;
margin-inline-end: 0.2em;
}

.add sans {
Expand Down
4 changes: 2 additions & 2 deletions ui/analyse/css/_fork.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $c-fork: $c-primary;
border-bottom: 1px solid $c-bg-box;

&:nth-child(odd) {
border-#{$end-direction}: 1px solid $c-bg-box;
border-inline-end: 1px solid $c-bg-box;
}
&.correct {
background: mix($c-secondary, $c-bg-box, 25%);
Expand All @@ -45,7 +45,7 @@ $c-fork: $c-primary;
glyph {
@extend %base-font;

margin-#{$start-direction}: 2px;
margin-inline-start: 2px;
}

eval {
Expand Down
2 changes: 1 addition & 1 deletion ui/analyse/css/_keyboard.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.keyboard-help {
td.mouse li {
list-style: disc inside;
margin-#{$start-direction}: 1em;
margin-inline-start: 1em;
}
}
2 changes: 1 addition & 1 deletion ui/analyse/css/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ body {
grid-area: board;

cg-container {
#{$end-direction}: 0;
@include pos-end(0);
}
}

Expand Down
8 changes: 4 additions & 4 deletions ui/analyse/css/_player-clock.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $clock-height: 20px;

.analyse__player_strip {
position: absolute;
#{$end-direction}: 0;
@include pos-end(0);
display: flex;

&.top {
Expand Down Expand Up @@ -35,7 +35,7 @@ $clock-height: 20px;
@extend %metal;

padding: 0 0.5em;
margin-#{$start-direction}: 12px;
margin-inline-start: 12px;
height: $clock-height;
font-weight: bold;
text-align: center;
Expand All @@ -62,14 +62,14 @@ $clock-height: 20px;
}

.material {
padding-#{$end-direction}: 1px;
padding-inline-end: 1px;

mpiece {
width: 20px;
height: 20px;

&.pawn {
margin-#{$start-direction}: -10px;
margin-inline-start: -10px;
}
}
score {
Expand Down
8 changes: 4 additions & 4 deletions ui/analyse/css/_practice.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@
}

.comment .wait {
padding-#{$start-direction}: 15px;
padding-inline-start: 15px;
}

.verdict {
font-weight: bold;
margin-#{$end-direction}: 10px;
margin-inline-end: 10px;
display: flex;
}

.verdict::before {
width: 30px;
height: 100%;
color: #fff;
margin-#{$end-direction}: 7px;
margin-inline-end: 7px;
text-align: center;
font-size: 1.4em;
font-weight: normal;
Expand Down Expand Up @@ -87,7 +87,7 @@
.comment {
move {
cursor: pointer;
margin-#{$start-direction}: 5px;
margin-inline-start: 5px;
color: $c-link;
transition: 0.3s;
}
Expand Down
2 changes: 1 addition & 1 deletion ui/analyse/css/_retro.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@

.continue i::before {
font-size: 2.5em;
margin-#{$end-direction}: 10px;
margin-inline-end: 10px;
}
}
4 changes: 2 additions & 2 deletions ui/analyse/css/_round-training.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
a {
@extend %flex-center-nowrap;
text-transform: inherit;
text-align: $start-direction;
text-align: start;
&::before {
font-size: 2.8em;
}
Expand Down Expand Up @@ -65,7 +65,7 @@

&__side {
flex: 0 0 calc(50% - #{$analyse-block-gap});
margin-#{$start-direction}: $analyse-block-gap;
margin-inline-start: $analyse-block-gap;
}

> a {
Expand Down
4 changes: 2 additions & 2 deletions ui/analyse/css/_round-underboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ $col2-panel-height: 240px;
strong,
a {
display: inline-block;
margin-#{$end-direction}: 1em;
margin-inline-end: 1em;
}
}

Expand All @@ -115,7 +115,7 @@ $col2-panel-height: 240px;
border: 0;
background: none;
padding: 0.3em;
margin-#{$end-direction}: 0.5em;
margin-inline-end: 0.5em;
}
}

Expand Down
4 changes: 2 additions & 2 deletions ui/analyse/css/_tools.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
button {
@extend %button-none;

margin-#{$start-direction}: 1em;
margin-inline-start: 1em;
color: $c-link;

&:hover {
Expand Down Expand Up @@ -92,7 +92,7 @@
}

&::before {
margin-#{$end-direction}: 0.3em;
margin-inline-end: 0.3em;
}

&.highlighted {
Expand Down
6 changes: 3 additions & 3 deletions ui/analyse/css/_training.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
.player {
display: flex;
align-items: center;
margin-#{$start-direction}: 10px;
margin-inline-start: 10px;
}

.no-square {
width: 64px;
height: 64px;
margin-#{$end-direction}: 10px;
margin-inline-end: 10px;
}

.is3d & div.no-square {
Expand All @@ -58,7 +58,7 @@
display: block;
width: 64px;
height: 64px;
margin-#{$end-direction}: 10px;
margin-inline-end: 10px;
font-size: 50px;
font-size: 64px;
line-height: 64px;
Expand Down
2 changes: 2 additions & 0 deletions ui/analyse/css/build/gen/analyse.forecast.dark.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import '../../../../common/css/theme/dark';
@import '../analyse.forecast';
2 changes: 2 additions & 0 deletions ui/analyse/css/build/gen/analyse.forecast.light.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import '../../../../common/css/theme/light';
@import '../analyse.forecast';
3 changes: 0 additions & 3 deletions ui/analyse/css/build/gen/analyse.forecast.ltr.dark.scss

This file was deleted.

Loading

0 comments on commit 7afc998

Please sign in to comment.