fix: username color
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2023-03-08 21:58:38 +08:00
parent 8f95283b53
commit bda7c96df6
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 13 additions and 3 deletions

View File

@ -510,9 +510,9 @@ class HTML {
'del' => [], 'del' => [],
'br' => [], 'br' => [],
'span' => [ 'span' => [
'class' => new CustomClassDef(['uoj-username'], ['uoj-username-']), 'class' => 'Enum#uoj-username,' . implode(',', array_map(fn ($c) => "uoj-username-{$c}", UOJUser::AVAILABLE_COLORS)),
'data-realname' => 'Text', 'data-realname' => 'Text',
'data-color' => 'Color', 'data-color' => 'Enum#' . implode(',', UOJUser::AVAILABLE_COLORS),
], ],
]; ];

View File

@ -26,6 +26,16 @@ class UOJUser {
], ],
]; ];
const AVAILABLE_COLORS = [
'blue',
'green',
'pink',
'red',
'orange',
'cyan',
'purple',
];
public static $visibility_codes = [ public static $visibility_codes = [
'all' => [ 'all' => [
'html' => '', 'html' => '',
@ -336,7 +346,7 @@ class UOJUser {
$color = $cfg['color'] ? UOJUser::getUserColor($user) : ''; $color = $cfg['color'] ? UOJUser::getUserColor($user) : '';
return HTML::tag('span', [ return HTML::tag('span', [
'class' => "uoj-username uoj-username-{$color}", 'class' => "uoj-username",
'data-realname' => trim(HTML::escape($realname)), 'data-realname' => trim(HTML::escape($realname)),
'data-color' => $color, 'data-color' => $color,
], $user['username']); ], $user['username']);