Skip to content
Snippets Groups Projects
Commit 0627dd38 authored by xaralis's avatar xaralis
Browse files

fix(shared): button block icon field description doesn't match actual block behavior

parent 81ae2adc
No related branches found
No related tags found
2 merge requests!561feat: improve image renditions to respect the focal point and provide srcset...,!560feat: improve image renditions to respect the focal point and provide srcset where meaningful as well
Pipeline #8673 passed
...@@ -331,6 +331,20 @@ class ButtonBlock(blocks.StructBlock): ...@@ -331,6 +331,20 @@ class ButtonBlock(blocks.StructBlock):
return super().clean(value) return super().clean(value)
def get_context(self, value, parent_context=None):
context = super().get_context(value, parent_context)
if value["icon"]:
context["icon_class"] = (
value["icon"]
if value["icon"].startswith("ico--")
else f"ico--{value['icon']}"
)
else:
context["icon_class"] = None
return context
class ButtonGroupBlock(blocks.StructBlock): class ButtonGroupBlock(blocks.StructBlock):
buttons = blocks.ListBlock(ButtonBlock(), label="Tlačítka") buttons = blocks.ListBlock(ButtonBlock(), label="Tlačítka")
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
{% if self.align == 'center' %}<div class="text-center">{% endif %} {% if self.align == 'center' %}<div class="text-center">{% endif %}
<a href="{{ target }}" class="btn btn--{{ self.color }} {% if self.hoveractive %}btn--hoveractive{% endif %} {% if self.icon %}btn--icon{% endif %} text-{{ self.size }} {% if self.mobile_fullwidth %}btn--fullwidth md:btn--autowidth{% else %}btn--autowidth{% endif %}" <a href="{{ target }}" class="btn btn--{{ self.color }} {% if self.hoveractive %}btn--hoveractive{% endif %} {% if self.icon %}btn--icon{% endif %} text-{{ self.size }} {% if self.mobile_fullwidth %}btn--fullwidth md:btn--autowidth{% else %}btn--autowidth{% endif %}"
> >
{% if self.icon %} {% if icon_class %}
<div class="btn__body-wrap"> <div class="btn__body-wrap">
<div class="btn__body ">{{ self.title }}</div> <div class="btn__body ">{{ self.title }}</div>
<div class="btn__icon "><i class="ico--{{ self.icon }}"></i></div> <div class="btn__icon "><i class="{{ icon_class }}"></i></div>
</div> </div>
{% else %} {% else %}
<div class="btn__body ">{{ self.title }}</div> <div class="btn__body ">{{ self.title }}</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment