<?php
/**
 * Card Pill Options - Template
 * 
 * @package OrokuBlocks
 * @author OrokuBlocks (https://orokublocks.com/)
 * 
 * @since 1.0.0
 * 
 * @param array $args {
 *   @type string $title            Options title.
 *   @type array  $options          Option names.
 *   @type string $align            Option alignment. One of: 'left', 'center'. Default: 'left'.          
 * }
 */

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

$defaults = [
  'title'   => '',
  'options' => [],
  'align'   => ''
];

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

$wrapper_classes = [
  'orokublocks-card__item',
  'orokublocks-card__item--divided',
  'orokublocks-card__item--gap--tiny',
  'orokublocks-card__item--align--center'
];

if ( $options['align'] === 'center'  ) {
  $wrapper_classes[] = 'orokublocks-card__item--justify--center';
} else if ( $options['align'] !== 'left' ) {
  $wrapper_classes[] = 'orokublocks-card__item--justify--space--between';
}

?>
<div class="<?php echo esc_attr( implode( ' ', $wrapper_classes ) ); ?>">
<?php if ( $options['title'] !== '' ) : ?>
  <div class="orokublocks-card__item">
    <p class="orokublocks-card__text orokublocks-card__text--size--regular"><?php echo esc_html( $options['title'] ); ?></p>
  </div>
<?php endif; ?>

<?php if ( count( $options['options'] ) > 0 ) : ?>
  <div class="orokublocks-card__item">
  <?php

    /**
     * Pill Options
     */
    orokublocks()->requireTemplate(
      'includes/template/pill-options',
      [
        'options' => $options['options']
      ]
    );

  ?>
  </div>
<?php endif; ?>
</div>