Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/timeline #347

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion projects/design-angular-kit/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"back": "Back",
"forward": "Forward",
"rate-star": "Rate {{current}} out of {{total}} stars",
"rating-star": "Rating {{current}} out of {{total}} stars"
"rating-star": "Rating {{current}} out of {{total}} stars",
"today": "Today"
},
"form": {
"caps-inserted": "CAPS LOCK entered",
Expand Down Expand Up @@ -103,6 +104,10 @@
"aria-label-toggle": "Show/Hide navigation",
"hide": "Hide navigation"
},
"timeline": {
"read-more": "Read more",
"read-more-on": "on {{title}}"
},
"utils": {
"selected": "Selected",
"language-selection": "Language selection: {{lang}}",
Expand Down
7 changes: 6 additions & 1 deletion projects/design-angular-kit/assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"back": "Indietro",
"forward": "Avanti",
"rate-star": "Valuta {{current}} stelle su {{total}}",
"rating-star": "Valutazione {{current}} stelle su {{total}}"
"rating-star": "Valutazione {{current}} stelle su {{total}}",
"today": "Oggi"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stefanozanelliunitn metterei la label "today" all'interno di "timeline" come scope

},
"form": {
"caps-inserted": "CAPS LOCK inserito",
Expand Down Expand Up @@ -103,6 +104,10 @@
"aria-label-toggle": "Mostra/Nascondi la navigazione",
"hide": "Nascondi la navigazione"
},
"timeline": {
"read-more": "Leggi di più",
"read-more-on": "su {{title}}"
},
"utils": {
"selected": "Selezionata",
"language-selection": "Selezione lingua: {{lang}}",
Expand Down
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"

Check failure on line 8 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-container/timeline-container.component.html

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Type 'string | undefined' is not assignable to type 'string'.

Check failure on line 8 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-container/timeline-container.component.html

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Type 'string | undefined' is not assignable to type 'string'.
[pinType]="element.pin?.type"

Check failure on line 9 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-container/timeline-container.component.html

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Type 'TimelinePINType | undefined' is not assignable to type 'TimelinePINType'.

Check failure on line 9 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-container/timeline-container.component.html

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Type 'TimelinePINType | undefined' is not assignable to type 'TimelinePINType'.
[pinIcon]="element.pin?.icon"

Check failure on line 10 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-container/timeline-container.component.html

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Type '"warning" | "arrow-down" | "arrow-down-circle" | "arrow-down-triangle" | "arrow-left" | "arrow-left-circle" | "arrow-left-triangle" | "arrow-right" | "arrow-right-circle" | ... 153 more ... | undefined' is not assignable to type '"warning" | "arrow-down" | "arrow-down-circle" | "arrow-down-triangle" | "arrow-left" | "arrow-left-circle" | "arrow-left-triangle" | "arrow-right" | "arrow-right-circle" | ... 152 more ... | "team-digitale"'.

Check failure on line 10 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-container/timeline-container.component.html

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Type '"warning" | "arrow-down" | "arrow-down-circle" | "arrow-down-triangle" | "arrow-left" | "arrow-left-circle" | "arrow-left-triangle" | "arrow-right" | "arrow-right-circle" | ... 153 more ... | undefined' is not assignable to type '"warning" | "arrow-down" | "arrow-down-circle" | "arrow-down-triangle" | "arrow-left" | "arrow-left-circle" | "arrow-left-triangle" | "arrow-right" | "arrow-right-circle" | ... 152 more ... | "team-digitale"'.
[pinText]="element.pin?.text"

Check failure on line 11 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-container/timeline-container.component.html

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Type 'string | undefined' is not assignable to type 'string'.

Check failure on line 11 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-container/timeline-container.component.html

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Type 'string | undefined' is not assignable to type 'string'.
[eventDate]="element.eventDate"
[dateFormat]="dateFormat"
[categoryTitle]="element.category?.title"
[categoryLink]="element.category?.link"
[showReadMore]="element.link?.length"
[readMoreLink]="element.link"></it-timeline-item>
</div>
}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ItTimelineContainerComponent } from './timeline-container.component';
import { tb_base } from '../../../../../test';

