-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): Add editor contact card component
- Loading branch information
Romuald Caplier
committed
Aug 1, 2024
1 parent
42a43a2
commit 5328200
Showing
7 changed files
with
128 additions
and
0 deletions.
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
Empty file.
21 changes: 21 additions & 0 deletions
21
libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.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 @@ | ||
<ng-container *ngIf="organization && contact"> | ||
<div | ||
class="flex flex-row border border-gray-200 bg-gray-50 rounded-xl p-4 gap-4" | ||
> | ||
<img [src]="organization.logoUrl" class="w-[56px] h-[56px] rounded-[4px]" /> | ||
<div class="flex flex-col w-full"> | ||
<div class="flex flex-row justify-between"> | ||
<span class="flex flex-wrap font-bold w-full" | ||
>{{ contact.firstName }} {{ contact.lastName }}</span | ||
> | ||
<gn-ui-button | ||
type="secondary" | ||
extraClass="w-[20px] h-[20px] flex items-center justify-center" | ||
(buttonClick)="removeContact(contact)" | ||
><span class="text-[14px] leading-[0] font-bold">✕</span> | ||
</gn-ui-button> | ||
</div> | ||
<div>{{ contact.email }}</div> | ||
</div> | ||
</div> | ||
</ng-container> |
32 changes: 32 additions & 0 deletions
32
libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.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,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<EditorContactCardComponent> | ||
|
||
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() | ||
}) | ||
}) |
39 changes: 39 additions & 0 deletions
39
libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.component.stories.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,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) => `<div style="max-width: 800px">${story}</div>` | ||
), | ||
], | ||
} as Meta<EditorContactCardComponent> | ||
|
||
export const Primary: StoryObj<EditorContactCardComponent> = { | ||
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'), | ||
}, | ||
}, | ||
} |
32 changes: 32 additions & 0 deletions
32
libs/ui/elements/src/lib/editor-contact-card/editor-contact-card.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,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<Individual>() | ||
|
||
removeContact(contact: Individual) { | ||
this.contactRemoved.emit(contact) | ||
} | ||
} |
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