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

Commit

Permalink
Make notificationBar tab-specific
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaraugusto committed Apr 20, 2017
1 parent 15b4dbc commit e5ecc26
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 10 deletions.
6 changes: 4 additions & 2 deletions app/renderer/components/styles/commonStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,12 @@ const styles = StyleSheet.create({
width: '100%',
cursor: 'default',
userSelect: 'none',
marginTop: globalStyles.spacing.navbarMenubarMargin
':last-child': {
borderBottom: `5px solid ${globalStyles.color.notificationBottomBorderColor}`
}
},
notificationBar__notificationItem: {
backgroundColor: '#ffefc0',
backgroundColor: globalStyles.color.notificationItemColor,
boxSizing: 'border-box',
borderTop: `1px solid ${globalStyles.color.tabsToolbarBorderColor}`,
borderBottom: `1px solid ${globalStyles.color.tabsToolbarBorderColor}`,
Expand Down
2 changes: 2 additions & 0 deletions app/renderer/components/styles/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ const globalStyles = {
statsBlue: '#0796fa',
statsLightGray: '#999999',
defaultIconBackground: '#F7F7F7',
notificationItemColor: '#f1e9e5',
notificationBottomBorderColor: '#ff5500',
almostInvisible: 'rgba(255,255,255,0.01)',
urlBarOutline: '#bbb',
alphaWhite: 'rgba(255,255,255,0.8)'
Expand Down
9 changes: 9 additions & 0 deletions app/renderer/components/tabs/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const NewSessionIcon = require('./content/newSessionIcon')
const PrivateIcon = require('./content/privateIcon')
const TabTitle = require('./content/tabTitle')
const CloseTabIcon = require('./content/closeTabIcon')
const {NotificationBarCaret} = require('../../../../js/components/notificationBar')

// Actions
const windowActions = require('../../../../js/actions/windowActions')
Expand Down Expand Up @@ -41,6 +42,7 @@ const throttle = require('../../../../js/lib/throttle')
const {getTabBreakpoint, tabUpdateFrameRate} = require('../../lib/tabUtil')
const {isWindows} = require('../../../common/lib/platformUtil')
const {getCurrentWindowId} = require('../../currentWindow')
const UrlUtil = require('../../../../js/lib/urlutil')

class Tab extends ImmutableComponent {
constructor () {
Expand Down Expand Up @@ -303,6 +305,13 @@ class Tab extends ImmutableComponent {
style={this.props.tabWidth ? { flex: `0 0 ${this.props.tabWidth}px` } : {}}
onMouseEnter={this.onMouseEnter}
onMouseLeave={this.onMouseLeave}>
{
this.props.isActive &&
this.props.notificationBarActive
.includes(UrlUtil.getUrlOrigin(this.props.tab.get('location')))
? <NotificationBarCaret />
: null
}
<div className={css(
styles.tab,
// Windows specific style
Expand Down
1 change: 1 addition & 0 deletions app/renderer/components/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class Tabs extends ImmutableComponent {
onTabClosedWithMouse={this.onTabClosedWithMouse}
tabWidth={this.props.fixTabWidth}
hasTabInFullScreen={this.props.hasTabInFullScreen}
notificationBarActive={this.props.notificationBarActive}
totalTabs={this.props.tabs.size}
partOfFullPageSet={this.props.partOfFullPageSet} />)
}
Expand Down
1 change: 1 addition & 0 deletions app/renderer/components/tabs/tabsToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class TabsToolbar extends ImmutableComponent {
startingFrameIndex={startingFrameIndex}
partOfFullPageSet={currentTabs.size === this.props.tabsPerTabPage}
fixTabWidth={this.props.fixTabWidth}
notificationBarActive={this.props.notificationBarActive}
/>
<div className='tabsToolbarButtons'>
<span data-l10n-id='menuButton'
Expand Down
18 changes: 11 additions & 7 deletions js/components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const TabPages = require('../../app/renderer/components/tabs/tabPages')
const TabsToolbar = require('../../app/renderer/components/tabs/tabsToolbar')
const FindBar = require('./findbar')
const UpdateBar = require('./updateBar')
const NotificationBar = require('./notificationBar')
const {NotificationBar} = require('./notificationBar')
const DownloadsBar = require('../../app/renderer/components/downloadsBar')
const SiteInfo = require('./siteInfo')
const BraveryPanel = require('./braveryPanel')
Expand Down Expand Up @@ -732,6 +732,10 @@ class Main extends ImmutableComponent {

const appStateSites = this.props.appState.get('sites')

const notifications = this.props.appState.get('notifications')
const hasNotifications = notifications && notifications.size
const notificationBarOrigin = notifications.map(bar => bar.get('frameOrigin'))

return <div id='window'
className={cx({
isFullScreen: activeFrame && activeFrame.get('isFullScreen'),
Expand Down Expand Up @@ -860,12 +864,6 @@ class Main extends ImmutableComponent {
}

<UpdateBar updates={this.props.appState.get('updates')} />
{
this.props.appState.get('notifications') && this.props.appState.get('notifications').size && activeFrame
? <NotificationBar notifications={this.props.appState.get('notifications')}
activeFrame={activeFrame} />
: null
}
{
showBookmarksToolbar
? <BookmarksToolbar
Expand Down Expand Up @@ -909,12 +907,18 @@ class Main extends ImmutableComponent {
key='tab-bar'
activeFrameKey={(activeFrame && activeFrame.get('key')) || undefined}
onMenu={this.onHamburgerMenu}
notificationBarActive={notificationBarOrigin}
hasTabInFullScreen={
sortedFrames
.map((frame) => frame.get('isFullScreen'))
.some(fullScreenMode => fullScreenMode === true)
}
/>
{
hasNotifications && activeFrame
? <NotificationBar notifications={notifications} activeFrame={activeFrame} />
: null
}

{
activeFrame && activeFrame.get('findbarShown') && !activeFrame.get('isFullScreen')
Expand Down
36 changes: 35 additions & 1 deletion js/components/notificationBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Button = require('./button')

const {StyleSheet, css} = require('aphrodite/no-important')
const commonStyles = require('../../app/renderer/components/styles/commonStyles')
const globalStyles = require('../../app/renderer/components/styles/global')

class NotificationItem extends ImmutableComponent {
clickHandler (buttonIndex, e) {
Expand Down Expand Up @@ -115,6 +116,14 @@ class NotificationBar extends ImmutableComponent {
}
}

class NotificationBarCaret extends ImmutableComponent {
render () {
return <div className={css(styles.caretWrapper)}>
<div className={css(styles.caret)} />
</div>
}
}

const styles = StyleSheet.create({
flexJustifyBetween: {
display: 'flex',
Expand Down Expand Up @@ -142,7 +151,32 @@ const styles = StyleSheet.create({
textDecoration: 'underline',
fontSize: '13px',
margin: '5px'
},
caretWrapper: {
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
zIndex: globalStyles.zindex.zindexTabs,
filter: 'drop-shadow(rgba(0,0,0,0.25) 0px 0px 1px)'
},
caret: {
position: 'relative',
margin: 'auto',
width: '16px',
':before': {
content: '""',
position: 'absolute',
bottom: 0,
left: 0,
borderBottom: `6px solid ${globalStyles.color.notificationItemColor}`,
borderLeft: '8px solid transparent',
borderRight: '8px solid transparent'
}
}
})

module.exports = NotificationBar
module.exports = {
NotificationBar,
NotificationBarCaret
}
9 changes: 9 additions & 0 deletions js/lib/urlutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,15 @@ const UrlUtil = {
*/
isHttpOrHttps: function (url) {
return url.startsWith('https://') || url.startsWith('http://')
},

/**
* Gets the origin of a given URL
* @param {string} url The URL to get the origin from
* @return {string} url The origin of the given URL
*/
getUrlOrigin: function (url) {
return new window.URL(url).origin
}
}

Expand Down

0 comments on commit e5ecc26

Please sign in to comment.