<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>
<?php
/**
 * Product list toolbar
 *
 * @var $block \Magento\Catalog\Block\Product\ProductList\Toolbar
 */
use Magento\Catalog\Model\Product\ProductList\Toolbar;

$arrowIcon =  $this->helper(Olegnax\Athlete2\Helper\Icons::class)->getToolbarIcon('arrow');
?>
<div class="toolbar-sorter sorter">
    <div class="js-toolbar-switch">
	<label class="sorter-label" for="sorter"><?= $block->escapeHtml(__('Sort By')) ?></label> 
		<?php foreach ($block->getAvailableOrders() as $_key => $_order): ?>
				<?php if ($block->isOrderCurrent($_key)): ?>
				<label class="current">
					<?= $block->escapeHtml(__($_order)) ?>
				</label>
				<?php endif; ?>			
        <?php endforeach; ?>
	<div  class="js-toolbar-dropdown sorter-options" id="sorter" >
        <?php foreach ($block->getAvailableOrders() as $_key => $_order): ?>
            <div data-role="sorter" data-value="<?= $block->escapeHtmlAttr($_key) ?>"
                <?php if ($block->isOrderCurrent($_key)): ?>
                    selected="selected"
                <?php endif; ?>
                >
				<?= $block->escapeHtml(__($_order)) ?>
            </div>
        <?php endforeach; ?>
    </div>
	</div>
    <?php if ($block->getCurrentDirection() == 'desc'): ?>
        <a title="<?= $block->escapeHtmlAttr(__('Set Ascending Direction')) ?>" href="#" class="action sorter-action sort-desc" data-role="direction-switcher" data-value="asc">
            <?php echo $arrowIcon ?><span><?= $block->escapeHtml(__('Set Ascending Direction')) ?></span>
        </a>
    <?php else: ?>
        <a title="<?= $block->escapeHtmlAttr(__('Set Descending Direction')) ?>" href="#" class="action sorter-action sort-asc" data-role="direction-switcher" data-value="desc">
            <?php echo $arrowIcon ?><span><?= $block->escapeHtml(__('Set Descending Direction')) ?></span>
        </a>
    <?php endif; ?>
</div>
