Files
CWC/views/blocks/homepage-hero/homepage-hero.php
T
Keith Solomon a0c6e3251b
Sync TODOs with Issues / sync_todos (push) Successful in 6s
feature: Homepage hero
Co-authored-by: Copilot <copilot@github.com>
2026-05-12 12:25:38 -05:00

118 lines
4.1 KiB
PHP

<?php
/**
* Block Name: Homepage Hero
*
* @package CWC
*/
namespace CWC;
// Retrieve ACF fields
$media = get_field( 'media' );
$heading = get_field( 'heading' );
$intro = get_field( 'intro' );
$ctas = get_field( 'calls_to_action' );
if ( $media === 'image' ) {
$heroImage = get_field( 'hero_image' );
if ( $heroImage ) {
$heroURL = $heroImage['url'];
}
} elseif ( $media === 'video' ) {
$heroVideo = get_field( 'hero_video' );
if ( $heroVideo ) {
$heroURL = $heroVideo;
}
}
$classes = 'homepage-hero mx-break-out relative text-light overflow-hidden';
$wrapper = blockWrapperAttributes( $classes, $is_preview );
?>
<section <?php echo wp_kses_post( $wrapper ); ?>>
<div class="container content-wrapper relative z-10">
<div class="max-w-4xl sm:text-center lg:text-left lg:items-center ml-0 pt-24">
<?php if ( ! empty( $heading ) ) : ?>
<h1 class="text-4xl lg:text-5xl font-bold leading-tight mb-4">
<?php echo esc_html( $heading ); ?>
</h1>
<?php endif; ?>
<?php if ( ! empty( $intro ) ) : ?>
<div class="intro">
<?php echo wp_kses_post( $intro ); ?>
</div>
<?php endif; ?>
<?php if ( ! empty( $ctas ) ) : ?>
<div class="reset mt-4 sm:mt-6 flex flex-wrap justify-center lg:justify-start gap-2">
<?php foreach ( $ctas as $index => $cta ) : ?>
<?php
$ctaLink = $cta['link'];
$ctaURL = $ctaLink['url'] ?? '#';
$ctaTarget = $ctaLink['target'] ?? '_self';
$ctaTitle = $ctaLink['title'] ?? '';
// Handle admin preview
if ( is_admin() && $ctaURL ) {
$ctaURL = '#';
}
?>
<x-button
btnclasses="button text-center min-w-32"
element="a"
url="<?php echo esc_url( $ctaURL ); ?>"
target="<?php echo esc_attr( $ctaTarget ); ?>"
title="<?php echo esc_attr( $ctaTitle ); ?>"
<?php if ( $index === 0 ) { ?>
color="primary"
<?php } else { ?>
color="primary" variant="outline"
<?php } ?>
width="small"
></x-button>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>
<div class="heroVector absolute inset-0 z-10">
<div class="vector absolute bottom-4 w-full">
<?php get_template_part( 'views/partials/hero-vector' ); ?>
</div>
</div>
<div class="topGradient absolute inset-0 z-1"><!-- Rectangle 88 --></div>
<div class="bgVector absolute inset-0 z-1"><!-- Rectangle 83 --></div>
<div class="heroBG absolute inset-0 z-1"><!-- Rectangle 2 --></div>
<div class="heroMedia absolute inset-0 z-0">
<?php if ( ! empty( $heroURL ) ) : ?>
<?php if ( $media === 'image' ) : ?>
<img
src="<?php echo esc_url( $heroURL ); ?>"
alt="<?php echo esc_attr( $heading ); ?>"
class="w-full h-full object-cover object-center"
/>
<?php elseif ( $media === 'video' ) : ?>
<video
autoplay
loop
muted
playsinline
disablePictureInPicture
class="w-full h-full object-cover object-center"
>
<source src="<?php echo esc_url( $heroURL ); ?>" type="video/mp4">
Your browser does not support the video tag.
</video>
<?php endif; ?>
<?php endif; ?>
</div>
</section>