<?php

/**
 * Elementor Widget
 * @package Meditest
 * @since 1.0.0
 */

namespace Elementor;

if (!defined('ABSPATH')) exit; // Exit if accessed directly.

class meditest_sub_heading extends Widget_Base
{

	/**
	 * Get widget name.
	 *
	 * Retrieve Elementor widget name.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget name.
	 */
	public function get_name()
	{
		return 'sub-heading';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title()
	{
		return esc_html__('Sub Heading', 'meditest-extra');
	}

	/**
	 * Get widget icon.
	 *
	 * Retrieve Elementor widget icon.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget icon.
	 */
	public function get_icon()
	{
		return 'fas fa-th-large';
	}

	/**
	 * Get widget categories.
	 *
	 * Retrieve the list of categories the Elementor widget belongs to.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return array Widget categories.
	 */
	public function get_categories()
	{
		return ['meditest_widgets'];
	}

	/**
	 * Register Elementor widget controls.
	 *
	 * Adds different input fields to allow the user to change and customize the widget settings.
	 *
	 * @since 1.0.0
	 * @access protected
	 */


	protected function register_controls()
	{
		$this->layout_options();
	}

	/**
	 * Layout Options
	 */
	private function layout_options()
	{


		$this->start_controls_section(
			'layout_option',
			[
				'label' => __('Layout Options', 'meditest-extra'),
				'tab' => Controls_Manager::TAB_CONTENT,
			]
		);


		$this->add_control(
			'sub_heading',
			[
				'label' => esc_html__('Sub Title', 'textdomain'),
				'type' => \Elementor\Controls_Manager::TEXTAREA,
				'placeholder' => esc_html__('Type your sub title here', 'textdomain'),
				'label_block' => true,
			]
		);

		$this->add_control(
			'shb_icon',
			[
				'label' => esc_html__('Before Sub Title Icon', 'textdomain'),
				'type' => \Elementor\Controls_Manager::ICONS,
				'default' => [
					'value' => 'fas fa-circle',
					'library' => 'fa-solid',
				],
			]
		);


		$this->end_controls_section();



		$this->start_controls_section(
			'style_option',
			[
				'label' => __('Style', 'meditest-extra'),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);


		$this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'label' => esc_html__('Sub Title Typography', 'textdomain'),
				'name' => 'shb_typograpy',
				'selector' => '{{WRAPPER}} .sub_heading_content .sub_t_subheading',
			]
		);

		$this->add_control(
			'bst_color',
			[
				'label' => esc_html__('Sub Title Color', 'textdomain'),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .sub_heading_content .sub_t_subheading' => 'color: {{VALUE}}',
				],
			]
		);

		$this->add_control(
			'icon_color',
			[
				'label' => esc_html__('Icon Color', 'textdomain'),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .sub_heading_content .shb-icon' => 'color: {{VALUE}}',
				],
			]
		);

		$this->add_control(
			'icon_size',
			[
				'label' => esc_html__('Icon Size', 'textdomain'),
				'type' => Controls_Manager::SLIDER,
				'size_units' => ['px', '%', 'em', 'rem', 'custom'],
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 1000,
						'step' => 1,
					]
				],
				'default' => [
					'unit' => 'px',
					'size' => 12,
				],
				'selectors' => [
					'{{WRAPPER}} .sub_heading_content .shb-icon i' => 'font-size: {{SIZE}}{{UNIT}};',
				],
			]
		);

		$this->add_control(
			'icon_color_svg',
			[
				'label' => esc_html__('SVG Icon Color', 'textdomain'),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .sub_heading_content .shb-icon' => 'fill: {{VALUE}}',
				],
			]
		);

		$this->add_control(
			'icon_size_svg',
			[
				'label' => esc_html__('SVG Icon Size', 'textdomain'),
				'type' => Controls_Manager::SLIDER,
				'size_units' => ['px', '%', 'em', 'rem', 'custom'],
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 1000,
						'step' => 1,
					]
				],
				'default' => [
					'unit' => 'px',
					'size' => 16,
				],
				'selectors' => [
					'{{WRAPPER}} .sub_heading_content .shb-icon' => 'width: {{SIZE}}{{UNIT}};',
				],
			]
		);



		$this->end_controls_section();
	}

	protected function render()
	{

		$settings = $this->get_settings_for_display();


?>

		<div class="theme_sub_heading">
			<div class="sub_heading_content">
				<div class="shb-icon"><?php \Elementor\Icons_Manager::render_icon($settings['shb_icon'], ['aria-hidden' => 'true']); ?></div>
				<span class="sub_t_subheading"><?php echo $settings['sub_heading']; ?></span>
			</div>
		</div>


<?php
	}
}

Plugin::instance()->widgets_manager->register_widget_type(new meditest_sub_heading());
