Skip to content

Commit

Permalink
adds theme toggle for avatar widget to allow opt-out without code change
Browse files Browse the repository at this point in the history
  • Loading branch information
mtbottens committed May 31, 2024
1 parent abbf0dd commit 68554e9
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 17 deletions.
8 changes: 8 additions & 0 deletions locales/en.default.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,14 @@
"options__2": {
"label": "Left"
}
},
"header__7": {
"content": "Customer accounts log in",
"info": "To manage customer accounts, go to your [customer accounts settings](/admin/settings/customer_accounts)."
},
"enable_customer_avatar": {
"label": "Show avatar",
"info": "Customers will only see their avatar when they're signed in with Shop"
}
}
},
Expand Down
3 changes: 0 additions & 3 deletions sections/footer.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,7 @@

{%- if shop.features.follow_on_shop? and section.settings.enable_follow_on_shop -%}
<div class="footer__follow-on-shop">
{% comment %} TODO: enable theme-check once `login_button` is accepted as valid filter {% endcomment %}
{% # theme-check-disable %}
{{ shop | login_button: action: 'follow' }}
{% # theme-check-enable %}
</div>
{%- endif -%}

Expand Down
30 changes: 23 additions & 7 deletions sections/header.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,17 @@

{%- if shop.customer_accounts_enabled -%}
<a href="{%- if customer -%}{{ routes.account_url }}{%- else -%}{{ routes.account_login_url }}{%- endif -%}" class="header__icon header__icon--account link focus-inset{% if section.settings.menu != blank %} small-hide{% endif %}">
<account-icon>
{%- if customer and customer.has_avatar? -%}
{{ customer | avatar }}
{%- else -%}
{% render 'icon-account' %}
{%- endif -%}
</account-icon>
{%- if section.settings.enable_customer_avatar -%}
<account-icon>
{%- if customer and customer.has_avatar? -%}
{{ customer | avatar }}
{%- else -%}
{% render 'icon-account' %}
{%- endif -%}
</account-icon>
{%- else -%}
{% render 'icon-account' %}
{%- endif -%}
<span class="visually-hidden">
{%- liquid
if customer
Expand Down Expand Up @@ -586,6 +590,18 @@
"default": true,
"label": "t:sections.header.settings.enable_language_selector.label"
},
{
"type": "header",
"content": "t:sections.header.settings.header__7.content",
"info": "t:sections.header.settings.header__7.info"
},
{
"type": "checkbox",
"id": "enable_customer_avatar",
"default": true,
"label": "t:sections.header.settings.enable_customer_avatar.label",
"info": "t:sections.header.settings.enable_customer_avatar.info"
},
{
"type": "header",
"content": "t:sections.header.settings.mobile_layout.content"
Expand Down
18 changes: 11 additions & 7 deletions snippets/header-drawer.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,17 @@
href="{%- if customer -%}{{ routes.account_url }}{%- else -%}{{ routes.account_login_url }}{%- endif -%}"
class="menu-drawer__account link focus-inset h5 medium-hide large-up-hide"
>
<account-icon>
{%- if customer and customer.has_avatar? -%}
{{ customer | avatar }}
{%- else -%}
{% render 'icon-account' %}
{%- endif -%}
</account-icon>
{%- if section.settings.enable_customer_avatar -%}
<account-icon>
{%- if customer and customer.has_avatar? -%}
{{ customer | avatar }}
{%- else -%}
{% render 'icon-account' %}
{%- endif -%}
</account-icon>
{%- else -%}
{% render 'icon-account' %}
{%- endif -%}
{%- liquid
if customer
echo 'customer.account_fallback' | t
Expand Down

0 comments on commit 68554e9

Please sign in to comment.