integrated handling for new thumbnail field from api response
This commit is contained in:
1 parent
36501d3096
commit
3def7a9936
12 files changed
+182
-46
No files matched your search
@@ -24,6 +24,7 @@
|
||||
}
|
||||
|
||||
h1 {
|
||||
position: relative;
|
||||
font-size: 2.5rem;
|
||||
background: linear-gradient(to top, #a0eddb 0%, #ffffff 100%);
|
||||
-webkit-background-clip: text;
|
||||
@@ -32,6 +33,7 @@ h1 {
|
||||
margin-top: 120px;
|
||||
margin-bottom: 40px;
|
||||
font-weight: 600;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.article-content {
|
||||
@@ -51,6 +53,39 @@ h1 {
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.article-thumb {
|
||||
width: 70%;
|
||||
aspect-ratio: 2.5 / 1;
|
||||
object-fit: cover;
|
||||
border-radius: 25px 25px 0 0;
|
||||
margin: 67px auto -200px auto;
|
||||
z-index: -100;
|
||||
|
||||
-webkit-mask-image: linear-gradient(
|
||||
to bottom,
|
||||
black 0%,
|
||||
rgba(0, 0, 0, 0.95) 50%,
|
||||
rgba(0, 0, 0, 0.7) 70%,
|
||||
rgba(0, 0, 0, 0.3) 85%,
|
||||
transparent 100%
|
||||
);
|
||||
mask-image: linear-gradient(
|
||||
to bottom,
|
||||
black 0%,
|
||||
rgba(0, 0, 0, 0.95) 50%,
|
||||
rgba(0, 0, 0, 0.7) 70%,
|
||||
rgba(0, 0, 0, 0.3) 85%,
|
||||
transparent 100%
|
||||
);
|
||||
|
||||
filter: brightness(0.9);
|
||||
}
|
||||
|
||||
.article-thumb.narrow {
|
||||
width: 100%;
|
||||
margin: 50px auto -160px auto;
|
||||
}
|
||||
|
||||
.article-meta {
|
||||
font-size: 1rem;
|
||||
color: #D6DAEFBD;
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
<!-- Article -->
|
||||
<div class="article-container">
|
||||
<div>
|
||||
<img
|
||||
class="article-thumb"
|
||||
[src]="article.thumb_url"
|
||||
[alt]="article.title + ' thumbnail'"
|
||||
(error)="onThumbError($event)"
|
||||
[ngClass]="{ 'narrow': isNarrow }"
|
||||
/>
|
||||
<h1>{{ article.title }}</h1>
|
||||
<div class="content-container" [ngStyle]="{'width': isNarrow ? '100%' : '70%'}">
|
||||
<markdown
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Component, OnInit, ViewEncapsulation} from '@angular/core';
|
||||
import { DatePipe, NgStyle } from '@angular/common';
|
||||
import {DatePipe, NgClass, NgStyle} from '@angular/common';
|
||||
import {ArticleService} from '../../shared/services/article.service';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {Title} from '@angular/platform-browser';
|
||||
@@ -13,6 +13,7 @@ interface Article {
|
||||
title: string;
|
||||
slug: string;
|
||||
content: string;
|
||||
thumb_url: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
views: number;
|
||||
@@ -28,7 +29,8 @@ interface Article {
|
||||
NgStyle,
|
||||
TranslatePipe,
|
||||
ParallaxComponent,
|
||||
MarkdownModule
|
||||
MarkdownModule,
|
||||
NgClass
|
||||
],
|
||||
templateUrl: './article-page.component.html',
|
||||
styleUrl: './article-page.component.css'
|
||||
@@ -43,6 +45,8 @@ export class ArticlePageComponent implements OnInit {
|
||||
|
||||
renderedContent: string = '';
|
||||
|
||||
readonly defaultThumbUrl = '/assets/ogimg.png';
|
||||
|
||||
isNarrow: boolean = false;
|
||||
|
||||
constructor(
|
||||
@@ -95,6 +99,14 @@ export class ArticlePageComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
onThumbError(event: Event): void {
|
||||
const img = event.target as HTMLImageElement;
|
||||
|
||||
if (img.src.endsWith(this.defaultThumbUrl)) return;
|
||||
|
||||
img.src = this.defaultThumbUrl;
|
||||
}
|
||||
|
||||
onArticleContentClick(event: MouseEvent) {
|
||||
const target = event.target as HTMLElement;
|
||||
|
||||
|
||||
Reference in new issue
Block a user