Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions config/settings_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
{
"name": "t:general.colors",
"settings": [
{
"type": "header",
"content": "t:labels.base_colors"
},
{
"type": "color",
"id": "background_color",
Expand All @@ -68,6 +72,54 @@
"default": "#333333",
"label": "t:labels.foreground"
},
{
"type": "header",
"content": "t:labels.brand_colors"
},
{
"type": "color",
"id": "color_primary",
"default": "#2B5BE0",
"label": "t:labels.color_primary"
},
{
"type": "color",
"id": "color_secondary",
"default": "#6B7280",
"label": "t:labels.color_secondary"
},
{
"type": "header",
"content": "t:labels.ui_colors"
},
{
"type": "color",
"id": "color_border",
"default": "#E5E7EB",
"label": "t:labels.color_border"
},
{
"type": "color",
"id": "color_error",
"default": "#EF4444",
"label": "t:labels.color_error"
},
{
"type": "color",
"id": "color_success",
"default": "#10B981",
"label": "t:labels.color_success"
},
{
"type": "color",
"id": "color_warning",
"default": "#F59E0B",
"label": "t:labels.color_warning"
},
{
"type": "header",
"content": "t:labels.inputs"
},
{
"type": "range",
"id": "input_corner_radius",
Expand Down
12 changes: 11 additions & 1 deletion locales/en.default.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@
"alignment": "Alignment",
"background": "Background",
"foreground": "Foreground",
"base_colors": "Base",
"brand_colors": "Brand colors",
"ui_colors": "UI & state colors",
"inputs": "Inputs",
"color_primary": "Primary",
"color_secondary": "Secondary",
"color_border": "Border",
"color_error": "Error",
"color_success": "Success",
"color_warning": "Warning",
"grid_gap": "Grid spacing",
"grid_item_width": "Grid item width",
"input_corner_radius": "Input corner radius",
Expand Down Expand Up @@ -72,6 +82,6 @@
"title": "Title",
"subtitle": "Subtitle",
"normal": "Normal text"
},
}
}
}
173 changes: 173 additions & 0 deletions sections/announcement-bar.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
{% if section.blocks.size > 0 %}
<announcement-bar
data-interval="{{ section.settings.rotation_interval }}"
style="background-color: {{ section.settings.background_color }};"
>
<div class="announcement-bar__track">
{% for block in section.blocks %}
<div
class="announcement-bar__slide{% if forloop.first %} is-active{% endif %}"
{{ block.shopify_attributes }}
>
{% if block.settings.link != blank %}
<a
class="announcement-bar__text"
href="{{ block.settings.link }}"
style="color: {{ section.settings.text_color }};"
>
{{- block.settings.text -}}
</a>
{% elsif block.settings.text != blank %}
<span
class="announcement-bar__text"
style="color: {{ section.settings.text_color }};"
>
{{- block.settings.text -}}
</span>
{% endif %}
</div>
{% endfor %}
</div>
</announcement-bar>
{% endif %}

{% stylesheet %}
announcement-bar {
display: block;
width: 100%;
padding: 0.6rem 1rem;
text-align: center;
}

.announcement-bar__track {
position: relative;
min-height: 1.25em;
display: flex;
align-items: center;
justify-content: center;
}

.announcement-bar__slide {
display: none;
animation: ab-fade-in 0.4s ease;
}

.announcement-bar__slide.is-active {
display: block;
}

.announcement-bar__text {
font-size: 0.8125rem;
letter-spacing: 0.04em;
text-decoration: none;
line-height: 1.4;
}

a.announcement-bar__text:hover {
text-decoration: underline;
}

@keyframes ab-fade-in {
from { opacity: 0; transform: translateY(-3px); }
to { opacity: 1; transform: translateY(0); }
}
{% endstylesheet %}

{% javascript %}
class AnnouncementBar extends HTMLElement {
connectedCallback() {
this._slides = Array.from(this.querySelectorAll('.announcement-bar__slide'));
if (this._slides.length <= 1) return;
this._index = 0;
const ms = (parseInt(this.dataset.interval, 10) || 5) * 1000;
this._timer = setInterval(this._rotate.bind(this), ms);
}

disconnectedCallback() {
clearInterval(this._timer);
}

_rotate() {
this._slides[this._index].classList.remove('is-active');
this._index = (this._index + 1) % this._slides.length;
this._slides[this._index].classList.add('is-active');
}
}

customElements.define('announcement-bar', AnnouncementBar);
{% endjavascript %}

{% schema %}
{
"name": "Announcement bar",
"max_blocks": 6,
"settings": [
{
"type": "color",
"id": "background_color",
"label": "Background color",
"default": "#000000"
},
{
"type": "color",
"id": "text_color",
"label": "Text color",
"default": "#ffffff"
},
{
"type": "range",
"id": "rotation_interval",
"label": "Rotation interval",
"min": 2,
"max": 15,
"step": 1,
"unit": "s",
"default": 5
}
],
"blocks": [
{
"type": "announcement",
"name": "Announcement",
"settings": [
{
"type": "text",
"id": "text",
"label": "Text",
"placeholder": "Announce something here"
},
{
"type": "url",
"id": "link",
"label": "Link"
}
]
}
],
"presets": [
{
"name": "Announcement bar",
"blocks": [
{
"type": "announcement",
"settings": {
"text": "Free shipping on orders over $100 →"
}
},
{
"type": "announcement",
"settings": {
"text": "New arrivals — shop the latest collection →"
}
},
{
"type": "announcement",
"settings": {
"text": "Complimentary gift wrapping available →"
}
}
]
}
]
}
{% endschema %}
39 changes: 38 additions & 1 deletion sections/header-group.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,49 @@
"type": "header",
"name": "t:general.header",
"sections": {
"announcement-bar": {
"type": "announcement-bar",
"blocks": {
"announcement-1": {
"type": "announcement",
"settings": {
"text": "Free shipping on orders over $100 →",
"link": ""
}
},
"announcement-2": {
"type": "announcement",
"settings": {
"text": "New arrivals — shop the latest collection →",
"link": ""
}
},
"announcement-3": {
"type": "announcement",
"settings": {
"text": "Complimentary gift wrapping available →",
"link": ""
}
}
},
"block_order": [
"announcement-1",
"announcement-2",
"announcement-3"
],
"settings": {
"background_color": "#000000",
"text_color": "#ffffff",
"rotation_interval": 5
}
},
"header": {
"type": "header",
"settings": {}
}
},
"order": [
"announcement-bar",
"header"
],
]
}
6 changes: 6 additions & 0 deletions snippets/css-variables.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
--page-margin: {{ settings.min_page_margin }}px;
--color-background: {{ settings.background_color }};
--color-foreground: {{ settings.foreground_color }};
--color-primary: {{ settings.color_primary }};
--color-secondary: {{ settings.color_secondary }};
--color-border: {{ settings.color_border }};
--color-error: {{ settings.color_error }};
--color-success: {{ settings.color_success }};
--color-warning: {{ settings.color_warning }};
--style-border-radius-inputs: {{ settings.input_corner_radius }}px;
}
{% endstyle %}
Loading