Avatar
All checks were successful
Deploy / deploy (push) Successful in 1m38s

This commit is contained in:
2026-07-27 01:58:53 +02:00
parent 32985d5785
commit 8b106e5b03
4 changed files with 194 additions and 68 deletions

View File

@@ -35,6 +35,19 @@ final class Lorelei
];
}
public static function componentDefinitions(): array
{
return [
'avatar_lorelei_eyes_variant' => ['label' => 'Augen', 'auto' => false],
'avatar_lorelei_eyebrows_variant' => ['label' => 'Augenbrauen', 'auto' => false],
'avatar_lorelei_mouth_variant' => ['label' => 'Mund', 'auto' => false],
'avatar_lorelei_glasses_variant' => ['label' => 'Brille', 'auto' => true],
'avatar_lorelei_hair_variant' => ['label' => 'Haare', 'auto' => true],
'avatar_lorelei_beard_variant' => ['label' => 'Bart', 'auto' => true],
'avatar_lorelei_earrings_variant' => ['label' => 'Ohrringe', 'auto' => true],
];
}
public static function selectColumns(string $alias = 'p'): string
{
$columns = array_keys(self::defaults());
@@ -162,6 +175,31 @@ final class Lorelei
return '/api/avatar?' . http_build_query(self::apiQuery($row));
}
public static function previewChoices(array $row, string $field): array
{
$definitions = self::componentDefinitions();
$options = self::options();
$avatar = self::normalize($row);
if (!isset($definitions[$field], $options[$field])) {
return [];
}
$choices = [];
foreach ($options[$field] as $value => $label) {
$variantRow = $avatar;
$variantRow[$field] = (string) $value;
$choices[] = [
'value' => (string) $value,
'label' => (string) $label,
'image' => self::buildProxyUrl($variantRow),
'checked' => $avatar[$field] === (string) $value,
];
}
return $choices;
}
public static function render(array $row, string $name = 'Mitglied', string $size = 'md'): string
{
$avatar = self::normalize($row);