✨ feat: Add team-grid block PHP template
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Block Name: Team Grid
|
||||
*
|
||||
* A responsive grid of team members. Each card uses a native <details>
|
||||
* element so the bio expands when the photo, name, or title is clicked.
|
||||
*
|
||||
* @package CWC
|
||||
*/
|
||||
|
||||
namespace CWC;
|
||||
|
||||
$members = get_field( 'members' );
|
||||
|
||||
if ( empty( $members ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$classes = 'team-grid container my-section mx-auto';
|
||||
$wrapper = blockWrapperAttributes( $classes, $is_preview );
|
||||
?>
|
||||
|
||||
<section <?php echo wp_kses_post( $wrapper ); ?>>
|
||||
<div class="team-grid__inner grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-8 lg:gap-12">
|
||||
<?php foreach ( $members as $member ) : ?>
|
||||
<article class="team-grid__card">
|
||||
<details class="team-grid__details">
|
||||
<summary class="team-grid__summary">
|
||||
<?php if ( ! empty( $member['image'] ) ) : ?>
|
||||
<img
|
||||
class="team-grid__photo"
|
||||
src="<?php echo esc_url( $member['image']['url'] ); ?>"
|
||||
alt="<?php echo esc_attr( $member['image']['alt'] ?? '' ); ?>"
|
||||
loading="lazy"
|
||||
/>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( ! empty( $member['name'] ) ) : ?>
|
||||
<h3 class="team-grid__name">
|
||||
<?php echo wp_kses_post( $member['name'] ); ?>
|
||||
</h3>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( ! empty( $member['title'] ) ) : ?>
|
||||
<p class="team-grid__title">
|
||||
<?php echo wp_kses_post( $member['title'] ); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</summary>
|
||||
|
||||
<div class="team-grid__bio-wrap">
|
||||
<div class="team-grid__bio-inner">
|
||||
<?php if ( ! empty( $member['bio'] ) ) : ?>
|
||||
<div class="team-grid__bio">
|
||||
<?php echo wp_kses_post( $member['bio'] ); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</section>
|
||||
Reference in New Issue
Block a user