<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
// @codingStandardsIgnoreFile
?>
<?php

/**
 * Product list toolbar
 *
 * @var $block \Magento\Catalog\Block\Product\ProductList\Toolbar
 */
use Magento\Catalog\Model\Product\ProductList\Toolbar;
?>
<?php if ($block->isEnabledViewSwitcher()): ?>
    <div class="modes">
        <?php $_modes = $block->getModes(); ?>
        <?php if ($_modes && count($_modes) > 1): ?>
            <strong class="label col-form-label-sm" id="modes-label"><?php /* @escapeNotVerified */ echo __('View as') ?></strong>
            
            <div class="btn-group btn-group-sm ml-2" role="group">
                <?php foreach ($block->getModes() as $_code => $_label): ?>
                    <?php $_icon = null;
                    if ($_code === 'grid'):
                        $_icon ='<i class="fas fa-th" title="' . $_label . '"></i>';
                    elseif ($_code === 'list'):
                        $_icon = '<i class="fas fa-list" title="' . $_label . '"></i>';
                    endif; ?>
                    <?php if ($block->isModeActive($_code)): ?>
                        <a href="#" title="<?php /* @escapeNotVerified */ echo $_label ?>"
                           class="modes-mode active mode-<?php /* @escapeNotVerified */ echo strtolower($_code); ?> btn btn-primary"
                           data-value="<?php /* @escapeNotVerified */ echo strtolower($_code); ?>">
                               <?php if ($_icon):
                                echo $_icon;
                                endif; ?>
                        </a>
                    <?php else: ?>
                        <a class="modes-mode mode-<?php /* @escapeNotVerified */ echo strtolower($_code); ?> btn btn-primary"
                           title="<?php /* @escapeNotVerified */ echo $_label ?>"
                           href="#"
                           data-role="mode-switcher"
                           data-value="<?php /* @escapeNotVerified */ echo strtolower($_code); ?>"
                           id="mode-<?php /* @escapeNotVerified */ echo strtolower($_code); ?>"
                           aria-labelledby="modes-label mode-<?php /* @escapeNotVerified */ echo strtolower($_code); ?>">
                               <?php if ($_icon):
                                   echo $_icon;
                            endif; ?>
                        </a>
                    <?php endif; ?>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>
    </div>
<?php endif; ?>
