discourse/app/assets/javascripts/admin/addon/components/changes-banner.gjs
Osama Sayegh 7fce724089
FEATURE: Theme-owned color palettes (#32795)
This commit removes the color palette dropdown from the theme page and replaces it with a new "Colors" tab where the theme's color palette can be edited directly in that tab on the theme page. With this change, a theme's color palette is strongly tied to its theme and can't be linked to other themes and it can't be selected by users without using the theme as well.

All of the changes are behind a feature flag. To enable it, turn on the `use_overhauled_theme_color_palette` setting.

Co-authored-by: Ella <ella.estigoy@gmail.com>
2025-06-04 07:47:58 +03:00

60 lines
1.6 KiB
Text
Vendored

import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
import { modifier } from "ember-modifier";
import DButton from "discourse/components/d-button";
import htmlSafe from "discourse/helpers/html-safe";
export default class ChangesBanner extends Component {
@tracked isSaving = false;
resizerModifier = modifier((element) => {
const container = document.getElementById("main-container");
const resizer = () => this.positionBanner(container, element);
resizer();
window.addEventListener("resize", resizer);
return () => window.removeEventListener("resize", resizer);
});
@action
async save() {
this.isSaving = true;
try {
await this.args.save();
} finally {
this.isSaving = false;
}
}
positionBanner(container, element) {
if (container) {
const { width } = container.getBoundingClientRect();
element.style.width = `${width}px`;
}
}
<template>
<div class="admin-changes-banner" {{this.resizerModifier}}>
<span class="admin-changes-banner__main-label">{{htmlSafe
@bannerLabel
}}</span>
<div class="controls">
<DButton
class="btn-secondary btn-small"
@action={{@discard}}
@disabled={{this.isSaving}}
@translatedLabel={{@discardLabel}}
/>
<DButton
class="btn-primary btn-small"
@action={{this.save}}
@isLoading={{this.isSaving}}
@translatedLabel={{@saveLabel}}
/>
</div>
</div>
</template>
}