Skip to content

Commit

Permalink
title cover (#6976)
Browse files Browse the repository at this point in the history
* work for "Title cover" : step 1

* work for "Title cover" : step 2 add vertical aligment &

* work for "Title cover" : step 3 add title & description components

* work for "Title cover" : step 4 add background image

* work for "Title cover" : step 5 save cover into theme

* work for "Title cover" : step 6 change layouting

* Work for #248 - Cover - implemented cover elements positioning

* Fixed titleView default to pass tests - surveyjs/private-tasks#248

* work for "Title cover" : small fixes

* Work for surveyjs/private-tasks#248 - implemented cover for react and vue2

* Fixed lint

* Work for surveyjs/private-tasks#248 - implemented cover for vue3

* Work for surveyjs/private-tasks#248 - implemented cover for angular

* Work for surveyjs/private-tasks#248 - fixed text width (allow be greater than cell width)

* Work for surveyjs/private-tasks#248 - added cover in titleView setter + generate default cover

* Work for surveyjs/private-tasks#248 - added cover in titleView setter + generate default cover - added vr-test

* Removed test.only

* Work for surveyjs/private-tasks#248 - try to fix PR

* work for "Title cover" : update etalon & try fix vue3

* work for "Title cover" : fix vue3

* work for "Title cover" : exclude jquery for knockout tests

* work for "Title cover" : exclude jquery for knockout tests

* work for "Title cover" : fix angular layout

---------

Co-authored-by: OlgaLarina <[email protected]>
Co-authored-by: tsv2013 <[email protected]>
Co-authored-by: tsv2013 <[email protected]>
  • Loading branch information
4 people authored Sep 26, 2023
1 parent f5ff072 commit cde9938
Show file tree
Hide file tree
Showing 41 changed files with 945 additions and 23 deletions.
2 changes: 1 addition & 1 deletion examples_test/defaultV2/knockout.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.5.0/knockout-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.6.4/showdown.min.js"></script>
<link rel="stylesheet" href="../../build/survey-knockout/defaultV2.min.css" />
Expand Down
9 changes: 6 additions & 3 deletions packages/survey-angular-ui/src/angular-ui.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import { RankingItemComponent } from "./questions/ranking-item.component";
import { SurveyStringComponent } from "./survey-string.component";
import { StringEditorComponent } from "./string-editor.component";
import { PanelDynamicAddBtn } from "./components/paneldynamic-actions/paneldynamic-add-btn.component";
import { PanelDynamicNextBtn }from "./components/paneldynamic-actions/paneldynamic-next-btn.component";
import { PanelDynamicNextBtn } from "./components/paneldynamic-actions/paneldynamic-next-btn.component";
import { PanelDynamicPrevBtn } from "./components/paneldynamic-actions/paneldynamic-prev-btn.component";
import { PanelDynamicProgressText } from "./components/paneldynamic-actions/paneldynamic-progress-text.component";
import { PanelDynamicQuestionComponent } from "./questions/paneldynamic.component";
Expand Down Expand Up @@ -112,7 +112,10 @@ import { NotifierComponent } from "./components/notifier/notifier.component";
import { ComponentsContainerComponent } from "./components-container.component";
import { MultipleTextRowComponent } from "./questions/multipletextrow.component";
import { LoadingIndicatorComponent } from "./angular-ui";
import { CoverComponent } from "./components/cover/cover.component";
import { CoverCellComponent } from "./components/cover/cover-cell.component";
import { ChooseFileBtn } from "./components/file-actions/choose-file.component";

@NgModule({
declarations: [
VisibleDirective, Key2ClickDirective, PanelDynamicAddBtn, PanelDynamicNextBtn, PanelDynamicPrevBtn, PanelDynamicProgressText, ElementComponent, TemplateRendererComponent,
Expand All @@ -129,7 +132,7 @@ import { ChooseFileBtn } from "./components/file-actions/choose-file.component";
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, LogoImageComponent, SkeletonComponent, TimerPanelComponent, PaneldynamicRemoveButtonComponent,
NotifierComponent, ComponentsContainerComponent, MultipleTextRowComponent, LoadingIndicatorComponent, ChooseFileBtn
NotifierComponent, ComponentsContainerComponent, MultipleTextRowComponent, LoadingIndicatorComponent, CoverComponent, CoverCellComponent, ChooseFileBtn
],
imports: [
CommonModule, FormsModule
Expand All @@ -150,7 +153,7 @@ import { ChooseFileBtn } from "./components/file-actions/choose-file.component";
MultipleTextComponent, MultipleTextItemComponent, DynamicComponentDirective, RankingQuestionComponent, RankingItemComponent, PanelDynamicQuestionComponent, EmbeddedViewContentComponent, CustomWidgetComponent, MatrixCellComponent, MatrixTableComponent, MatrixDropdownComponent,
MatrixDynamicComponent, MatrixDetailButtonComponent, MatrixDynamicRemoveButtonComponent, MatrixDynamicDragDropIconComponent, MatrixRequiredHeader, ExpressionComponent, SafeResourceUrlPipe,
CustomQuestionComponent, CompositeQuestionComponent, ButtonGroupQuestionComponent, ModalComponent, LogoImageComponent, SkeletonComponent, TimerPanelComponent, PaneldynamicRemoveButtonComponent,
NotifierComponent, ComponentsContainerComponent, MultipleTextRowComponent, LoadingIndicatorComponent
NotifierComponent, ComponentsContainerComponent, MultipleTextRowComponent, LoadingIndicatorComponent, CoverComponent, CoverCellComponent
],
providers: [PopupService],
})
Expand Down
2 changes: 2 additions & 0 deletions packages/survey-angular-ui/src/angular-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ export * from "./questions/custom.component";
export * from "./questions/composite.component";
export * from "./base-angular";
export * from "./components/loading-indicator/loading-indicator.component";
export * from "./components/cover/cover.component";
export * from "./components/cover/cover-cell.component";

export * from "./component-factory";
export * from "./angular-ui.module";
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

<ng-template #template>
<div [class]="model.css" [style]="model.style">
<div class="sv-cover__cell-content" [style]="model.contentStyle">
<div *ngIf="model.showLogo" class="sv-cover__logo">
<div [class]="model.survey.logoClassNames">
<ng-template [component]="{ name: model.survey.getElementWrapperComponentName(model.survey, 'logo-image'), data: { data: model.survey.getElementWrapperComponentData(model.survey, 'logo-image') } }"></ng-template>
</div>
</div>
<div *ngIf="model.showTitle" class="sv-cover__title" [style]="{ maxWidth: model.textWidth }">
<sv-ng-element-title [element]="model.survey"></sv-ng-element-title>
</div>
<div *ngIf="model.showDescription" class="sv-cover__description" [style]="{ maxWidth: model.textWidth }">
<h5 *ngIf="model.survey.renderedHasDescription" [class]="model.survey.css.description" [model]="model.survey.locDescription" sv-ng-string></h5>
</div>
</div>
</div>
</ng-template>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Component, Input, ViewChild, ViewContainerRef } from "@angular/core";
import { BaseAngular } from "../../base-angular";
import { EmbeddedViewContentComponent } from "../../embedded-view-content.component";
import { AngularComponentFactory } from "../../component-factory";
import { Cover, CoverCell, SurveyModel } from "survey-core";

