diff --git a/app/renderer/components/styles/commonStyles.js b/app/renderer/components/styles/commonStyles.js index 401d3324cb7..0e8cb3fff71 100644 --- a/app/renderer/components/styles/commonStyles.js +++ b/app/renderer/components/styles/commonStyles.js @@ -161,7 +161,7 @@ const styles = StyleSheet.create({ notificationBar__notificationItem: { backgroundColor: globalStyles.color.notificationItemColor, boxSizing: 'border-box', - borderTop: `1px solid ${globalStyles.color.tabsToolbarBorderColor}`, + boxShadow: `0 -1px 0 ${globalStyles.color.tabsToolbarBorderColor}`, lineHeight: '24px', padding: '8px 20px' }, diff --git a/app/renderer/components/styles/global.js b/app/renderer/components/styles/global.js index 886752485f4..b87159a4002 100644 --- a/app/renderer/components/styles/global.js +++ b/app/renderer/components/styles/global.js @@ -162,7 +162,7 @@ const globalStyles = { aboutPageDetailsPageWidth: '704px', aboutPageSectionPadding: '24px', aboutPageSectionMargin: '10px', - defaultTabPadding: '0 4px', + defaultTabMargin: '6px', defaultIconPadding: '2px', iconSize: '16px', sessionIconSize: '15px', @@ -214,6 +214,7 @@ const globalStyles = { zindexWindowIsPreview: '1100', zindexDownloadsBar: '1000', zindexTabs: '1000', + zindexTabsAudioTopBorder: '10001', zindexTabsThumbnail: '1100', zindexTabsDragIndicator: '1100', zindexNavigationBar: '2000', diff --git a/app/renderer/components/tabs/tab.js b/app/renderer/components/tabs/tab.js index f4069e5883e..277729a2bbb 100644 --- a/app/renderer/components/tabs/tab.js +++ b/app/renderer/components/tabs/tab.js @@ -3,7 +3,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ const React = require('react') -const {StyleSheet, css} = require('aphrodite') +const {StyleSheet, css} = require('aphrodite/no-important') const Immutable = require('immutable') // Components @@ -23,7 +23,8 @@ const windowActions = require('../../../../js/actions/windowActions') // Store const windowStore = require('../../../../js/stores/windowStore') -// State +// State helpers +const privateState = require('../../../common/state/tabContentState/privateState') const audioState = require('../../../common/state/tabContentState/audioState') const tabUIState = require('../../../common/state/tabUIState') const tabState = require('../../../common/state/tabState') @@ -33,6 +34,7 @@ const dragTypes = require('../../../../js/constants/dragTypes') // Styles const globalStyles = require('../styles/global') +const {theme} = require('../styles/theme') // Utils const cx = require('../../../../js/lib/classSet') @@ -200,10 +202,10 @@ class Tab extends React.Component { this.tabNode.addEventListener('auxclick', this.onAuxClick.bind(this)) } - componentDidUpdate () { + componentDidUpdate (prevProps) { // if a tab was just pinned, unobserve its intersection // this gives us some more performance boost - if (this.props.isPinnedTab) { + if (prevProps.isPinnedTab !== this.props.isPinnedTab) { this.observer.unobserve(this.tabSentinel) } } @@ -234,24 +236,33 @@ class Tab extends React.Component { mergeProps (state, ownProps) { const currentWindow = state.get('currentWindow') const frame = frameStateUtil.getFrameByKey(currentWindow, ownProps.frameKey) || Immutable.Map() + const frameKey = ownProps.frameKey + const tabId = frame.get('tabId', tabState.TAB_ID_NONE) + const isPinned = tabState.isTabPinned(state, tabId) + + // TODO: this should have its own method const notifications = state.get('notifications') const notificationOrigins = notifications ? notifications.map(bar => bar.get('frameOrigin')) : false const notificationBarActive = frame.get('location') && notificationOrigins && notificationOrigins.includes(UrlUtil.getUrlOrigin(frame.get('location'))) - const tabId = frame.get('tabId', tabState.TAB_ID_NONE) const props = {} // used in renderer props.frameKey = ownProps.frameKey props.isPrivateTab = frame.get('isPrivate') props.notificationBarActive = notificationBarActive + + // used in renderer + props.frameKey = frameKey + props.isPinnedTab = isPinned + props.isPrivateTab = privateState.isPrivateTab(currentWindow, frameKey) props.isActive = frameStateUtil.isFrameKeyActive(currentWindow, props.frameKey) props.tabWidth = currentWindow.getIn(['ui', 'tabs', 'fixTabWidth']) - props.isPinnedTab = tabState.isTabPinned(state, tabId) - props.canPlayAudio = audioState.canPlayAudio(currentWindow, props.frameKey) - props.themeColor = tabUIState.getThemeColor(currentWindow, props.frameKey) + props.themeColor = tabUIState.getThemeColor(currentWindow, frameKey) props.title = frame.get('title') props.partOfFullPageSet = ownProps.partOfFullPageSet + props.showAudioTopBorder = audioState.showAudioTopBorder(currentWindow, frameKey, isPinned) + props.centralizeTabIcons = tabUIState.centralizeTabIcons(currentWindow, frameKey, isPinned) // used in other functions props.totalTabs = state.get('tabs').size @@ -265,7 +276,7 @@ class Tab extends React.Component { render () { // we don't want themeColor if tab is private const perPageStyles = !this.props.isPrivateTab && StyleSheet.create({ - themeColor: { + tab_themeColor: { color: this.props.themeColor ? getTextColorForBackground(this.props.themeColor) : 'inherit', background: this.props.themeColor ? this.props.themeColor : 'inherit', ':hover': { @@ -301,13 +312,15 @@ class Tab extends React.Component { className={css( styles.tab, // Windows specific style - isWindows && styles.tabForWindows, - this.props.isPinnedTab && styles.isPinned, - this.props.isActive && styles.active, - this.props.isActive && this.props.themeColor && perPageStyles.themeColor, + isWindows && styles.tab_forWindows, + this.props.isPinnedTab && styles.tab_pinned, + this.props.isActive && styles.tab_active, + this.props.showAudioTopBorder && styles.tab_audioTopBorder, + this.props.isActive && this.props.themeColor && perPageStyles.tab_themeColor, // Private color should override themeColor - this.props.isPrivateTab && styles.private, - this.props.isActive && this.props.isPrivateTab && styles.activePrivateTab + this.props.isPrivateTab && styles.tab_private, + this.props.isActive && this.props.isPrivateTab && styles.tab_active_private, + this.props.centralizeTabIcons && styles.tab__content_centered )} data-test-id='tab' data-frame-key={this.props.frameKey} @@ -323,7 +336,10 @@ class Tab extends React.Component { ref={(node) => { this.tabSentinel = node }} className={css(styles.tab__sentinel)} /> -