Commit 1f86ca6b authored by Adryan Reis's avatar Adryan Reis
Browse files

update br text

parent d232a6d1
......@@ -334,27 +334,11 @@ def br_card(title='', text='', icon_class=None, icon_extra_class="", icon_style=
}
return render_to_string("dsgov/components/card_with_icon.html", context)
@register.simple_tag
def br_text(text='', tag='p', align='', wrap='', transform='', weight='', size='', extra_classes='', responsive_classes='', style=''):
def br_text(text='', tag='p', align='', wrap='', transform='', weight='', size='', extra_classes='', responsive_classes='', style='', href='', target=''):
"""
Renderiza um elemento de texto DSGov com classes de tipografia personalizáveis.
Parâmetros:
- text: o texto a ser exibido
- tag: elemento HTML (p, span, h1, h2, etc.) - padrão 'p'
- align: alinhamento (center, justify, left, right)
- wrap: comportamento de quebra (wrap, nowrap, truncate, break)
- transform: transformação (lowercase, uppercase, capitalize)
- weight: peso da fonte (thin, extra-light, light, regular, medium, semi-bold, bold, extra-bold, black)
- size: tamanho da fonte (up-07, up-06, up-05, up-04, up-03, up-02, up-01, base, down-01, down-02, down-03)
- extra_classes: classes CSS adicionais
- responsive_classes: classes responsivas personalizadas (ex: "text-lg-up-06 text-lg-left")
- style: estilos CSS inline
Exemplo de uso:
{% br_text text="Título Principal" tag="h1" size="up-05" weight="bold" align="center" %}
{% br_text text="Texto variável" size="up-01" responsive_classes="text-lg-up-06 text-lg-left" %}
Se href for fornecido, renderiza como link.
"""
# Construir classes baseadas nos parâmetros
classes = []
......@@ -392,11 +376,23 @@ def br_text(text='', tag='p', align='', wrap='', transform='', weight='', size='
# Adicionar style se fornecido
style_attr = f' style="{style}"' if style else ''
# Renderizar o elemento
return format_html(
'<{tag}{class_attr}{style_attr}>{text}</{tag}>',
tag=tag,
class_attr=f' class="{class_str}"' if class_str else '',
style_attr=style_attr,
text=text
)
\ No newline at end of file
# Se href for fornecido, renderiza como link
if href:
target_attr = f' target="{target}"' if target else ''
return format_html(
'<a href="{href}"{class_attr}{style_attr}{target_attr}>{text}</a>',
href=href,
class_attr=f' class="{class_str}"' if class_str else '',
style_attr=style_attr,
target_attr=target_attr,
text=text
)
else:
# Renderizar o elemento normal
return format_html(
'<{tag}{class_attr}{style_attr}>{text}</{tag}>',
tag=tag,
class_attr=f' class="{class_str}"' if class_str else '',
style_attr=style_attr,
text=text
)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment