<?php
$preset = isset($attributes['preset']) ? (string) $attributes['preset'] : 'favorites';
$title = isset($attributes['title']) ? (string) $attributes['title'] : '';
$background = isset($attributes['backgroundColor']) ? (string) $attributes['backgroundColor'] : '';
$text_color = isset($attributes['textColor']) ? (string) $attributes['textColor'] : '';

$styles = [];
if ($background !== '') {
  $styles[] = 'background:' . $background;
}
if ($text_color !== '') {
  $styles[] = 'color:' . $text_color;
}
$style_attr = $styles ? ' style="' . esc_attr(implode(';', $styles)) . '"' : '';

$presets = [
  'favorites' => 'Our Favorites',
  'collections' => 'Collections',
  'about' => 'About Us',
];

$label = $preset !== 'custom' && isset($presets[$preset]) ? $presets[$preset] : $title;
if ($label === '') {
  $label = 'Section Title';
}
?>
<div class="fjord-favorites__pill fjord-reveal"<?php echo $style_attr; ?>>
  <h2><?php echo esc_html($label); ?></h2>
</div>
