This commit is contained in:
@@ -209,6 +209,9 @@ final class AvatarManager
|
||||
$styleClass = (string)$meta['class'];
|
||||
$styleConfig = $currentStyle === $meta['key'] ? $currentConfig : $styleClass::defaultConfig();
|
||||
$components = [];
|
||||
$colorDefinitions = $styleClass::colorDefinitions();
|
||||
$colorControls = is_array($meta['color_controls'] ?? null) ? $meta['color_controls'] : [];
|
||||
$colorGroups = is_array($meta['color_groups'] ?? null) ? $meta['color_groups'] : [];
|
||||
|
||||
foreach ($styleClass::componentDefinitions() as $field => $definition) {
|
||||
$options = [];
|
||||
@@ -221,24 +224,28 @@ final class AvatarManager
|
||||
];
|
||||
}
|
||||
|
||||
$componentColors = [];
|
||||
foreach (($colorGroups[$field] ?? []) as $colorField) {
|
||||
if (!isset($colorDefinitions[$colorField])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$componentColors[$colorField] = [
|
||||
'field' => $colorField,
|
||||
'label' => (string)($colorControls[$colorField]['label'] ?? $colorDefinitions[$colorField]['label'] ?? $colorField),
|
||||
'value' => (string)($styleConfig[$colorField] ?? ''),
|
||||
'default' => (string)($colorControls[$colorField]['default'] ?? $colorDefinitions[$colorField]['default'] ?? '#c4a484'),
|
||||
'samples' => is_array($colorControls[$colorField]['samples'] ?? null) ? $colorControls[$colorField]['samples'] : [],
|
||||
'allow_custom' => (bool)($colorControls[$colorField]['allow_custom'] ?? true),
|
||||
];
|
||||
}
|
||||
|
||||
$components[$field] = [
|
||||
'field' => $field,
|
||||
'label' => (string)($definition['label'] ?? $field),
|
||||
'count' => count(array_filter($options, static fn(array $option): bool => $option['value'] !== '')),
|
||||
'options' => $options,
|
||||
];
|
||||
}
|
||||
|
||||
$colors = [];
|
||||
foreach ($styleClass::colorDefinitions() as $field => $definition) {
|
||||
$colors[$field] = [
|
||||
'field' => $field,
|
||||
'label' => (string)($definition['label'] ?? $field),
|
||||
'value' => (string)($styleConfig[$field] ?? ''),
|
||||
'default' => (string)($definition['default'] ?? '#c4a484'),
|
||||
'fill' => (string)($styleConfig[$field . 'Fill'] ?? ''),
|
||||
'fill_stops' => (string)($styleConfig[$field . 'FillStops'] ?? ''),
|
||||
'angle' => (string)($styleConfig[$field . 'Angle'] ?? ''),
|
||||
'colors' => $componentColors,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -246,7 +253,6 @@ final class AvatarManager
|
||||
'key' => $meta['key'],
|
||||
'label' => $meta['label'],
|
||||
'components' => $components,
|
||||
'colors' => $colors,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user