Skip to content

Commit ef42ae9

Browse files
authored
UI Components, Letter Avatars, Contrast too low, see #31102 and #0031153 (ILIAS-eLearning#3530)
1 parent 0f02fc1 commit ef42ae9

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

Services/User/Avatar/classes/class.ilUserAvatarLetter.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,14 @@
99
class ilUserAvatarLetter extends ilUserAvatarBase
1010
{
1111
/**
12+
* all variants of letter avatar background colors (MUST be 26), note for a11y reason, they must be in contrast 3x1 to white (foreground color)
1213
* @var array
1314
*/
15+
1416
protected static $colors = [
15-
"#1abc9c", "#16a085", "#f1c40f",
16-
"#f39c12", "#2ecc71", "#27ae60",
17-
"#e67e22", "#d35400", "#3498db",
18-
"#2980b9", "#e74c3c", "#c0392b",
19-
"#9b59b6", "#8e44ad", "#bdc3c7",
20-
"#34495e", "#2c3e50", "#95a5a6",
21-
"#7f8c8d", "#ec87bf", "#d870ad",
22-
"#f69785", "#9ba37e", "#b49255",
23-
"#b49255", "#a94136"
17+
"#0e6252", "#107360", "#aa890a", "#c87e0a", "#176437", "#196f3d", "#bf6516", "#a04000", "#1d6fa5", "#1b557a",
18+
"#bf2718", "#81261d", "#713b87", "#522764", "#78848c", "#34495e", "#2c3e50", "#566566", "#90175a", "#9e2b6e",
19+
"#d22f10", "#666d4e", "#715a32", "#83693a", "#963a30", "#e74c3c"
2420
];
2521

2622
/**

src/UI/Implementation/Component/Symbol/Avatar/Letter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ public function getAbbreviation() : string
1414

1515
public function getBackgroundColorVariant() : int
1616
{
17-
return (crc32($this->getUsername()) % 26) + 1;
17+
return ((crc32($this->getAbbreviation()) % 26) + 1);
1818
}
1919
}

templates/default/delos.css

+5
Original file line numberDiff line numberDiff line change
@@ -10633,6 +10633,11 @@ footer {
1063310633
border-color: #e5b3ad;
1063410634
color: white;
1063510635
}
10636+
.il-avatar.il-avatar-letter.il-avatar-letter-color-26 {
10637+
background-color: #e74c3c;
10638+
border-color: #fdf3f2;
10639+
color: white;
10640+
}
1063610641
@media only screen and (max-width: 768px) {
1063710642
.il-avatar {
1063810643
height: 22.5px;

templates/default/less/variables.less

+2-2
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,8 @@ with the il- variable set here.
752752
@il-avatar-letter-abbreviation-font-weight: lighter;
753753
//** change the abbreviations font transform
754754
@il-avatar-letter-abbreviation-font-transform: inherit;
755-
//** all variants of letter avatar background colors (MUST be 26)
756-
@il-avatar-letter-color-variants: #0e6252, #107360, #aa890a, #c87e0a, #176437, #196f3d, #bf6516, #a04000, #1d6fa5, #1b557a, #bf2718, #81261d, #713b87, #522764, #78848c, #34495e, #2c3e50, #566566, #90175a, #9e2b6e, #d22f10, #666d4e, #715a32, #83693a, #963a30;
755+
//** all variants of letter avatar background colors (MUST be 26), note for a11y reason, they must be in contrast 3x1 to white (foreground color)
756+
@il-avatar-letter-color-variants: #0e6252, #107360, #aa890a, #c87e0a, #176437, #196f3d, #bf6516, #a04000, #1d6fa5, #1b557a, #bf2718, #81261d, #713b87, #522764, #78848c, #34495e, #2c3e50, #566566, #90175a, #9e2b6e, #d22f10, #666d4e, #715a32, #83693a, #963a30, #e74c3c;
757757

758758

759759
//== System Info

tests/UI/Component/Symbol/Avatar/AvatarTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function testRenderingPictureWithSomeAlternativeText()
178178
* @param int $length
179179
* @return Generator|Closure
180180
*/
181-
public function getRandom26StringsForAllColorVariants(int $color_variants = 26, int $length = 10) : Generator
181+
public function getRandom26StringsForAllColorVariants(int $color_variants = 26, int $length = 2) : Generator
182182
{
183183
$sh = static function ($length = 10) {
184184
return substr(str_shuffle(str_repeat($x = 'abcdefghijklmnopqrstuvwxyz', (int) ceil($length / strlen($x)))), 1, $length);

0 commit comments

Comments
 (0)