Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
review commit 3
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed Sep 13, 2017
1 parent 1c51823 commit e54ce52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions app/common/lib/bookmarkToolbarUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const padding = parseInt(globalStyles.spacing.bookmarksItemPadding, 10) * 2
const itemMargin = parseInt(globalStyles.spacing.bookmarksItemMargin, 10)
const toolbarPadding = parseInt(globalStyles.spacing.bookmarksToolbarPadding)
const overflowButtonWidth = parseInt(globalStyles.spacing.bookmarksToolbarOverflowButtonWidth, 10)
const chevronMargin = parseInt(globalStyles.spacing.bookmarksItemChevronMargin)
const chevronFontSize = parseInt(globalStyles.spacing.bookmarksItemChevronFontSize)
const chevronWidth = chevronMargin + chevronFontSize

const getBookmarkKeys = (width, bookmarks) => {
if (bookmarks == null) {
Expand All @@ -41,10 +44,11 @@ const getBookmarkKeys = (width, bookmarks) => {
let i = 0
for (let item of bookmarks) {
let iconWidth
const isFolder = bookmarkFoldersUtil.isFolder(item)

if (onlyText) {
iconWidth = 0
} else if (textAndFavicon || bookmarkFoldersUtil.isFolder(item)) {
} else if (textAndFavicon || isFolder) {
iconWidth = iconSize + itemMargin
} else if (onlyFavicon) {
iconWidth = iconSize
Expand All @@ -59,11 +63,15 @@ const getBookmarkKeys = (width, bookmarks) => {
} else if (onlyFavicon) {
extraWidth = padding + iconWidth

if (bookmarkFoldersUtil.isFolder(item)) {
if (isFolder) {
extraWidth += item.get('width')
}
}

if (isFolder) {
extraWidth += chevronWidth
}

extraWidth = Math.min(extraWidth, maxWidth)
widthAccountedFor += extraWidth + margin

Expand Down
4 changes: 2 additions & 2 deletions test/unit/app/browser/reducers/bookmarkFoldersReducerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('bookmarkFoldersReducer unit test', function () {
windows: [
{
windowId: 1,
width: 70,
width: 80,
bookmarksToolbar: {
toolbar: [],
other: []
Expand All @@ -40,7 +40,7 @@ describe('bookmarkFoldersReducer unit test', function () {
windows: [
{
windowId: 1,
width: 70,
width: 80,
bookmarksToolbar: {
toolbar: [],
other: []
Expand Down

0 comments on commit e54ce52

Please sign in to comment.