Skip to content

Commit 5fe4c48

Browse files
authoredFeb 6, 2021
Allow custom gradient in page header overlays (mmistakes#2806)
* Allow custom gradient in page header overlays * Update documentation * Update CHANGELOG and history
1 parent d585934 commit 5fe4c48

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed
 

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- Update Indonesian localized UI text strings. [#2731](https://github.com/mmistakes/minimal-mistakes/pull/2731)
1515
- Update remote theme documentation. [#2734](https://github.com/mmistakes/minimal-mistakes/pull/2734)
1616
- Update allejo/jekyll-toc to v1.1.0, skip headings without an ID. [#2752](https://github.com/mmistakes/minimal-mistakes/pull/2752)
17+
- Allow custom gradient for page header overlay. [#2806](https://github.com/mmistakes/minimal-mistakes/pull/2806)
1718

1819
## [4.21.0](https://github.com/mmistakes/minimal-mistakes/releases/tag/4.21.0)
1920

‎_includes/page__hero.html

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
{% capture overlay_img_path %}{{ page.header.overlay_image | relative_url }}{% endcapture %}
22

3-
{% if page.header.overlay_filter contains "rgba" %}
3+
{% if page.header.overlay_filter contains "gradient" %}
44
{% capture overlay_filter %}{{ page.header.overlay_filter }}{% endcapture %}
5+
{% elsif page.header.overlay_filter contains "rgba" %}
6+
{% capture overlay_filter %}{{ page.header.overlay_filter }}{% endcapture %}
7+
{% capture overlay_filter %}linear-gradient({{ overlay_filter }}, {{ overlay_filter }}){% endcapture %}
58
{% elsif page.header.overlay_filter %}
69
{% capture overlay_filter %}rgba(0, 0, 0, {{ page.header.overlay_filter }}){% endcapture %}
10+
{% capture overlay_filter %}linear-gradient({{ overlay_filter }}, {{ overlay_filter }}){% endcapture %}
711
{% endif %}
812

913
{% if page.header.image_description %}
@@ -15,7 +19,7 @@
1519
{% assign image_description = image_description | markdownify | strip_html | strip_newlines | escape_once %}
1620

1721
<div class="page__hero{% if page.header.overlay_color or page.header.overlay_image %}--overlay{% endif %}"
18-
style="{% if page.header.overlay_color %}background-color: {{ page.header.overlay_color | default: 'transparent' }};{% endif %} {% if overlay_img_path %}background-image: {% if overlay_filter %}linear-gradient({{ overlay_filter }}, {{ overlay_filter }}), {% endif %}url('{{ overlay_img_path }}');{% endif %}"
22+
style="{% if page.header.overlay_color %}background-color: {{ page.header.overlay_color | default: 'transparent' }};{% endif %} {% if overlay_img_path %}background-image: {% if overlay_filter %}{{ overlay_filter }}, {% endif %}url('{{ overlay_img_path }}');{% endif %}"
1923
>
2024
{% if page.header.overlay_color or page.header.overlay_image %}
2125
<div class="wrapper">

‎docs/_docs/10-layouts.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -428,14 +428,16 @@ To overlay text on top of a header image you have a few more options:
428428
| Name | Description | Default |
429429
| ---- | ----------- | ------- |
430430
| **overlay_image** | Header image you'd like to overlay. Same rules as `header.image` from above. | |
431-
| **overlay_filter** | Color/opacity to overlay on top of the header image eg: `0.5` or `rgba(255, 0, 0, 0.5)`. |
431+
| **overlay_filter** | Color/opacity to overlay on top of the header image. Example: `0.5`, `rgba(255, 0, 0, 0.5)` or [`linear-gradient`][mdn-linear-gradient]. |
432432
| **show_overlay_excerpt** | Display excerpt in the overlay text | true |
433433
| **excerpt** | Auto-generated page excerpt is added to the overlay text or can be overridden. | |
434434
| **tagline** | Overrides page excerpt. Useful when header text needs to be different from excerpt in archive views. | |
435435
| **actions** | Call to action button links (`actions` array: `label` and `url`). More than one button link can be assigned. | |
436436
| **cta_label** | Deprecated, use `actions` instead. Call to action button text label. | `more_label` in UI Text data file |
437437
| **cta_url** | Deprecated, use `actions` instead. Call to action button URL. | |
438438

439+
[mdn-linear-gradient]: https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient()
440+
439441
With this YAML Front Matter:
440442

441443
```yaml
@@ -477,7 +479,7 @@ header:
477479
url: "https://github.com"
478480
```
479481

480-
Or if you want to do more fancy things, go full rgba:
482+
Or if you feel colorful, use full rgba:
481483

482484
![transparent red overlay]({{ "/assets/images/mm-header-overlay-red-filter.jpg" | relative_url }})
483485

@@ -492,6 +494,21 @@ header:
492494
url: "https://github.com"
493495
```
494496

497+
Or if you want to do more fancy things, go all the way to [linear-gradient][mdn-linear-gradient]:
498+
499+
![transparent custom overlay]({{ "/assets/images/mm-header-overlay-custom-filter.jpg" | relative_url }})
500+
501+
```yaml
502+
excerpt: "This post should [...]"
503+
header:
504+
overlay_image: /assets/images/unsplash-image-1.jpg
505+
overlay_filter: linear-gradient(rgba(255, 0, 0, 0.5), rgba(0, 255, 255, 0.5))
506+
caption: "Photo credit: [**Unsplash**](https://unsplash.com)"
507+
actions:
508+
- label: "Download"
509+
url: "https://github.com"
510+
```
511+
495512
Multiple call to action button links can be assigned like this:
496513

497514
```yaml

‎docs/_docs/18-history.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ toc: false
2525
- Update Indonesian localized UI text strings. [#2731](https://github.com/mmistakes/minimal-mistakes/pull/2731)]
2626
- Update remote theme documentation. [#2734](https://github.com/mmistakes/minimal-mistakes/pull/2734)
2727
- Update allejo/jekyll-toc to v1.1.0, skip headings without an ID. [#2752](https://github.com/mmistakes/minimal-mistakes/pull/2752)
28+
- Allow custom gradient for page header overlay. [#2806](https://github.com/mmistakes/minimal-mistakes/pull/2806)
2829

2930
## [4.21.0](https://github.com/mmistakes/minimal-mistakes/releases/tag/4.21.0)
3031

Loading

0 commit comments

Comments
 (0)
Please sign in to comment.