扩展宣传栏的功能,以支持更多。
    编辑代码, Sections > announcement-bar.liquid 替换内容即可

    1. {%- for block in section.blocks -%}
    2. {%- case block.type -%}
    3. {%- when 'announcement' -%}
    4. <div class="announcement-bar color-{{ block.settings.color_scheme }} gradient" role="region" aria-label="{{ 'sections.header.announcement' | t }}" {{ block.shopify_attributes }}>
    5. {%- if block.settings.text != blank -%}
    6. {%- if block.settings.link != blank -%}
    7. <a href="{{ block.settings.link }}" class="announcement-bar__link link link--text focus-inset animate-arrow">
    8. {%- endif -%}
    9. {%- capture announcement_style -%}
    10. font-size: {{ block.settings.font_size }}px;
    11. color: {{ block.settings.font_color }};
    12. background-color: {{ block.settings.background_color }};
    13. padding: {{block.settings.padding}}rem {{ block.settings.padding | times: 2 }}rem;
    14. {%- endcapture -%}
    15. <p class="announcement-bar__message h5" style="{{ announcement_style }}">
    16. {{ block.settings.text | escape }}
    17. {%- if block.settings.link != blank -%}
    18. {% render 'icon-arrow' %}
    19. {%- endif -%}
    20. </p>
    21. {%- if block.settings.link != blank -%}
    22. </a>
    23. {%- endif -%}
    24. {%- endif -%}
    25. </div>
    26. {%- endcase -%}
    27. {%- endfor -%}
    28. {% schema %}
    29. {
    30. "name": "t:sections.announcement-bar.name",
    31. "max_blocks": 12,
    32. "blocks": [
    33. {
    34. "type": "announcement",
    35. "name": "t:sections.announcement-bar.blocks.announcement.name",
    36. "settings": [
    37. {
    38. "type": "text",
    39. "id": "text",
    40. "default": "Welcome to our store",
    41. "label": "t:sections.announcement-bar.blocks.announcement.settings.text.label"
    42. },
    43. {
    44. "type": "url",
    45. "id": "link",
    46. "label": "t:sections.announcement-bar.blocks.announcement.settings.link.label"
    47. },
    48. {
    49. "type": "color",
    50. "id": "background_color",
    51. "label": "Background Color"
    52. },
    53. {
    54. "type": "color",
    55. "id": "font_color",
    56. "label": "Font Color"
    57. },
    58. {
    59. "type": "range",
    60. "id": "padding",
    61. "label": "Announcement Padding",
    62. "info": "To change the height of Announcement",
    63. "min": 0,
    64. "max": 5,
    65. "step": 0.5,
    66. "default": 1,
    67. "unit": "rem"
    68. },
    69. {
    70. "type": "range",
    71. "id": "font_size",
    72. "label": "Announcement Font Size",
    73. "min": 12,
    74. "max": 30,
    75. "step": 1,
    76. "default": 20,
    77. "unit": "px"
    78. }
    79. ]
    80. }
    81. ],
    82. "default": {
    83. "blocks": [
    84. {
    85. "type": "announcement"
    86. }
    87. ]
    88. }
    89. }
    90. {% endschema %}

    Tips: 如有引用请标注源文章地址

    关注我的【小红书】,第一时间掌握更新动态


    你的鼓励就是我创作的动力!
    zanshang.png