NTP5: Implementing two rows option for Apps:

  - Apps content now will display 2 rows of Apps when there's enough vertical space
  - App styling/spacing has been tweaked
  - Margin of some elements replaced with padding so we can use offsetHeight to dynamically calculate the fixed height of the Bottom Panel (header + footer)

This CL depends on https://codereview.chromium.org/11412214/


BUG=164023

Review URL: https://chromiumcodereview.appspot.com/11428075

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171159 0039d316-1c4b-4281-b951-d872f2087c98
parent 1c8834e3
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* found in the LICENSE file. */ * found in the LICENSE file. */
.apps-page .tile-cell { .apps-page .tile-cell {
-webkit-margin-start: 12px; -webkit-margin-start: 22px;
margin-bottom: 12px; margin-bottom: 12px;
} }
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
.apps-page .app .title { .apps-page .app .title {
color: #777; color: #777;
font-size: 0.9166em; font-size: 0.9166em;
margin-top: 2px; margin-top: 4px;
} }
.app-contents { .app-contents {
......
...@@ -578,7 +578,7 @@ cr.define('ntp', function() { ...@@ -578,7 +578,7 @@ cr.define('ntp', function() {
// The width of a cell. // The width of a cell.
cellWidth: 70, cellWidth: 70,
// The start margin of a cell (left or right according to text direction). // The start margin of a cell (left or right according to text direction).
cellMarginStart: 12, cellMarginStart: 22,
// The maximum number of Tiles to be displayed. // The maximum number of Tiles to be displayed.
maxTileCount: 20, maxTileCount: 20,
// Whether the TilePage content will be scrollable. // Whether the TilePage content will be scrollable.
......
...@@ -44,6 +44,10 @@ ...@@ -44,6 +44,10 @@
background: rgb(255, 255, 119); background: rgb(255, 255, 119);
} }
.debug #bookmark-bar-spacer {
background: rgb(255, 255, 119);
}
.debug .hide-col-0 .tile-col-0, .debug .hide-col-0 .tile-col-0,
.debug .hide-col-1 .tile-col-1, .debug .hide-col-1 .tile-col-1,
.debug .hide-col-2 .tile-col-2, .debug .hide-col-2 .tile-col-2,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#dot-list { #dot-list {
height: 15px; height: 15px;
margin: 10px 0 8px; margin: 0;
overflow: hidden; overflow: hidden;
padding: 0; padding: 0;
} }
......
...@@ -72,7 +72,7 @@ body { ...@@ -72,7 +72,7 @@ body {
#bottom-panel { #bottom-panel {
-webkit-transition: opacity 200ms; -webkit-transition: opacity 200ms;
position: absolute; position: absolute;
top: 364px; top: 300px;
visibility: hidden; visibility: hidden;
width: 100%; width: 100%;
} }
...@@ -82,7 +82,7 @@ body { ...@@ -82,7 +82,7 @@ body {
} }
#card-slider-frame { #card-slider-frame {
height: 92px; height: 100px;
overflow: hidden; overflow: hidden;
} }
...@@ -95,17 +95,21 @@ body { ...@@ -95,17 +95,21 @@ body {
#bottom-panel-header, #bottom-panel-header,
#bottom-panel-footer, #bottom-panel-footer,
#bottom-panel-toolbar { #bottom-panel-toolbar {
margin: 10px auto; margin: 0 auto;
text-align: center; text-align: center;
} }
#bottom-panel-header { #bottom-panel-header {
margin-bottom: 20px; padding: 10px 0 20px;
} }
#bottom-panel-toolbar { #bottom-panel-toolbar {
height: 18px; height: 18px;
margin-top: 8px; padding: 10px 0;
}
#bookmark-bar-spacer {
height: 48px;
} }
#promo-bubble-anchor { #promo-bubble-anchor {
......
...@@ -99,6 +99,7 @@ ...@@ -99,6 +99,7 @@
</div> </div>
</div> </div>
</div> </div>
<div id="bookmark-bar-spacer"></div>
</div> </div>
</div> </div>
<div id="promo-bubble-anchor"></div> <div id="promo-bubble-anchor"></div>
......
...@@ -37,7 +37,7 @@ cr.define('ntp', function() { ...@@ -37,7 +37,7 @@ cr.define('ntp', function() {
* @type {number} * @type {number}
* @const * @const
*/ */
var HEIGHT_FOR_BOTTOM_PANEL = 558; var HEIGHT_FOR_BOTTOM_PANEL = 531;
/** /**
* The Bottom Panel width required to show 6 cols of Tiles, which is used * The Bottom Panel width required to show 6 cols of Tiles, which is used
...@@ -75,6 +75,12 @@ cr.define('ntp', function() { ...@@ -75,6 +75,12 @@ cr.define('ntp', function() {
*/ */
var NORMAL_BOTTOM_PANEL_WIDTH = 500; var NORMAL_BOTTOM_PANEL_WIDTH = 500;
/**
* @type {number}
* @const
*/
var TILE_ROW_HEIGHT = 100;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
/** /**
...@@ -111,6 +117,27 @@ cr.define('ntp', function() { ...@@ -111,6 +117,27 @@ cr.define('ntp', function() {
*/ */
var startTime; var startTime;
/**
* The top position of the Bottom Panel.
* @type {number|undefined}
* @private
*/
var bottomPanelOffsetTop;
/**
* The height of the Bottom Panel Header, in pixels.
* @type {number|undefined}
* @private
*/
var headerHeight;
/**
* The height of the Bottom Panel Footer, in pixels.
* @type {number|undefined}
* @private
*/
var footerHeight;
/** /**
* The time in milliseconds for most transitions. This should match what's * The time in milliseconds for most transitions. This should match what's
* in new_tab.css. Unfortunately there's no better way to try to time * in new_tab.css. Unfortunately there's no better way to try to time
...@@ -713,9 +740,28 @@ cr.define('ntp', function() { ...@@ -713,9 +740,28 @@ cr.define('ntp', function() {
// Finally, dispatch the layout method to the current page. // Finally, dispatch the layout method to the current page.
var currentPage = opt_page || this.cardSlider.currentCardValue; var currentPage = opt_page || this.cardSlider.currentCardValue;
var contentHeight = TILE_ROW_HEIGHT;
if (!opt_page && currentPage.config.scrollable) {
contentHeight = viewHeight - bottomPanelOffsetTop -
headerHeight - footerHeight;
contentHeight = Math.max(TILE_ROW_HEIGHT, contentHeight);
contentHeight = Math.min(2 * TILE_ROW_HEIGHT, contentHeight);
}
this.contentHeight_ = contentHeight;
$('card-slider-frame').style.height = contentHeight + 'px';
currentPage.layout(opt_animate); currentPage.layout(opt_animate);
}, },
/**
* @return {number} The height of the Bottom Panel's content.
*/
get contentHeight() {
return this.contentHeight_;
},
/** /**
* @return {number} The width of the Bottom Panel's content. * @return {number} The width of the Bottom Panel's content.
*/ */
...@@ -768,6 +814,10 @@ cr.define('ntp', function() { ...@@ -768,6 +814,10 @@ cr.define('ntp', function() {
newTabView = new NewTabView(); newTabView = new NewTabView();
bottomPanelOffsetTop = $('bottom-panel').offsetTop;
headerHeight = $('bottom-panel-header').offsetHeight;
footerHeight = $('bottom-panel-footer').offsetHeight;
notificationContainer = getRequiredElement('notification-container'); notificationContainer = getRequiredElement('notification-container');
notificationContainer.addEventListener( notificationContainer.addEventListener(
'webkitTransitionEnd', onNotificationTransitionEnd); 'webkitTransitionEnd', onNotificationTransitionEnd);
...@@ -1074,6 +1124,10 @@ cr.define('ntp', function() { ...@@ -1074,6 +1124,10 @@ cr.define('ntp', function() {
newTabView.layout(opt_animate); newTabView.layout(opt_animate);
} }
function getContentHeight() {
return newTabView.contentHeight;
}
function getContentWidth() { function getContentWidth() {
return newTabView.contentWidth; return newTabView.contentWidth;
} }
...@@ -1081,12 +1135,14 @@ cr.define('ntp', function() { ...@@ -1081,12 +1135,14 @@ cr.define('ntp', function() {
// Return an object with all the exports // Return an object with all the exports
return { return {
APP_LAUNCH: APP_LAUNCH, APP_LAUNCH: APP_LAUNCH,
TILE_ROW_HEIGHT: TILE_ROW_HEIGHT,
appAdded: appAdded, appAdded: appAdded,
appMoved: appMoved, appMoved: appMoved,
appRemoved: appRemoved, appRemoved: appRemoved,
appsPrefChangeCallback: appsPrefChangeCallback, appsPrefChangeCallback: appsPrefChangeCallback,
getAppsCallback: getAppsCallback, getAppsCallback: getAppsCallback,
getCardSlider: getCardSlider, getCardSlider: getCardSlider,
getContentHeight: getContentHeight,
getContentWidth: getContentWidth, getContentWidth: getContentWidth,
getThumbnailUrl: getThumbnailUrl, getThumbnailUrl: getThumbnailUrl,
incrementHoveredThumbnailCount: incrementHoveredThumbnailCount, incrementHoveredThumbnailCount: incrementHoveredThumbnailCount,
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
.tile-row { .tile-row {
-webkit-transition: opacity 200ms; -webkit-transition: opacity 200ms;
height: 92px; height: 100px;
text-align: start; text-align: start;
white-space: nowrap; white-space: nowrap;
} }
...@@ -118,11 +118,6 @@ ...@@ -118,11 +118,6 @@
Scroll Bars Scroll Bars
----------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
.tile-page-content {
/* TODO(pedrosimonetti): Remove this when fixing the Apps page height. */
height: 92px;
}
.scrollable { .scrollable {
overflow-y: auto; overflow-y: auto;
} }
......
...@@ -15,12 +15,6 @@ cr.define('ntp', function() { ...@@ -15,12 +15,6 @@ cr.define('ntp', function() {
*/ */
var MAX_SCROLL_SHADOW_GAP = 16; var MAX_SCROLL_SHADOW_GAP = 16;
/**
* @type {number}
* @const
*/
var TILE_ROW_HEIGHT = 92;
/** /**
* @type {number} * @type {number}
* @const * @const
...@@ -576,7 +570,7 @@ cr.define('ntp', function() { ...@@ -576,7 +570,7 @@ cr.define('ntp', function() {
if (isRTL()) if (isRTL())
col = colCount - col - 1; col = colCount - col - 1;
var config = this.config; var config = this.config;
var top = TILE_ROW_HEIGHT * row; var top = ntp.TILE_ROW_HEIGHT * row;
var left = col * (config.cellWidth + config.cellMarginStart); var left = col * (config.cellWidth + config.cellMarginStart);
return {top: top, left: left}; return {top: top, left: left};
}, },
...@@ -690,6 +684,9 @@ cr.define('ntp', function() { ...@@ -690,6 +684,9 @@ cr.define('ntp', function() {
* @param {boolean=} opt_animate Whether the layout be animated. * @param {boolean=} opt_animate Whether the layout be animated.
*/ */
layout: function(opt_animate) { layout: function(opt_animate) {
var contentHeight = ntp.getContentHeight();
this.content_.style.height = contentHeight + 'px';
var contentWidth = ntp.getContentWidth(); var contentWidth = ntp.getContentWidth();
var colCount = this.getColCountForWidth_(contentWidth); var colCount = this.getColCountForWidth_(contentWidth);
var lastColCount = this.colCount_; var lastColCount = this.colCount_;
......
...@@ -12,7 +12,7 @@ namespace search { ...@@ -12,7 +12,7 @@ namespace search {
// should be visible. This value is calculated from the // should be visible. This value is calculated from the
// chrome/browser/resources/ntp_search/ tile_page.js // chrome/browser/resources/ntp_search/ tile_page.js
// HEIGHT_FOR_BOTTOM_PANEL constant. // HEIGHT_FOR_BOTTOM_PANEL constant.
static const int kMinContentHeightForBottomBookmarkBar = 558; static const int kMinContentHeightForBottomBookmarkBar = 531;
// The maximum width of the detached bookmark bar. // The maximum width of the detached bookmark bar.
static const int kMaxWidthForBottomBookmarkBar = 720; static const int kMaxWidthForBottomBookmarkBar = 720;
......
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