Skip to content

Commit

Permalink
Work for #7670 - added headerView ITheme property
Browse files Browse the repository at this point in the history
  • Loading branch information
tsv2013 committed Jan 16, 2024
1 parent bed17cf commit 6efa592
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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]": {
Expand Down
14 changes: 14 additions & 0 deletions src/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
22 changes: 22 additions & 0 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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({
Expand Down

0 comments on commit 6efa592

Please sign in to comment.