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

Commit

Permalink
Merge pull request #4837 from maaz93/magic-number
Browse files Browse the repository at this point in the history
Fixing magic number bug in downloads bar
  • Loading branch information
bbondy authored Oct 17, 2016
2 parents 8b6606f + 1a1b658 commit 75b91b4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
7 changes: 5 additions & 2 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,11 @@ class Frame extends ImmutableComponent {
e.stopPropagation()
})
this.webview.addEventListener('update-target-url', (e) => {
const downloadsBarHeight = 50
let nearBottom = e.y > (window.innerHeight - 150 - downloadsBarHeight) // todo: magic number
if (!this.root) {
this.root = window.getComputedStyle(document.querySelector(':root'))
this.downloadsBarHeight = Number.parseInt(this.root.getPropertyValue('--downloads-bar-height'), 10)
}
let nearBottom = e.y > (window.innerHeight - 150 - this.downloadsBarHeight)
let mouseOnLeft = e.x < (window.innerWidth / 2)
let showOnRight = nearBottom && mouseOnLeft
windowActions.setLinkHoverPreview(e.url, showOnRight)
Expand Down
11 changes: 7 additions & 4 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ const addFolderMenuItem = (closestDestinationDetail, isParent) => {
}
}

const getDownloadsBarHeight = () => {
const root = window.getComputedStyle(document.querySelector(':root'))
return Number.parseInt(root.getPropertyValue('--downloads-bar-height'), 10)
}

function tabPageTemplateInit (framePropsList) {
return [{
label: locale.translation('unmuteTabs'),
Expand Down Expand Up @@ -1202,8 +1207,7 @@ function onShowBookmarkFolderMenu (bookmarks, bookmark, activeFrame, e) {
*/
function onShowUsernameMenu (usernames, origin, action, boundingRect,
topOffset) {
// TODO: magic number
const downloadsBarOffset = windowStore.getState().getIn(['ui', 'downloadsToolbar', 'isVisible']) ? 50 : 0
const downloadsBarOffset = windowStore.getState().getIn(['ui', 'downloadsToolbar', 'isVisible']) ? getDownloadsBarHeight() : 0
const menuTemplate = usernameTemplateInit(usernames, origin, action)
windowActions.setContextMenuDetail(Immutable.fromJS({
left: boundingRect.left,
Expand All @@ -1214,8 +1218,7 @@ function onShowUsernameMenu (usernames, origin, action, boundingRect,

function onShowAutofillMenu (suggestions, boundingRect, frame) {
const menuTemplate = autofillTemplateInit(suggestions, frame)
// TODO: magic number
const downloadsBarOffset = windowStore.getState().getIn(['ui', 'downloadsToolbar', 'isVisible']) ? 50 : 0
const downloadsBarOffset = windowStore.getState().getIn(['ui', 'downloadsToolbar', 'isVisible']) ? getDownloadsBarHeight() : 0
const offset = {
x: (window.innerWidth - boundingRect.clientWidth),
y: (window.innerHeight - boundingRect.clientHeight)
Expand Down
2 changes: 1 addition & 1 deletion less/downloadBar.less
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
border-top: 1px solid #888;
color: black;
display: flex;
height: 50px;
height: @downloadsBarHeight;
padding: 5px var(--download-bar-padding);
width: 100%;
z-index: @zindexDownloadsBar;
Expand Down
2 changes: 2 additions & 0 deletions less/variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
@switchNubShadow: 1px 1px 5px -2px black;

@navbarHeight: 36px;
@downloadsBarHeight: 50px;
@tabsToolbarHeight: 23px;
@tabPagesHeight: 12px;
@bookmarksToolbarHeight: 24px;
Expand Down Expand Up @@ -144,4 +145,5 @@

:root {
--navbar-height: @navbarHeight;
--downloads-bar-height: @downloadsBarHeight;
}

0 comments on commit 75b91b4

Please sign in to comment.