<?php
/**
 * Block Name: Pull Quote
 *
 * A decorative pull quote with background vectors and accent border.
 *
 * @package CWC
 */

namespace CWC;

$quote_bg      = get_field( 'quote_bg' );
$quote_bgColor = get_field( 'quote_bg_color' );
$quote_text    = get_field( 'quote_text' );

if ( empty( $quote_text ) ) {
	return;
}

if ( $quote_bgColor ) {
    $quote_bgColor = 'bg-[' . esc_attr( $quote_bgColor ) . '] ';
} else {
    $quote_bgColor = 'bg-(--color-pullquote-bg) ';
}

$classes = $quote_bgColor . 'pull-quote mx-break-out';
$wrapper = blockWrapperAttributes( $classes, $is_preview );
?>

<section <?php echo wp_kses_post( $wrapper ); ?>>
	<div class="pull-quote__vector" aria-hidden="true">
		<?php if ( $quote_bg ) : ?>
            <img class="pull-quote__vector--bg" src="<?php echo esc_url( $quote_bg['url'] ); ?>" alt="" loading="lazy" role="presentation" />
		<?php endif; ?>
		<img class="pull-quote__vector--mobile" src="<?php echo esc_url( get_theme_file_uri( '/static/img/pullquote-mobile-linework.png' ) ); ?>" alt="" loading="lazy" role="presentation" />
	</div>

	<div class="container wider pull-quote__content">
		<div class="pull-quote__text">
			<?php echo wp_kses_post( $quote_text ); ?>
		</div>
	</div>
</section>
