<?php
/**
 * Field.
 *
 * @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();

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

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

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

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

		// Color.
		$id       = 'color';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'     => esc_attr__( 'Color', 'aura-prime' ),
				'type'      => 'color',
				'default'   => Value::get_default( $section, $id ),
				'transport' => 'auto',
				'choices'   => [
					'alpha' => true,
				],
				'output'    => [
					[
						'element'  => ':root',
						'property' => '--aura-g-field-color',
					],
				],
			],
		);

		// Background color.
		$id       = 'background_color';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'     => esc_attr__( 'Background color', 'aura-prime' ),
				'type'      => 'color',
				'default'   => Value::get_default( $section, $id ),
				'transport' => 'auto',
				'choices'   => [
					'alpha' => true,
				],
				'output'    => [
					[
						'element'  => ':root',
						'property' => '--aura-g-field-background-color',
					],
				],
			],
		);

		// Border color.
		$id       = 'border_color';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'     => esc_attr__( 'Border color', 'aura-prime' ),
				'type'      => 'color',
				'default'   => Value::get_default( $section, $id ),
				'transport' => 'auto',
				'choices'   => [
					'alpha' => true,
				],
				'output'    => [
					[
						'element'  => ':root',
						'property' => '--aura-g-field-border-color',
					],
				],
			],
		);

		// Focus color.
		$id       = 'focus_color';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'     => esc_attr__( 'Focus color', 'aura-prime' ),
				'type'      => 'color',
				'default'   => Value::get_default( $section, $id ),
				'transport' => 'auto',
				'choices'   => [
					'alpha' => true,
				],
				'output'    => [
					[
						'element'  => ':root',
						'property' => '--aura-g-field-focus-color',
					],
				],
			],
		);

		// Focus background color.
		$id       = 'focus_background_color';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'     => esc_attr__( 'Focus background color', 'aura-prime' ),
				'type'      => 'color',
				'default'   => Value::get_default( $section, $id ),
				'transport' => 'auto',
				'choices'   => [
					'alpha' => true,
				],
				'output'    => [
					[
						'element'  => ':root',
						'property' => '--aura-g-field-focus-background-color',
					],
				],
			],
		);

		// Focus border color.
		$id       = 'focus_border_color';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'     => esc_attr__( 'Focus border color', 'aura-prime' ),
				'type'      => 'color',
				'default'   => Value::get_default( $section, $id ),
				'transport' => 'auto',
				'choices'   => [
					'alpha' => true,
				],
				'output'    => [
					[
						'element'  => ':root',
						'property' => '--aura-g-field-focus-border-color',
					],
				],
			],
		);

		// Typography.
		$id       = 'typography';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'   => esc_attr__( 'Typography', 'aura-prime' ),
				'type'    => 'typography',
				'default' => Value::get_default( $section, $id ),
				'output'  => [
					[
						'choice'   => 'font-family',
						'element'  => ':root',
						'property' => '--aura-g-field-font-family',
					],
					[
						'choice'   => 'font-size',
						'element'  => ':root',
						'property' => '--aura-g-field-font-size',
					],
					[
						'choice'   => 'line-height',
						'element'  => ':root',
						'property' => '--aura-g-field-line-height',
					],
					[
						'choice'   => 'letter-spacing',
						'element'  => ':root',
						'property' => '--aura-g-field-letter-spacing',
					],
				],
			],
		);

		// Padding.
		$id       = 'padding';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'     => esc_attr__( 'Padding', 'aura-prime' ),
				'type'      => 'dimensions',
				'default'   => Value::get_default( $section, $id ),
				'transport' => 'auto',
				'output'    => [
					[
						'element'  => ':root',
						'property' => '--aura-g-field-padding',
					],
				],
			],
		);

		// Border width.
		$id       = 'border_width';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'   => esc_attr__( 'Border width', 'aura-prime' ),
				'type'    => 'dimensions',
				'default' => Value::get_default( $section, $id ),
				'choices' => [
					'labels' => [
						'top'    => esc_html__( 'Top', 'aura-prime' ),
						'right'  => esc_html__( 'Right', 'aura-prime' ),
						'bottom' => esc_html__( 'Bottom', 'aura-prime' ),
						'left'   => esc_html__( 'Left', 'aura-prime' ),
					],
				],
				'output'  => [
					[
						'choice'   => 'top',
						'element'  => ':root',
						'property' => '--aura-g-field-border-top-width',
					],
					[
						'choice'   => 'right',
						'element'  => ':root',
						'property' => '--aura-g-field-border-right-width',
					],
					[
						'choice'   => 'bottom',
						'element'  => ':root',
						'property' => '--aura-g-field-border-bottom-width',
					],
					[
						'choice'   => 'left',
						'element'  => ':root',
						'property' => '--aura-g-field-border-left-width',
					],
				],
			],
		);

		// Border radius.
		$id       = 'border_radius';
		$priority = Add::field(
			$section,
			$id,
			$priority,
			[
				'label'     => esc_attr__( 'Border radius', 'aura-prime' ),
				'type'      => 'dimensions',
				'default'   => Value::get_default( $section, $id ),
				'choices'   => [
					'labels' => [
						'top-left'     => esc_html__( 'Top left', 'aura-prime' ),
						'top-right'    => esc_html__( 'Top right', 'aura-prime' ),
						'bottom-right' => esc_html__( 'Bottom right', 'aura-prime' ),
						'bottom-left'  => esc_html__( 'Bottom left', 'aura-prime' ),
					],
				],
				'transport' => 'auto',
				'output'    => [
					[
						'choice'   => 'top-left',
						'element'  => ':root',
						'property' => '--aura-g-field-border-top-left-radius',
					],
					[
						'choice'   => 'top-right',
						'element'  => ':root',
						'property' => '--aura-g-field-border-top-right-radius',
					],
					[
						'choice'   => 'bottom-right',
						'element'  => ':root',
						'property' => '--aura-g-field-border-bottom-right-radius',
					],
					[
						'choice'   => 'bottom-left',
						'element'  => ':root',
						'property' => '--aura-g-field-border-bottom-left-radius',
					],
				],
			],
		);
	}
}
