refactor: item tile headers

This commit is contained in:
Ben Goldsworthy 2025-04-09 10:15:56 +02:00
parent d81c72a9dd
commit 0ed6a77690
No known key found for this signature in database
5 changed files with 72 additions and 68 deletions

View file

@ -5,6 +5,10 @@
&:hover { &:hover {
border-color: $dark; border-color: $dark;
& .item-tile__title-wrapper {
opacity: 1;
}
} }
} }
@ -13,47 +17,34 @@
} }
.item-tile { .item-tile {
display: grid; background-position: center center;
min-block-size: 180px;
grid-template-columns: 5% auto 5%;
grid-template-rows: 2.5% auto 2.5%;
grid-template-areas:
". . ."
". tile-details ."
". . .";
background-size: cover;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-size: cover;
word-break: break-word; block-size: 15em;
border: 2px solid $dark;
align-content: center;
position: relative;
@media (prefers-reduced-data: reduce) { @media (prefers-reduced-data: reduce) {
background: none !important; background: none !important;
} }
&__header { &__series {
text-align: center; margin-block: 0 1em;
margin-inline: auto;
font-size: 1.2em;
top: 0;
}
&__title-wrapper {
display: flex;
flex-direction: column;
background-color: $dark; background-color: $dark;
opacity: 0.9; opacity: 0.9;
display: grid; text-align: center;
grid-area: tile-details; margin: auto;
grid-template-columns: 5px auto 5px; width: 80%;
grid-template-rows: 0 1.8em auto auto; margin-block: auto;
grid-template-areas:
". . ."
". banner ."
". tile-title ."
". tile-subtitle .";
}
&--heading {
font-size: 3em;
& .item-tile__header,
& .item-tile__redacted {
opacity: 1;
grid-template-rows: auto;
grid-template-areas: ". tile-title .";
}
} }
&--ohwhatohjeez { &--ohwhatohjeez {
@ -68,6 +59,15 @@
border: 2px solid $omphaloskepsis; border: 2px solid $omphaloskepsis;
} }
&--heading {
text-align: center;
background-color: $dark;
& .item-tile__header {
font-size: 3em;
}
}
&__banner { &__banner {
padding-inline: 0.75em; padding-inline: 0.75em;
grid-area: banner; grid-area: banner;
@ -83,6 +83,14 @@
background-color: #ebebeb; background-color: #ebebeb;
} }
& hgroup {
padding: 1em 0.5em;
& > * {
margin: 0.25lh;
}
}
&__title, &__title,
&__subtitle { &__subtitle {
color: $light; color: $light;

View file

@ -32,19 +32,6 @@
padding-inline: 1em; padding-inline: 1em;
& .article-header { & .article-header {
text-align: center;
background-color: $dark;
opacity: 0.8;
color: $light;
display: grid;
grid-area: post-header-details;
grid-template-columns: 1fr;
padding: 20px;
grid-template-rows: 1fr auto auto 1fr;
justify-items: center;
align-items: center;
grid-template-areas: "." "post-title" "post-subtitle" ".";
&__series { &__series {
margin-block: 0 1em; margin-block: 0 1em;
margin-inline: auto; margin-inline: auto;

View file

@ -69,14 +69,14 @@
" "
/> />
{{- end }} {{- end }}
<header class="item-tile__header"> <header class="item-tile__header item-tile__title-wrapper">
{{ if ( or .Params.series .Params.published_in ) }} {{ if ( or .Params.series .Params.published_in ) }}
<span <span
class="item-tile__banner item-tile__banner--{{ if .Params.series }} class="item-tile__banner item-tile__banner--{{ if .Params.series -}}
series series
{{ else if .Params.published_in }} {{- else if .Params.published_in -}}
published-in published-in
{{ end }}" {{- end }}"
> >
{{- if .Params.series -}} {{- if .Params.series -}}
{{ .Params.series | safeHTML }} {{ .Params.series | safeHTML }}
@ -85,15 +85,10 @@
{{- end -}} {{- end -}}
</span> </span>
{{ end }} {{ end }}
<h2
class="p-name item-tile__title {{ if gt ( len ( .Title | plainify ) ) 40 }}item-tile__title--long{{ end }}" {{- partialCached "text/item-title.html" ( dict "pc" . "sc" $ "class" "item-tile" ) .File.Filename -}}
itemprop="name"
>
{{ default .Title .Params.markup_title | $.Page.RenderString }}
</h2>
{{ with .Params.subtitle }}
<p class="item-tile__subtitle">{{ . | $.Page.RenderString }}</p>
{{ end }}
<p style="display: none;"> <p style="display: none;">
Published: Published:
<time <time

View file

@ -40,14 +40,7 @@
<div class="article-header__title-wrapper"> <div class="article-header__title-wrapper">
<a class="u-url u-uid" style="display: none" href="{{ .pc.Permalink }}"></a> <a class="u-url u-uid" style="display: none" href="{{ .pc.Permalink }}"></a>
<hgroup class="p-name" itemprop="name"> {{- partialCached "text/item-title.html" ( dict "pc" .pc "sc" .sc "class" "article-header" ) .File.Filename -}}
<h2 class="article-header__title {{ if gt ( len ( .pc.Title | plainify ) ) 40 }}article-header__title--long{{ end }}">
{{- default .pc.Title .pc.Params.markup_title | .pc.Page.RenderString -}}
</h2>
{{ with .pc.Params.subtitle }}
<p class="article-header__subtitle">{{ . | $.pc.Page.RenderString }}</p>
{{ end }}
</hgroup>
</div> </div>
{{ with ( .pc.Resources.GetMatch .pc.Params.featured_image ) }} {{ with ( .pc.Resources.GetMatch .pc.Params.featured_image ) }}

View file

@ -0,0 +1,21 @@
{{- /*
Displays an itemtitle with optional subtitle.
@params pc Page context.
@params sc Site context.
@params class The base of the element CSS class.
*/
-}}
<hgroup
class="p-name"
itemprop="name"
>
<h2 class="{{ .class }}__title {{ if gt ( len ( .pc.Title | plainify ) ) 40 }}{{ .class }}__title--long{{ end }}">
{{- default .pc.Title .pc.Params.markup_title | .pc.Page.RenderString -}}
</h2>
{{ with .pc.Params.subtitle }}
<p class="{{ $.class }}__subtitle">{{ . | $.pc.Page.RenderString }}</p>
{{ end }}
</hgroup>