<?php

namespace GriffinForms\Admin\App\Html\Widgets\TitleBar;

final class PreviewBtn extends \GriffinForms\Admin\App\Html\Widgets\TitleBar\Format
{
    public function getHtml()
    {
        $form_id = isset($_GET['form_id']) ? absint($_GET['form_id']) : 0;
        if (!$form_id) {
            return;
        }

        $icon_path = $this->config->getRootUrl() . 'admin/images/icons/preview.svg';

        echo '<button type="button"';
        echo ' class="gf-titlebar-btn gf-titlebar-btn-preview gf-titlebar-btn-outlined"';
        echo ' aria-label="' . esc_attr(__('Frontend Preview', 'griffinforms-form-builder')) . '"';
        echo ' data-bs-toggle="modal" data-bs-target="#griffinforms-builder-modal-preview">';
        echo '<img src="' . esc_url($icon_path) . '" alt="" width="20" height="20">';
        echo esc_html__('Preview', 'griffinforms-form-builder');
        echo '</button>';
    }

    public function getJs()
    {
    }
}
