<?php

/**
 * @see https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/block-api/block-metadata.md#render
 */

/**
 * Stack Cards Block Render Template
 */

$spacing = isset($attributes['spacing']) ? $attributes['spacing'] : 25;
$cardHeight = isset($attributes['cardHeight']) ? $attributes['cardHeight'] : 400;
$stickyOffset = isset($attributes['stickyOffset']) ? $attributes['stickyOffset'] : 50;
$cardOffset = isset($attributes['cardOffset']) ? $attributes['cardOffset'] : 1;

$wrapper_attributes = get_block_wrapper_attributes([
  'class' => 'wp-block-orphic-ui-stack-card-wrapper',
  'style' => sprintf(
    '--card-height: %dpx; --sticky-offset: %dpx; --spacing: %dpx;',
    esc_attr($cardHeight),
    esc_attr($stickyOffset),
    esc_attr($spacing)
  ),
  'data-card-offset' => esc_attr($cardOffset),
  'data-card-sticky-offset' => esc_attr($stickyOffset),
]);
?>

<div <?php echo $wrapper_attributes; ?>>
  <div class="stack-items-container">
    <?php echo $content; ?>
  </div>
</div>