<?php
/**
 * Sidebar navigation partial.
 *
 * @package MonitorCat
 *
 * @var \MonitorCat\Module\ModuleInterface[] $modules Active modules from the registry.
 */

defined( 'ABSPATH' ) || exit;

// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reading page query param for nav highlighting.
$monitorcat_current_page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
?>

<nav class="mc-nav" aria-label="<?php esc_attr_e( 'Plugin navigation', 'monitor-cat' ); ?>">
	<ul class="mc-nav-list">
		<li class="mc-nav-item">
			<a
				href="<?php echo esc_url( admin_url( 'admin.php?page=monitor-cat' ) ); ?>"
				class="mc-nav-link <?php echo esc_attr( 'monitor-cat' === $monitorcat_current_page ? 'is-active' : '' ); ?>"
			>
				<span class="mc-nav-icon"><i class="fa-duotone fa-grid-2"></i></span>
				<span class="mc-nav-label"><?php esc_html_e( 'Dashboard', 'monitor-cat' ); ?></span>
			</a>
		</li>
		<?php if ( ! empty( $modules ) ) : ?>
			<?php foreach ( $modules as $monitorcat_module ) : ?>
				<?php
				$monitorcat_slug      = $monitorcat_module->slug();
				$monitorcat_page_slug = 'monitor-cat-' . $monitorcat_slug;
				?>
				<li class="mc-nav-item">
					<a
						href="<?php echo esc_url( admin_url( 'admin.php?page=' . $monitorcat_page_slug ) ); ?>"
						class="mc-nav-link <?php echo esc_attr( $monitorcat_page_slug === $monitorcat_current_page ? 'is-active' : '' ); ?>"
					>
						<span class="mc-nav-icon"><i class="fa-duotone <?php echo esc_attr( $monitorcat_module->icon() ); ?>"></i></span>
						<span class="mc-nav-label"><?php echo esc_html( $monitorcat_module->name() ); ?></span>
					</a>
				</li>
			<?php endforeach; ?>
		<?php endif; ?>
	</ul>
</nav>
