From 6efa5920b72bca3796c3859b3019d09f8b2a27fa Mon Sep 17 00:00:00 2001 From: tsv2013 Date: Tue, 16 Jan 2024 12:44:01 +0300 Subject: [PATCH] Work for #7670 - added headerView ITheme property --- .vscode/settings.json | 3 +-- src/themes.ts | 14 ++++++++++++++ tests/surveytests.ts | 22 ++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index b77e1f9c30..8bfbe962cb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,8 +5,7 @@ }, "[typescript]": { "editor.codeActionsOnSave": { - "source.fixAll": true, - //"source.organizeImports": true, // be vare of https://github.com/microsoft/vscode-typescript-tslint-plugin/issues/51 + "source.fixAll": "explicit" } }, "[html]": { diff --git a/src/themes.ts b/src/themes.ts index 3d121a29e6..425bea3d2d 100644 --- a/src/themes.ts +++ b/src/themes.ts @@ -61,6 +61,20 @@ export interface ITheme { * An object with [advanced survey header settings](https://surveyjs.io/form-library/documentation/api-reference/iheader). Applies when `SurveyModel`'s [`headerView`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#headerView) property is set to `"advanced"`. */ header?: IHeader; + /** + * Specifies whether the survey header uses only basic appearance settings or applies advanced settings from the survey theme. + * + * Possible values: + * + * - `"basic"` (default)\ + * A basic header view applies only the [`title`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#title), [`description`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#description), and logo-related properties ([`logo`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#logo), [`logoPosition`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#logoPosition), etc.). + * + * - `"advanced"`\ + * An advanced header view applies the same properties as the basic view, plus [header settings](https://surveyjs.io/form-library/documentation/api-reference/iheader) from the [survey theme](https://surveyjs.io/form-library/documentation/api-reference/itheme#header). The advanced view features a more flexible header layout, a capability to specify a background image, and other settings that give a more professional look to the survey header. + * + * [View Demo](https://surveyjs.io/form-library/examples/brand-your-survey-header/ (linkStyle)) + */ + headerView?: "advanced" | "basic"; /** * An object with CSS variables. */ diff --git a/tests/surveytests.ts b/tests/surveytests.ts index 5b6a0e95a1..77d58447de 100644 --- a/tests/surveytests.ts +++ b/tests/surveytests.ts @@ -18016,6 +18016,7 @@ QUnit.test("survey.applyTheme", function (assert) { assert.equal(survey.backgroundImageAttachment, "scroll", "before applyTheme"); assert.equal(survey.backgroundOpacity, 1, "before applyTheme"); assert.equal(survey["isCompact"], false, "before applyTheme"); + assert.equal(survey.headerView, "basic", "before applyTheme"); survey.applyTheme({ "cssVariables": { @@ -18038,6 +18039,27 @@ QUnit.test("survey.applyTheme", function (assert) { assert.equal(survey.backgroundImageAttachment, "fixed"); assert.equal(survey.backgroundOpacity, 0.6); assert.equal(survey["isCompact"], true); + assert.equal(survey.headerView, "basic", "before applyTheme"); +}); +QUnit.test("survey.applyTheme respects headerView", function (assert) { + const survey = new SurveyModel({ + elements: [ + { type: "text", name: "q1" }, + { type: "multipletext", name: "q2", items: [{ name: "q2_item1" }, { name: "q2_item2" }] } + ] + }); + + assert.equal(survey.headerView, "basic", "before applyTheme"); + survey.applyTheme({ + "headerView": "advanced" + }); + assert.equal(survey.headerView, "advanced"); + survey.applyTheme({ + "headerView": "basic" + }); + assert.equal(survey.headerView, "basic"); + survey.applyTheme({}); + assert.equal(survey.headerView, "basic"); }); QUnit.test("page/panel delete do it recursively", function (assert) { const survey = new SurveyModel({