<?php
$buttons_align = mb_get_block_field("component-buttons-align");
$buttons_side_margin = mb_get_block_field("component-buttons-margin-side");
$buttons_bottom_margin = mb_get_block_field("component-buttons-margin-bottom");
$fullwidth = mb_get_block_field("component-buttons-mobile-fullwidth");
$buttons = mb_get_block_field("component-buttons");
if (!empty($buttons_side_margin)) {
  $side_margin = $buttons_side_margin;
} else {
  $side_margin = 0;
}
if (!empty($buttons_bottom_margin)) {
  $bottom_margin = $buttons_bottom_margin;
} else {
  $bottom_margin = 0;
}

if ($buttons) { ?>
<section <?= inoby_block_attrs($attributes, ["class" => "component-buttons"]) ?>>
  <div class="container">
    <div class="row">
      <div class="col-12 buttons-wrap <?php if ($fullwidth == 1):
        echo "fullwidth-mobile";
      endif; ?>"
        style="justify-content: <?= $buttons_align ?>;">
        <?php foreach ($buttons as $button) {
          $target = "";
          if (!empty($button["target"])) {
            if ($button["target"]) {
              $target = "_blank";
            } else {
              $target = "_self";
            }
          } else {
            $target = "_self";
          }
          echo '<a href="' .
            $button["url"] .
            '" target="' .
            $target .
            '" class="' .
            $button["type"] .
            '" style="margin: 0 ' .
            $side_margin .
            "px " .
            $bottom_margin .
            'px;">' .
            $button["text"] .
            "</a>";
        } ?>
      </div>
    </div>
  </div>
</section>
<?php }
