feat(article list): article clickable and equal height

This commit is contained in:
Jimmy Cai 2020-09-24 23:59:00 +02:00
parent c6661196ad
commit 96897be941
No known key found for this signature in database
GPG Key ID: 3EA408E527F37B18
4 changed files with 48 additions and 33 deletions

View File

@ -11,7 +11,7 @@
border-radius: var(--card-border-radius); border-radius: var(--card-border-radius);
overflow: hidden; overflow: hidden;
transition: box-shadow .3s ease; transition: box-shadow 0.3s ease;
&:hover { &:hover {
box-shadow: var(--shadow-l2); box-shadow: var(--shadow-l2);
@ -159,24 +159,32 @@
border-radius: var(--card-border-radius); border-radius: var(--card-border-radius);
box-shadow: var(--shadow-l1); box-shadow: var(--shadow-l1);
background-color: var(--card-background); background-color: var(--card-background);
--image-size: 60px;
@media (max-width: $on-tablet) {
--image-size: 50px;
}
& + .pagination { & + .pagination {
margin-top: var(--section-separation); margin-top: var(--section-separation);
} }
article { article {
display: flex; & > a {
align-items: center; display: flex;
padding: var(--small-card-padding); align-items: center;
padding: var(--small-card-padding);
}
&:not(:last-of-type) { &:not(:last-of-type) {
border-bottom: 2px solid var(--card-separator-color); border-bottom: 1.5px solid var(--card-separator-color);
} }
.article-details { .article-details {
flex-grow: 1; flex-grow: 1;
padding: 0; padding: 0;
padding-right: 15px; padding-right: 15px;
min-height: var(--image-size);
} }
.article-title { .article-title {
@ -190,10 +198,14 @@
.article-image { .article-image {
img { img {
width: 60px; width: var(--image-size);
height: 60px; height: var(--image-size);
} }
} }
.article-time {
font-size: 1.4rem;
}
} }
} }

View File

@ -43,7 +43,7 @@
} }
} }
article { .main-article {
background: var(--card-background); background: var(--card-background);
border-radius: var(--card-border-radius); border-radius: var(--card-border-radius);
box-shadow: var(--shadow-l1); box-shadow: var(--shadow-l1);

View File

@ -63,6 +63,9 @@ $defaultTagColors: #fff, #fff, #fff, #fff, #fff;
} }
--small-card-padding: 25px; --small-card-padding: 25px;
@media (max-width: $on-tablet) {
--small-card-padding: 25px 20px;
}
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
--card-background: #424242; --card-background: #424242;

View File

@ -1,27 +1,27 @@
<article> <article>
<div class="article-details"> <a href="{{ .Permalink }}">
<h2 class="article-title"> <div class="article-details">
<a href="{{ .Permalink }}"> <h2 class="article-title">
{{- .Title -}} {{- .Title -}}
</a> </h2>
</h2> <footer class="article-time">
<footer class="article-time"> <time datetime='{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}'>
<time datetime='{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}'> {{- .Date.Format (or .Site.Params.dateFormat.published "Jan 02, 2006") -}}
{{- .Date.Format (or .Site.Params.dateFormat.published "Jan 02, 2006") -}} </time>
</time> </footer>
</footer>
</div>
{{- $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink "articleList" -}}
{{ if $image.exists }}
<div class="article-image">
{{ if $image.resource }}
{{- $thumbnail := $image.resource.Fill "120x120" -}}
<img src="{{ $thumbnail.RelPermalink }}" width="{{ $thumbnail.Width }}"
height="{{ $thumbnail.Height }}" loading="lazy">
{{ else }}
<img src="{{ $image.permalink }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
{{ end }}
</div> </div>
{{ end }}
{{- $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink "articleList" -}}
{{ if $image.exists }}
<div class="article-image">
{{ if $image.resource }}
{{- $thumbnail := $image.resource.Fill "120x120" -}}
<img src="{{ $thumbnail.RelPermalink }}" width="{{ $thumbnail.Width }}"
height="{{ $thumbnail.Height }}" loading="lazy">
{{ else }}
<img src="{{ $image.permalink }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
{{ end }}
</div>
{{ end }}
</a>
</article> </article>