Skip to content

Commit

Permalink
changed badge offset
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Seipelt authored and jeremy-seipelt committed Nov 19, 2021
1 parent c251345 commit e44ef60
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 66 deletions.
60 changes: 22 additions & 38 deletions Resources/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@
<name>Add Manually</name>
<name lang="de-DE">Manuell Einfügen</name>
</option>
<option>
<id>top_left</id>
<name>top left</name>
<name lang="de-DE">oben links</name>
</option>
<option>
<id>top_right</id>
<name>top right</name>
<name lang="de-DE">oben rechts</name>
</option>
<option>
<id>bottom_left</id>
<name>bottom left</name>
<name lang="de-DE">unten links</name>
</option>
<option>
<id>bottom_right</id>
<name>bottom right</name>
<name lang="de-DE">unten rechts</name>
</option>
</options>
</input-field>

Expand Down Expand Up @@ -82,44 +102,8 @@
</options>
</input-field>

<input-field type="single-select">
<name>float</name>
<label>Badge Float</label>
<label lang="de-DE">Badge Float</label>
<helpText>Select if the badge should be floating instead of being part of the footer</helpText>
<helpText lang="de-DE">Wählen Sie ob das Badge am Bildschirm klebt, anstelle Teil des Footers zu sein</helpText>
<defaultValue>none</defaultValue>
<options>
<option>
<id>none</id>
<name>none</name>
<name lang="de-DE">keins</name>
</option>
<option>
<id>top_left</id>
<name>top left</name>
<name lang="de-DE">oben links</name>
</option>
<option>
<id>top_right</id>
<name>top right</name>
<name lang="de-DE">oben rechts</name>
</option>
<option>
<id>bottom_left</id>
<name>bottom left</name>
<name lang="de-DE">unten links</name>
</option>
<option>
<id>bottom_right</id>
<name>bottom right</name>
<name lang="de-DE">unten rechts</name>
</option>
</options>
</input-field>

<input-field type="int">
<name>offsetX</name>
<name>floatingOffsetX</name>
<label>Offset X axis</label>
<label lang="de-DE">Abstand X Achse</label>
<helpText>Offset on the X axis from the nearest edge. Only affects floating badges!</helpText>
Expand All @@ -128,7 +112,7 @@
</input-field>

<input-field type="int">
<name>offsetY</name>
<name>floatingOffsetY</name>
<label>Offset Y axis</label>
<label lang="de-DE">Abstand Y Achse</label>
<helpText>Offset on the Y axis from the nearest edge. Only affects floating badges!</helpText>
Expand Down
26 changes: 3 additions & 23 deletions Resources/views/storefront/base.html.twig
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
{% sw_extends '@Storefront/storefront/base.html.twig' %}

{% set float = config('ZmbGoogleCustomerReviews.config.float') %}
{% set offsetY = config('ZmbGoogleCustomerReviews.config.offsetY') %}
{% set offsetX = config('ZmbGoogleCustomerReviews.config.offsetX') %}

{% macro offset(context) %}
{% if context.float == "top_left" %}
{% set axisY = "top" %}
{% set axisX = "left" %}
{% elseif context.float == "top_right" %}
{% set axisY = "top" %}
{% set axisX = "right" %}
{% elseif context.float == "bottom_left" %}
{% set axisY = "bottom" %}
{% set axisX = "left" %}
{% elseif context.float == "bottom_right" %}
{% set axisY = "bottom" %}
{% set axisX = "right" %}
{% endif %}
{{axisY}}:{{context.offsetY}}px;{{axisX}}:{{context.offsetX}}px;
{% endmacro %}

{% set position = config('ZmbGoogleCustomerReviews.config.position') %}

{% block base_body_inner %}
{{parent()}}

{% if float != 'none' %}
{% sw_include '@Storefront/pro-customer-reviews/components/badge.html.twig' with { class: "floating", offset: _self.offset(_context) } %}
{% if position == 'top_left' or position == 'top_right' or position == 'bottom_right' or position == 'bottom_left' %}
{% sw_include '@Storefront/pro-customer-reviews/components/badge.html.twig' with { class: "floating" } %}
{% endif %}

{% endblock %}
8 changes: 3 additions & 5 deletions Resources/views/storefront/layout/footer/footer.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,19 @@
{% block layout_footer_navigation_information_links %}
{{parent()}}

{% if position == "footer-nav" and loop.last and float == "none" %}
{% sw_include '@ZmbGoogleCustomerReviews/storefront/pro-customer-reviews/components/badge.html.twig' %}
{% if position == "footer-nav" and loop.last %}
{% endif %}
{% endblock %}

{% block layout_footer_shipping_logos %}
{{parent()}}

{% if position == "shipping-payment" and float == "none" %}
{% sw_include '@ZmbGoogleCustomerReviews/storefront/pro-customer-reviews/components/badge.html.twig' with { class: "footer-logo" } %}
{% if position == "shipping-payment" %}
{% endif %}
{% endblock %}

{% block layout_footer_copyright %}
{% if position == "copyright-before" and float == "none" %}
{% if position == "copyright-before" %}
<div class="footer-copyright" style="margin-bottom: 16px">
{% sw_include '@ZmbGoogleCustomerReviews/storefront/pro-customer-reviews/components/badge.html.twig' %}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
{% block pro_customer_reviews_badge %}{% apply spaceless %}
{% set theme = theme ?: config('ZmbGoogleCustomerReviews.config.theme') %}
{% set position = config('ZmbGoogleCustomerReviews.config.position') %}
{% set offsetY = config('ZmbGoogleCustomerReviews.config.floatingOffsetY') %}
{% set offsetX = config('ZmbGoogleCustomerReviews.config.floatingOffsetX') %}

{% macro offset(context) %}
{% if context.position == "top_left" %}
{% set axisY = "top" %}
{% set axisX = "left" %}
{% elseif context.position == "top_right" %}
{% set axisY = "top" %}
{% set axisX = "right" %}
{% elseif context.position == "bottom_left" %}
{% set axisY = "bottom" %}
{% set axisX = "left" %}
{% elseif context.position == "bottom_right" %}
{% set axisY = "bottom" %}
{% set axisX = "right" %}
{% endif %}
{{axisY}}:{{context.offsetY}}px;{{axisX}}:{{context.offsetX}}px;
{% endmacro %}

<a data-pro-customer-reviews target="_blank" rel="noopener" data-key="{{ config('ZmbGoogleCustomerReviews.config.apiKey') }}" data-id="{{ config('ZmbGoogleCustomerReviews.config.placeId') }}" data-load-lib="{{ config('ZmbGoogleCustomerReviews.config.loadLib') }}" class="theme-{{theme}}{% if class %} {{ class }}{% endif %}" style="{% if offset %} {{ offset }}{% endif %}">
{% block pro_customer_reviews_badge_content %}
Expand Down

0 comments on commit e44ef60

Please sign in to comment.