<?php
/**
 * Template part for displaying the jobs orderby block
 *
 * @link        https://matadorjobs.com/
 *
 * @since       3.9.0
 *
 * @package     Matador Jobs
 * @subpackage  Blocks
 * @author      Matador Software LLC, Jeremy Scott, Paul Bearne
 * @copyright   (c) 2017-2025, Matador Software, LLC
 *
 * @license     https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
 */

 use matador\MatadorJobs\Editors\Blocks\Blocks;

/**
 * Defined before include:
 *
 * @var array  $attributes - associative array of block attributes
 * @var WP_Block  $block - all the block settings and attributes
 */

$css_var_mappings = [
	'labelPosition'        => '--matador-jobs-orderby-label-position',
	'inputTextColor'       => '--matador-jobs-orderby-input-text-color',
	'inputBackgroundColor' => '--matador-jobs-orderby-input-background-color',
	'inputPadding'         => [
		'top'    => '--matador-jobs-orderby-input-padding-top',
		'right'  => '--matador-jobs-orderby-input-padding-right',
		'bottom' => '--matador-jobs-orderby-input-padding-bottom',
		'left'   => '--matador-jobs-orderby-input-padding-left',
	],
	'inputMargin'          => [
		'top'    => '--matador-jobs-orderby-input-margin-top',
		'right'  => '--matador-jobs-orderby-input-margin-right',
		'bottom' => '--matador-jobs-orderby-input-margin-bottom',
		'left'   => '--matador-jobs-orderby-input-margin-left',
	],
];

$style = Blocks::generate_css_variables( $css_var_mappings, $block );

$args = [];

if ( ! empty( $attributes['labelText'] ) ) {
	$args['label_text'] = $attributes['labelText'];
}

?>
<div <?php echo get_block_wrapper_attributes( [ 'style' => $style ] ); ?>>
	<?php matador_jobs_orderby( $args ); ?>
</div>