Skip to content

Commit

Permalink
Push Block: Add wrap link to push if no cta text and background-color…
Browse files Browse the repository at this point in the history
… is now available
  • Loading branch information
sebousan committed Feb 23, 2023
1 parent 2645653 commit 030adb8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
6 changes: 4 additions & 2 deletions assets/sass/components/_push.sass
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
.push
--push-background-color: #{$body-color}
--push-color: #{$body-bg}
--bs-card-spacer-y: 2rem
--bs-card-spacer-x: 2rem
@extend .card
@extend .ratio
@extend .ratio-21x9
background-color: $body-color
background-color: var(--push-background-color)
border: 0
color: $body-bg
color: var(--push-color)
position: relative
overflow: hidden
@include media-breakpoint-down(md)
Expand Down
37 changes: 30 additions & 7 deletions layouts/partials/blocks/templates/pushes.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,37 @@
<div class="items items-{{ $column }}">
{{ range . }}
<div>

{{ $hasOnlyLink := false }}
{{ with .cta }}
{{ if and (or (not (isset . "text")) (eq .text "")) (and (isset . "url") (ne .url "")) }}
{{ $hasOnlyLink = true }}
{{ end }}
{{ end }}

<div class="push push-{{ .offset }}"{{ with .background_color }} style="--push-background-color: {{ .}};"{{ end }}>

{{ if $hasOnlyLink }}
{{ $blank := .cta.blank | default false }}
{{ $title := i18n "link.blank" }}
<a href="{{ .cta.url }}" {{ if $blank }} target="_blank" title="{{ $title }}"{{ end }}>
{{ end }}

<div class="push push-{{ .offset }}">
{{ if or .title .text .cta.text }}
<div class="content">
{{ with .title }}
{{- with .title }}
{{- printf "<%s>" $tag | safeHTML -}}
{{ partial "func/PrepareHTML" . }}
{{- printf "</%s>" $tag | safeHTML -}}
{{ end }}
{{ with .text }}
{{ end -}}
{{- with .text }}
<p>{{ partial "func/PrepareHTML" . }}</p>
{{ end }}
{{ end -}}
{{ with .cta }}
{{ partial "commons/cta.html" . }}
{{ end }}
{{ partial "commons/cta.html" . }}
{{ end }}
</div>
{{ end }}

{{ with .image }}
{{ $columnTotal := site.Params.column | default false }}
Expand All @@ -47,6 +63,13 @@
"mobile" $mobile
) }}
{{ end }}

{{ if $hasOnlyLink }}
{{ $blank := .blank | default false }}
{{ $title := i18n "link.blank_aria" (dict "Title" (partial "func/PrepareHTML" .text))}}
</a>
{{ end }}

</div>

</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hugolify-theme",
"version": "1.3.2",
"version": "1.3.3",
"homepage": "https://www.hugolify.com",
"repository": "https://github.com/hugolify/hugolify-theme",
"bugs": {
Expand Down

0 comments on commit 030adb8

Please sign in to comment.