<?php
defined( 'ABSPATH' ) || exit;

class Jalpi_Element_Divider extends Jalpi_Element {
    public static function type(): string { return 'divider'; }

    public function render( array $node, Jalpi_Renderer $renderer ): string {
        $id     = sanitize_html_class( $node['id'] ?? '' );
        $styles = $node['styles'] ?? [];
        $a      = $renderer->get_css_attrs( $node );
        $renderer->add_css( '.jalpi-el.jalpi-' . $id . '{display:block;' . $renderer->styles_to_css( $styles ) . '}' );
        return '<hr class="jalpi-el jalpi-divider jalpi-' . esc_attr( $id ) . $a['extra_cls'] . '"' . $a['id_attr'] . '>';
    }
}
