<?php
/**
 * Customizer fields for blog and archive layout settings.
 *
 * @package Eronex
 * @since   0.0.1
 */

use Kirki\Field\Dimensions;
use Kirki\Field\Image;
use Kirki\Field\Number;
use Kirki\Field\Select;
use Kirki\Pro\Field\Divider;
use Kirki\Pro\Field\HeadlineToggle;

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

new HeadlineToggle(
	array(
		'label'    => esc_html__( 'Banner', 'eronex' ),
		'settings' => 'eronex_archive_banner_enable',
		'section'  => 'eronex_layout_archive',
		'default'  => true,
		array(
			'setting'  => 'eronex_banner_enable',
			'operator' => '===',
			'value'    => true,
		),
	)
);

new Image(
	array(
		'label'           => esc_html__( 'Background Image', 'eronex' ),
		'settings'        => 'eronex_archive_banner_bg',
		'section'         => 'eronex_layout_archive',
		'transport'       => 'auto',
		'output'          => array(
			array(
				'element'  => 'body.blog .eronex-banner,body.archive .eronex-banner',
				'property' => 'background-image',
			),
		),
		'active_callback' => array(
			array(
				'setting'  => 'eronex_banner_enable',
				'operator' => '===',
				'value'    => true,
			),
			array(
				'setting'  => 'eronex_archive_banner_enable',
				'operator' => '===',
				'value'    => true,
			),
		),
	)
);

new Divider(
	array(
		'settings' => 'eronex_archive_container_layout_separator',
		'section'  => 'eronex_layout_archive',
		'choices'  => array(
			'color' => $separator_color,
		),
	),
);

new Select(
	array(
		'label'    => esc_html__( 'Container Layout', 'eronex' ),
		'settings' => 'eronex_archive_container_layout',
		'section'  => 'eronex_layout_archive',
		'default'  => '',
		'choices'  => array(
			''                => esc_html__( 'Default', 'eronex' ),
			'container'       => esc_html__( 'Normal', 'eronex' ),
			'container-fluid' => esc_html__( 'Fluid', 'eronex' ),
			'full-width'      => esc_html__( 'Full Width', 'eronex' ),
		),
	)
);

new Divider(
	array(
		'settings' => 'eronex_archive_sidebar_layout_separator',
		'section'  => 'eronex_layout_archive',
		'choices'  => array(
			'color' => $separator_color,
		),
	),
);

new Select(
	array(
		'label'    => esc_html__( 'Sidebar Layout', 'eronex' ),
		'settings' => 'eronex_archive_sidebar_layout',
		'section'  => 'eronex_layout_archive',
		'default'  => '',
		'choices'  => array(
			''      => esc_html__( 'Default', 'eronex' ),
			'none'  => esc_html__( 'No Sidebar', 'eronex' ),
			'left'  => esc_html__( 'Left Sidebar', 'eronex' ),
			'right' => esc_html__( 'Right Sidebar', 'eronex' ),
		),
	)
);

new Divider(
	array(
		'settings' => 'eronex_archive_content_padding_separator',
		'section'  => 'eronex_layout_archive',
		'choices'  => array(
			'color' => $separator_color,
		),
	),
);

new Dimensions(
	array(
		'settings'   => 'eronex_archive_content_padding',
		'label'      => esc_html__( 'Content Padding', 'eronex' ),
		'section'    => 'eronex_layout_archive',
		'default'    => array(
			'mobile'  => array(
				'padding-top'    => '',
				'padding-bottom' => '',
			),
			'tablet'  => array(
				'padding-top'    => '',
				'padding-bottom' => '',
			),
			'desktop' => array(
				'padding-top'    => '',
				'padding-bottom' => '',
			),
		),
		'choices'    => array(
			'labels' => array(
				'padding-top'    => esc_html__( 'Top', 'eronex' ),
				'padding-bottom' => esc_html__( 'Bottom', 'eronex' ),
			),
		),
		'output'     => array(
			array(
				'element'     => 'body.blog .eronex-content-inner,body.archive .eronex-content-inner',
				'media_query' => array(
					'desktop' => $desktop_media_query,
					'tablet'  => $tablet_media_query,
					'mobile'  => $mobile_media_query,
				),
			),
		),
		'transport'  => 'auto',
		'responsive' => true,
	)
);

new Divider(
	array(
		'settings' => 'eronex_archive_post_layout_separator',
		'section'  => 'eronex_layout_archive',
		'choices'  => array(
			'color' => $separator_color,
		),
	),
);

new Select(
	array(
		'label'    => esc_html__( 'Post Layout', 'eronex' ),
		'settings' => 'eronex_archive_post_layout',
		'section'  => 'eronex_layout_archive',
		'default'  => 'list',
		'choices'  => array(
			'list' => esc_html__( 'List', 'eronex' ),
			'grid' => esc_html__( 'Grid', 'eronex' ),
		),
	)
);

new Divider(
	array(
		'settings'        => 'eronex_archive_post_per_row_separator',
		'section'         => 'eronex_layout_archive',
		'choices'         => array(
			'color' => $separator_color,
		),
		'active_callback' => array(
			array(
				'setting'  => 'eronex_archive_post_layout',
				'operator' => '===',
				'value'    => 'grid',
			),
		),
	),
);

new Number(
	array(
		'label'           => esc_html__( 'Item Per Row', 'eronex' ),
		'settings'        => 'eronex_archive_post_per_row',
		'section'         => 'eronex_layout_archive',
		'default'         => array(
			'mobile'  => 1,
			'tablet'  => 2,
			'desktop' => 2,
		),
		'choices'         => array(
			'min'  => 1,
			'max'  => 6,
			'step' => 1,
		),
		'transport'       => 'auto',
		'responsive'      => true,
		'output'          => array(
			array(
				'element'     => '.eronex-archive-layout-grid',
				'property'    => '--eronex-archive-grid-items',
				'media_query' => array(
					'desktop' => $desktop_media_query,
					'tablet'  => $tablet_media_query,
					'mobile'  => $mobile_media_query,
				),
			),
		),
		'active_callback' => array(
			array(
				'setting'  => 'eronex_archive_post_layout',
				'operator' => '===',
				'value'    => 'grid',
			),
		),
	),
);

new Divider(
	array(
		'settings' => 'eronex_archive_post_excerpt_length_separator',
		'section'  => 'eronex_layout_archive',
		'choices'  => array(
			'color' => $separator_color,
		),
	),
);

new Number(
	array(
		'label'     => esc_html__( 'Excerpt', 'eronex' ),
		'settings'  => 'eronex_archive_post_excerpt_length',
		'section'   => 'eronex_layout_archive',
		'default'   => '',
		'choices'   => array(
			'min'  => 5,
			'max'  => 50,
			'step' => 1,
		),
	),
);
