Commit f28e477a authored by Eduardo Silva's avatar Eduardo Silva
Browse files

alteracao na tag de footer #5

parent 671b9985
......@@ -3,6 +3,7 @@ from django.utils.html import format_html
from django.templatetags.static import static
from django.template.loader import render_to_string
from django.utils.safestring import mark_safe
from django.template.base import token_kwargs
register = template.Library()
......@@ -161,27 +162,37 @@ def do_footer_social_section(parser, token):
Esta tag agora lida com TODA a seção social,
incluindo o layout de linha e colunas, resolvendo o problema de coordenação.
"""
bits = token.split_contents()
kwargs = token_kwargs(bits[1:], parser)
nodelist = parser.parse(('end_br_footer_social_section',))
parser.delete_first_token()
return SocialSectionNode(nodelist)
return SocialSectionNode(nodelist, kwargs)
class SocialSectionNode(template.Node):
def __init__(self, nodelist):
def __init__(self, nodelist, kwargs):
self.nodelist = nodelist
self.kwargs = kwargs
def render(self, context):
# A tag filha vai popular essas listas no contexto
# Pega o título se tiver, senão usa padrão
title = self.kwargs.get('title')
if title:
title = title.resolve(context)
else:
title = "Redes Sociais"
# Coleta os dados
social_links = []
assign_images = []
with context.push(social_links=social_links, assign_images=assign_images):
self.nodelist.render(context)
# Agora construímos o HTML com os dados coletados
# HTML dos ícones e imagens
social_links_html = ''.join([format_html(
'<a class="br-button circle" href="{}" aria-label="{}"><i class="fab {}" aria-hidden="true"></i></a>',
link['href'], link['aria_label'], link['icone']
) for link in social_links])
assign_images_html = ''.join([format_html(
'<img class="ml-4" src="{}" alt="{}"/>',
img['src'], img['alt']
......@@ -192,13 +203,14 @@ class SocialSectionNode(template.Node):
<div class="row align-items-end justify-content-between py-5">
<div class="col">
<div class="social-network">
<div class="social-network-title">Redes Sociais</div>
<div class="social-network-title">{}</div>
<div class="d-flex">{}</div>
</div>
</div>
<div class="col assigns text-right">{}</div>
</div>
</div>''',
title,
mark_safe(social_links_html),
mark_safe(assign_images_html)
)
......
{% extends "dsgov/base.html" %}
{% load footer_tags %}
{% load br_footer_tags %}
{% load static %}
{% block title %}
......@@ -80,7 +80,7 @@
{% end_br_footer_columns_group %}
{# Seção de Redes Sociais que organiza suas próprias colunas e linhas #}
{% br_footer_social_section %}
{% br_footer_social_section title="Nossas Redes" %}
{% br_footer_rede_social href="#" icone="fa-facebook-f" aria_label="Facebook" %}
{% br_footer_rede_social href="#" icone="fa-twitter" aria_label="Twitter" %}
{% br_footer_rede_social href="#" icone="fa-linkedin-in" aria_label="LinkedIn" %}
......@@ -171,7 +171,7 @@
{% end_br_footer_columns_group %}
{# Seção de Redes Sociais que organiza suas próprias colunas e linhas #}
{% br_footer_social_section %}
{% br_footer_social_section title="Nossas Redes" %}
{% br_footer_rede_social href="#" icone="fa-facebook-f" aria_label="Facebook" %}
{% br_footer_rede_social href="#" icone="fa-twitter" aria_label="Twitter" %}
{% br_footer_rede_social href="#" icone="fa-linkedin-in" aria_label="LinkedIn" %}
......
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