Commit 8b319d7a authored by Adryan Reis's avatar Adryan Reis
Browse files

br text

parent 5432c185
...@@ -319,3 +319,70 @@ def br_card(title='', text='', icon_class=None, icon_extra_class="", icon_style= ...@@ -319,3 +319,70 @@ def br_card(title='', text='', icon_class=None, icon_extra_class="", icon_style=
"text_style": text_style, "text_style": text_style,
} }
return render_to_string("dsgov/components/card_with_icon.html", context) 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=''):
"""
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" %}
"""
# Construir classes baseadas nos parâmetros
classes = []
# Alinhamento
if align in ['center', 'justify', 'left', 'right']:
classes.append(f'text-{align}')
# Wrap e overflow
if wrap in ['wrap', 'nowrap', 'truncate', 'break']:
classes.append(f'text-{wrap}')
# Transformação
if transform in ['lowercase', 'uppercase', 'capitalize']:
classes.append(f'text-{transform}')
# Peso
if weight in ['thin', 'extra-light', 'light', 'regular', 'medium', 'semi-bold', 'bold', 'extra-bold', 'black']:
classes.append(f'text-weight-{weight}')
# Tamanho
if size in ['up-07', 'up-06', 'up-05', 'up-04', 'up-03', 'up-02', 'up-01', 'base', 'down-01', 'down-02', 'down-03']:
classes.append(f'text-{size}')
# Adicionar classes extras e responsivas
if extra_classes:
classes.append(extra_classes)
if responsive_classes:
classes.append(responsive_classes)
# Montar classe final
class_str = ' '.join(classes).strip()
# 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
File mode changed from 100644 to 100755
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