@Component({
selector: "sv-ng-cover-cell",
templateUrl: "./cover-cell.component.html",
styles: [":host { display: none; }"],
})
export class CoverCellComponent extends EmbeddedViewContentComponent {
@Input() model!: CoverCell;
@ViewChild("actionContent", { read: ViewContainerRef, static: true }) actionContent!: ViewContainerRef;
}

AngularComponentFactory.Instance.registerComponent("sv-cover-cell", CoverCellComponent);
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<ng-template #template>
<div *ngIf="(survey.titleView === 'cover' && survey.renderedHasHeader)" [class]="model.coverClasses" [style]="{ height: model.renderedHeight, backgroundColor: model.backgroundColor }">
<div *ngIf="!!model.backgroundImage" [style]="model.backgroundImageStyle" [class]="model.backgroundImageClasses"></div>
<div [class]="model.contentClasses">
<ng-container *ngFor="let cell of model.cells">
<sv-ng-cover-cell [model]="cell"></sv-ng-cover-cell>
</ng-container>
</div>
</div>
</ng-template>
Empty file.
21 changes: 21 additions & 0 deletions packages/survey-angular-ui/src/components/cover/cover.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Component, ElementRef, Input, ViewChild } from "@angular/core";
import { AngularComponentFactory } from "../../component-factory";
import { BaseAngular } from "../../base-angular";
import { Cover, CoverCell, SurveyModel } from "survey-core";

@Component({
selector: "sv-cover, sv-ng-cover",
templateUrl: "./cover.component.html",
styles: [":host { display: none }"]
})
export class CoverComponent extends BaseAngular<Cover> {
@Input() model!: Cover;
@Input() survey!: SurveyModel;
@ViewChild("container") container!: ElementRef<HTMLDivElement>;
getModel(): Cover {
this.model.survey = this.survey;
return this.model;
}
}

