<?php
/**
 * Grid card — image, category, title, meta.
 *
 * @package Kutby
 * @since   2.9.0
 */

declare(strict_types=1);

namespace Kutby\Cards\Variants;

use Kutby\Cards\Contracts\CardVariantInterface;
use Kutby\Cards\Parts\CategoryBadge;
use Kutby\Cards\Parts\Meta;
use Kutby\Cards\Parts\Thumbnail;
use Kutby\Cards\Parts\Title;
use Kutby\Cards\Support\CardContext;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class GridCard
 */
final class GridCard implements CardVariantInterface {

	/**
	 * {@inheritdoc}
	 */
	public static function id(): string {
		return 'grid';
	}

	/**
	 * {@inheritdoc}
	 */
	public static function render( CardContext $ctx ): void {
		$classes = trim( 'kutby-card kutby-card--grid ' . $ctx->extra_class() );
		?>
		<article <?php post_class( $classes, $ctx->post() ); ?>>
			<?php Thumbnail::render( $ctx, array( 'size' => 'medium_large', 'lazy' => true ) ); ?>
			<div class="kutby-card__body">
				<?php CategoryBadge::render( $ctx ); ?>
				<?php Title::render( $ctx ); ?>
				<?php Meta::render( $ctx ); ?>
			</div>
		</article>
		<?php
	}
}
