Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Websites UFRPE
django-dsgov
Commits
8b319d7a
Commit
8b319d7a
authored
Oct 28, 2025
by
Adryan Reis
Browse files
br text
parent
5432c185
Changes
2
Hide whitespace changes
Inline
Side-by-side
dsgov/templatetags/br_components.py
View file @
8b319d7a
...
@@ -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
tests/django_dsgov_test1/setup.sh
100644 → 100755
View file @
8b319d7a
File mode changed from 100644 to 100755
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment