Skip to content

Commit

Permalink
fix: improve display
Browse files Browse the repository at this point in the history
  • Loading branch information
f-necas committed Jul 25, 2023
1 parent 98a6dc8 commit 3f8b954
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
[title]="organisation.name"
>
<div
class="flex-shrink-0 bg-gray-100 rounded-lg w-full border border-gray-300 h-36 group-hover:shadow-xl group-hover:border-0"
class="flex-shrink-0 bg-gray-100 rounded-lg overflow-hidden w-full border border-gray-300 h-36 group-hover:shadow-xl group-hover:border-0"
>
<gn-ui-thumbnail
class="relative h-full w-full"
[thumbnailUrl]="organisation.logoUrl"
fit="contain"
>
</gn-ui-thumbnail>
</div>
Expand All @@ -24,15 +23,6 @@
>
{{ organisation.description }}
</p>
<!--
<button
translate
class="flex items-center justify-center capitalize bg-[#c2cfe3] text-white p-1 rounded text-sm my-2 p-0 pr-1"
>
<mat-icon class="flex text-base">add </mat-icon>
<span>suivre</span>
</button>
-->
<div class="flex-shrink-0 text-primary opacity-50 flex leading-6">
<mat-icon class="text-primary opacity-50 mr-1">folder_open </mat-icon>
<span class="mx-1">{{ organisation.recordCount }}</span>
Expand Down
16 changes: 8 additions & 8 deletions libs/ui/elements/src/lib/thumbnail/thumbnail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ThumbnailComponent implements AfterViewInit, OnDestroy {
this.imgUrl = url || this.placeholderUrl
this.isPlaceholder = !url
}
@Input() fit: 'cover' | 'contain' = 'contain'
@Input() fit: 'cover' | 'contain' | 'scale-down'
@ViewChild('imageElement') imgElement: ElementRef<HTMLImageElement>
imgUrl: string
placeholderUrl = this.optionalPlaceholderUrl || DEFAULT_PLACEHOLDER
Expand Down Expand Up @@ -67,13 +67,13 @@ export class ThumbnailComponent implements AfterViewInit, OnDestroy {
}

setObjectFit(e) {
if (e && e.target) {
if (
e.target.naturalWidth > e.target.parentElement.clientWidth ||
e.target.naturalHeight > e.target.parentElement.clientHeight
) {
this.fit = 'cover'
}
const cw = e?.target?.parentElement.clientWidth
const ch = e?.target?.parentElement.clientHeight
if (!this.fit && cw > 0 && ch > 0) {
this.fit =
e.target.naturalWidth > cw || e.target.naturalHeight > ch
? 'cover'
: 'scale-down'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
style="width: 42px; height: 42px; font-size: 42px; margin: 10px"
>{{ hasOnlyPerson ? 'face' : 'home_work' }}</mat-icon
>
<img
<gn-ui-thumbnail
*ngIf="hasLogo"
[src]="contact.logoUrl"
alt="Organization logo"
class="object-contain w-full h-full"
[thumbnailUrl]="contact.logoUrl"
/>
</div>
<div class="flex flex-col overflow-hidden items-start">
Expand Down

0 comments on commit 3f8b954

Please sign in to comment.