<?php
/**
 * Back-to-top control.
 *
 * @package Kutby
 * @since   2.7.0
 */

declare(strict_types=1);

namespace Kutby\Footer\Components;

use Kutby\Footer\Contracts\FooterComponentInterface;
use Kutby\Footer\Support\FooterContext;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class BackToTop
 */
final class BackToTop implements FooterComponentInterface {

	/**
	 * {@inheritdoc}
	 */
	public static function render( FooterContext $ctx, array $args = array() ): void {
		if ( ! $ctx->bool( 'back_to_top' ) ) {
			return;
		}
		?>
		<button
			type="button"
			class="kutby-back-to-top"
			data-kutby-back-to-top
			aria-label="العودة إلى الأعلى"
		>
			<span aria-hidden="true">↑</span>
		</button>
		<?php
	}
}
