<?php

/*
Widget Name: CircleBox
Description: Display one or more circlebox depicting a percentage value in a multi-column grid.
Author: ThemesFlat
Author URI: https://www.themesflatthemes.com
*/
namespace ThemesflatAddons\Widgets;

use  Elementor\Widget_Base ;
use  Elementor\Controls_Manager ;
use  Elementor\Utils ;
use  Elementor\Scheme_Color ;
use  Elementor\Group_Control_Typography ;
use  Elementor\Scheme_Typography ;
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
// Exit if accessed directly
class TFL_CircleBox_Widget extends TFL_Widget_Base
{
    public function get_name()
    {
        return 'tfl-circlebox';
    }
    
    public function get_title()
    {
        return __( 'CircleBox', 'themesflat' );
    }
    
    public function get_icon()
    {
        return 'tfl-icon-telegram';
    }
    
    public function get_categories()
    {
        return array( 'themesflat-addons' );
    }
    
    public function get_custom_help_url()
    {
        return 'https://themesflatelementor.com/docs/themesflat-addons/core-addons/circlebox-addon/';
    }
    
    public function get_script_depends()
    {
        return [ 'tfl-waypoints', 'tfl-frontend-scripts' ];
    }
    
    public function get_style_depends()
    {
        return [ 'tfl-animate-styles', 'tfl-frontend-styles', 'tfl-circlebox-styles' ];
    }
    
    protected function register_controls()
    {
        $this->start_controls_section( 'section_circlebox', [
            'label' => __( 'CircleBox', 'themesflat' ),
        ] );
        $this->add_control( 'style', [
            'type'    => Controls_Manager::SELECT,
            'label'   => __( 'Choose Style', 'themesflat' ),
            'default' => 'style1',
            'options' => [
            'style1' => __( 'Style 1', 'themesflat' ),
        ],
        ] );

        $this->add_control( 'image', [
            'label'       => __( 'Image', 'themesflat' ),
            'type'        => Controls_Manager::MEDIA,
            'default'     => [
                'url' => Utils::get_placeholder_image_src(),
            ],
            'label_block' => true,
            'dynamic'     => [
                'active' => true,
            ],
        ] );

        $this->add_control( 'short_text', [
            'type'        => 'textarea',
            'label'       => __( 'Short Text', 'themesflat' ),
            'description' => __( 'Short text generally displayed below the circlebox title.', 'themesflat' ),
            'condition'   => [
            'style' => [ 'style1', 'style2' ],
        ],
            'dynamic'     => [
            'active' => true,
        ],
        ] );

        $this->add_control( 'widget_animation', [
            "type"    => Controls_Manager::SELECT,
            "label"   => __( "Animation Type", "themesflat" ),
            'options' => tfl_get_animation_options(),
            'default' => 'none',
        ] );
        $this->end_controls_section();

        // New section Short Text style
        $this->start_controls_section( 'section_shorttext_styling', [
            'label' => __( 'Short Text', 'themesflat' ),
            'tab'   => Controls_Manager::TAB_STYLE,
        ] );

        $this->add_control( 'text_color', [
            'label'     => __( 'Color', 'themesflat' ),
            'type'      => Controls_Manager::COLOR,
            'selectors' => [
                '{{WRAPPER}} .tfl-circlebox .tfl-text .text-inner' => 'color: {{VALUE}};',
            ],
        ] );
        $this->add_group_control( Group_Control_Typography::get_type(), [
            'name'     => 'text_typography',
            'selector' => '{{WRAPPER}} .tfl-circlebox .tfl-text .text-inner',
        ] );

        $this->end_controls_section();
        // End section 

    }
    
    protected function render()
    {
        $settings = $this->get_settings_for_display();
        $settings = apply_filters( 'tfl_circlebox_' . $this->get_id() . '_settings', $settings );
        $args['settings'] = $settings;
        $args['widget_instance'] = $this;
        tfl_get_template_part( "addons/circlebox/{$settings['style']}", $args );
    }
    
    protected function content_template()
    {
    }

}