<?php
/**
 * Template part for displaying featured posts in the sidebar
 *
 * @package MarComm-AUX
 * @since 1.0.0
 */
declare(strict_types=1);

use WP_AUX\Entities\Posts\FeaturedPostsEntity;
use WP_AUX\Services\AuxFramework\ElementClassesService;

$featuredPosts = new FeaturedPostsEntity();

if (!$featuredPosts->getCount()) {
  return;
}

$sidebarClasses = ElementClassesService::buildClasses('sidebar-panel');
$sidebarClasses->addModifier('featured-post');

foreach ($featuredPosts->getPostTypes() as $postType) {
  $sidebarClasses->addModifier('featured-' . $postType);
}
?>
<aside class="col-3">
  <div class="<?php echo $sidebarClasses; ?>">
    <div class="sidebar-panel__heading">
      <h2 class="heading">Featured <?php echo $featuredPosts->getLabel(); ?></h2>
      <svg><use href="#aux_sparkles"></use></svg>
    </div>
    <div class="sidebar-panel__content">
      <?php
        echo $featuredPosts->getCardsContent();
      ?>
    </div>
  </div>
</aside>
