Skip to content

Commit

Permalink
Work for surveyjs/survey-creator#3390: implement wrapper for logo (#4932
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dk981234 committed Sep 30, 2022
1 parent 214e56b commit ddb3c3c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 33 deletions.
5 changes: 3 additions & 2 deletions packages/survey-angular-ui/src/angular-ui.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import { ModalComponent } from "./components/popup/modal-container.component";
import { ButtonGroupQuestionComponent } from "./questions/button-group/button-group.component";
import { ButtonGroupItemComponent } from "./questions/button-group/button-group-item.component";
import { MatrixRowComponent } from "./questions/matrix-row.component";
import { LogoImageComponent } from "./components/survey-header/logo-image.component";
@NgModule({
declarations: [
VisibleDirective, Key2ClickDirective, PanelDynamicAddBtn, PanelDynamicNextBtn, PanelDynamicPrevBtn, PanelDynamicProgressText, ElementComponent, TemplateRendererComponent,
Expand All @@ -111,7 +112,7 @@ import { MatrixRowComponent } from "./questions/matrix-row.component";
SurveyHeaderComponent, ProgressDefaultComponent, ProgressButtonsComponent, SurveyNavigationButton, MatrixQuestionComponent, SvgIconComponent, FileQuestionComponent, SafeUrlPipe, SafeHtmlPipe, CommentQuestionComponent, SignaturePadQuestionComponent, ErrorsComponent,
MultipleTextComponent, MultipleTextItemComponent, DynamicComponentDirective, RankingQuestionComponent, RankingItemComponent, PanelDynamicQuestionComponent, EmbeddedViewContentComponent, CustomWidgetComponent, MatrixCellComponent, MatrixTableComponent, MatrixDropdownComponent,
MatrixDynamicComponent, MatrixDetailButtonComponent, MatrixDynamicRemoveButtonComponent, MatrixDynamicDragDropIconComponent, MatrixRequiredHeader, ExpressionComponent, SafeResourceUrlPipe, BrandInfoComponent,
CustomQuestionComponent, CompositeQuestionComponent, ButtonGroupItemComponent, ButtonGroupQuestionComponent, MatrixRowComponent, ModalComponent
CustomQuestionComponent, CompositeQuestionComponent, ButtonGroupItemComponent, ButtonGroupQuestionComponent, MatrixRowComponent, ModalComponent, LogoImageComponent
],
imports: [
CommonModule, FormsModule
Expand All @@ -130,7 +131,7 @@ import { MatrixRowComponent } from "./questions/matrix-row.component";
SurveyHeaderComponent, ProgressDefaultComponent, ProgressButtonsComponent, SurveyNavigationButton, MatrixQuestionComponent, SvgIconComponent, FileQuestionComponent, SafeUrlPipe, SafeHtmlPipe, CommentQuestionComponent, SignaturePadQuestionComponent, ErrorsComponent,
MultipleTextComponent, MultipleTextItemComponent, DynamicComponentDirective, RankingQuestionComponent, RankingItemComponent, PanelDynamicQuestionComponent, EmbeddedViewContentComponent, CustomWidgetComponent, MatrixCellComponent, MatrixTableComponent, MatrixDropdownComponent,
MatrixDynamicComponent, MatrixDetailButtonComponent, MatrixDynamicRemoveButtonComponent, MatrixDynamicDragDropIconComponent, MatrixRequiredHeader, ExpressionComponent, SafeResourceUrlPipe, BrandInfoComponent,
CustomQuestionComponent, CompositeQuestionComponent, ButtonGroupQuestionComponent, ModalComponent
CustomQuestionComponent, CompositeQuestionComponent, ButtonGroupQuestionComponent, ModalComponent, LogoImageComponent
],
providers: [PopupService],
})
Expand Down
1 change: 1 addition & 0 deletions packages/survey-angular-ui/src/angular-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from "./components/tagbox/tagbox-item.component";
export * from "./components/tagbox/tagbox.component";
export * from "./components/renderAs/dropdown-select/dropdown-option-item.component";
export * from "./components/renderAs/dropdown-select/dropdown-select.component";
export * from "./components/survey-header/logo-image.component";
export * from "./questions/text.component";
export * from "./questions/html.component";
export * from "./questions/radiogroup.component";
Expand Down
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>
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);
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>
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 = () => {};
}
}

0 comments on commit ddb3c3c

Please sign in to comment.