From 77a15c8d392ba617fe750b9e6ee412dec0da3f6f Mon Sep 17 00:00:00 2001 From: FawzyAshraf Date: Mon, 16 Dec 2024 18:34:12 +0200 Subject: [PATCH 1/5] Enable sass parser in ui/build to parse indirect color assignments The sass build for colors currently only works for direct assignments, but doesn't work correctly when being assigned to another variables and causes the assignee to be #000 instead. --- ui/.build/src/sass.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ui/.build/src/sass.ts b/ui/.build/src/sass.ts index bbf63ed84bf9f..40d7352741b56 100644 --- a/ui/.build/src/sass.ts +++ b/ui/.build/src/sass.ts @@ -235,6 +235,7 @@ async function parseScss(src: string) { async function parseThemeColorDefs() { const themeFiles = await globArray('./common/css/theme/_*.scss', { absolute: false }); const themes: string[] = ['dark']; + const capturedColors = new Map(); for (const themeFile of themeFiles ?? []) { const theme = /_([^/]+)\.scss/.exec(themeFile)?.[1]; if (!theme) { @@ -242,9 +243,22 @@ async function parseThemeColorDefs() { continue; } const text = fs.readFileSync(themeFile, 'utf8'); - const colorMap = new Map(); for (const match of text.matchAll(/\s\$c-([-a-z0-9]+):\s*([^;]+);/g)) { - colorMap.set(match[1], clr(match[2])); + capturedColors.set(match[1], match[2]); + } + const colorMap = new Map(); + for (const [color, colorVal] of capturedColors) { + let val = colorVal; + const visitedVariables = new Set(); + while (val.startsWith('$')) { + const inferredValue = capturedColors.get(val.substring(3)) ?? '#000'; + if (visitedVariables.has(inferredValue)) { + break; + } + visitedVariables.add(inferredValue); + val = inferredValue; + } + colorMap.set(color, clr(val)); } if (theme !== 'default') themes.push(theme); themeColorMap.set(theme, colorMap); From 8732d9ac082be7859890d8ffc35c432794daceb8 Mon Sep 17 00:00:00 2001 From: FawzyAshraf Date: Wed, 18 Dec 2024 21:49:14 +0200 Subject: [PATCH 2/5] Declare $c-good by hsl instead of scss variable --- ui/common/css/theme/_default.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/common/css/theme/_default.scss b/ui/common/css/theme/_default.scss index f28ffa0780e5c..52e44c64d9527 100644 --- a/ui/common/css/theme/_default.scss +++ b/ui/common/css/theme/_default.scss @@ -30,7 +30,7 @@ $c-shade: hsl(0, 0%, 30%); $c-inaccuracy: hsl(202, 78%, 62%); $c-mistake: hsl(41, 100%, 45%); $c-blunder: hsl(0, 69%, 60%); -$c-good: $c-secondary; +$c-good: hsl(88, 62%, 37%); $c-brilliant: hsl(129, 71%, 45%); $c-interesting: hsl(307, 80%, 70%); $c-paper: hsl(60, 56%, 91%); From 845db1787168feff390006fbef16077a105a6a74 Mon Sep 17 00:00:00 2001 From: YaFred Date: Thu, 19 Dec 2024 10:24:11 +0100 Subject: [PATCH 3/5] update teacher info after transferring student to another class --- modules/clas/src/main/ClasApi.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/clas/src/main/ClasApi.scala b/modules/clas/src/main/ClasApi.scala index b37969700376e..2aac6c93d2be4 100644 --- a/modules/clas/src/main/ClasApi.scala +++ b/modules/clas/src/main/ClasApi.scala @@ -260,7 +260,7 @@ final class ClasApi( def move(s: Student.WithUser, toClas: Clas)(using teacher: Me): Fu[Option[Student]] = for _ <- closeAccount(s) - stu = s.student.copy(id = Student.makeId(s.user.id, toClas.id), clasId = toClas.id) + stu = s.student.copy(id = Student.makeId(s.user.id, toClas.id), clasId = toClas.id, created = lila.clas.Clas.Recorded(by = teacher.userId, at = nowInstant)) moved <- colls.student.insert .one(stu) .inject(stu.some) From ef79d8bc9811095b89311edbb5231add05f3cff3 Mon Sep 17 00:00:00 2001 From: YaFred Date: Thu, 19 Dec 2024 10:31:50 +0100 Subject: [PATCH 4/5] scalafmtAll --- modules/clas/src/main/ClasApi.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/clas/src/main/ClasApi.scala b/modules/clas/src/main/ClasApi.scala index 2aac6c93d2be4..2fa62973ad1c3 100644 --- a/modules/clas/src/main/ClasApi.scala +++ b/modules/clas/src/main/ClasApi.scala @@ -260,7 +260,11 @@ final class ClasApi( def move(s: Student.WithUser, toClas: Clas)(using teacher: Me): Fu[Option[Student]] = for _ <- closeAccount(s) - stu = s.student.copy(id = Student.makeId(s.user.id, toClas.id), clasId = toClas.id, created = lila.clas.Clas.Recorded(by = teacher.userId, at = nowInstant)) + stu = s.student.copy( + id = Student.makeId(s.user.id, toClas.id), + clasId = toClas.id, + created = lila.clas.Clas.Recorded(by = teacher.userId, at = nowInstant) + ) moved <- colls.student.insert .one(stu) .inject(stu.some) From 2115237d6b2ea7bd33f203931ab9cb1586277da3 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Thu, 19 Dec 2024 11:13:53 +0100 Subject: [PATCH 5/5] remove unnecessary FQN --- modules/clas/src/main/ClasApi.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/clas/src/main/ClasApi.scala b/modules/clas/src/main/ClasApi.scala index 2fa62973ad1c3..8f494960682c6 100644 --- a/modules/clas/src/main/ClasApi.scala +++ b/modules/clas/src/main/ClasApi.scala @@ -263,7 +263,7 @@ final class ClasApi( stu = s.student.copy( id = Student.makeId(s.user.id, toClas.id), clasId = toClas.id, - created = lila.clas.Clas.Recorded(by = teacher.userId, at = nowInstant) + created = Clas.Recorded(by = teacher.userId, at = nowInstant) ) moved <- colls.student.insert .one(stu)