/*
 * Caledros Basic Blocks - Easy to use Gutenberg blocks
 * Copyright (C) 2025  David Arnado
 * 
 * This file is part of Caledros Basic Blocks.
 * 
 * Caledros Basic Blocks is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.

 * Caledros Basic Blocks is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License along
 * with Caledros Basic Blocks; if not, see <https://www.gnu.org/licenses/>.
 */

import { useBlockProps } from "@wordpress/block-editor";

export default function SaveBlock({ attributes }) {
  const {
    icon,
    iconLink,
    iconLinkEnabled,
    iconsSize,
    iconsColor,
    iconsDarkColor,
  } = attributes;
  // Block props
  const blockProps = useBlockProps.save({
    className: `cbb-icon cbb-icon--${icon}`,
    style: {
      "--cbb-icon-size": `${iconsSize}px`,
      "--cbb-icon-color": `${iconsColor}`,
      "--cbb-icon-dark-color": `${iconsDarkColor}`,
    },
  });
  return (
    <div {...blockProps}>
      <span className="cbb-icon__icon-container"></span>
      {iconLinkEnabled && (
        <a
          href={iconLink}
          className="cbb-icon__main-link"
          aria-label={icon}
        ></a>
      )}
      {!iconLinkEnabled && <span className="cbb-icon__simple-icon"></span>}
    </div>
  );
}
