Skip to content

Commit

Permalink
Add heading font size setting in Rich text section (#188)
Browse files Browse the repository at this point in the history
* Add heading setting in Rich text

* adjust style class

* Changed the approach to not require a large set of if/elsif

Co-authored-by: tyleralsbury <tyler.alsbury@shopify.com>
  • Loading branch information
tauthomas01 and tyleralsbury authored Jul 29, 2021
1 parent e185803 commit 1177f84
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions locales/en.default.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,9 @@
"options__2": {
"label": "Medium"
},
"options__3": {
"label": "Large"
},
"label": "Heading font size"
}
}
Expand Down
12 changes: 8 additions & 4 deletions sections/rich-text.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{%- for block in section.blocks -%}
{%- case block.type -%}
{%- when 'heading' -%}
<h2 class="{% if block.settings.heading_size == 'small' %}h2{% else %}h1{% endif %}" {{ block.shopify_attributes }}>{{ block.settings.heading | escape }}</h2>
<h2 class="{{ block.settings.heading_size }}" {{ block.shopify_attributes }}>{{ block.settings.heading | escape }}</h2>
{%- when 'text' -%}
<div class="rich-text__text rte" {{ block.shopify_attributes }}>{{ block.settings.text }}</div>
{%- when 'button' -%}
Expand Down Expand Up @@ -79,15 +79,19 @@
"id": "heading_size",
"options": [
{
"value": "small",
"value": "h2",
"label": "t:sections.rich-text.blocks.heading.settings.heading_size.options__1.label"
},
{
"value": "medium",
"value": "h1",
"label": "t:sections.rich-text.blocks.heading.settings.heading_size.options__2.label"
},
{
"value": "h0",
"label": "t:sections.rich-text.blocks.heading.settings.heading_size.options__3.label"
}
],
"default": "medium",
"default": "h1",
"label": "t:sections.rich-text.blocks.heading.settings.heading_size.label"
}
]
Expand Down

0 comments on commit 1177f84

Please sign in to comment.