Commit 31d8f60d authored by Ramya Nagarajan's avatar Ramya Nagarajan Committed by Commit Bot

[NTP] Improve readability of text on custom backgrounds.

Applies a 20% black overlay on a custom background image, uses white font text,
and a white settings icon.

Bug: 850312, 851285
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Ia6cab65d08bc6e54a42b78732b42b9cd4d8dc549
Reviewed-on: https://chromium-review.googlesource.com/1098557
Commit-Queue: Ramya Nagarajan <ramyan@chromium.org>
Reviewed-by: default avatarccameron <ccameron@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568088}
parent 649d05df
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
width: 100%; width: 100%;
} }
.non-white-bg #edit-bg-gear {
background: url(../../../../ui/webui/resources/images/icon_settings_white.svg) no-repeat center;
background-size: 16px 16px;
}
#edit-bg-overlay { #edit-bg-overlay {
display: none; display: none;
height: 100%; height: 100%;
......
...@@ -180,6 +180,8 @@ var LOG_TYPE = { ...@@ -180,6 +180,8 @@ var LOG_TYPE = {
*/ */
var WHITE_BACKGROUND_COLORS = ['rgba(255,255,255,1)', 'rgba(0,0,0,0)']; var WHITE_BACKGROUND_COLORS = ['rgba(255,255,255,1)', 'rgba(0,0,0,0)'];
const CUSTOM_BACKGROUND_OVERLAY =
'linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2))';
/** /**
* Enum for keycodes. * Enum for keycodes.
...@@ -300,8 +302,13 @@ function renderTheme() { ...@@ -300,8 +302,13 @@ function renderTheme() {
updateThemeAttribution(info.attributionUrl, info.imageHorizontalAlignment); updateThemeAttribution(info.attributionUrl, info.imageHorizontalAlignment);
setCustomThemeStyle(info); setCustomThemeStyle(info);
if (info.customBackgroundConfigured) {
var imageWithOverlay =
[CUSTOM_BACKGROUND_OVERLAY, info.imageUrl].join(',').trim();
document.body.style.setProperty('background-image', imageWithOverlay);
}
$(customBackgrounds.IDS.RESTORE_DEFAULT).hidden = $(customBackgrounds.IDS.RESTORE_DEFAULT).hidden =
!(info.imageUrl && info.imageUrl.length > 0); !info.customBackgroundConfigured;
if (configData.isGooglePage) { if (configData.isGooglePage) {
$('edit-bg').hidden = $('edit-bg').hidden =
......
...@@ -11,6 +11,9 @@ RGBAColor::RGBAColor() ...@@ -11,6 +11,9 @@ RGBAColor::RGBAColor()
a(0) { a(0) {
} }
RGBAColor::RGBAColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
: r(r), g(g), b(b), a(a) {}
RGBAColor::~RGBAColor() { RGBAColor::~RGBAColor() {
} }
......
...@@ -44,6 +44,7 @@ enum ThemeBackgroundImageTiling { ...@@ -44,6 +44,7 @@ enum ThemeBackgroundImageTiling {
// The RGBA color components for the text and links of the theme. // The RGBA color components for the text and links of the theme.
struct RGBAColor { struct RGBAColor {
RGBAColor(); RGBAColor();
RGBAColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
~RGBAColor(); ~RGBAColor();
bool operator==(const RGBAColor& rhs) const; bool operator==(const RGBAColor& rhs) const;
......
...@@ -342,6 +342,11 @@ v8::Local<v8::Object> GenerateThemeBackgroundInfo( ...@@ -342,6 +342,11 @@ v8::Local<v8::Object> GenerateThemeBackgroundInfo(
if (theme_info.using_default_theme && if (theme_info.using_default_theme &&
!theme_info.custom_background_url.is_empty()) { !theme_info.custom_background_url.is_empty()) {
builder.Set("alternateLogo", true);
RGBAColor whiteTextRgba = RGBAColor{255, 255, 255, 255};
builder.Set("textColorRgba",
internal::RGBAColorToArray(isolate, whiteTextRgba));
builder.Set("customBackgroundConfigured", true);
builder.Set("imageUrl", builder.Set("imageUrl",
"url('" + theme_info.custom_background_url.spec() + "')"); "url('" + theme_info.custom_background_url.spec() + "')");
builder.Set("imageTiling", std::string(kCSSBackgroundRepeatNo)); builder.Set("imageTiling", std::string(kCSSBackgroundRepeatNo));
......
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#e8eaed" preserveAspectRatio="xMidYMid meet"><path class="gear-icon" d="M19.43 12.98c.04-.32.07-.64.07-.98s-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.3-.61-.22l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.23-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98s.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.23.09.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z"></path></svg>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment