Commit 0b8830e5 authored by Esmael El-Moslimany's avatar Esmael El-Moslimany Committed by Commit Bot

WebUI NTP: style the middle-slot promo to match modules

The restyle to match the modules is only enabled when the ntp-modules
feature flag is enabled.

Bug: 1110067
Change-Id: Ib394df60498bca8845b3cbd49bd49cdedd72c2c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2429230
Commit-Queue: Esmael Elmoslimany <aee@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810673}
parent 1de922ba
...@@ -80,6 +80,15 @@ ...@@ -80,6 +80,15 @@
width: var(--ntp-search-box-width); width: var(--ntp-search-box-width);
} }
:host([modules-enabled_]) ntp-middle-slot-promo {
width: var(--ntp-search-box-width);
}
:host(:not([modules-enabled_])) ntp-middle-slot-promo {
bottom: 16px;
position: fixed;
}
ntp-realbox { ntp-realbox {
visibility: hidden; visibility: hidden;
} }
...@@ -94,11 +103,7 @@ ...@@ -94,11 +103,7 @@
--tile-hover-color: rgba(255, 255, 255, .1); --tile-hover-color: rgba(255, 255, 255, .1);
} }
ntp-middle-slot-promo { ntp-middle-slot-promo + ntp-module-wrapper,
bottom: 16px;
position: fixed;
}
ntp-module-wrapper + ntp-module-wrapper { ntp-module-wrapper + ntp-module-wrapper {
margin-top: 24px; margin-top: 24px;
} }
......
...@@ -191,6 +191,13 @@ class AppElement extends PolymerElement { ...@@ -191,6 +191,13 @@ class AppElement extends PolymerElement {
computed: 'computeRealboxShown_(theme_)', computed: 'computeRealboxShown_(theme_)',
}, },
/** @private */
modulesEnabled_: {
type: Boolean,
value: () => loadTimeData.getBoolean('modulesEnabled'),
reflectToAttribute: true,
},
/** /**
* If true, renders additional elements that were not deemed crucial to * If true, renders additional elements that were not deemed crucial to
* to show up immediately on load. * to show up immediately on load.
...@@ -732,6 +739,11 @@ class AppElement extends PolymerElement { ...@@ -732,6 +739,11 @@ class AppElement extends PolymerElement {
/** @private */ /** @private */
onMiddleSlotPromoLoaded_() { onMiddleSlotPromoLoaded_() {
// The promo is always shown when modules are enabled since it will not
// overlap with other elements.
if (this.modulesEnabled_) {
return;
}
const onResize = () => { const onResize = () => {
const promoElement = $$(this, 'ntp-middle-slot-promo'); const promoElement = $$(this, 'ntp-middle-slot-promo');
const hidePromo = this.$.mostVisited.getBoundingClientRect().bottom >= const hidePromo = this.$.mostVisited.getBoundingClientRect().bottom >=
......
<style include="cr-hidden-style"> <style include="cr-hidden-style">
:host { :host {
font-size: 12px; font-size: 12px;
max-width: 537px;
white-space: pre; white-space: pre;
} }
:host([modules-enabled_]):host {
font-size: 13px;
}
:host(:not([modules-enabled_])):host {
max-width: 537px;
}
#container { #container {
align-items: center; align-items: center;
background-color: var(--cr-card-background-color); background-color: var(--ntp-background-override-color);
border: 1px solid var(--ntp-border-color); border: solid var(--ntp-border-color) 1px;
border-radius: 16px; border-radius: 24px;
box-sizing: border-box; box-sizing: border-box;
color: var(--cr-primary-text-color); color: var(--cr-primary-text-color);
display: flex; display: flex;
flex-direction: row; flex-direction: row;
height: 32px; height: 30px;
padding: 0 16px; justify-content: center;
padding-inline-end: 8px;
padding-inline-start: 8px;
}
:host([modules-enabled_]) #container {
border-radius: 5px;
height: 48px;
} }
a { a {
...@@ -30,9 +44,12 @@ ...@@ -30,9 +44,12 @@
outline: none; outline: none;
} }
.image { * + .image {
margin-inline-end: 8px; margin-inline-start: 8px;
margin-inline-start: -12px; }
.image + * {
margin-inline-start: 8px;
} }
img { img {
...@@ -42,6 +59,13 @@ ...@@ -42,6 +59,13 @@
width: 24px; width: 24px;
} }
:host([modules-enabled_]) img {
background-color: var(--google-grey-refresh-100);
height: 22px;
padding: 5px;
width: 22px;
}
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
img { img {
background-color: var(--google-grey-200); background-color: var(--google-grey-200);
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'chrome://resources/cr_elements/hidden_style_css.m.js'; import 'chrome://resources/cr_elements/hidden_style_css.m.js';
import 'chrome://resources/cr_elements/shared_vars_css.m.js'; import 'chrome://resources/cr_elements/shared_vars_css.m.js';
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {BrowserProxy} from './browser_proxy.js'; import {BrowserProxy} from './browser_proxy.js';
...@@ -23,6 +24,17 @@ class MiddleSlotPromoElement extends PolymerElement { ...@@ -23,6 +24,17 @@ class MiddleSlotPromoElement extends PolymerElement {
return html`{__html_template__}`; return html`{__html_template__}`;
} }
static get properties() {
return {
/** @private */
modulesEnabled_: {
type: Boolean,
value: () => loadTimeData.getBoolean('modulesEnabled'),
reflectToAttribute: true,
},
};
}
constructor() { constructor() {
super(); super();
/** @private {newTabPage.mojom.PageHandlerRemote} */ /** @private {newTabPage.mojom.PageHandlerRemote} */
......
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