<?php 
$toolbarHelper = $this->helper('Wyomind\ElasticsearchLayeredNavigation\Helper\Toolbar');
$currentMode = $toolbarHelper->getCurrentMode(); 
$_modes = $toolbarHelper->getModes(); ?>

<div class="modes eln-modes">
    <?php if ($_modes && count($_modes) > 1): ?>
        <strong class="modes-label" id="modes-label"><?= $block->escapeHtml(__('View as')) ?></strong>
        <?php foreach ($toolbarHelper->getModes() as $_code => $_label): ?>
            <?php if ($toolbarHelper->isModeActive($_code)): ?>
                <a class="el modes-mode active mode-<?= $block->escapeHtml(strtolower($_code)) ?>"
                   title="<?= $block->escapeHtml(__($_label)) ?>"
                   href="#"
                   data-role="mode-switcher"
                   data-value="<?= $block->escapeHtml(strtolower($_code)) ?>"
                   id="mode-<?= $block->escapeHtml(strtolower($_code)) ?>"
                   aria-labelledby="modes-label mode-<?= $block->escapeHtml(strtolower($_code)) ?>">
                    <span><?= $block->escapeHtml(__($_label)) ?></span>
                </a>
            <?php else: ?>
                <a class="el modes-mode mode-<?= $block->escapeHtml(strtolower($_code)) ?>"
                   title="<?= $block->escapeHtml(__($_label)) ?>"
                   href="#"
                   data-role="mode-switcher"
                   data-value="<?= $block->escapeHtml(strtolower($_code)) ?>"
                   id="mode-<?= $block->escapeHtml(strtolower($_code)) ?>"
                   aria-labelledby="modes-label mode-<?= $block->escapeHtml(strtolower($_code)) ?>">
                    <span><?= $block->escapeHtml(__($_label)) ?></span>
                </a>
            <?php endif; ?>
        <?php endforeach; ?>
    <?php endif; ?>
</div>