Skip to content

FEATURE: Theme-owned color palettes #32795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

OsamaSayegh
Copy link
Member

This PR replaces the color palette dropdown on the theme page with a color palette editor that enables editing the theme's color palette directly from 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.

Screenshot:

@OsamaSayegh OsamaSayegh force-pushed the feature/theme-owned-palettes branch 4 times, most recently from 768923f to 53295b1 Compare May 19, 2025 09:48
@@ -76,6 +60,10 @@ export default class ColorScheme extends EmberObject {
init() {
super.init(...arguments);

const colors = A(this.colors ?? []);
this.colors = colors.map((c) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these looping in the PR is also making me wonder if we selected the wrong data structure here. Perhaps we should be using a object here instead of an array so that we can easily look up a color object by its name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've eliminated all the loops except for this one. I think we'd still need to loop here even if we changed the data structure because this converts the data from POJOs to ColorSchemeColor objects.

Comment on lines +195 to +183
updated_color = theme_page.color_palette_editor.get_color_value("primary")
expect(updated_color).to eq("#ff000e")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not relying on capybara matches so has a good chance to be flaky.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this particular case it should be fine given that we're reloading the page just before this line and we're testing that the color input is rendered with this value. If we were testing that the color input is changed in reaction to something, then yeah we'd have a flaky test here.

@OsamaSayegh OsamaSayegh force-pushed the feature/theme-owned-palettes branch from f903ffa to 3169855 Compare May 29, 2025 12:54
@github-actions github-actions bot added the i18n PRs which update English locale files or i18n related code label May 29, 2025
@OsamaSayegh OsamaSayegh force-pushed the feature/theme-owned-palettes branch 2 times, most recently from 531c599 to 4e4de6c Compare May 29, 2025 19:06
@OsamaSayegh OsamaSayegh force-pushed the feature/theme-owned-palettes branch from 23cd630 to 839286d Compare May 30, 2025 15:44
@OsamaSayegh OsamaSayegh force-pushed the feature/theme-owned-palettes branch from 839286d to 069de0f Compare May 30, 2025 15:57
Comment on lines +18 to +24
get pendingChangesSaveLabel() {
return i18n("admin.customize.theme.save_colors");
}

get pendingChangesDiscardLabel() {
return i18n("admin.customize.theme.discard_colors");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont need getters is not going to be recomputed

Comment on lines +24 to +27
@action
discard() {
this.args.discard();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can probably just use @discard in the template

Comment on lines +29 to +42
@action
setupResizeObserver(element) {
const container = document.getElementById("main-container");
this._resizer = () => this.positionBanner(container, element);

this._resizer();

this._resizeObserver = window.addEventListener("resize", this._resizer);
}

@action
teardownResizeObserver() {
window.removeEventListener("resize", this._resizer);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just use a modifier so you do all in one function and don't need this _resizer variable

@@ -174,6 +185,34 @@ class Theme extends RestModel {
return field ? field.error : "";
}

async changeColors() {
const payload = [];
Copy link
Contributor

@jjaffeux jjaffeux May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to call it colors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n PRs which update English locale files or i18n related code
Development

Successfully merging this pull request may close these issues.

4 participants