免插件添加适用于任何主题的 Shopify 信任徽章或图标
创建 Section
highlights-banners.liquid
{% if section.blocks.size > 0 %}
{% for block in section.blocks %}
{% if block.settings.text != blank or block.settings.title != blank %}
{% capture block_icon %}
{% if block.settings.icon != 'none' or block.settings.image != blank %}
{% if block.settings.image != blank %}
{%
include 'rimg',
class: 'highlights-banners-custom-icon',
img: block.settings.image,
size: 'x46'
%}
{% else %}
{% include 'icon-library', id: block.settings.icon %}
{% endif %}
{% endif %}
{% endcapture %}
{% unless section.settings.text_alignment == 'right' %}
{{ block_icon }}
{% endunless %}
{% if block.settings.title != blank %}
{{ block.settings.title | escape }}
{% endif %}
{% if block.settings.text != blank %}
{{ block.settings.text }}
{% endif %}
{% if section.settings.text_alignment == 'right' %}
{{ block_icon }}
{% endif %}
{% if block.settings.link != blank %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% schema %}
{
"name": "信任徽章",
"class": "highlights-banners--section",
"settings": [
{
"type": "range",
"id": "section_spacing_desktop",
"label": "高度调节",
"info": "[使用参考](https://shopify2006.com/shopify-add-trust-badge-function/)",
"min": 0,
"max": 100,
"step": 1,
"unit": "px",
"default": 45
},
{
"type": "select",
"id": "text_alignment",
"label": "文字对齐方式",
"options": [
{
"value": "left",
"label": "文字在右"
},
{
"value": "center",
"label": "文字置底"
},
{
"value": "right",
"label": "文字在左"
}
],
"default": "center"
},
{
"type": "header",
"content": "颜色"
},
{
"id": "heading_color",
"type": "color",
"label": "Heading 颜色",
"default": "#4d4d4d"
},
{
"id": "color",
"type": "color",
"label": "文字颜色",
"default": "#4d4d4d"
},
{
"id": "icon_color",
"type": "color",
"label": "图标颜色",
"default": "#4d4d4d"
},
{
"id": "dividers_color",
"type": "color",
"label": "分割线颜色",
"default": "#e3e3e3"
},
{
"id": "inner_background_color",
"type": "color",
"label": "Section 背景色",
"default": "#f8f8f8"
}
],
"blocks": [
{
"type": "highlight",
"name": "Highlight",
"settings": [
{
"id": "icon",
"type": "select",
"label": "内置 Icon",
"options": [
{
"value": "none",
"label": "No icon"
},
{
"value": "icon-cell-phone",
"label": "Cellphone"
},
{
"value": "icon-chat",
"label": "Chat"
},
{
"value": "icon-chat-alternate",
"label": "Chat alternate"
},
{
"value": "icon-credit-card",
"label": "Credit card"
},
{
"value": "icon-delivery",
"label": "Delivery"
},
{
"value": "icon-delivery-alt",
"label": "Delivery alternate"
},
{
"value": "icon-email",
"label": "Email"
},
{
"value": "icon-envelope",
"label": "Envelope"
},
{
"value": "icon-gift-card",
"label": "Gift card"
},
{
"value": "icon-heart",
"label": "Heart"
},
{
"value": "icon-label-tag",
"label": "Label tag"
},
{
"value": "icon-lock-alternate",
"label": "Lock"
},
{
"value": "icon-people",
"label": "People"
},
{
"value": "icon-people-alternate",
"label": "People alternate"
},
{
"value": "icon-pin",
"label": "Pin"
},
{
"value": "icon-question-mark",
"label": "Question mark"
},
{
"value": "icon-smile",
"label": "Smile"
},
{
"value": "icon-store",
"label": "Store"
},
{
"value": "icon-transfer",
"label": "Transfer"
},
{
"value": "icon-wallet",
"label": "Wallet"
}
],
"default": "none"
},
{
"id": "image",
"type": "image_picker",
"label": "自定义 Image",
"info": "推荐使用 50x50 的图片,设置之后会替换上方选择的图标"
},
{
"id": "title",
"type": "text",
"label": "Heading",
"default": "Highlight"
},
{
"id": "text",
"type": "richtext",
"label": "Text",
"default": "Highlight text
"
},
{
"id": "link",
"type": "url",
"label": "Link"
}
],
"limit": 4
}
],
"presets": [
{
"name": "信任徽章-shopify2006",
"category": "Advanced",
"blocks": [
{
"type": "highlight",
"settings": {
"icon": "icon-delivery",
"title": "Free shipping",
"text": "When you spend $100+
"
}
},
{
"type": "highlight",
"settings": {
"icon": "icon-cell-phone",
"title": "Give us a call",
"text": "+1 (201) 555-5555
"
}
},
{
"type": "highlight",
"settings": {
"icon": "icon-chat-alternate",
"title": "Chat with us",
"text": "We offer 24-hour chat support
"
}
},
{
"type": "highlight",
"settings": {
"icon": "icon-pin",
"title": "Locations",
"text": "Find a store near you
"
}
}
]
}
]
}
{% endschema %}
{% comment %}
powered by https://supershopify.online/
{% endcomment %}
创建 Snippet
icon-library.liquid
{% comment %}
@param id {String}
Name of icon to display
@param icon_class {string}
Custom class to add to SVG
{% endcomment %}
{%- capture icon -%}
{%- capture shared_svg_attrs -%}
class="{{ id | replace: '_', '-' }} {% if icon_class %}{{ icon_class }}{% endif %}"
aria-hidden="true"
focusable="false"
role="presentation"
xmlns="http://www.w3.org/2000/svg"
{%- endcapture -%}
{% assign icon_name = id | replace: '-', '_' %}
{% assign icon_name = 'general.icons.' | append: icon_name %}
{% assign icon_name = icon_name | t %}
{% capture icon_title %}
{{ 'general.icons.icon_title' | t: name: icon_name }}
{% endcapture %}
{% if id == 'icon-account' %}
{% endif %}
{% if id == 'icon-cart' %}
{% endif %}
{% if id == 'icon-bag' %}
{% endif %}
{% if id == 'icon-close' %}
{% endif %}
{% if id == 'icon-cell-phone' %}
{% endif %}
{% if id == 'icon-chat-alternate' %}
{% endif %}
{% if id == 'icon-chat' %}
{% endif %}
{% if id == 'icon-checkbox' %}
{% endif %}
{% if id == 'icon-checkmark' %}
{% endif %}
{% if id == 'icon-checkout-lock' %}
{% endif %}
{% if id == 'icon-chevron-down-small' %}
{% endif %}
{% if id == 'icon-chevron-down-thin' %}
{% endif %}
{% if id == 'icon-chevron-down' %}
{% endif %}
{% if id == 'icon-chevron-signpost' %}
{% endif %}
{% if id == 'icon-credit-card' %}
{% endif %}
{% if id == 'icon-delivery-alt' %}
{% endif %}
{% if id == 'icon-delivery' %}
{% endif %}
{% if id == 'icon-email' %}
{% endif %}
{% if id == 'icon-envelope' %}
{% endif %}
{% if id == 'icon-filters' %}
{% endif %}
{% if id == 'icon-gift-card' %}
{% endif %}
{% if id == 'icon-grid' %}
{% endif %}
{% if id == 'icon-heart' %}
{% endif %}
{% if id == 'icon-label-tag' %}
{% endif %}
{% if id == 'icon-list' %}
{% endif %}
{% if id == 'icon-lock-alternate' %}
{% endif %}
{% if id == 'icon-lock' %}
{% endif %}
{% if id == 'icon-menu-close' %}
{% endif %}
{% if id == 'icon-people-alternate' %}
{% endif %}
{% if id == 'icon-people' %}
{% endif %}
{% if id == 'icon-pin' %}
{% endif %}
{% if id == 'icon-model-thumb' %}
{% endif %}
{% if id == 'icon-play' %}
{% endif %}
{% if id == 'icon-play-thumb' %}
{% endif %}
{% if id == 'icon-question-mark' %}
{% endif %}
{% if id == 'icon-remove' %}
{% endif %}
{% if id == 'icon-rss' %}
{% endif %}
{% if id == 'icon-menu' %}
{% endif %}
{% if id == 'icon-search' %}
{% endif %}
{% if id == 'icon-search-close' %}
{% endif %}
{% if id == 'icon-burger-close' %}
{% endif %}
{% if id == 'icon-smile' %}
{% endif %}
{% if id == 'icon-spinner' %}
{% endif %}
{% if id == 'icon-store' %}
{% endif %}
{% if id == 'icon-tap' %}
{% endif %}
{% if id == 'icon-loading' %}
{% endif %}
{% if id == 'icon-transfer' %}
{% endif %}
{% if id == 'icon-wallet' %}
{% endif %}
{% if id == 'icon-zoom' %}
{% endif %}
{% if id == 'icon-check-circle' %}
{% endif %}
{% if id == 'icon-3D' %}
{% endif %}
{%- endcapture -%}
{{ icon | strip_newlines }}
{% comment %}
powered by https://supershopify.online/
{% endcomment %}
在主题样式文件中添加以下代码,例如 theme.css
/* Highlights Banners */
@media screen and (max-width: 500px) {
.highlights-banners-container{
display: none;
}
}
.highlights-banners-container {
max-width: 100vw;
/* padding-right: 10px;
padding-left: 10px; */
margin-right: auto;
margin-left: auto;
}
/* @media screen and (max-width: 1079px) and (min-width: 720px) {
.highlights-banners-container{
padding-right: 1.75rem;
padding-left: 1.75rem;
}
} */
/* @media screen and (min-width: 1080px) {
.highlights-banners-container{
padding-right: 40px;
padding-left: 40px;
}
} */
.highlights-banners {
position: relative;
display: flex;
justify-content: center;
padding: 1.25rem 0;
outline: 0;
}
.highlights-banners .flickity-slider {
height: 100%;
display: flex;
align-items: center;
}
.highlights-banners:before, .highlights-banners:after {
position: absolute;
top: 0;
right: calc(100% - 20px);
bottom: 0;
left: 0;
z-index: 2;
content: '';
}
.highlights-banners:after {
right: 0;
left: calc(100% - 20px);
}
@media screen and (max-width: 1023px) {
.highlights-banners {
overflow: hidden;
}
}
@media screen and (min-width: 1024px) {
.highlights-banners {
height: auto;
padding-top: 1.75rem;
padding-bottom: 1.75rem;
}
.highlights-banners:before, .highlights-banners:after {
display: none;
}
}
.highlights-banners-block {
position: relative;
display: flex;
align-items: center;
width: 100%;
padding: 0 1.25rem;
color: #4D4D4D;
text-decoration: none;
}
.highlight-banners-align-center .highlights-banners-block {
flex-direction: column;
justify-content: center;
text-align: center;
}
.highlight-banners-align-right .highlights-banners-block {
justify-content: flex-end;
text-align: right;
}
@media screen and (max-width: 1023px) {
.highlights-banners-block {
max-width: 17.1875rem;
min-width: 12.5rem;
height: auto;
}
.flickity-slider .highlights-banners-block {
top: 0;
}
.highlight-banners-count-2 .highlights-banners-block {
width: 50%;
}
.highlight-banners-count-3 .highlights-banners-block {
width: 33%;
}
.highlight-banners-count-4 .highlights-banners-block {
width: 25%;
}
}
@media screen and (min-width: 1024px) {
.highlight-banners-count-2 .highlights-banners-block,
.highlight-banners-count-3 .highlights-banners-block {
width: 33%;
max-width: 21.25rem;
}
.highlight-banners-count-4 .highlights-banners-block {
width: 25%;
}
}
.highlights-banners-block:not(:last-of-type)::after {
position: absolute;
top: 0;
right: 0;
width: 1px;
height: 100%;
content: "";
}
.highlights-banners-icon {
width: auto;
height: 2.25rem;
margin-right: 1rem;
background-position: center;
background-size: contain;
background-repeat: no-repeat;
}
@media screen and (min-width: 680px) {
.highlights-banners-icon {
height: 2.5rem;
}
}
@media screen and (min-width: 1024px) {
.highlights-banners-icon {
height: 2.875rem;
margin-right: 1.25rem;
}
}
.highlights-banners-icon svg {
height: 100%;
max-width: 3.75rem;
}
.highlights-banners-icon .highlights-banners-custom-icon {
width: auto;
height: 100%;
}
.highlight-banners-align-center .highlights-banners-icon {
margin-right: 0;
margin-bottom: 0.75rem;
}
@media screen and (min-width: 1024px) {
.highlight-banners-align-center .highlights-banners-icon {
margin-bottom: 1rem;
}
}
.highlight-banners-align-right .highlights-banners-icon {
margin-right: 0;
margin-left: 1.25rem;
}
.highlights-banners-text {
font-size: var(--font-size-body-smaller);
max-width: 100%;
line-height: 1.4;
}
.highlights-banners-text p {
margin: 0;
}
@media screen and (min-width: 1024px) {
.highlights-banners-text {
font-size: var(--font-size-body);
}
}
.highlights-banners-text a {
position: relative;
z-index: 1;
color: inherit;
text-decoration: underline;
}
.highlights-banners-heading {
/* font-size: var(--font-size-highlight-banner-heading);
font-family: {{ fonts_type_highlights_bar_family }};
font-style: {{ fonts_type_highlights_bar_style }};
font-weight: {{ fonts_type_highlights_bar_weight }}; */
letter-spacing: {{ settings.type_highlights_spacing | divided_by: 100.0 | append: 'em' }};
margin: 0;
}
{%- if settings.type_highlights_capitalize -%}
.highlights-banners-heading {
text-transform: uppercase;
}
{%- else -%}
.highlights-banners-heading {
text-transform: none;
}
{%- endif -%}
.highlights-banners-block-link {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
{% comment %}
powered by https://supershopify.online/
{% endcomment %}