Skip to content

Commit

Permalink
work for #5094 Create a theme model that inherits from a base class w…
Browse files Browse the repository at this point in the history
…ith serialization information.
  • Loading branch information
OlgaLarina committed Apr 12, 2024
1 parent 67bdc13 commit 5431844
Show file tree
Hide file tree
Showing 13 changed files with 195 additions and 506 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { setSurveyJSONForPropertyGrid } from "../../property-grid";
import { propertyGridCss } from "../../property-grid-theme/property-grid";
import { ColorCalculator, assign, ingectAlpha, notShortCircuitAnd, parseColor } from "../../utils/utils";
import { settings } from "../../creator-settings";
import { DefaultFonts, fontsettingsFromCssVariable, fontsettingsToCssVariable } from "./theme-custom-questions/font-settings";
import { elementSettingsFromCssVariable, elementSettingsToCssVariable } from "./theme-custom-questions/element-settings";
import { UndoRedoManager } from "../../plugins/undo-redo/undo-redo-manager";
import { PredefinedColors, PredefinedThemes, Themes } from "./themes";
import { updateCustomQuestionJSONs } from "./theme-custom-questions";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,41 +60,6 @@ export function elementSettingsToCssVariable(value: any, property: JsonObjectPro
});
}

// export function elementSettingsToCssVariableOld(question: Question, themeCssVariables: { [index: string]: string }) {
// Object.keys(question.value).forEach(key => {
// if (key === "corner") return;

// const propertyName = `--sjs-${question.name.toLocaleLowerCase()}-${key}`;
// if (!question.defaultValue || question.value[key] !== (question as Question).defaultValue[key]) {
// themeCssVariables[propertyName] = question.value[key];
// } else {
// themeCssVariables[propertyName] = undefined;
// }
// });
// }

// export function elementSettingsFromCssVariableOld(question: Question, themeCssVariables: { [index: string]: string }, defaultBackcolorVariable: string, defaultHovercolorVariable: string): void {
// if (!question) return;

// const compositeQuestion = <QuestionCompositeModel>question;
// const elementSettingsFromTheme = Object.keys(themeCssVariables).filter(key => key.indexOf(question.name.toLocaleLowerCase()) !== -1);

// elementSettingsFromTheme.forEach(key => {
// const propertyName = key.split("-").pop();

// if (propertyName === "cornerRadius" && themeCssVariables[key] !== undefined) {
// compositeQuestion.contentPanel.getQuestionByName("corner").value = parseFloat(themeCssVariables[key].toString());
// } else {
// compositeQuestion.contentPanel.getQuestionByName(propertyName).value = themeCssVariables[key];
// }
// });

// if (elementSettingsFromTheme.length === 0) {
// (<QuestionCompositeModel>question).contentPanel.getQuestionByName("backcolor").value = defaultBackcolorVariable;
// (<QuestionCompositeModel>question).contentPanel.getQuestionByName("hovercolor").value = defaultHovercolorVariable;
// }
// }

export function elementSettingsFromCssVariable(property: JsonObjectProperty, themeCssVariables: { [index: string]: string }, defaultBackcolorVariableName: string, defaultHovercolorVariableName: string, defaultCornerRadius: number): any {
if (!property) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,6 @@ export function updateFontSettingsJSON() {
config.json.elementsJSON = getElementsJSON();
}

// export function fontsettingsToCssVariableOld(question: Question, themeCssVariables: { [index: string]: string }) {
// Object.keys(question.value).forEach(key => {
// const innerQ = (<QuestionCompositeModel>question).contentPanel.getQuestionByName(key);
// const propertyName = `--sjs-font-${question.name.toLocaleLowerCase()}-${key}`;
// if (!question.defaultValue || question.value[key] !== question.defaultValue[key]) {
// themeCssVariables[propertyName] = question.value[key] + (innerQ.unit?.toString() || "");
// } else {
// themeCssVariables[propertyName] = undefined;
// }
// });
// }

export function fontsettingsToCssVariable(value: any, property: JsonObjectProperty, themeCssVariables: { [index: string]: string }) {
Object.keys(value).forEach(key => {
const propertyName = `--sjs-font-${property.name.toLocaleLowerCase()}-${key}`;
Expand All @@ -130,26 +118,6 @@ export function fontsettingsToCssVariable(value: any, property: JsonObjectProper
});
}

// export function fontsettingsFromCssVariableOld(question: Question, themeCssVariables: { [index: string]: string }, defaultColorVariable?: string, defaultPlaceholderColorVariable?: string): void {
// if (!question) return;

// const compositeQuestion = <QuestionCompositeModel>question;
// const fontSettingsFromTheme = Object.keys(themeCssVariables).filter(key => key.indexOf(question.name.toLocaleLowerCase()) !== -1);
// fontSettingsFromTheme.forEach(key => {
// const propertyName = key.split("-").pop();
// compositeQuestion.contentPanel.getQuestionByName(propertyName).value = themeCssVariables[key];
// });

// if (fontSettingsFromTheme.length === 0) {
// if (!!defaultColorVariable) {
// compositeQuestion.contentPanel.getQuestionByName("color").value = defaultColorVariable;
// }
// if (!!defaultPlaceholderColorVariable) {
// compositeQuestion.contentPanel.getQuestionByName("placeholdercolor").value = defaultPlaceholderColorVariable;
// }
// }
// }

export function fontsettingsFromCssVariable(property: JsonObjectProperty, themeCssVariables: { [index: string]: string }, defaultColorVariableName?: string, defaultPlaceholderColorVariableName?: string): any {
if (!property) return;

Expand Down
Loading

0 comments on commit 5431844

Please sign in to comment.