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(image): add image preview description template #16500

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions src/app/components/image/image.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@
max-width: 100vw;
max-height: 100vh;
}

.p-image-description {
line-height: normal;
}
}
5 changes: 5 additions & 0 deletions src/app/components/image/image.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ export interface ImageTemplates {
* Custom template of closeicon.
*/
closeicon(): TemplateRef<any>;

/**
* Custom template of imagedescription.
Copy link
Contributor

Choose a reason for hiding this comment

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

space here? image description

Copy link
Author

Choose a reason for hiding this comment

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

@SoyDiego It is a name of the template which is imagedescription (without space).
I made it the same way as comments above (closeicon, rotaterighticon etc). Do you still want me to put a space there?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh ok, sorry, thanks for re check!
Now we should wait if PrimeNG Team approve it!

*/
imagedescription(): TemplateRef<any>;
}
9 changes: 9 additions & 0 deletions src/app/components/image/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ import { FocusTrapModule } from 'primeng/focustrap';
(@animation.done)="onAnimationEnd($event)"
>
<img [attr.src]="previewImageSrc ? previewImageSrc : src" [attr.srcset]="previewImageSrcSet" [attr.sizes]="previewImageSizes" class="p-image-preview" [ngStyle]="imagePreviewStyle()" (click)="onPreviewImageClick()" />
<div class="p-image-description">
<ng-template *ngTemplateOutlet="imageDescriptionTemplate"></ng-template>
</div>
</div>
</div>
</span>
Expand Down Expand Up @@ -224,6 +227,8 @@ export class Image implements AfterContentInit {

closeIconTemplate: TemplateRef<any> | undefined;

imageDescriptionTemplate: TemplateRef<any> | undefined;

maskVisible: boolean = false;

previewVisible: boolean = false;
Expand Down Expand Up @@ -287,6 +292,10 @@ export class Image implements AfterContentInit {
this.closeIconTemplate = item.template;
break;

case 'imagedescription':
this.imageDescriptionTemplate = item.template;
break;

default:
this.indicatorTemplate = item.template;
break;
Expand Down
14 changes: 14 additions & 0 deletions src/app/showcase/doc/apidoc/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -10732,6 +10732,14 @@
"default": "true",
"description": "Specifies if autofocus should happen on show."
},
{
"name": "focusOnClose",
"optional": true,
"readonly": false,
"type": "boolean",
"default": "true",
"description": "Specifies if autofocus should happen on close."
},
{
"name": "focusTrap",
"optional": true,
Expand Down Expand Up @@ -12964,6 +12972,12 @@
"name": "closeicon",
"parameters": [],
"description": "Custom template of closeicon."
},
{
"parent": "image",
"name": "imagedescription",
"parameters": [],
"description": "Custom template of imagedescription."
}
]
}
Expand Down