mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-01-30 16:31:52 +01:00
feat(article-link): reimplement card hover using ::before method
The previous method was not intuitive since there was nothing in the <a> tag, and required group-xxx classes for every element. The new pseudo element method fixes those problems, see: https://kittygiraudel.com/2022/04/02/accessible-cards/
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/}}
|
||||
{{ $constrainItemsWidth := .Page.Site.Params.list.constrainItemsWidth | default false }}
|
||||
|
||||
{{ $articleClasses := "group-hover-card group flex flex-wrap md:flex-nowrap article relative" }}
|
||||
{{ $articleClasses := "flex flex-wrap md:flex-nowrap article relative" }}
|
||||
{{ if .Site.Params.list.showCards }}
|
||||
{{ $articleClasses = delimit (slice $articleClasses "border border-neutral-200 dark:border-neutral-700 border-2 rounded-md overflow-hidden") " " }}
|
||||
{{ else }}
|
||||
@@ -63,30 +63,28 @@
|
||||
|
||||
|
||||
<div class="{{ $articleClasses }}">
|
||||
<a
|
||||
{{ partial "article-link/_external-link.html" . | safeHTMLAttr }}
|
||||
class="absolute inset-0"
|
||||
aria-label="{{ $.Title }}"></a>
|
||||
{{ with $featuredURL }}
|
||||
<div class="{{ $articleImageClasses }}" style="background-image:url({{ . }});"></div>
|
||||
{{ end }}
|
||||
<div class="{{ $articleInnerClasses }}">
|
||||
<div class="items-center text-start text-xl font-semibold">
|
||||
{{ with .Params.externalUrl }}
|
||||
<div
|
||||
class="group-hover-card-title decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 group-hover:underline group-hover:underline-offset-2">
|
||||
{{ $.Title | emojify }}
|
||||
<span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500">
|
||||
<span class="rtl:hidden">↗</span>
|
||||
<span class="ltr:hidden">↖</span>
|
||||
</span>
|
||||
</div>
|
||||
{{ else }}
|
||||
<div
|
||||
class="group-hover-card-title decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 group-hover:underline group-hover:underline-offset-2">
|
||||
{{ .Title | emojify }}
|
||||
</div>
|
||||
{{ end }}
|
||||
<a
|
||||
{{ partial "article-link/_external-link.html" . | safeHTMLAttr }}
|
||||
class="not-prose before:absolute before:inset-0 decoration-primary-500 dark:text-neutral text-xl font-bold text-neutral-800 hover:underline hover:underline-offset-2">
|
||||
{{ with .Params.externalUrl }}
|
||||
<div>
|
||||
{{ $.Title | emojify }}
|
||||
<span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500">
|
||||
<span class="rtl:hidden">↗</span>
|
||||
<span class="ltr:hidden">↖</span>
|
||||
</span>
|
||||
</div>
|
||||
{{ else }}
|
||||
<div>
|
||||
{{ .Title | emojify }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</a>
|
||||
{{ if and .Draft .Site.Params.article.showDraftLabel }}
|
||||
<div class="ms-2">{{ partial "badge.html" (i18n "article.draft" | emojify) }}</div>
|
||||
{{ end }}
|
||||
@@ -94,7 +92,7 @@
|
||||
{{ partial "extend-article-link.html" . }}
|
||||
{{ end }}
|
||||
</div>
|
||||
<div class="group-hover-cancel text-sm text-neutral-500 dark:text-neutral-400">
|
||||
<div class="text-sm text-neutral-500 dark:text-neutral-400">
|
||||
{{ partial "article-meta/basic.html" . }}
|
||||
</div>
|
||||
{{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
|
||||
|
||||
Reference in New Issue
Block a user