Skip to content

Commit

Permalink
work for #7104 Themes API: Rename cover -> header, list its propertie…
Browse files Browse the repository at this point in the history
…s, create an interface for onThemeApplied arguments (#7112)

Co-authored-by: OlgaLarina <olga.larina.dev@gmail.com>
  • Loading branch information
OlgaLarina and OlgaLarina committed Oct 10, 2023
1 parent 49dc3e1 commit 2ba9115
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class Cover extends Base {
.toString();
}
public fromTheme(theme: ITheme): void {
super.fromJSON(theme.cover);
super.fromJSON(theme.header);
if(!!theme.cssVariables) {
this.backgroundColor = theme.cssVariables["--sjs-cover-backcolor"];
}
Expand Down
5 changes: 5 additions & 0 deletions src/survey-events-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { QuestionMatrixDynamicModel } from "./question_matrixdynamic";
import { QuestionPanelDynamicModel } from "./question_paneldynamic";
import { SurveyModel } from "./survey";
import { SurveyError } from "./survey-error";
import { ITheme } from "./themes";
import { Trigger } from "./trigger";

export interface QuestionEventMixin {
Expand Down Expand Up @@ -941,4 +942,8 @@ export interface PopupVisibleChangedEvent extends QuestionEventMixin {
* Indicates whether the popup is visible now.
*/
visible: boolean;
}

export interface ThemeAppliedEvent {
theme: ITheme;
}
6 changes: 3 additions & 3 deletions src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import {
MatrixCellValidateEvent, DynamicPanelModifiedEvent, DynamicPanelRemovingEvent, TimerPanelInfoTextEvent, DynamicPanelItemValueChangedEvent, DynamicPanelGetTabTitleEvent,
IsAnswerCorrectEvent, DragDropAllowEvent, ScrollingElementToTopEvent, GetQuestionTitleActionsEvent, GetPanelTitleActionsEvent, GetPageTitleActionsEvent,
GetPanelFooterActionsEvent, GetMatrixRowActionsEvent, ElementContentVisibilityChangedEvent, GetExpressionDisplayValueEvent, ServerValidateQuestionsEvent,
MultipleTextItemAddedEvent, MatrixColumnAddedEvent, GetQuestionDisplayValueEvent, PopupVisibleChangedEvent
MultipleTextItemAddedEvent, MatrixColumnAddedEvent, GetQuestionDisplayValueEvent, PopupVisibleChangedEvent, ThemeAppliedEvent
} from "./survey-events-api";
import { QuestionMatrixDropdownModelBase } from "./question_matrixdropdownbase";
import { QuestionMatrixDynamicModel } from "./question_matrixdynamic";
Expand Down Expand Up @@ -140,7 +140,7 @@ export class SurveyModel extends SurveyElementCore
* An event that is raised after a [theme](/form-library/documentation/manage-default-themes-and-styles) is [applied](#applyTheme) to the survey.
* @see applyTheme
*/
onThemeApplied: EventBase<SurveyModel> = new EventBase<SurveyModel>();
onThemeApplied: EventBase<SurveyModel, ThemeAppliedEvent> = new EventBase<SurveyModel, ThemeAppliedEvent>();

//#region Event declarations
/**
Expand Down Expand Up @@ -7353,7 +7353,7 @@ export class SurveyModel extends SurveyElementCore
if (!theme) return;

Object.keys(theme).forEach((key: keyof ITheme) => {
if (key === "cover") {
if (key === "header") {
this.removeLayoutElement("cover");
const newCoverModel = new Cover();
newCoverModel.fromTheme(theme);
Expand Down
2 changes: 1 addition & 1 deletion src/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface ITheme {
/**
* An object with survey header settings.
*/
cover?: {[index: string]: any};
header?: {[index: string]: any};
/**
* An object with CSS variables.
*/
Expand Down

0 comments on commit 2ba9115

Please sign in to comment.