<?php
/**
 * Feature List - Template
 * 
 * @package OrokuBlocks
 * @author OrokuBlocks (https://orokublocks.com/)
 * 
 * @since 1.0.0
 * 
 * @param array $args {
 *   @type string $style                  Feature list style, one of: 'row'.
 *   @type array  $features               {
 *     @type string $text       Feature text.
 *   }
 *   @type bool   $enabled                True to show enabled icons, false otherwise. Default: true.
 *   @type string $status_tag_style       Status tag style, one of: 'regular', 'background', 'background-round', 'outline'.
 *   @type string $icon                   Custom SVG icon name.
 * }
 */

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
  exit;
}

$defaults = [
  'style'     => '',
  'features'  => [],
  'enabled'   => true,
  'icon'      => ''
];

$options = array_merge( $defaults, $args );

$status_tag_args = [
  'enabled' => $options['enabled']
];

if ( $options['icon'] !== '' ) {
  $status_tag_args['icon'] = $options['icon'];
}

switch ( $options['status_tag_style'] ) {
  case 'background-round':
    $status_tag_args['background'] = true;
    break;
  case 'background':
    $status_tag_args['background'] = true;
    $status_tag_args['radius'] = true;
    break;
  case 'outline':
    $status_tag_args['outline'] = true;
    break;
}

$wrapper_classes = [
  'orokublocks-feature-list'
];

if ( $options['style'] !== '' ) {
  $wrapper_classes[] = 'orokublocks-feature-list--style--' . $options['style'];
}

?>
<div class="<?php echo esc_attr( implode( ' ', $wrapper_classes ) ); ?>">
<?php foreach ( $options['features'] as $feature ) : ?>
  <?php if ( $feature['text'] !== '' ) : ?>
    <div class="orokublocks-feature-list__item">
    <?php

      /**
       * Status Tag
       */
      orokublocks()->requireTemplate( 'includes/template/status-tag', $status_tag_args );

    ?>
      <p class="orokublocks-feature-list__item-text orokublocks-card__text orokublocks-card__text--style--bold orokublocks-card__text--line--height--small"><?php echo esc_html( $feature['text'] ); ?></p>
    </div>
  <?php endif; ?>
<?php endforeach; ?>
</div>