<?php
$align = isset($attributes['align']) ? $attributes['align'] : '';
$link = isset($attributes['link']) ? $attributes['link'] : [];
$text = isset($attributes['text']) ? $attributes['text'] : '';
$color = isset($attributes['color']) ? $attributes['color'] : 'red';


$svg_arrow_path = get_template_directory() . '/resources/img/carhop-fleche-lien-externe-full.svg';


$wrapper_attributes = get_block_wrapper_attributes([
	'class' => 'align--' . esc_attr($align),
	'style' => sprintf(
		'color: %s; --cta-current-color: %s;',
		esc_attr($color),
		esc_attr($color)
	)
]);

$link_url = isset($link['url']) ? esc_url($link['url']) : '#';
?>

<a href="<?php echo $link_url; ?>" <?php echo $wrapper_attributes; ?>>
	<?php echo esc_html($text); ?>
	<div class="icon">

		<svg id="fleche-lien-externe-full" viewBox="0 0 32 32" style="--cta-current-color: <?php echo esc_attr($color); ?>">
			<g>
				<path class="cls-1" d="M21.15,10.59l-9.38,10.02" />
				<path class="cls-1" d="M21.15,21.4v-10.81h-10.32" />
			</g>
			<circle class="cls-1" cx="16" cy="16" r="15" />
		</svg>
	</div>
</a>