Skip to content

Commit b5666e9

Browse files
Kateryna ProkopenkoDevtools-frontend LUCI CQ
authored andcommitted
Add color shift warning to format picker menu and mark affected items
Screenshot: http://b/441687854#attachment69995235 Fixed: 441687854 Change-Id: Ic2cf9d277e2cd3f0feaf8179bac0d8d6c1bc3e3e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7025372 Reviewed-by: Philip Pfaffe <[email protected]> Commit-Queue: Kateryna Prokopenko <[email protected]>
1 parent 710f5de commit b5666e9

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

front_end/ui/legacy/components/color_picker/FormatPickerContextMenu.ts

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44

55
import * as Common from '../../../../core/common/common.js';
66
import * as i18n from '../../../../core/i18n/i18n.js';
7-
import * as IconButton from '../../../components/icon_button/icon_button.js';
87
import * as UI from '../../legacy.js';
98

109
const UIStrings = {
1110
/**
12-
* @description Tooltip text describing that a color was clipped after conversion to match the target gamut
13-
* @example {rgb(255 255 255)} PH1
11+
* @description Menu warning that some color will be clipped after conversion to match the target gamut
1412
*/
15-
colorClippedTooltipText: 'This color was clipped to match the format\'s gamut. The actual result was {PH1}',
13+
colorShiftWarning: '⚠️ Conversion to a narrow gamut will cause color shifts',
1614
} as const;
1715
const str_ = i18n.i18n.registerUIStrings('ui/legacy/components/color_picker/FormatPickerContextMenu.ts', UIStrings);
1816
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
@@ -56,10 +54,13 @@ export class FormatPickerContextMenu {
5654
Common.Color.Format.XYZ_D65,
5755
];
5856
const menu = new UI.ContextMenu.ContextMenu(e, {onSoftMenuClosed: () => resolve()});
57+
const disclamerSection = menu.section('disclaimer');
5958
const legacySection = menu.section('legacy');
6059
const wideSection = menu.section('wide');
6160
const colorFunctionSection = menu.section('color-function').appendSubMenuItem('color()', false, 'color').section();
6261

62+
disclamerSection.appendItem(i18nString(UIStrings.colorShiftWarning), () => {}, {disabled: true});
63+
6364
if (!(this.#color instanceof Common.Color.Nickname)) {
6465
const nickname = this.#color.asLegacyColor().nickname();
6566
if (nickname) {
@@ -102,27 +103,13 @@ export class FormatPickerContextMenu {
102103
return;
103104
}
104105
}
105-
const label = newColor.asString();
106+
const label = newColor.isGamutClipped() ? newColor.asString() + ' ⚠️' : newColor.asString();
106107
if (!label) {
107108
return;
108109
}
109-
let icon = undefined;
110-
if (newColor.isGamutClipped()) {
111-
icon = new IconButton.Icon.Icon();
112-
icon.name = 'warning';
113-
icon.classList.add('medium');
114-
icon.style.marginLeft = '1px';
115-
icon.style.marginTop = '-1px';
116-
icon.style.minWidth = '16px';
117-
icon.style.minHeight = '16px';
118-
}
119-
const tooltip =
120-
icon ? i18nString(UIStrings.colorClippedTooltipText, {PH1: newColor.getAsRawString() ?? 'none'}) : undefined;
121110

122111
const handler = (): void => onSelect(newColor);
123112

124-
section.appendItem(
125-
label, handler,
126-
{additionalElement: icon, tooltip, jslogContext: newColor.isGamutClipped() ? 'color' : 'clipped-color'});
113+
section.appendItem(label, handler, {jslogContext: newColor.isGamutClipped() ? 'color' : 'clipped-color'});
127114
}
128115
}

0 commit comments

Comments
 (0)