✨ feat: Add services-list block PHP template
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Block Name: Services List
|
||||
*
|
||||
* A row of service cards. Card count (2, 3, or 4) determines the layout.
|
||||
*
|
||||
* @package CWC
|
||||
*/
|
||||
|
||||
namespace CWC;
|
||||
|
||||
$items = get_field( 'items' );
|
||||
|
||||
if ( empty( $items ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$count = count( $items );
|
||||
$grid_cols = max( 2, min( 4, (int) $count ) );
|
||||
$grid_class = 'lg:grid-cols-' . $grid_cols;
|
||||
$line_url = '/wp-content/themes/community-works-collaborative/static/img/services-list-line.svg';
|
||||
|
||||
$classes = 'services-list mx-break-out relative ' . $grid_class;
|
||||
$wrapper = blockWrapperAttributes( $classes, $is_preview );
|
||||
?>
|
||||
|
||||
<section <?php echo wp_kses_post( $wrapper ); ?>>
|
||||
<div class="services-list__line" aria-hidden="true" style="background-image: url('<?php echo esc_url( $line_url ); ?>');"></div>
|
||||
|
||||
<div class="container">
|
||||
<div class="services-list__grid grid grid-cols-1 <?php echo esc_attr( $grid_class ); ?> gap-8 lg:gap-12">
|
||||
<?php foreach ( $items as $item ) : ?>
|
||||
<article class="services-list__card">
|
||||
<?php if ( ! empty( $item['image'] ) ) : ?>
|
||||
<figure class="services-list__media aspect-square">
|
||||
<img
|
||||
class="services-list__img"
|
||||
src="<?php echo esc_url( $item['image']['url'] ); ?>"
|
||||
alt="<?php echo esc_attr( $item['image']['alt'] ?? '' ); ?>"
|
||||
loading="lazy"
|
||||
/>
|
||||
</figure>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( ! empty( $item['heading'] ) ) : ?>
|
||||
<h3 class="services-list__heading">
|
||||
<?php echo wp_kses_post( $item['heading'] ); ?>
|
||||
</h3>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( ! empty( $item['description'] ) ) : ?>
|
||||
<div class="services-list__desc">
|
||||
<?php echo wp_kses_post( $item['description'] ); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
Reference in New Issue
Block a user