-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- enhance layout - show link domain - show comment count - show time since added
- Loading branch information
1 parent
77b9e3c
commit 068e901
Showing
10 changed files
with
126 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './core.module'; | ||
export * from './backend/backend.service'; | ||
export * from './animations/list.animations'; | ||
export * from './util/time.service'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
@Injectable() | ||
export class TimeService { | ||
constructor() {} | ||
|
||
timeSince(timestamp: number) { | ||
const seconds = Math.floor(new Date().getTime() / 1000 - timestamp); | ||
|
||
let interval = Math.floor(seconds / 31536000); | ||
|
||
if (interval > 1) { | ||
return `${interval} years`; | ||
} | ||
interval = Math.floor(seconds / 2592000); | ||
if (interval > 1) { | ||
return `${interval} months`; | ||
} | ||
interval = Math.floor(seconds / 86400); | ||
if (interval > 1) { | ||
return `${interval} days`; | ||
} | ||
interval = Math.floor(seconds / 3600); | ||
if (interval > 1) { | ||
return `${interval} hours`; | ||
} | ||
interval = Math.floor(seconds / 60); | ||
if (interval > 1) { | ||
return `${interval} minutes`; | ||
} | ||
return `${Math.floor(seconds)} seconds`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
<mat-card> | ||
<p class="user">{{post.by}} <mat-icon>person</mat-icon></p> | ||
<h2><span><mat-icon>thumb_up</mat-icon> {{post.score}}</span> <a [href]="post.url" target="_blank">{{post.title}}</a></h2> | ||
<div class="score"><mat-icon>thumb_up</mat-icon> {{post.score}}</div> | ||
<div class="content"> | ||
<h2><a [href]="post.url" target="_blank"><mat-icon>link</mat-icon> {{post.title}}</a> <span>({{post.domain}})</span></h2> | ||
<p><mat-icon>info</mat-icon>#{{index}} by {{post.by}} {{post.timeSince}} ago</p> | ||
</div> | ||
<button mat-fab *ngIf="post.descendants > 0"> | ||
<mat-icon>comment</mat-icon> <span>{{post.descendants}}</span> | ||
</button> | ||
</mat-card> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters