import Component from "@ember/component"; import { action, computed } from "@ember/object"; import { next } from "@ember/runloop"; import { fmt } from "discourse/lib/computed"; import { isDocumentRTL } from "discourse/lib/text-direction"; import discourseComputed from "discourse-common/utils/decorators"; import { i18n } from "discourse-i18n"; export default class AdminThemeEditor extends Component { warning = null; @fmt("fieldName", "currentTargetName", "%@|%@") editorId; @discourseComputed("theme.targets", "onlyOverridden", "showAdvanced") visibleTargets(targets, onlyOverridden, showAdvanced) { return targets.filter((target) => { if (target.advanced && !showAdvanced) { return false; } if (!onlyOverridden) { return true; } return target.edited; }); } @discourseComputed("currentTargetName", "onlyOverridden", "theme.fields") visibleFields(targetName, onlyOverridden, fields) { fields = fields[targetName]; if (onlyOverridden) { fields = fields.filter((field) => field.edited); } return fields; } @discourseComputed("currentTargetName", "fieldName") activeSectionMode(targetName, fieldName) { if (["settings", "translations"].includes(targetName)) { return "yaml"; } if (["extra_scss"].includes(targetName)) { return "scss"; } if (["color_definitions"].includes(fieldName)) { return "scss"; } return fieldName && fieldName.includes("scss") ? "scss" : "html"; } @discourseComputed("currentTargetName", "fieldName") placeholder(targetName, fieldName) { if (fieldName && fieldName === "color_definitions") { const example = ":root {\n" + " --mytheme-tertiary-or-highlight: #{dark-light-choose($tertiary, $highlight)};\n" + "}"; return i18n("admin.customize.theme.color_definitions.placeholder", { example: isDocumentRTL() ? `