Commit 94c3e23b authored by Zéfling's avatar Zéfling 🎨
Browse files

Fix calendar and add links

parent 49bb19eb
......@@ -44,8 +44,9 @@
<div *ngIf="month || search.active"
class="tweets">
<section *ngFor="let tweet of (!search.active ? month.tweets : search.tweets)"
class="tweet"
[class.retweet]="">
[class.tweet]="true"
[class.retweet]="false"
[id]="tweet.id">
<div class="tweet-infos">
<a href="https://twitter.com/{{tweet.user_screen_name}}">{{tweet.user_name}}</a>
<time class="tweet-date">{{tweet.created_date | date:'yyyy-MM-dd HH:mm:ss'}}</time>
......@@ -105,7 +106,14 @@
[class.current]="day.current"
[class.with-tweets]="day.tweets"
[title]="day.title">
{{day.date}}
<ng-container *ngIf="day.id; else noLink">
<a [href]="'#'+day.id">
{{day.date}}
</a>
</ng-container>
<ng-template #noLink>
{{day.date}}
</ng-template>
</td>
</tr>
</table>
......
......@@ -182,6 +182,8 @@
table {
width: 100%;
text-align: center;
position: sticky;
top: 0;
}
th {
......
......@@ -97,7 +97,6 @@ export class TweetsCalendarComponent implements OnInit, OnDestroy {
const date = new Date(`${month.year}-${month.month + 1 < 10 ? '0' : ''}${month.month + 1}-01`);
date.setDate(date.getDate() - this.mountCalandarGetDay(date) + 1);
console.log('month.month', month.month, (month.month + 1) % 12);
while (
(date.getMonth() !== (month.month + 1) % 12) ||
(date.getMonth() === (month.month + 1) % 12 && this.mountCalandarGetDay(date) - 1)
......@@ -112,13 +111,19 @@ export class TweetsCalendarComponent implements OnInit, OnDestroy {
}
let tweets = 0;
let id;
const current = date.getMonth() === month.month;
const dateYear = date['_getDayOfYear']();
if (current) {
const list = this.month.tweets.filter(t => t.created_date['_getDayOfYear']() === dateYear);
tweets = list ? list.length : 0;
if (list && list.length) {
list.sort((d1, d2) => d2.created_date.getTime() - d1.created_date.getTime());
id = list[0].id;
tweets = list.length;
}
}
this.calendar[week].push({
id: id,
current: current,
date: `${date.getDate()}`,
tweets: tweets > 0,
......@@ -128,7 +133,6 @@ export class TweetsCalendarComponent implements OnInit, OnDestroy {
date.setDate(date.getDate() + 1);
}
console.log(this.calendar);
}
mountCalandarGetDay(date: Date) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment