<?php

function renderShapeElement($b, $element, $custom_classes, $elStyles, $colors, $viewport) {
  $data = $element['data'];
  $user_data = $data['user_data'];
  $elMarkup = "";

  $use_link = $user_data['isLinkable'];
  $gradientClass = isset($user_data['useGradient']) && $user_data['useGradient'] ? 'has-gradient' : '';

  $elementWidthPx = $data['elementWidth'] * 16;
  $elementHeightPx = $data['elementHeight'] * 16;
  $custom_classes .= $elementWidthPx == 1 ? ' '.$b.'__element--vertical-line ' : '';
  $custom_classes .= $elementHeightPx == 1 ? ' '.$b.'__element--horizontal-line ' : '';

  $elMarkup .= '<div class="'.$b.'__element '.$b.'__element--'.$element["id"].' '.$b.'__element--shape '.$gradientClass.' '.$custom_classes.'" style="'.$elStyles.'">';
  $target = $user_data['targetBlank'] ? "_blank" : "_self";
  if ($use_link) {
    $elMarkup .= '
      <a
        class="'.$b.'__element--image-link"
        href="'.$user_data['blockLink'].'"
        target="'.$target.'"
      ></a>
    ';
  }

  $elMarkup .= '</div>';

  return $elMarkup;
}
