<?php 
    if (isset($block['data']['isExample']) && $block['data']['isExample']) {
        echo '<img src="' . esc_url( $block['data']['preview_image'] ) . '"style="max-width:100%; min-width:100%" alt="Preview" />';
        return;
    }

    global $rdgb;
    $rdgb = (!empty($rdgb)) ? $rdgb : Rdg_Blocks::instance();

    $block_styles = [];
    $block_classes = [BLOCK_RDG_BANNER_SIDEBAR];
    $block_banner_sidebar = $rdgb->settings->getBlock(BLOCK_RDG_BANNER_SIDEBAR);

    if (!empty($block['backgroundColor'])) {
        $block_classes[] = 'has-background';
        $block_classes[] = 'has-'.$block['backgroundColor'].'-background-color';
    }

    if (!empty($block['style']['color']['background'])) {
        $block_styles[] = 'background-color: '.$block['style']['color']['background'].';';
    }
    
    $texts = get_field('texts');
    $member = get_field('member');
    $padding_spaces = get_field('padding_spaces');
    $position_block = $rdgb->helpers->getBlocksSpaces(get_fields());
    $style_block = $block_banner_sidebar->get_style('block', get_field('background'));
    $style_position = $block_banner_sidebar->get_style('position', get_field('padding_spaces'));
?>

<div class="rdg-blocks">
    <div class="<?php echo esc_attr(join(' ', $block_classes)); ?>" style="<?php echo $position_block . esc_attr(join(' ', $block_styles)); ?>">
        <div class="container content grid-container">
            <div class="body" style="<?php echo $style_block; ?>">
                <div class="positions" style="<?php echo $style_position; ?>">
                    <?php $block_banner_sidebar->get_texts($padding_spaces, $texts, $member); ?>
                </div>
            </div>
        </div>
    </div>
</div>
