<?php
/**
 * The template to display hamburger.
 *
 * This template can be overridden by copying it to
 * your-child-theme/views/hamburger.php.
 *
 * @package MadeByAura\Prime
 * @author  MadeByAura.com
 *
 * @param array $args
 */

namespace MadeByAura\Prime;

use MadeByAura\Prime\Helpers\Markup;

defined( 'ABSPATH' ) || die();

// Merge incoming `$args` with defaults.
$args = array_replace_recursive(
	[
		'open_text'  => __( 'Open menu', 'aura-prime' ),
		'close_text' => __( 'Close menu', 'aura-prime' ),
		'closed'     => false,
		'class'      => '',
		'attrs'      => [],
	],
	$args,
);

// Text.
$text = ( true === $args['closed'] ) ? $args['close_text'] : $args['open_text'];

// Set CSS classes.
$classes[] = $args['class'];
$classes[] = 'aura-hamburger';
$classes[] = ( true === $args['closed'] ) ? 'aura-hamburger--closed' : '';

// Set HTML attributes.
$attrs['class']           = $classes;
$attrs['href']            = '#';
$attrs['data-open-text']  = $args['open_text'];
$attrs['data-close-text'] = $args['close_text'];

// Merge explicit attributes with implicit attributes.
$attrs = Markup::merge_attrs( $attrs, $args['attrs'] );
?>

<a <?php Markup::echo_attrs( $attrs ); ?>>
	<div class="aura-hamburger__inner">
		<span class="screen-reader-text"><?php echo esc_html( $text ); ?></span>
		<span class="aura-hamburger__bar aura-hamburger__bar--top"></span>
		<span class="aura-hamburger__bar aura-hamburger__bar--middle"></span>
		<span class="aura-hamburger__bar aura-hamburger__bar--bottom"></span>
	</div>
</a>