AngularComponentFactory.Instance.registerComponent("sv-cover", CoverComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<form onsubmit="return false;">
<div class="sv_custom_header" [hidden]="model.hasLogo"></div>
<div [class]="model.css.container">
<div *ngIf="model.renderedHasHeader" [class]="model.css.header" [survey]="model" sv-ng-survey-header></div>
<div *ngIf="model.titleView === 'title' && model.renderedHasHeader" [class]="model.css.header" [survey]="model" sv-ng-survey-header></div>
<ng-template [component]="{ name: 'sv-components-container', data: { survey: model, container: 'header', needRenderWrapper: false } }"></ng-template>
<div *ngIf="model.isShowingPage" [class]="model.bodyContainerCss">
<ng-template [component]="{ name: 'sv-components-container', data: { survey: model, container: 'left' } }"></ng-template>
Expand Down
2 changes: 1 addition & 1 deletion packages/survey-vue3-ui/src/Survey.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<form onsubmit="return false;">
<div v-if="!vueSurvey.hasLogo" class="sv_custom_header"></div>
<div :class="css.container">
<survey-header :survey="vueSurvey" />
<survey-header v-if="vueSurvey.titleView === 'title'" :survey="vueSurvey" />
<component
:is="'sv-components-container'"
:survey="vueSurvey"
Expand Down
27 changes: 27 additions & 0 deletions packages/survey-vue3-ui/src/components/cover/Cover.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<div :class="model.coverClasses" :style="{ 'height': model.renderedHeight, 'backgroundColor': model.backgroundColor }">
<div v-if="!!model.backgroundImage" :class="model.backgroundImageClasses" :style="model.backgroundImageStyle"></div>
<div :class="model.contentClasses">
<sv-cover-cell
v-for="cell in model.cells"
:model="cell"
></sv-cover-cell>
</div>
</div>
</template>

<script lang="ts" setup>
import { Base, SurveyModel, Cover, CoverCell } from "survey-core";
import { useBase } from "@/base";
import { onMounted, onUnmounted, ref } from "vue";
const props = defineProps<{
model: Cover;
survey: SurveyModel;
}>();
useBase(() => {
props.model.survey = props.survey
return props.model;
});
</script>
35 changes: 35 additions & 0 deletions packages/survey-vue3-ui/src/components/cover/CoverCell.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<template>
<div :class="model.css" :style="model.style">
<div class="sv-cover__cell-content" :style="model.contentStyle">
<div v-if="model.showLogo" class="sv-cover__logo">
<div :class="model.survey.logoClassNames">
<img
:class="model.survey.css.logoImage"
:src="model.survey.locLogo.renderedHtml"
:width="model.survey.renderedLogoWidth"
:height="model.survey.renderedLogoHeight"
:alt="model.survey.locTitle.renderedHtml"
:style="{ 'objectFit': model.survey.logoFit as any, 'width': model.survey.renderedStyleLogoWidth, 'height': model.survey.renderedStyleLogoHeight }"
/>
</div>
</div>
<div v-if="model.showTitle" class="sv-cover__title" :style="{ 'maxWidth': model.textWidth }">
<survey-element-title :element="model.survey" :css="model.survey.css" />
</div>
<div v-if="model.showDescription" class="sv-cover__description" :style="{ 'maxWidth': model.textWidth }">
<h5 v-if="model.survey.renderedHasDescription" :class="model.survey.css.description">
<survey-string :locString="model.survey.locDescription" />
</h5>
</div>
</div>
</div>
</template>

<script lang="ts" setup>
import { Base, SurveyModel, Cover, CoverCell } from "survey-core";
import { onMounted, onUnmounted, ref } from "vue";
const props = defineProps<{
model: CoverCell;
}>();
</script>
6 changes: 6 additions & 0 deletions packages/survey-vue3-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ import Custom from "./Custom.vue";
import TimerPanel from "./TimerPanel.vue";
import LoadingIndicator from "./components/LoadingIndicator.vue";

import Cover from "./components/cover/Cover.vue";
import CoverCell from "./components/cover/CoverCell.vue";

import {
SurveyModel,
doKey2ClickBlur,
Expand Down Expand Up @@ -236,6 +239,9 @@ function registerComponents(app: App) {
app.component("sv-timerpanel", TimerPanel);
app.component("sv-loading-indicator", LoadingIndicator);

app.component("sv-cover", Cover);
app.component("sv-cover-cell", CoverCell);

app.directive("key2click", {
// When the bound element is inserted into the DOM...
mounted: function (el: HTMLElement, binding: any) {
Expand Down
2 changes: 2 additions & 0 deletions src/base-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ export type ISurveyEnvironment = {
}

export type LayoutElementContainer = "header" | "footer" | "left" | "right" | "contentTop" | "contentBottom";
export type HorizontalAlignment = "left" | "center" | "right";
export type VerticalAlignment = "top" | "middle" | "bottom";

export interface ISurveyLayoutElement {
id: string;
Expand Down
Loading

0 comments on commit cde9938

Please sign in to comment.