['desktop' => $attributes[$name] ?? '']; $color = [Style::class, 'color']; // The hover shadow follows the normal shadow's color unless it has its own. $shadowColor = $attributes['shadowColor'] ?? ''; $hoverShadowColor = ($attributes['hoverShadowColor'] ?? '') ?: $shadowColor; $styles ->add('text-color', $single('textColor'), $color) ->add('link-color', $single('linkColor'), $color) ->add('link-hover-color', $single('linkHoverColor'), $color) ->add('background-color', $single('backgroundColor'), $color) ->add('background-gradient', $single('backgroundGradient'), [Style::class, 'gradient']) ->add('background-image', $attributes['backgroundImage'] ?? [], [Style::class, 'backgroundImage']) ->add('background-position', $attributes['backgroundPosition'] ?? [], [Style::class, 'position']) ->add('background-size', $single('backgroundSize'), static fn($value): string => Style::oneOf($value, self::BACKGROUND_SIZES)) ->add('background-repeat', $single('backgroundRepeat'), static fn($value): string => Style::oneOf($value, self::BACKGROUND_REPEATS)) ->add('background-attachment', $single('backgroundAttachment'), static fn($value): string => Style::oneOf($value, self::BACKGROUND_ATTACHMENTS)) ->add('overlay-color', $attributes['overlayColor'] ?? [], $color) ->add('overlay-gradient', $attributes['overlayGradient'] ?? [], [Style::class, 'overlayGradient']) ->add('overlay-opacity', $attributes['overlayOpacity'] ?? [], [Style::class, 'opacity']) ->box('border-width', $attributes['borderWidth'] ?? [], [Style::class, 'length']) ->box('border-radius', $attributes['borderRadius'] ?? [], [Style::class, 'length'], ResponsiveStyles::CORNERS) ->add('box-shadow', $single('shadow'), static fn(mixed $value): string => Style::shadow($value, $shadowColor)) ->add('hover-box-shadow', $single('hoverShadow'), static fn(mixed $value): string => Style::shadow($value, $hoverShadowColor)); // A border style or color only matters, and is only printed, when a side has a width. if (str_contains($styles->classNames(), 'has-codexa-border-width-')) { $styles ->add('border-style', $single('borderStyle'), static fn($value): string => Style::oneOf($value, self::BORDER_STYLES)) ->add('border-color', $single('borderColor'), $color); } return self::hiddenClasses($attributes); } /** * The classes that hide a block on the devices its hideOn setting names. * Blocks with only the Visibility setting call this alone. * * @param array $attributes Block attributes. * @return string[] One class per device the block is hidden on. */ public static function hiddenClasses(array $attributes): array { $hideOn = is_array($attributes['hideOn'] ?? null) ? $attributes['hideOn'] : []; $hidden = []; foreach (array_keys(ResponsiveStyles::DEVICES) as $device) { if (($hideOn[$device] ?? false) === true) { $hidden[] = 'codexa-hide-' . $device; } } return $hidden; } }