<?php

namespace Elementor;

class BantaMenuToggle extends Widget_Base
{

    public function get_name()
    {
        return 'banta_menu_toggle';
    }

    public function get_title()
    {
        return __('Mobile Nav Toggle', TEXT_DOMAIN);
    }

    public function get_icon()
    {
        return 'eicon-menu-toggle';
    }

    public function get_categories()
    {
        return ['jiawaz_header'];
    }

    public function get_keywords()
    {
        return ['menu', 'link', 'button','header','nav','toggle','button'];
    }

    protected function _register_controls()
    {


        $this->start_controls_section(
            'section_title',
            [
                'label' => esc_html__( 'Content', TEXT_DOMAIN ),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'menu_toggle_alignment',
            [
                'type' => \Elementor\Controls_Manager::CHOOSE,
                'label' => esc_html__( 'alignment', TEXT_DOMAIN ),
                'options' => [
                    'text-end' => [
                        'title' => esc_html__( 'left', TEXT_DOMAIN ),
                        'icon' => 'eicon-text-align-left',
                    ],
                    'text-center' => [
                        'title' => esc_html__( 'center', TEXT_DOMAIN ),
                        'icon' => 'eicon-text-align-center',
                    ],
                    'text-start' => [
                        'title' => esc_html__( 'right', TEXT_DOMAIN ),
                        'icon' => 'eicon-text-align-right',
                    ],
                ],
                'default' => 'text-center',
            ]
        );


        $this->end_controls_section();




        // styles

        $this->start_controls_section(
            'section_style',
            [
                'label' => esc_html__( 'Style', TEXT_DOMAIN ),
                'tab' => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_control(
            'icon_color',
            [
                'label'     => esc_html__( 'icon color', TEXT_DOMAIN ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .banta-elementor-toggle span' => 'background: {{VALUE}};',
                ],
            ]
        );

        $this->end_controls_section();

    }

    protected function render()
    {
        $settings = $this->get_settings_for_display();
        $align = $settings['menu_toggle_alignment'];

        echo "<div class='$align'><span class='banta-elementor-toggle' onclick='menuToggleElementor()'>";
        echo "<span></span><span></span><span></span>";
        echo "</span></div>";
    }


}

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