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:
@@ -2543,13 +2543,6 @@ body.zen-mode-enable {
|
||||
}
|
||||
}
|
||||
}
|
||||
.group-hover\:underline-offset-2 {
|
||||
&:is(:where(.group):hover *) {
|
||||
@media (hover: hover) {
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.group-hover\:opacity-100 {
|
||||
&:is(:where(.group):hover *) {
|
||||
@media (hover: hover) {
|
||||
@@ -2640,6 +2633,18 @@ body.zen-mode-enable {
|
||||
border-top-color: transparent;
|
||||
}
|
||||
}
|
||||
.before\:absolute {
|
||||
&::before {
|
||||
content: var(--tw-content);
|
||||
position: absolute;
|
||||
}
|
||||
}
|
||||
.before\:inset-0 {
|
||||
&::before {
|
||||
content: var(--tw-content);
|
||||
inset: calc(var(--spacing) * 0);
|
||||
}
|
||||
}
|
||||
.after\:clear-both {
|
||||
&::after {
|
||||
content: var(--tw-content);
|
||||
@@ -3850,9 +3855,6 @@ pre {
|
||||
text-decoration-thickness: 3px;
|
||||
text-underline-offset: 4px;
|
||||
}
|
||||
.group-hover-card:hover:has(.group-hover-cancel:hover) .group-hover-card-title {
|
||||
text-decoration: none !important;
|
||||
}
|
||||
@layer base {
|
||||
[type='text'],input:where(:not([type])),[type='email'],[type='url'],[type='password'],[type='number'],[type='date'],[type='datetime-local'],[type='month'],[type='search'],[type='tel'],[type='time'],[type='week'],[multiple],textarea,select {
|
||||
appearance: none;
|
||||
|
||||
@@ -278,8 +278,3 @@ pre {
|
||||
text-decoration-thickness: 3px;
|
||||
text-underline-offset: 4px;
|
||||
}
|
||||
|
||||
/* Cancel group hover if .group-hover-card contains .group-hover-cancel*/
|
||||
.group-hover-card:hover:has(.group-hover-cancel:hover) .group-hover-card-title {
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{{ $constrainItemsWidth := site.Params.list.constrainItemsWidth | default false }}
|
||||
{{ $disableImageOptimization := site.Params.disableImageOptimization | 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,19 +63,17 @@
|
||||
|
||||
|
||||
<div class="{{ $articleClasses }}">
|
||||
<a
|
||||
{{ partial "article-link/_external-link.html" $target | 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">
|
||||
<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 $target.Params.externalUrl }}
|
||||
<div>
|
||||
<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">
|
||||
<div>
|
||||
{{ $target.Title | emojify }}
|
||||
<span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500">
|
||||
<span class="rtl:hidden">↗</span>
|
||||
@@ -84,12 +82,11 @@
|
||||
</div>
|
||||
</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"
|
||||
href="{{ $target.RelPermalink }}">
|
||||
<div>
|
||||
{{ $target.Title | emojify }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</a>
|
||||
{{ if and $target.Draft site.Params.article.showDraftLabel }}
|
||||
<div class="ms-2">
|
||||
{{ partial "badge.html" (i18n "article.draft" | emojify) }}
|
||||
@@ -99,7 +96,7 @@
|
||||
{{ partial "extend-article-link.html" $target }}
|
||||
{{ 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" $target }}
|
||||
</div>
|
||||
{{ $showSummary := false }}
|
||||
|
||||
@@ -32,11 +32,7 @@
|
||||
|
||||
|
||||
<div
|
||||
class="group-hover-card group relative min-h-full min-w-full overflow-hidden rounded border border-2 border-neutral-200 shadow-2xl dark:border-neutral-700">
|
||||
<a
|
||||
{{ partial "article-link/_external-link.html" . | safeHTMLAttr }}
|
||||
class="absolute inset-0"
|
||||
aria-label="{{ $.Title }}"></a>
|
||||
class="relative min-h-full min-w-full overflow-hidden rounded border border-2 border-neutral-200 shadow-2xl dark:border-neutral-700">
|
||||
{{ with $featuredURL }}
|
||||
<div class="thumbnail_card_related nozoom w-full" style="background-image:url({{ . }});"></div>
|
||||
{{ end }}
|
||||
@@ -46,9 +42,11 @@
|
||||
</span>
|
||||
{{ end }}
|
||||
<div class="px-6 py-4">
|
||||
<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
|
||||
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">
|
||||
<div>
|
||||
{{ $.Title | emojify }}
|
||||
<span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500">
|
||||
<span class="rtl:hidden">↗</span>
|
||||
@@ -56,12 +54,12 @@
|
||||
</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">
|
||||
<div>
|
||||
{{ .Title | emojify }}
|
||||
</div>
|
||||
{{ end }}
|
||||
<div class="group-hover-cancel text-sm text-neutral-500 dark:text-neutral-400">
|
||||
</a>
|
||||
<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) }}
|
||||
|
||||
@@ -36,11 +36,7 @@
|
||||
|
||||
|
||||
<div
|
||||
class="group-hover-card group relative min-h-full min-w-full overflow-hidden rounded border border-2 border-neutral-200 shadow-2xl dark:border-neutral-700">
|
||||
<a
|
||||
{{ partial "article-link/_external-link.html" . | safeHTMLAttr }}
|
||||
class="absolute inset-0"
|
||||
aria-label="{{ $.Title }}"></a>
|
||||
class="relative min-h-full min-w-full overflow-hidden rounded border border-2 border-neutral-200 shadow-2xl dark:border-neutral-700">
|
||||
{{ with $featuredURL }}
|
||||
<div class="thumbnail_card nozoom w-full" style="background-image:url({{ . }});"></div>
|
||||
{{ end }}
|
||||
@@ -50,9 +46,11 @@
|
||||
</span>
|
||||
{{ end }}
|
||||
<div class="px-6 py-4">
|
||||
<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
|
||||
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">
|
||||
<div>
|
||||
{{ $.Title | emojify }}
|
||||
<span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500">
|
||||
<span class="rtl:hidden">↗</span>
|
||||
@@ -60,12 +58,12 @@
|
||||
</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">
|
||||
<div>
|
||||
{{ .Title | emojify }}
|
||||
</div>
|
||||
{{ end }}
|
||||
<div class="group-hover-cancel text-sm text-neutral-500 dark:text-neutral-400">
|
||||
</a>
|
||||
<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) }}
|
||||
|
||||
@@ -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,18 +63,16 @@
|
||||
|
||||
|
||||
<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">
|
||||
<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
|
||||
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">
|
||||
<div>
|
||||
{{ $.Title | emojify }}
|
||||
<span class="cursor-default align-top text-xs text-neutral-400 dark:text-neutral-500">
|
||||
<span class="rtl:hidden">↗</span>
|
||||
@@ -82,11 +80,11 @@
|
||||
</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">
|
||||
<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