-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV-108 add timeline and minor fixes
- Loading branch information
Showing
5 changed files
with
99 additions
and
6 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
corn-frontend/src/app/pages/boards/sidebar-button/sidebar-button.component.html
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,5 +1,5 @@ | ||
<button (click)="click()" [class.bg-corn-primary-900]="selected" class="flex items-center justify-right py-2 space-x-2 w-full p-2 rounded-[4px]" | ||
mat-basic-button> | ||
<ng-icon [name]="iconName"></ng-icon> | ||
<ng-icon [class.text-black]="selected" [name]="iconName"></ng-icon> | ||
<span [class.text-black]="selected">{{ label }}</span> | ||
</button> |
24 changes: 23 additions & 1 deletion
24
corn-frontend/src/app/pages/boards/timeline/timeline.component.html
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 +1,23 @@ | ||
<h1>Timeline</h1> | ||
<div class="text-4xl font-thin p-5">Timeline</div> | ||
|
||
<div class="bg-dark-color-settings-main-background p-4 mr-[24px] rounded shadow font-light"> | ||
<div class="flex justify-between items-center mb-4"> | ||
<button class="flex items-center p-2 bg-corn-primary-500 text-black rounded hover:bg-corn-primary-600" (click)="prevMonth()"> | ||
<ng-icon name="matArrowBack"></ng-icon> | ||
</button> | ||
<h2 class="text-2xl">{{ currentMonth | date: 'MMMM yyyy' }}</h2> | ||
<button class="flex items-center p-2 bg-corn-primary-500 text-black rounded hover:bg-corn-primary-600" (click)="nextMonth()"> | ||
<ng-icon name="matArrowForward"></ng-icon> | ||
</button> | ||
</div> | ||
<div class="grid grid-cols-7 gap-2"> | ||
<div *ngFor="let day of days" class="text-center font-bold tracking-wider text-corn-primary-500">{{ day }}</div> | ||
</div> | ||
<div class="grid grid-cols-7 gap-1"> | ||
<ng-container *ngFor="let week of weeks"> | ||
<div *ngFor="let date of week.days"> | ||
<div class="text-center bg-dark-color-settings-grey-bg">{{ date.day }}</div> | ||
</div> | ||
</ng-container> | ||
</div> | ||
</div> |
74 changes: 72 additions & 2 deletions
74
corn-frontend/src/app/pages/boards/timeline/timeline.component.ts
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,10 +1,80 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, OnInit } from '@angular/core'; | ||
import { DatePipe, NgForOf } from "@angular/common"; | ||
import { CommonModule } from '@angular/common'; | ||
import { MatIcon} from "@angular/material/icon"; | ||
import { NgIcon, provideIcons } from "@ng-icons/core"; | ||
import { matArrowBack, matArrowForward } from "@ng-icons/material-icons/baseline"; | ||
|
||
interface Week { | ||
days: Day[] | ||
} | ||
|
||
interface Day { | ||
day: number | undefined, | ||
month: number | ||
} | ||
|
||
@Component({ | ||
selector: 'app-timeline', | ||
standalone: true, | ||
imports: [], | ||
imports: [ | ||
DatePipe, | ||
NgForOf, | ||
CommonModule, | ||
MatIcon, | ||
NgIcon, | ||
], | ||
templateUrl: './timeline.component.html', | ||
viewProviders: [provideIcons({ | ||
matArrowForward, | ||
matArrowBack, | ||
})] | ||
}) | ||
export class TimelineComponent { | ||
currentMonth: Date = new Date(); | ||
days: string[] = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; | ||
weeks: Week[] = []; | ||
|
||
constructor() { } | ||
|
||
ngOnInit(): void { | ||
this.generateCalendar(); | ||
} | ||
generateCalendar(): void { | ||
const startDate = new Date(this.currentMonth.getFullYear(), this.currentMonth.getMonth(), 1); | ||
const endDate = new Date(this.currentMonth.getFullYear(), this.currentMonth.getMonth() + 1, 0); | ||
const numDays = endDate.getDate(); | ||
const startDay = startDate.getDay(); | ||
|
||
let dateCounter = 1; | ||
for (let i = 0; i < 6; i++) { | ||
const week : Week = { | ||
days: [] | ||
}; | ||
for (let j = 0; j < 7; j++) { | ||
if ((i === 0 && j < startDay) || dateCounter > numDays) { | ||
week.days.push({ day: undefined, month: -1 }); | ||
} else { | ||
week.days.push({ day: dateCounter, month: this.currentMonth.getMonth() + 1 }); | ||
dateCounter++; | ||
} | ||
} | ||
this.weeks.push(week); | ||
} | ||
} | ||
|
||
prevMonth(): void { | ||
this.currentMonth = new Date(this.currentMonth.getFullYear(), this.currentMonth.getMonth() - 1); | ||
this.resetCalendar(); | ||
} | ||
|
||
nextMonth(): void { | ||
this.currentMonth = new Date(this.currentMonth.getFullYear(), this.currentMonth.getMonth() + 1); | ||
this.resetCalendar(); | ||
} | ||
|
||
resetCalendar(): void { | ||
this.weeks = []; | ||
this.generateCalendar(); | ||
} | ||
} |
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