<?php
/**
 * Headings.
 *
 * @package MadeByAura\Prime\Customizer\Fields\Content
 * @author  MadeByAura.com
 */

namespace MadeByAura\Prime\Customizer\Fields\Content;

use MadeByAura\Prime\Customizer\Modules\Add;
use MadeByAura\Prime\Customizer\Modules\Value;
use MadeByAura\Prime\Helpers\SingletonTrait;

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

/**
 * Headings.
 */
class Headings {
	use SingletonTrait;

	/**
	 * Constructor.
	 */
	protected function __construct() {
		add_action( 'after_setup_theme', [ __CLASS__, 'add_section' ] );
	}

	/**
	 * Add section.
	 */
	public static function add_section() {
		$section  = 'content_headings';
		$priority = 10;

		// Section.
		Add::section(
			$section,
			[
				'title'    => esc_attr__( 'Headings', 'aura-prime' ),
				'section'  => 'aura_section_content',
				'priority' => 0,
			],
		);

		// H1 to H6.
		$tags = [
			'h1' => __( 'H1', 'aura-prime' ),
			'h2' => __( 'H2', 'aura-prime' ),
			'h3' => __( 'H3', 'aura-prime' ),
			'h4' => __( 'H4', 'aura-prime' ),
			'h5' => __( 'H5', 'aura-prime' ),
			'h6' => __( 'H6', 'aura-prime' ),
		];

		foreach ( $tags as $tag => $label ) {
			$id       = $tag;
			$priority = Add::field(
				$section,
				$id,
				$priority,
				[
					'label'   => $label,
					'type'    => 'typography',
					'default' => Value::get_default( $section, $id ),
					'output'  => [
						[
							'choice'   => 'font-size',
							'element'  => '.aura-formatted-content',
							'property' => "--aura-g-{$tag}-font-size",
						],
						[
							'choice'   => 'line-height',
							'element'  => '.aura-formatted-content',
							'property' => "--aura-g-{$tag}-line-height",
						],
						[
							'choice'   => 'letter-spacing',
							'element'  => '.aura-formatted-content',
							'property' => "--aura-g-{$tag}-letter-spacing",
						],
						[
							'choice'   => 'text-transform',
							'element'  => '.aura-formatted-content',
							'property' => "--aura-g-{$tag}-text-transform",
						],
					],
				],
			);
		}
	}
}
