-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work for #3390 - Implement logo image wrapper
- Loading branch information
Showing
4 changed files
with
57 additions
and
3 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
19 changes: 19 additions & 0 deletions
19
packages/survey-creator-angular/src/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,19 @@ | ||
<ng-template #template> | ||
<div class="svc-logo-image" #container> | ||
<input type="file" aria-hidden="true" tabindex="-1" accept="image/*" class="svc-choose-file-input" /> | ||
<ng-container *ngIf="!survey.locLogo.renderedHtml"> | ||
<ng-container *ngIf="model.allowEdit"> | ||
<div class="svc-logo-image-placeholder" (click)="model.chooseFile(model)" [key2click]> | ||
<svg> | ||
<use xlink:href="#icon-logo"></use> | ||
</svg> | ||
</div> | ||
</ng-container> | ||
</ng-container> | ||
<ng-container *ngIf="survey.locLogo.renderedHtml"> | ||
<div [class]="model.containerCss" (click)="model.chooseFile(model)" [key2click]> | ||
<sv-logo-image [data]="survey"></sv-logo-image> | ||
</div> | ||
</ng-container> | ||
</div> | ||
</ng-template> |
35 changes: 35 additions & 0 deletions
35
packages/survey-creator-angular/src/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,35 @@ | ||
import { AfterViewInit, Component, ElementRef, Input, ViewChild } from "@angular/core"; | ||
import { CreatorModelComponent } from "../creator-model.component"; | ||
import { SurveyModel } from "survey-core"; | ||
import { CreatorBase, LogoImageViewModel } from "survey-creator-core"; | ||
import { AngularComponentFactory } from "survey-angular-ui"; | ||
|
||
@Component({ | ||
selector: "svc-logo-image", | ||
templateUrl: "./logo-image.component.html", | ||
styles: [":host { display: none; }"] | ||
}) | ||
export class CreatorLogoImageComponent extends CreatorModelComponent<LogoImageViewModel> implements AfterViewInit { | ||
@Input() data!: CreatorBase; | ||
@ViewChild("container", { read: ElementRef }) container!: ElementRef<HTMLDivElement>; | ||
public model!: LogoImageViewModel; | ||
protected createModel(): void { | ||
this.model = new LogoImageViewModel(this.creator, null); | ||
} | ||
protected getModel(): LogoImageViewModel { | ||
return this.model; | ||
} | ||
protected getPropertiesToTrack(): string[] { | ||
return ["data"]; | ||
} | ||
public get creator(): CreatorBase { | ||
return this.data; | ||
} | ||
public get survey(): SurveyModel { | ||
return this.creator.survey; | ||
} | ||
ngAfterViewInit(): void { | ||
this.model.root = this.container.nativeElement; | ||
} | ||
} | ||
AngularComponentFactory.Instance.registerComponent("svc-logo-image", CreatorLogoImageComponent); |
3 changes: 1 addition & 2 deletions
3
packages/survey-creator-angular/src/tabs/designer/designer-survey.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