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

Commit

Permalink
Add support for dynamic breakpoint for tabs
Browse files Browse the repository at this point in the history
Auditors: @bsclifton
Fix #9779
  • Loading branch information
cezaraugusto committed Jul 26, 2017
1 parent 38f4618 commit fe8c036
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/common/state/tabContentState.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const tabContentState = {
isActive &&
// Larger sizes still have a relative closeIcon
// We don't resize closeIcon as we do with favicon so don't show it (smallest)
!hasBreakpoint(frame.get('breakpoint'), ['default', 'large', 'smallest'])
!hasBreakpoint(frame.get('breakpoint'), ['dynamic', 'default', 'large', 'smallest'])
)
},

Expand All @@ -161,7 +161,7 @@ const tabContentState = {
}

return frameStateUtil.getTabHoverState(state, frameKey) &&
hasBreakpoint(frame.get('breakpoint'), ['default', 'large'])
hasBreakpoint(frame.get('breakpoint'), ['dynamic', 'default', 'large'])
},

/**
Expand Down
1 change: 1 addition & 0 deletions app/renderer/components/styles/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const globalStyles = {
breakpointTinyWin32: '500px',
breakpointNewPrivateTab: '890px',
tab: {
dynamic: '99999px', // add a large number as new spec will set tab width based on window size
default: '184px', // match tabArea max-width
large: '120px',
largeMedium: '83px',
Expand Down
6 changes: 3 additions & 3 deletions app/renderer/lib/tabUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

const styles = require('../components/styles/global')
const tabBreakpoint = require('../components/styles/global').breakpoint.tab

/**
* Get tab's breakpoint name for current tab size.
* @param {Number} tabWidth current tab size
* @returns {String} The matching breakpoint.
*/
module.exports.getTabBreakpoint = (tabWidth) => {
const sizes = ['default', 'large', 'largeMedium', 'medium', 'mediumSmall', 'small', 'extraSmall', 'smallest']
const sizes = Object.keys(tabBreakpoint)
let currentSize

sizes.map(size => {
if (tabWidth <= Number.parseInt(styles.breakpoint.tab[size], 10)) {
if (tabWidth <= Number.parseInt(tabBreakpoint[size], 10)) {
currentSize = size
return false
}
Expand Down

0 comments on commit fe8c036

Please sign in to comment.