-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(timeline): added timeline component
Co-authored-by: Stefano Zanelli <stefano.zanelli@unitn.it>
- Loading branch information
1 parent
be076df
commit 147b8f5
Showing
27 changed files
with
520 additions
and
1 deletion.
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
45 changes: 45 additions & 0 deletions
45
...n-angular-kit/src/lib/components/core/timeline/timeline-item/timeline-item.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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<div class="timeline-element"> | ||
@if (pinType === 'now') { | ||
<span class="it-now-label d-none d-lg-flex">{{ 'it.timeline.today' | translate }}</span> | ||
} | ||
<div class="it-pin-wrapper" [ngClass]="{ 'it-evidence': pinType === 'evidence', 'it-now': pinType === 'now' }"> | ||
<div class="pin-icon"> | ||
@if (pinIcon) { | ||
<it-icon [name]="pinIcon"></it-icon> | ||
} @else { | ||
<it-icon name="code-circle"></it-icon> | ||
} | ||
</div> | ||
<div class="pin-text"> | ||
<span>{{ pinText }}</span> | ||
</div> | ||
</div> | ||
<div class="card-wrapper"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
@if ((categoryTitle && categoryLink) || eventDate) { | ||
<div class="category-top"> | ||
@if (categoryTitle) { | ||
<a class="category" [href]="categoryLink">{{ categoryTitle }}</a> | ||
} | ||
@if (eventDate) { | ||
<span class="data">{{ eventDate | date: dateFormat }}</span> | ||
} | ||
</div> | ||
} | ||
<h5 class="card-title">{{ title }}</h5> | ||
<p class="card-text">{{ text }}</p> | ||
@if (signature) { | ||
<span class="card-signature">{{ signature }}</span> | ||
} | ||
@if (showReadMore) { | ||
<a class="read-more" [href]="readMoreLink"> | ||
<span class="text">{{ 'it.timeline.read-more' | translate }}</span> | ||
<span class="visually-hidden">{{ 'it.timeline.read-more-on' | translate: { title: title } }}</span> | ||
<it-icon name="arrow-right"></it-icon> | ||
</a> | ||
} | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
24 changes: 24 additions & 0 deletions
24
...ngular-kit/src/lib/components/core/timeline/timeline-item/timeline-item.component.spec.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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { ItTimelineItemComponent } from './timeline-item.component'; | ||
import { tb_base } from '../../../../../test'; | ||
|
||
describe('ItTimelineItemComponent', () => { | ||
let component: ItTimelineItemComponent; | ||
let fixture: ComponentFixture<ItTimelineItemComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule(tb_base).compileComponents(); | ||
|
||
// await TestBed.configureTestingModule({ | ||
// imports: [ItTimelineItemComponent], | ||
// }).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ItTimelineItemComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
86 changes: 86 additions & 0 deletions
86
...ign-angular-kit/src/lib/components/core/timeline/timeline-item/timeline-item.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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; | ||
import { ItAbstractComponent } from '../../../../abstracts/abstract.component'; | ||
import { ItIconComponent } from '../../../utils/icon/icon.component'; | ||
import { DatePipe, NgClass } from '@angular/common'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { TimelinePINType } from '../../../../interfaces/core'; | ||
import { IconName } from '../../../../interfaces/icon'; | ||
import { inputToBoolean } from '../../../../utils/coercion'; | ||
|
||
/** | ||
* Timeline Item | ||
* @description Represents a single event for Timeline component. | ||
*/ | ||
@Component({ | ||
standalone: true, | ||
selector: 'it-timeline-item', | ||
templateUrl: './timeline-item.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
imports: [ItIconComponent, DatePipe, TranslateModule, NgClass], | ||
}) | ||
export class ItTimelineItemComponent extends ItAbstractComponent { | ||
/** | ||
* Timeline element title | ||
*/ | ||
@Input({ required: true }) title!: string; | ||
|
||
/** | ||
* Timeline element text | ||
*/ | ||
@Input({ required: true }) text!: string; | ||
|
||
/** | ||
* Timeline element signature | ||
*/ | ||
@Input() signature: string | undefined; | ||
|
||
/** | ||
* Timeline element reference date | ||
*/ | ||
@Input() eventDate: Date | undefined; | ||
|
||
/** | ||
* Timeline element reference date format | ||
* @default dd/MM/yyyy | ||
*/ | ||
@Input() dateFormat: string = 'dd/MM/yyyy'; | ||
|
||
/** | ||
* Timeline element PIN text | ||
*/ | ||
@Input({ required: true }) pinText: string | undefined; | ||
|
||
/** | ||
* Timeline element PIN type | ||
* @default none | ||
*/ | ||
@Input() pinType: TimelinePINType | undefined = 'default'; | ||
|
||
/** | ||
* Timeline element PIN icon | ||
* @default code-circle | ||
*/ | ||
@Input() pinIcon: IconName | undefined = 'code-circle'; | ||
|
||
/** | ||
* Timeline element category title | ||
*/ | ||
@Input() categoryTitle: string | undefined; | ||
|
||
/** | ||
* Timeline element category link | ||
*/ | ||
@Input() categoryLink: string | undefined; | ||
|
||
/** | ||
* Timeline element show detail link | ||
* @default false | ||
*/ | ||
@Input({ transform: inputToBoolean }) | ||
showReadMore: boolean = false; | ||
|
||
/** Timeline element detail link | ||
* @default # | ||
*/ | ||
@Input() readMoreLink: string | undefined = '#'; | ||
} |
21 changes: 21 additions & 0 deletions
21
projects/design-angular-kit/src/lib/components/core/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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div class="it-timeline-wrapper"> | ||
<div class="row"> | ||
@for (element of timelineElements; track $index) { | ||
<div class="col-12"> | ||
<it-timeline-item | ||
[title]="element.title" | ||
[text]="element.text" | ||
[signature]="element.signature" | ||
[pinType]="element.pin?.type" | ||
[pinIcon]="element.pin?.icon" | ||
[pinText]="element.pin?.text" | ||
[eventDate]="element.eventDate" | ||
[dateFormat]="dateFormat" | ||
[categoryTitle]="element.category?.title" | ||
[categoryLink]="element.category?.link" | ||
[showReadMore]="!!element.link?.length" | ||
[readMoreLink]="element.link" /> | ||
</div> | ||
} | ||
</div> | ||
</div> |
21 changes: 21 additions & 0 deletions
21
projects/design-angular-kit/src/lib/components/core/timeline/timeline.component.spec.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ItTimelineComponent } from './timeline.component'; | ||
import { tb_base } from '../../../../test'; | ||
|
||
describe('ItTimelineComponent', () => { | ||
let component: ItTimelineComponent; | ||
let fixture: ComponentFixture<ItTimelineComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule(tb_base).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ItTimelineComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
projects/design-angular-kit/src/lib/components/core/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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; | ||
import { ItTimelineItemComponent } from './timeline-item/timeline-item.component'; | ||
import { ItIconComponent } from '../../utils/icon/icon.component'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { ItAbstractComponent } from '../../../abstracts/abstract.component'; | ||
import { TimelineElement } from '../../../interfaces/core'; | ||
|
||
/** | ||
* Timeline | ||
* @description Build timeline for chronological representation of events. | ||
*/ | ||
@Component({ | ||
standalone: true, | ||
selector: 'it-timeline', | ||
templateUrl: './timeline.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
imports: [ItIconComponent, TranslateModule, ItTimelineItemComponent], | ||
}) | ||
export class ItTimelineComponent extends ItAbstractComponent { | ||
/** | ||
* Timeline elements array | ||
* @default [] | ||
*/ | ||
@Input() timelineElements: TimelineElement[] = []; | ||
|
||
/** | ||
* Default date format for timeline element reference date | ||
* @default dd/MM/yyyy | ||
*/ | ||
@Input() dateFormat: string = 'dd/MM/yyyy'; | ||
} |
11 changes: 11 additions & 0 deletions
11
projects/design-angular-kit/src/lib/components/core/timeline/timeline.module.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { ItTimelineComponent } from './timeline.component'; | ||
import { ItTimelineItemComponent } from './timeline-item/timeline-item.component'; | ||
|
||
const timelineComponents = [ItTimelineComponent, ItTimelineItemComponent]; | ||
|
||
@NgModule({ | ||
imports: timelineComponents, | ||
exports: timelineComponents, | ||
}) | ||
export class ItTimelineModule {} |
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
7 changes: 7 additions & 0 deletions
7
src/app/timeline/timeline-default-example/timeline-default-example.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<h3>Esempi</h3> | ||
|
||
<div class="bd-example"> | ||
<div class="example-section"> | ||
<it-timeline [timelineElements]="timelineElements" [dateFormat]="defaultDateFormat" /> | ||
</div> | ||
</div> |
22 changes: 22 additions & 0 deletions
22
src/app/timeline/timeline-default-example/timeline-default-example.component.spec.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { TimelineDefaultExampleComponent } from './timeline-default-example.component'; | ||
|
||
describe('TimelineDefaultExampleComponent', () => { | ||
let component: TimelineDefaultExampleComponent; | ||
let fixture: ComponentFixture<TimelineDefaultExampleComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [TimelineDefaultExampleComponent], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(TimelineDefaultExampleComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.