describe('ItTimelineContainerComponent', () => {
let component: ItTimelineContainerComponent;
let fixture: ComponentFixture<ItTimelineContainerComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule(tb_base).compileComponents();

fixture = TestBed.createComponent(ItTimelineContainerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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 'projects/design-angular-kit/src/lib/abstracts/abstract.component';
import { TimelineElement } from 'projects/design-angular-kit/src/lib/interfaces/core';

@Component({
standalone: true,
selector: 'it-timeline-container',
templateUrl: './timeline-container.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [ItIconComponent, TranslateModule, ItTimelineItemComponent],
})
export class ItTimelineContainerComponent extends ItAbstractComponent {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lo chiamerei semplicemente ItTimelineComponent che ne dici @AntoninoBonanno ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhh forse si

/** 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';
}
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.core.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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ItTimelineItemComponent } from './timeline-item.component';

describe('ItTimelineItemComponent', () => {
let component: ItTimelineItemComponent;
let fixture: ComponentFixture<ItTimelineItemComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ItTimelineItemComponent],
}).compileComponents();

fixture = TestBed.createComponent(ItTimelineItemComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { ChangeDetectionStrategy, Component, Input, booleanAttribute } 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 'projects/design-angular-kit/src/lib/interfaces/core';
import { IconName } from 'projects/design-angular-kit/src/lib/interfaces/icon';

@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;

Check failure on line 18 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-item/timeline-item.component.ts

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Property 'title' has no initializer and is not definitely assigned in the constructor.

Check failure on line 18 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-item/timeline-item.component.ts

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Property 'title' has no initializer and is not definitely assigned in the constructor.
/** Timeline element text */
@Input({ required: true }) text: string;

Check failure on line 20 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-item/timeline-item.component.ts

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Property 'text' has no initializer and is not definitely assigned in the constructor.

Check failure on line 20 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-item/timeline-item.component.ts

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Property 'text' has no initializer and is not definitely assigned in the constructor.
/** Timeline element signature */
@Input() signature: string;

Check failure on line 22 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-item/timeline-item.component.ts

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Property 'signature' has no initializer and is not definitely assigned in the constructor.

Check failure on line 22 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-item/timeline-item.component.ts

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Property 'signature' has no initializer and is not definitely assigned in the constructor.
/** Timeline element reference date */
@Input() eventDate?: Date;
/** Timeline element reference date format
* @default dd/MM/yyyy
*/
@Input() dateFormat: string = 'dd/MM/yyyy';

/** Timeline element PIN text */
@Input({ required: true }) pinText: string;

Check failure on line 31 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-item/timeline-item.component.ts

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Property 'pinText' has no initializer and is not definitely assigned in the constructor.

Check failure on line 31 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-item/timeline-item.component.ts

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Property 'pinText' has no initializer and is not definitely assigned in the constructor.
/** Timeline element PIN type
* @default none
*/
@Input() pinType: TimelinePINType = 'default';
/** Timeline element PIN icon
* @default code-circle
*/
@Input() pinIcon: IconName = 'code-circle';

/** Timeline element category title */
@Input() categoryTitle: string;

Check failure on line 42 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-item/timeline-item.component.ts

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Property 'categoryTitle' has no initializer and is not definitely assigned in the constructor.

Check failure on line 42 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-item/timeline-item.component.ts

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Property 'categoryTitle' has no initializer and is not definitely assigned in the constructor.
/** Timeline element category link */
@Input() categoryLink: string;

Check failure on line 44 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-item/timeline-item.component.ts

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Property 'categoryLink' has no initializer and is not definitely assigned in the constructor.

Check failure on line 44 in projects/design-angular-kit/src/lib/components/core/timeline/timeline-item/timeline-item.component.ts

View workflow job for this annotation

GitHub Actions / run-build-and-tests

Property 'categoryLink' has no initializer and is not definitely assigned in the constructor.

/** Timeline element show detail link
* @default false
*/
@Input({ transform: booleanAttribute })
showReadMore: boolean = false;
/** Timeline element detail link
* @default #
*/
@Input() readMoreLink: string = '#';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { NgModule } from '@angular/core';
import { ItTimelineContainerComponent } from './timeline-container/timeline-container.component';
import { ItTimelineItemComponent } from './timeline-item/timeline-item.component';

const timelineComponents = [ItTimelineContainerComponent, ItTimelineItemComponent];

@NgModule({
imports: timelineComponents,
exports: timelineComponents,
})
export class ItTimelineModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
<div class="row">
<div class="col-12">
<div class="it-header-slim-wrapper-content">
<a class="d-none d-lg-block navbar-brand" href="#">{{ slimTitle }}</a>
<a class="d-none d-lg-block navbar-brand" [href]="slimTitleLink" [target]="slimTitleLink !== '#' ? '_blank' : '_self'">
{{ slimTitle }}
</a>
<div class="nav-mobile">
<nav [attr.aria-label]="'it.navigation.secondary-navigation' | translate">
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class ItHeaderComponent implements AfterViewInit, OnChanges {
@Input({ transform: inputToBoolean }) showSearch?: boolean = true;

@Input() slimTitle: string | undefined;
@Input() slimTitleLink: string | undefined = '#';

@Input() loginStyle: 'none' | 'default' | 'full' = 'none';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { ItLanguageSwitcherComponent } from './components/utils/language-switche
import { ItDateAgoPipe } from './pipes/date-ago.pipe';
import { ItDurationPipe } from './pipes/duration.pipe';
import { ItMarkMatchingTextPipe } from './pipes/mark-matching-text.pipe';
import { ItTimelineModule } from './components/core/timeline/timeline.module';

/**
* Core components
Expand Down Expand Up @@ -72,6 +73,7 @@ const core = [
ItTabModule,
ItTableModule,
ItTooltipDirective,
ItTimelineModule,
];

/**
Expand Down
19 changes: 19 additions & 0 deletions projects/design-angular-kit/src/lib/interfaces/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ export type DropdownDirection = 'dropup' | 'dropend' | 'dropstart';

export type CarouselType = 'default' | 'three-cols' | 'three-cols-arrow-visible';

export type TimelinePINType = 'default' | 'evidence' | 'now';

export interface TimelineElement {
pin: {
type?: TimelinePINType;
icon?: IconName;
text: string;
};
category?: {
title: string;
link: string;
};
title: string;
text: string;
signature?: string;
eventDate?: Date;
link?: string;
}

export interface Notification {
/**
* Notification type
Expand Down
1 change: 1 addition & 0 deletions projects/design-angular-kit/src/lib/interfaces/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const IconNameArray = [
'close',
'close-big',
'close-circle',
'code-circle',
'comment',
'copy',
'delete',
Expand Down
1 change: 1 addition & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const routes: Routes = [
{ path: 'range', loadChildren: () => import('src/app/range/range.module').then(m => m.RangeModule) },
{ path: 'autocomplete', loadChildren: () => import('src/app/autocomplete/autocomplete.module').then(m => m.AutocompleteModule) },
{ path: 'sidebar', loadChildren: () => import('src/app/sidebar/sidebar.module').then(m => m.SidebarModule) },
{ path: 'timeline', loadChildren: () => import('src/app/timeline/timeline.module').then(m => m.TimelineModule) },
],
},
{ path: 'error/not-found', component: ItErrorPageComponent, data: { errorCode: 404 } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ <h3>Componente Header</h3>
<div class="bd-example">
<it-header
slimTitle="Ente di appartenenza"
slimTitleLink="https://italia.github.io/design-angular-kit"
[loginStyle]="login"
[light]="light"
[showSearch]="search"
Expand Down
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-container [timelineElements]="timelineElements" [dateFormat]="defaultDateFormat"></it-timeline-container>
</div>
</div>
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();
});
});
Loading