Skip to content

Commit

Permalink
ntp: fixed gradients to match macOS (#1374)
Browse files Browse the repository at this point in the history
* ntp: fixed gradients to match macOS

* add test

* added a comment explaining the reasoning
  • Loading branch information
shakyShane authored Jan 7, 2025
1 parent 3df3d1b commit 24f6503
Show file tree
Hide file tree
Showing 11 changed files with 208 additions and 169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export class CustomizerPage {
async selectsGradient() {
const { page } = this.ntp;
await page.locator('aside').getByLabel('Gradients').click();
await this.orderOfGradientsMatchesMacos();
await page.getByRole('radio', { name: 'Select gradient01' }).click();
const calls = await this.ntp.mocks.waitForCallCount({ count: 1, method: named.notification('customizer_setBackground') });
expect(calls[0].payload).toMatchObject({
Expand Down Expand Up @@ -408,4 +409,37 @@ export class CustomizerPage {
{ style: 'background: rgb(226, 132, 153);', value: 'color19' },
]);
}

async orderOfGradientsMatchesMacos() {
const { page } = this.ntp;
const subscreen = page.locator('aside').locator('[data-sub="gradient"]');

// wait for the elements to show, before getting any values
await subscreen.locator('[role=radio][data-value]').nth(0).waitFor();

const styles = await page
.locator('aside')
.locator('[data-sub="gradient"]') // wait for sub-screen to show
.evaluate((colorSelectionScreen) => {
const colorSwatches = colorSelectionScreen.querySelectorAll('[role=radio][data-value]');
return Array.from(colorSwatches).map((swatch) => {
return {
value: swatch.getAttribute('data-value'),
};
});
});

// This test is here to prevent changes to the gradients colors from impacting the UI
// these need to be exact to prevent migrations from becoming a problem
expect(styles).toStrictEqual([
{ value: 'gradient01' },
{ value: 'gradient02' },
{ value: 'gradient02.01' },
{ value: 'gradient03' },
{ value: 'gradient04' },
{ value: 'gradient05' },
{ value: 'gradient06' },
{ value: 'gradient07' },
]);
}
}
17 changes: 11 additions & 6 deletions special-pages/pages/new-tab/app/customizer/values.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ export const values = {
gradients: {
gradient01: { path: 'gradients/gradient01.svg', fallback: '#f2e5d4', colorScheme: 'light' },
gradient02: { path: 'gradients/gradient02.svg', fallback: '#d5bcd1', colorScheme: 'light' },
gradient03: { path: 'gradients/gradient03.svg', fallback: '#f4ca78', colorScheme: 'light' },
gradient04: { path: 'gradients/gradient04.svg', fallback: '#e6a356', colorScheme: 'light' },
gradient05: { path: 'gradients/gradient05.svg', fallback: '#4448ae', colorScheme: 'dark' },
gradient06: { path: 'gradients/gradient06.svg', fallback: '#a55778', colorScheme: 'dark' },
gradient07: { path: 'gradients/gradient07.svg', fallback: '#222566', colorScheme: 'dark' },
gradient08: { path: 'gradients/gradient08.svg', fallback: '#0e0e3d', colorScheme: 'dark' },
/**
* Note: the following name `gradient02.01` is used to allow migration for existing macOS users.
* When switching to the web-based NTP, we introduced an eight gradient to round-out the columns, but
* the colors in the gradient meant it needed to be wedged in between 02 and 03.
*/
'gradient02.01': { path: 'gradients/gradient02.01.svg', fallback: '#f4ca78', colorScheme: 'light' },
gradient03: { path: 'gradients/gradient03.svg', fallback: '#e6a356', colorScheme: 'light' },
gradient04: { path: 'gradients/gradient04.svg', fallback: '#4448ae', colorScheme: 'dark' },
gradient05: { path: 'gradients/gradient05.svg', fallback: '#a55778', colorScheme: 'dark' },
gradient06: { path: 'gradients/gradient06.svg', fallback: '#222566', colorScheme: 'dark' },
gradient07: { path: 'gradients/gradient07.svg', fallback: '#0e0e3d', colorScheme: 'dark' },
},
userImages: {
'01': {
Expand Down
4 changes: 2 additions & 2 deletions special-pages/pages/new-tab/messages/types/colors.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"enum": [
"gradient01",
"gradient02",
"gradient02.01",
"gradient03",
"gradient04",
"gradient05",
"gradient06",
"gradient07",
"gradient08"
"gradient07"
]
},
"colors": {
Expand Down
31 changes: 31 additions & 0 deletions special-pages/pages/new-tab/public/gradients/gradient02.01.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 19 additions & 19 deletions special-pages/pages/new-tab/public/gradients/gradient03.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 33 additions & 18 deletions special-pages/pages/new-tab/public/gradients/gradient04.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 24f6503

Please sign in to comment.