<?php

/**
 * @author : Webforia Studio
 */

namespace Retheme\Customizer;

use Retheme\Customizer_Base;

class Brand extends Customizer_Base {

    public function __construct() {
        $this->add_brand_logo();
        $this->mobile_color_browser();
    }

    public function mobile_color_browser() {
        $section = 'title_tagline';

        $this->add_header([
            'label' => __('Browser Brand', 'jelajah-text'),
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'color',
            'choices' => ['alpha' => true],
            'label' => __('Color Browser', 'jelajah-text'),
            'settings' => 'brand_color_browser',
            'description' => __('Change the Color of Address Bar in Mobile Browser', 'jelajah-text'),
            'section' => $section,
            'default' => rt_get_theme('color')['primary'],
        ]);
    }

    public function add_brand_logo() {

        $section = 'title_tagline';

        // Logo Desktop
        $this->add_header([
            'label' => __('Desktop Logo', 'jelajah-text'),
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'image',
            'settings' => 'brand_logo_primary',
            'label' => __('Main Logo', 'jelajah-text'),
            'description' => __('This logo will be used as your default logo on desktop device', 'jelajah-text'),
            'section' => $section,
            'choices' => [
                'save_as' => 'array',
            ],
            'partial_refresh'    => [
                'brand_logo_primary' => [
                    'selector'        => '.rt-logo',
                    'render_callback' => '',
                ],
            ],
        ]);

        $this->add_field([
            'type' => 'slider',
            'settings' => 'brand_logo_primary_width',
            'label' => __('Main Logo Size', 'jelajah-text'),
            'section' => $section,
            'choices' => [
                'min' => '10',
                'max' => '300',
                'step' => '1',
            ],
            'default' => '180',
            'output' => [
                [
                    'element' => '.site-header .rt-logo',
                    'property' => 'width',
                    'units' => 'px',
                ],

            ],
            'transport' => 'auto',
        ]);

        // Logo Mobile
        $this->add_header([
            'label' => __('Mobile Logo', 'jelajah-text'),
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'image',
            'settings' => 'brand_logo_mobile',
            'label' => __('Mobile Logo', 'jelajah-text'),
            'description' => __('This logo will be used on mobile devices. If it is not available, the main logo will be used.', 'jelajah-text'),
            'section' => $section,
            'choices' => [
                'save_as' => 'array',
            ],
            'partial_refresh'    => [
                'brand_logo_mobile' => [
                    'selector'        => '.rt-logo-mobile',
                    'render_callback' => '',
                ],
            ],
        ]);

        $this->add_field([
            'type' => 'slider',
            'settings' => 'brand_logo_mobile_width',
            'label' => __('Mobile Logo Size', 'jelajah-text'),
            'section' => $section,
            'choices' => [
                'min' => '10',
                'max' => '300',
                'step' => '1',
            ],
            'default' => '130',
            'output' => [
                [
                    'element' => '.rt-logo-mobile',
                    'property' => 'width',
                    'units' => 'px',
                ],
            ],
            'transport' => 'auto',
        ]);
    }

    // end class
}

new Brand;
