-
Notifications
You must be signed in to change notification settings - Fork 776
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work for surveyjs/survey-creator#3390: implement wrapper for logo (#4932
- Loading branch information
Showing
6 changed files
with
52 additions
and
33 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
10 changes: 10 additions & 0 deletions
10
packages/survey-angular-ui/src/components/survey-header/logo-image.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,10 @@ | ||
<ng-template #template> | ||
<img | ||
[class]="survey.css.logoImage" | ||
[attr.src]="survey.locLogo.renderedHtml | safeUrl" | ||
[attr.width]="survey.logoWidth ? survey.logoWidth : undefined" | ||
[attr.height]="survey.logoHeight ? survey.logoHeight : undefined" | ||
[attr.alt]="survey.locTitle.renderedHtml" | ||
[style.objectFit]="survey.logoFit" | ||
/> | ||
</ng-template> |
16 changes: 16 additions & 0 deletions
16
packages/survey-angular-ui/src/components/survey-header/logo-image.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,16 @@ | ||
import { Component, Input } from "@angular/core"; | ||
import { AngularComponentFactory } from "../../component-factory"; | ||
import { EmbeddedViewContentComponent } from "../../embedded-view-content.component"; | ||
import { SurveyModel } from "survey-core"; | ||
@Component({ | ||
selector: "sv-logo-image", | ||
templateUrl: "./logo-image.component.html", | ||
styleUrls: ["../../hide-host.scss"] | ||
}) | ||
export class LogoImageComponent extends EmbeddedViewContentComponent { | ||
@Input() data!: SurveyModel; | ||
get survey(): SurveyModel { | ||
return this.data; | ||
} | ||
} | ||
AngularComponentFactory.Instance.registerComponent("sv-logo-image", LogoImageComponent); |
41 changes: 13 additions & 28 deletions
41
packages/survey-angular-ui/src/components/survey-header/survey-header.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,31 +1,16 @@ | ||
<div *ngIf="survey.isLogoBefore" [class]="survey.logoClassNames"> | ||
<img | ||
[class]="survey.css.logoImage" | ||
[attr.src]="survey.locLogo.renderedHtml | safeUrl" | ||
[attr.width]="survey.logoWidth ? survey.logoWidth : undefined" | ||
[attr.height]="survey.logoHeight ? survey.logoHeight : undefined" | ||
[attr.alt]="survey.locTitle.renderedHtml" | ||
[style.objectFit]="survey.logoFit" | ||
/> | ||
</div> | ||
<ng-template [component]="{ name: survey.getElementWrapperComponentName(survey, 'logo-image'), data: { data: survey.getElementWrapperComponentData(survey, 'logo-image') } }"></ng-template> | ||
</div> | ||
<div | ||
*ngIf="survey.renderedHasTitle" | ||
[class]="survey.css.headerText" | ||
[style.maxWidth]="survey.titleMaxWidth" | ||
> | ||
<sv-ng-element-title [element]="survey"></sv-ng-element-title> | ||
<h5 *ngIf="survey.renderedHasDescription" [class]="survey.css.description" [model]="survey.locDescription" sv-ng-string></h5> | ||
</div> | ||
|
||
<div | ||
*ngIf="survey.renderedHasTitle" | ||
[class]="survey.css.headerText" | ||
[style.maxWidth]="survey.titleMaxWidth" | ||
> | ||
<sv-ng-element-title [element]="survey"></sv-ng-element-title> | ||
<h5 *ngIf="survey.renderedHasDescription" [class]="survey.css.description" [model]="survey.locDescription" sv-ng-string></h5> | ||
</div> | ||
|
||
<div *ngIf="survey.isLogoAfter" [class]="survey.logoClassNames"> | ||
<img | ||
[class]="survey.css.logoImage" | ||
[attr.src]="survey.locLogo.renderedHtml | safeUrl" | ||
[attr.width]="survey.logoWidth ? survey.logoWidth : undefined" | ||
[attr.height]="survey.logoHeight ? survey.logoHeight : undefined" | ||
[alt]="survey.locTitle.renderedHtml" | ||
[style.objectFit]="survey.logoFit" | ||
/> | ||
</div> | ||
<div *ngIf="survey.isLogoAfter" [class]="survey.logoClassNames"> | ||
<ng-template [component]="{ name: survey.getElementWrapperComponentName(survey, 'logo-image'), data: { data: survey.getElementWrapperComponentData(survey, 'logo-image') } }"></ng-template> | ||
</div> | ||
<div [class]="survey.css.headerClose"></div> |
12 changes: 9 additions & 3 deletions
12
packages/survey-angular-ui/src/components/survey-header/survey-header.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 |
---|---|---|
@@ -1,14 +1,20 @@ | ||
import { AfterViewInit, Component, Input, ViewContainerRef } from "@angular/core"; | ||
import { AfterViewInit, ChangeDetectorRef, Component, Input, OnDestroy, ViewContainerRef } from "@angular/core"; | ||
import { SurveyModel } from "survey-core"; | ||
|
||
@Component({ | ||
selector: "'[sv-ng-survey-header]'", | ||
templateUrl: "survey-header.component.html" | ||
}) | ||
export class SurveyHeaderComponent implements AfterViewInit { | ||
export class SurveyHeaderComponent implements AfterViewInit, OnDestroy { | ||
@Input() survey!: SurveyModel; | ||
constructor(private viewContainerRef: ViewContainerRef) {} | ||
constructor(private viewContainerRef: ViewContainerRef, private changeDetectorRef: ChangeDetectorRef) {} | ||
ngAfterViewInit(): void { | ||
this.survey.afterRenderHeader(this.viewContainerRef.element.nativeElement); | ||
this.survey.locLogo.onChanged = () => { | ||
this.changeDetectorRef.detectChanges(); | ||
}; | ||
} | ||
ngOnDestroy(): void { | ||
this.survey.locLogo.onChanged = () => {}; | ||
} | ||
} |