-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Configurable media component (#19067)
- Loading branch information
Showing
17 changed files
with
1,030 additions
and
113 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
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
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
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
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
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
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
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
111 changes: 80 additions & 31 deletions
111
projects/storefrontlib/shared/components/media/media.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 |
---|---|---|
@@ -1,36 +1,85 @@ | ||
<ng-container *ngIf="!!media"> | ||
<picture *ngIf="media.srcset && !isLegacy; else legacyImgTmp"> | ||
<source | ||
*ngFor=" | ||
let source of media!.srcset! | cxMediaSources; | ||
trackBy: trackByMedia | ||
<ng-container *cxFeature="'useExtendedMediaComponentConfiguration'"> | ||
<picture | ||
*ngIf=" | ||
!!media?.sources?.length && elementType !== 'img'; | ||
else imageElementTmp | ||
" | ||
[srcset]="source.srcset" | ||
[media]="source.media" | ||
/> | ||
> | ||
<source | ||
*ngFor="let source of media.sources; trackBy: trackByMedia" | ||
[media]="source.media" | ||
[srcset]="source.srcset" | ||
[attr.width]="source.width" | ||
[attr.height]="source.height" | ||
/> | ||
|
||
<img | ||
[loading]="loading" | ||
[alt]="media.alt" | ||
[title]="media.alt" | ||
[src]="media.src" | ||
[attr.role]="media.role" | ||
(load)="loadHandler()" | ||
(error)="errorHandler()" | ||
/> | ||
</picture> | ||
<img | ||
[loading]="loading" | ||
[alt]="media.alt" | ||
[title]="media.alt" | ||
[src]="media.src" | ||
[attr.role]="media.role" | ||
[attr.width]="width" | ||
[attr.height]="height" | ||
[attr.sizes]="sizes" | ||
(load)="loadHandler()" | ||
(error)="errorHandler()" | ||
/> | ||
</picture> | ||
|
||
<ng-template #legacyImgTmp> | ||
<img | ||
*ngIf="media.src" | ||
[loading]="loading" | ||
[alt]="media.alt" | ||
[title]="media.alt" | ||
[src]="media.src" | ||
[srcset]="media?.srcset || media.src" | ||
[attr.role]="media.role" | ||
(load)="loadHandler()" | ||
(error)="errorHandler()" | ||
/> | ||
</ng-template> | ||
<ng-template #imageElementTmp> | ||
<img | ||
*ngIf="media.src" | ||
[loading]="loading" | ||
[alt]="media.alt" | ||
[title]="media.alt" | ||
[src]="media.src" | ||
[srcset]="media.srcset || media.src" | ||
[attr.role]="media.role" | ||
[attr.width]="width" | ||
[attr.height]="height" | ||
[attr.sizes]="sizes" | ||
(load)="loadHandler()" | ||
(error)="errorHandler()" | ||
/> | ||
</ng-template> | ||
</ng-container> | ||
|
||
<ng-container *cxFeature="'!useExtendedMediaComponentConfiguration'"> | ||
<picture *ngIf="media.srcset && !isLegacy; else legacyImgTmp"> | ||
<source | ||
*ngFor=" | ||
let source of media!.srcset! | cxMediaSources; | ||
trackBy: trackByMedia | ||
" | ||
[srcset]="source.srcset" | ||
[media]="source.media" | ||
/> | ||
|
||
<img | ||
[loading]="loading" | ||
[alt]="media.alt" | ||
[title]="media.alt" | ||
[src]="media.src" | ||
[attr.role]="media.role" | ||
(load)="loadHandler()" | ||
(error)="errorHandler()" | ||
/> | ||
</picture> | ||
|
||
<ng-template #legacyImgTmp> | ||
<img | ||
*ngIf="media.src" | ||
[loading]="loading" | ||
[alt]="media.alt" | ||
[title]="media.alt" | ||
[src]="media.src" | ||
[srcset]="media?.srcset || media.src" | ||
[attr.role]="media.role" | ||
(load)="loadHandler()" | ||
(error)="errorHandler()" | ||
/> | ||
</ng-template> | ||
</ng-container> | ||
</ng-container> |
Oops, something went wrong.