From 532820037ab137b2981cc95adb2096163b20f752 Mon Sep 17 00:00:00 2001 From: Romuald Caplier Date: Mon, 29 Jul 2024 14:11:13 +0200 Subject: [PATCH] feat(ui): Add editor contact card component --- libs/ui/elements/src/index.ts | 1 + .../editor-contact-card.component.css | 0 .../editor-contact-card.component.html | 21 ++++++++++ .../editor-contact-card.component.spec.ts | 32 +++++++++++++++ .../editor-contact-card.component.stories.ts | 39 +++++++++++++++++++ .../editor-contact-card.component.ts | 32 +++++++++++++++ .../ui/elements/src/lib/ui-elements.module.ts | 3 ++ 7 files changed, 128 insertions(+) create mode 100644 libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.css create mode 100644 libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.html create mode 100644 libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.spec.ts create mode 100644 libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.stories.ts create mode 100644 libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.ts diff --git a/libs/ui/elements/src/index.ts b/libs/ui/elements/src/index.ts index 578e08b8ed..15ee8b6cb3 100644 --- a/libs/ui/elements/src/index.ts +++ b/libs/ui/elements/src/index.ts @@ -3,6 +3,7 @@ export * from './lib/avatar/avatar.component' export * from './lib/content-ghost/content-ghost.component' export * from './lib/download-item/download-item.component' export * from './lib/downloads-list/downloads-list.component' +export * from './lib/editor-contact-card/editor-contact-card.component' export * from './lib/error/error.component' export * from './lib/image-overlay-preview/image-overlay-preview.component' export * from './lib/link-card/link-card.component' diff --git a/libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.css b/libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.html b/libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.html new file mode 100644 index 0000000000..ac23076b16 --- /dev/null +++ b/libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.html @@ -0,0 +1,21 @@ + +
+ +
+
+ {{ contact.firstName }} {{ contact.lastName }} + + +
+
{{ contact.email }}
+
+
+
diff --git a/libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.spec.ts b/libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.spec.ts new file mode 100644 index 0000000000..90e0e6e922 --- /dev/null +++ b/libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.spec.ts @@ -0,0 +1,32 @@ +import { NO_ERRORS_SCHEMA } from '@angular/core' +import { ComponentFixture, TestBed } from '@angular/core/testing' +import { EditorContactCardComponent } from './editor-contact-card.component' + +describe('LinkCardComponent', () => { + let component: EditorContactCardComponent + let fixture: ComponentFixture + + beforeEach(async () => { + await TestBed.configureTestingModule({ + schemas: [NO_ERRORS_SCHEMA], + imports: [EditorContactCardComponent], + }).compileComponents() + }) + + beforeEach(() => { + fixture = TestBed.createComponent(EditorContactCardComponent) + component = fixture.componentInstance + component.link = { + name: 'Consulter sur Géoclip', + description: + 'Lorem ipsum dolor sit amet, consect etur adipiscing elit. Donec id condim entum ex. Etiam sed molestie est.', + url: new URL('https://example.com/someurlpath'), + type: 'link', + } + fixture.detectChanges() + }) + + it('should create', () => { + expect(component).toBeTruthy() + }) +}) diff --git a/libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.stories.ts b/libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.stories.ts new file mode 100644 index 0000000000..d4ddcde93d --- /dev/null +++ b/libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.stories.ts @@ -0,0 +1,39 @@ +import { + applicationConfig, + componentWrapperDecorator, + Meta, + moduleMetadata, + StoryObj, +} from '@storybook/angular' +import { EditorContactCardComponent } from './editor-contact-card.component' +import { BrowserAnimationsModule } from '@angular/platform-browser/animations' +import { importProvidersFrom } from '@angular/core' + +export default { + title: 'Elements/LinkCardComponent', + component: EditorContactCardComponent, + decorators: [ + moduleMetadata({ + imports: [EditorContactCardComponent], + }), + applicationConfig({ + providers: [importProvidersFrom(BrowserAnimationsModule)], + }), + componentWrapperDecorator( + (story) => `
${story}
` + ), + ], +} as Meta + +export const Primary: StoryObj = { + args: { + compact: false, + link: { + type: 'link', + name: 'Consulter sur Géoclip', + description: + 'Lorem ipsum dolor sit amet, consect etur adipiscing elit. Donec id condim entum ex. Etiam sed molestie est.', + url: new URL('https://example.com/someurlpath'), + }, + }, +} diff --git a/libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.ts b/libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.ts new file mode 100644 index 0000000000..b919d8e7a7 --- /dev/null +++ b/libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.ts @@ -0,0 +1,32 @@ +import { + ChangeDetectionStrategy, + Component, + EventEmitter, + Input, + Output, +} from '@angular/core' +import { + Individual, + Organization, +} from '@geonetwork-ui/common/domain/model/record' +import { MatIconModule } from '@angular/material/icon' +import { CommonModule } from '@angular/common' +import { ButtonComponent } from '@geonetwork-ui/ui/inputs' + +@Component({ + selector: 'gn-ui-editor-contact-card', + templateUrl: './editor-contact-card.component.html', + styleUrls: ['./editor-contact-card.component.css'], + changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [CommonModule, MatIconModule, ButtonComponent], +}) +export class EditorContactCardComponent { + @Input() contact: Individual + @Input() organization: Organization + @Output() contactRemoved = new EventEmitter() + + removeContact(contact: Individual) { + this.contactRemoved.emit(contact) + } +} diff --git a/libs/ui/elements/src/lib/ui-elements.module.ts b/libs/ui/elements/src/lib/ui-elements.module.ts index 274cbc06fe..6897aaef22 100644 --- a/libs/ui/elements/src/lib/ui-elements.module.ts +++ b/libs/ui/elements/src/lib/ui-elements.module.ts @@ -31,6 +31,7 @@ import { MarkdownParserComponent } from './markdown-parser/markdown-parser.compo import { ImageOverlayPreviewComponent } from './image-overlay-preview/image-overlay-preview.component' import { UserFeedbackItemComponent } from './user-feedback-item/user-feedback-item.component' import { TimeSincePipe } from './user-feedback-item/time-since.pipe' +import { EditorContactCardComponent } from './editor-contact-card/editor-contact-card.component' @NgModule({ imports: [ @@ -50,6 +51,7 @@ import { TimeSincePipe } from './user-feedback-item/time-since.pipe' TimeSincePipe, BadgeComponent, MaxLinesComponent, + EditorContactCardComponent, ], declarations: [ MetadataInfoComponent, @@ -77,6 +79,7 @@ import { TimeSincePipe } from './user-feedback-item/time-since.pipe' ContentGhostComponent, DownloadItemComponent, DownloadsListComponent, + EditorContactCardComponent, ApiCardComponent, RelatedRecordCardComponent, MetadataContactComponent,