From 9421ead0f4d127d5c0306dcf1606360d61192bfd Mon Sep 17 00:00:00 2001 From: Riley Tatum Date: Wed, 25 Jan 2023 17:57:04 +0000 Subject: [PATCH] [NTP][Panorama] Select current color in chrome colors Wrapped the currently selected chrome color in a check_mark_wrapper. If it is not classic chrome/no background, nothing should be checked. Anything that isn't a chrome color will have the custom color selector selected. Also, changed the box-shadow for the wrapper to a border instead. Accomodating for the size of the shadow and shrinking the size of the element, causes the element to move since the shadow doesn't actually take up any space like a border does. This fixes the existing problem of this also happening in Overview colors. Chrome Colors screenshot: screenshot/9hQZyiSfX3EHgQK Overview screenshot: screenshot/3Q8AmZUb46fWkfZ Bug: 1384250, 1402969 Change-Id: Id6b33dd865095ae37955b3aea013ab94af3bd1d2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4189570 Reviewed-by: Tibor Goldschwendt Commit-Queue: Riley Tatum Cr-Commit-Position: refs/heads/main@{#1096852} --- .../customize_chrome/check_mark_wrapper.html | 2 +- .../customize_chrome/chrome_colors.html | 19 +++++-- .../customize_chrome/chrome_colors.ts | 19 ++++++- .../side_panel/customize_chrome/color.html | 20 ++++---- .../customize_chrome/chrome_colors_test.ts | 51 ++++++++++++++++++- .../side_panel/customize_chrome/color_test.ts | 4 +- 6 files changed, 94 insertions(+), 21 deletions(-) diff --git a/chrome/browser/resources/side_panel/customize_chrome/check_mark_wrapper.html b/chrome/browser/resources/side_panel/customize_chrome/check_mark_wrapper.html index 0817641c99574..404a4c87017f1 100644 --- a/chrome/browser/resources/side_panel/customize_chrome/check_mark_wrapper.html +++ b/chrome/browser/resources/side_panel/customize_chrome/check_mark_wrapper.html @@ -48,7 +48,7 @@ } :host([checked]) ::slotted(*) { - box-shadow: 0 0 0 2px var(--customize-chrome-check-mark-wrapper-color); + border: 2px solid var(--customize-chrome-check-mark-wrapper-color); } diff --git a/chrome/browser/resources/side_panel/customize_chrome/chrome_colors.html b/chrome/browser/resources/side_panel/customize_chrome/chrome_colors.html index d63a6b0a36e72..7400352d481b2 100644 --- a/chrome/browser/resources/side_panel/customize_chrome/chrome_colors.html +++ b/chrome/browser/resources/side_panel/customize_chrome/chrome_colors.html @@ -62,6 +62,9 @@ customize-chrome-color { --customize-chrome-color-border-radius: 12px; + --customize-chrome-color-check-mark-end: -4px; + --customize-chrome-color-check-mark-size: 20px; + --customize-chrome-color-check-mark-top: -6px; padding: 0; } @@ -75,13 +78,15 @@

$i18n{chromeColors}

+ foreground-color="[[customColor_.foreground]]" + checked="[[isCustomColorSelected_]]">
$i18n{chromeColors} id="defaultColor" class="tile" title="$i18n{defaultColorName}" - aria-label="$i18n{defaultColorName}" + aria-label$="$i18n{defaultColorName}" + aria-checked$="[[isDefaultColorSelected_]]" tabindex="0" on-click="onDefaultColorClick_" background-color="[[defaultColor_.background]]" - foreground-color="[[defaultColor_.foreground]]"> + foreground-color="[[defaultColor_.foreground]]" + checked="[[isDefaultColorSelected_]]"> diff --git a/chrome/browser/resources/side_panel/customize_chrome/chrome_colors.ts b/chrome/browser/resources/side_panel/customize_chrome/chrome_colors.ts index 085201c7acc94..176d91e229ad5 100644 --- a/chrome/browser/resources/side_panel/customize_chrome/chrome_colors.ts +++ b/chrome/browser/resources/side_panel/customize_chrome/chrome_colors.ts @@ -9,9 +9,11 @@ import './color.js'; import {hexColorToSkColor, skColorToRgba} from 'chrome://resources/js/color_utils.js'; import {FocusOutlineManager} from 'chrome://resources/js/focus_outline_manager.js'; +import {SkColor} from 'chrome://resources/mojo/skia/public/mojom/skcolor.mojom-webui.js'; import {DomRepeatEvent, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {getTemplate} from './chrome_colors.html.js'; +import {ColorElement} from './color.js'; import {Color, ColorType, DARK_DEFAULT_COLOR, LIGHT_DEFAULT_COLOR, SelectedColor} from './color_utils.js'; import {ChromeColor, CustomizeChromePageHandlerInterface, Theme} from './customize_chrome.mojom-webui.js'; import {CustomizeChromeApiProxy} from './customize_chrome_api_proxy.js'; @@ -21,7 +23,9 @@ export interface ChromeColorsElement { backButton: HTMLElement, colorPicker: HTMLInputElement, colorPickerIcon: HTMLElement, - defaultColor: HTMLElement, + defaultColor: ColorElement, + customColor: ColorElement, + customColorContainer: HTMLElement, }; } @@ -46,6 +50,10 @@ export class ChromeColorsElement extends PolymerElement { type: Object, computed: 'computeSelectedColor_(theme_, colors_)', }, + isDefaultColorSelected_: { + type: Object, + computed: 'computeIsDefaultColorSelected_(selectedColor_)', + }, isCustomColorSelected_: { type: Object, computed: 'computeIsCustomColorSelected_(selectedColor_)', @@ -100,6 +108,10 @@ export class ChromeColorsElement extends PolymerElement { this.setThemeListenerId_!); } + private computeIsDefaultColorSelected_(): boolean { + return this.selectedColor_.type === ColorType.DEFAULT; + } + private computeIsCustomColorSelected_(): boolean { return this.selectedColor_.type === ColorType.CUSTOM; } @@ -128,6 +140,11 @@ export class ChromeColorsElement extends PolymerElement { LIGHT_DEFAULT_COLOR; } + private isChromeColorSelected_(color: SkColor): boolean { + return this.selectedColor_.type === ColorType.CHROME && + this.selectedColor_.chromeColor!.value === color.value; + } + private onBackClick_() { this.dispatchEvent(new Event('back-click')); } diff --git a/chrome/browser/resources/side_panel/customize_chrome/color.html b/chrome/browser/resources/side_panel/customize_chrome/color.html index e39a2327e5ec5..c538a4a5470be 100644 --- a/chrome/browser/resources/side_panel/customize_chrome/color.html +++ b/chrome/browser/resources/side_panel/customize_chrome/color.html @@ -1,6 +1,9 @@