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 #7685 from cezaraugusto/tabsbar/7665
Browse files Browse the repository at this point in the history
Adjust min threshold for play button
  • Loading branch information
bbondy committed Mar 15, 2017
2 parents 7ae16d4 + e27916a commit 131fce7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 31 deletions.
1 change: 1 addition & 0 deletions app/renderer/components/styles/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const globalStyles = {
breakpointSmallWin32: '650px',
breakpointTinyWin32: '500px',
tab: {
large: '120px',
largeMedium: '83px',
medium: '66px',
mediumSmall: '53px',
Expand Down
6 changes: 1 addition & 5 deletions app/renderer/components/styles/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ const styles = StyleSheet.create({
narrowViewPlayIndicator: {
borderWidth: '2px 1px 0',
borderStyle: 'solid',
borderColor: 'lightskyblue transparent transparent'
},

activeTabNarrowViewPlayIndicator: {
borderColor: `lightskyblue ${globalStyles.color.chromeControlsBackground} ${globalStyles.color.chromeControlsBackground}`
borderColor: `lightskyblue ${globalStyles.color.chromeControlsBackground} transparent transparent`
},

tabNarrowestView: {
Expand Down
14 changes: 7 additions & 7 deletions app/renderer/components/tabContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ class AudioTabIcon extends ImmutableComponent {
return this.props.tabProps.get('audioPlaybackActive') || this.props.tabProps.get('audioMuted')
}

get mediumView () {
const sizes = ['large', 'largeMedium']
return sizes.includes(this.props.tabProps.get('breakpoint'))
}

get narrowView () {
const sizes = ['medium', 'mediumSmall', 'small', 'extraSmall', 'smallest']
return sizes.includes(this.props.tabProps.get('breakpoint'))
Expand All @@ -116,7 +121,7 @@ class AudioTabIcon extends ImmutableComponent {
}

render () {
return this.pageCanPlayAudio && !this.narrowView
return this.pageCanPlayAudio && !this.mediumView && !this.narrowView
? <TabIcon className={css(styles.icon, styles.audioIcon)} symbol={this.audioIcon} onClick={this.props.onClick} />
: null
}
Expand Down Expand Up @@ -186,18 +191,13 @@ class TabTitle extends ImmutableComponent {
return !!this.props.tabProps.get('pinnedLocation')
}

get pageCanPlayAudio () {
return this.props.tabProps.get('audioPlaybackActive') || this.props.tabProps.get('audioMuted')
}

get hoveredOnNarrowView () {
const sizes = ['mediumSmall', 'small', 'extraSmall', 'smallest']
return this.props.tabProps.get('hoverState') && sizes.includes(this.props.tabProps.get('breakpoint'))
}

get shouldHideTitle () {
return (this.props.tabProps.get('breakpoint') === 'largeMedium' && this.pageCanPlayAudio && this.locationHasSecondaryIcon) ||
(this.props.tabProps.get('breakpoint') === 'mediumSmall' && this.locationHasSecondaryIcon) ||
return (this.props.tabProps.get('breakpoint') === 'mediumSmall' && this.locationHasSecondaryIcon) ||
this.props.tabProps.get('breakpoint') === 'extraSmall' || this.props.tabProps.get('breakpoint') === 'smallest' ||
this.hoveredOnNarrowView
}
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/lib/tabUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const styles = require('../components/styles/global')
* @returns {String} The matching breakpoint.
*/
module.exports.getTabBreakpoint = (tabWidth) => {
const sizes = ['largeMedium', 'medium', 'mediumSmall', 'small', 'extraSmall', 'smallest']
const sizes = ['large', 'largeMedium', 'medium', 'mediumSmall', 'small', 'extraSmall', 'smallest']
let currentSize

sizes.map(size => {
Expand Down
9 changes: 7 additions & 2 deletions js/components/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ class Tab extends ImmutableComponent {
return tab && !this.isPinned ? tab.getBoundingClientRect().width : null
}

get mediumView () {
const sizes = ['large', 'largeMedium']
return sizes.includes(this.props.tab.get('breakpoint'))
}

get narrowView () {
const sizes = ['medium', 'mediumSmall', 'small', 'extraSmall', 'smallest']
return sizes.includes(this.props.tab.get('breakpoint'))
Expand Down Expand Up @@ -224,6 +229,7 @@ class Tab extends ImmutableComponent {
}

render () {
const playIndicatorBreakpoint = this.mediumView || this.narrowView
const perPageStyles = StyleSheet.create({
themeColor: {
color: this.themeColor ? getTextColorForBackground(this.themeColor) : 'inherit',
Expand Down Expand Up @@ -254,8 +260,7 @@ class Tab extends ImmutableComponent {
this.props.isActive && styles.active,
this.props.tab.get('isPrivate') && styles.private,
this.props.isActive && this.props.tab.get('isPrivate') && styles.activePrivateTab,
this.narrowView && this.canPlayAudio && styles.narrowViewPlayIndicator,
this.props.isActive && this.narrowView && this.canPlayAudio && styles.activeTabNarrowViewPlayIndicator,
playIndicatorBreakpoint && this.canPlayAudio && styles.narrowViewPlayIndicator,
this.props.isActive && this.themeColor && perPageStyles.themeColor,
!this.isPinned && this.narrowView && styles.tabNarrowView,
!this.isPinned && this.narrowestView && styles.tabNarrowestView,
Expand Down
16 changes: 0 additions & 16 deletions test/unit/app/renderer/tabContentTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,22 +305,6 @@ describe('tabContent components', function () {
)
assert.notEqual(wrapper.text(), pageTitle1)
})
it('should not show text if size is largeMedium and location has audio and a secondary icon', function () {
const wrapper = shallow(
<TabTitle
tabProps={
Immutable.Map({
location: url1,
title: pageTitle1,
breakpoint: 'largeMedium',
audioPlaybackActive: true,
isPrivate: true
})}
pageTitle={pageTitle1}
/>
)
assert.notEqual(wrapper.text(), pageTitle1)
})
it('should not show text if size is mediumSmall and location has a secondary icon', function () {
const wrapper = shallow(
<TabTitle
Expand Down

0 comments on commit 131fce7

Please sign in to comment.