Skip to content

Commit eb0c241

Browse files
committed
Signal on transparent problem colors
1 parent e81837d commit eb0c241

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

webapp/src/Service/CheckConfigService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,9 @@ public function checkContestsValidate(): ConfigCheckItem
474474
if (empty($cp->getColor())) {
475475
$result = ($result === 'E' ? 'E' : 'W');
476476
$cperrors[$cid] .= " - No color for problem `" . $cp->getShortname() . "` in contest c" . $cid . "\n";
477+
} elseif (Utils::parseHexColor($cp->getColor())[3] !== 255) {
478+
$result = ($result === 'E' ? 'E' : 'W');
479+
$cperrors[$cid] .= " - Semi-transparent color for problem `" . $cp->getShortname() . "` in contest c" . $cid . "\n";
477480
}
478481
}
479482
}

webapp/src/Utils/Utils.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,9 @@ public static function convertToColor(string $hex): ?string
343343
}
344344

345345
/**
346-
* Parse a hex color into it's three RGB values.
346+
* Parse a hex color into it's four RGBA values.
347347
*
348-
* @return array{int, int, int}
348+
* @return array{int, int, int, int}
349349
*/
350350
public static function parseHexColor(string $hex): array
351351
{

webapp/tests/Unit/Utils/UtilsTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,10 @@ public function testConvertToHexConvert(): void
321321

322322
public function testParseHexColor(): void
323323
{
324-
self::assertEquals([255, 255, 255], Utils::parseHexColor('#ffffff'));
325-
self::assertEquals([0, 0, 0], Utils::parseHexColor('#000000'));
326-
self::assertEquals([171, 205, 239], Utils::parseHexColor('#abcdef'));
327-
self::assertEquals([254, 220, 186], Utils::parseHexColor('#FEDCBA'));
324+
self::assertEquals([255, 255, 255, 255], Utils::parseHexColor('#ffffff'));
325+
self::assertEquals([0, 0, 0, 255], Utils::parseHexColor('#000000'));
326+
self::assertEquals([171, 205, 239, 255], Utils::parseHexColor('#abcdef'));
327+
self::assertEquals([254, 220, 186, 255], Utils::parseHexColor('#FEDCBA'));
328328
}
329329

330330
public function testComponentToHex(): void

0 commit comments

Comments
 (0)