<?php
/**
 * Form.
 *
 * @package MadeByAura\Prime\Customizer\Fields\Forms
 * @author  MadeByAura.com
 */

namespace MadeByAura\Prime\Customizer\Fields\Forms;

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

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

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

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

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

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

		// Gap between fieldsets.
		$id       = 'fieldsets_gap';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'     => esc_attr__( 'Gap between fieldsets', 'aura-prime' ),
				'type'      => 'dimension',
				'default'   => Value::get_default( $section, $id ),
				'transport' => 'auto',
				'output'    => [
					[
						'element'  => ':root',
						'property' => '--aura-g-fieldset-gap-y',
					],
				],
			],
		);

		// Gap between fields.
		$id       = 'fields_gap';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'     => esc_attr__( 'Gap between fields', 'aura-prime' ),
				'type'      => 'dimensions',
				'default'   => Value::get_default( $section, $id ),
				'choices'   => [
					'labels' => [
						'column' => esc_html__( 'Column', 'aura-prime' ),
						'row'    => esc_html__( 'Row', 'aura-prime' ),
					],
				],
				'transport' => 'auto',
				'output'    => [
					[
						'choice'   => 'column',
						'element'  => ':root',
						'property' => '--aura-g-field-wrapper-gap-x',
					],
					[
						'choice'   => 'row',
						'element'  => ':root',
						'property' => '--aura-g-field-wrapper-gap-y',
					],
				],
			],
		);
	}
}
