<?php

namespace Lknwp\CrowdfundingExtension\Includes\elementorFields\controls;

use Elementor\Controls_Manager;

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

class LknwpCrowdfundingListingImage
{
    public static function getControl($input)
    {
        $input->start_controls_section(
            'image_section',
            [
                'label' => __('Image', 'link-nacional-wp-crowdfunding-extension'),
                'tab'   => Controls_Manager::TAB_STYLE,
            ]
        );

        $input->add_control(
            'show_image',
            [
                'label'        => __('Show Image', 'link-nacional-wp-crowdfunding-extension'),
                'type'         => Controls_Manager::SWITCHER,
                'label_on'     => __('Yes', 'link-nacional-wp-crowdfunding-extension'),
                'label_off'    => __('No', 'link-nacional-wp-crowdfunding-extension'),
                'return_value' => 'yes',
                'default'      => 'yes',
            ]
        );

        $input->add_control(
            'image_width',
            [
                'label'      => __('Image Width', 'link-nacional-wp-crowdfunding-extension'),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em'],
                'range'      => [
                    'px' => [
                        'min' => 10,
                        'max' => 1000,
                    ],
                    '%' => [
                        'min' => 10,
                        'max' => 100,
                    ],
                    'em' => [
                        'min' => 1,
                        'max' => 50,
                    ],
                ],
                'default' => [
                    'unit' => 'px',
                    'size' => 300,
                ],
                'selectors' => [
                    '{{WRAPPER}} .lknwp-image' => 'width: {{SIZE}}{{UNIT}};',
                ],
                'condition' => [
                    'show_image' => 'yes',
                ],
            ]
        );

        $input->add_control(
            'image_height',
            [
                'label'      => __('Image Height', 'link-nacional-wp-crowdfunding-extension'),
                'type'       => Controls_Manager::SLIDER,
                'size_units' => ['px', '%', 'em'],
                'range'      => [
                    'px' => [
                        'min' => 10,
                        'max' => 1000,
                    ],
                    '%' => [
                        'min' => 10,
                        'max' => 100,
                    ],
                    'em' => [
                        'min' => 1,
                        'max' => 50,
                    ],
                ],
                'default' => [
                    'unit' => 'px',
                    'size' => 160,
                ],
                'selectors' => [
                    '{{WRAPPER}} .lknwp-image' => 'height: {{SIZE}}{{UNIT}};',
                ],
                'condition' => [
                    'show_image' => 'yes',
                ],
            ]
        );

        $input->add_control(
            'thumbnail_size',
            [
                'label'   => __('Image Size', 'link-nacional-wp-crowdfunding-extension'),
                'type'    => Controls_Manager::SELECT,
                'options' => [
                    'thumbnail' => __('Thumbnail', 'link-nacional-wp-crowdfunding-extension'),
                    'medium'    => __('Medium', 'link-nacional-wp-crowdfunding-extension'),
                    'large'     => __('Large', 'link-nacional-wp-crowdfunding-extension'),
                    'full'      => __('Full', 'link-nacional-wp-crowdfunding-extension'),
                ],
                'default' => 'full',
                'condition' => [
                    'show_image' => 'yes',
                ],
            ]
        );

        $input->end_controls_section();

        return $input;
    }
}
