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

Commit ffc2d9b

Browse files
committed
Make notificationBar tab-specific
Auditors: @bradleyrichter, @jonathansampson Close #6935
1 parent 15b4dbc commit ffc2d9b

File tree

8 files changed

+78
-11
lines changed

8 files changed

+78
-11
lines changed

app/renderer/components/styles/commonStyles.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,20 @@ const styles = StyleSheet.create({
174174
width: '100%',
175175
cursor: 'default',
176176
userSelect: 'none',
177-
marginTop: globalStyles.spacing.navbarMenubarMargin
177+
// if there's more than one notification per site,
178+
// ensure border is on the last only
179+
':last-child': {
180+
borderBottom: `5px solid ${globalStyles.color.notificationBottomBorderColor}`
181+
},
182+
// last-child will always be orange, but others can be gray
183+
':not(:last-child)': {
184+
borderBottom: `1px solid ${globalStyles.color.tabsToolbarBorderColor}`
185+
}
178186
},
179187
notificationBar__notificationItem: {
180-
backgroundColor: '#ffefc0',
188+
backgroundColor: globalStyles.color.notificationItemColor,
181189
boxSizing: 'border-box',
182190
borderTop: `1px solid ${globalStyles.color.tabsToolbarBorderColor}`,
183-
borderBottom: `1px solid ${globalStyles.color.tabsToolbarBorderColor}`,
184191
lineHeight: '24px',
185192
padding: '8px 20px'
186193
},

app/renderer/components/styles/global.js

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ const globalStyles = {
7575
statsBlue: '#0796fa',
7676
statsLightGray: '#999999',
7777
defaultIconBackground: '#F7F7F7',
78+
notificationItemColor: '#f1e9e5',
79+
notificationBottomBorderColor: '#ff5500',
7880
almostInvisible: 'rgba(255,255,255,0.01)',
7981
urlBarOutline: '#bbb',
8082
alphaWhite: 'rgba(255,255,255,0.8)'

app/renderer/components/tabs/tab.js

+9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const NewSessionIcon = require('./content/newSessionIcon')
1414
const PrivateIcon = require('./content/privateIcon')
1515
const TabTitle = require('./content/tabTitle')
1616
const CloseTabIcon = require('./content/closeTabIcon')
17+
const {NotificationBarCaret} = require('../../../../js/components/notificationBar')
1718

1819
// Actions
1920
const windowActions = require('../../../../js/actions/windowActions')
@@ -41,6 +42,7 @@ const throttle = require('../../../../js/lib/throttle')
4142
const {getTabBreakpoint, tabUpdateFrameRate} = require('../../lib/tabUtil')
4243
const {isWindows} = require('../../../common/lib/platformUtil')
4344
const {getCurrentWindowId} = require('../../currentWindow')
45+
const UrlUtil = require('../../../../js/lib/urlutil')
4446

4547
class Tab extends ImmutableComponent {
4648
constructor () {
@@ -303,6 +305,13 @@ class Tab extends ImmutableComponent {
303305
style={this.props.tabWidth ? { flex: `0 0 ${this.props.tabWidth}px` } : {}}
304306
onMouseEnter={this.onMouseEnter}
305307
onMouseLeave={this.onMouseLeave}>
308+
{
309+
this.props.isActive &&
310+
this.props.notificationBarActive
311+
.includes(UrlUtil.getUrlOrigin(this.props.tab.get('location')))
312+
? <NotificationBarCaret />
313+
: null
314+
}
306315
<div className={css(
307316
styles.tab,
308317
// Windows specific style

app/renderer/components/tabs/tabs.js

+1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class Tabs extends ImmutableComponent {
160160
onTabClosedWithMouse={this.onTabClosedWithMouse}
161161
tabWidth={this.props.fixTabWidth}
162162
hasTabInFullScreen={this.props.hasTabInFullScreen}
163+
notificationBarActive={this.props.notificationBarActive}
163164
totalTabs={this.props.tabs.size}
164165
partOfFullPageSet={this.props.partOfFullPageSet} />)
165166
}

app/renderer/components/tabs/tabsToolbar.js

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class TabsToolbar extends ImmutableComponent {
6868
startingFrameIndex={startingFrameIndex}
6969
partOfFullPageSet={currentTabs.size === this.props.tabsPerTabPage}
7070
fixTabWidth={this.props.fixTabWidth}
71+
notificationBarActive={this.props.notificationBarActive}
7172
/>
7273
<div className='tabsToolbarButtons'>
7374
<span data-l10n-id='menuButton'

js/components/main.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const TabPages = require('../../app/renderer/components/tabs/tabPages')
2323
const TabsToolbar = require('../../app/renderer/components/tabs/tabsToolbar')
2424
const FindBar = require('./findbar')
2525
const UpdateBar = require('./updateBar')
26-
const NotificationBar = require('./notificationBar')
26+
const {NotificationBar} = require('./notificationBar')
2727
const DownloadsBar = require('../../app/renderer/components/downloadsBar')
2828
const SiteInfo = require('./siteInfo')
2929
const BraveryPanel = require('./braveryPanel')
@@ -732,6 +732,10 @@ class Main extends ImmutableComponent {
732732

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

735+
const notifications = this.props.appState.get('notifications')
736+
const hasNotifications = notifications && notifications.size
737+
const notificationBarOrigin = notifications.map(bar => bar.get('frameOrigin'))
738+
735739
return <div id='window'
736740
className={cx({
737741
isFullScreen: activeFrame && activeFrame.get('isFullScreen'),
@@ -860,12 +864,6 @@ class Main extends ImmutableComponent {
860864
}
861865

862866
<UpdateBar updates={this.props.appState.get('updates')} />
863-
{
864-
this.props.appState.get('notifications') && this.props.appState.get('notifications').size && activeFrame
865-
? <NotificationBar notifications={this.props.appState.get('notifications')}
866-
activeFrame={activeFrame} />
867-
: null
868-
}
869867
{
870868
showBookmarksToolbar
871869
? <BookmarksToolbar
@@ -909,12 +907,18 @@ class Main extends ImmutableComponent {
909907
key='tab-bar'
910908
activeFrameKey={(activeFrame && activeFrame.get('key')) || undefined}
911909
onMenu={this.onHamburgerMenu}
910+
notificationBarActive={notificationBarOrigin}
912911
hasTabInFullScreen={
913912
sortedFrames
914913
.map((frame) => frame.get('isFullScreen'))
915914
.some(fullScreenMode => fullScreenMode === true)
916915
}
917916
/>
917+
{
918+
hasNotifications && activeFrame
919+
? <NotificationBar notifications={notifications} activeFrame={activeFrame} />
920+
: null
921+
}
918922

919923
{
920924
activeFrame && activeFrame.get('findbarShown') && !activeFrame.get('isFullScreen')

js/components/notificationBar.js

+35-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const Button = require('./button')
1515

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

1920
class NotificationItem extends ImmutableComponent {
2021
clickHandler (buttonIndex, e) {
@@ -115,6 +116,14 @@ class NotificationBar extends ImmutableComponent {
115116
}
116117
}
117118

119+
class NotificationBarCaret extends ImmutableComponent {
120+
render () {
121+
return <div className={css(styles.caretWrapper)}>
122+
<div className={css(styles.caret)} />
123+
</div>
124+
}
125+
}
126+
118127
const styles = StyleSheet.create({
119128
flexJustifyBetween: {
120129
display: 'flex',
@@ -142,7 +151,32 @@ const styles = StyleSheet.create({
142151
textDecoration: 'underline',
143152
fontSize: '13px',
144153
margin: '5px'
154+
},
155+
caretWrapper: {
156+
position: 'absolute',
157+
bottom: 0,
158+
left: 0,
159+
right: 0,
160+
zIndex: globalStyles.zindex.zindexTabs,
161+
filter: 'drop-shadow(rgba(0,0,0,0.25) 0px 0px 1px)'
162+
},
163+
caret: {
164+
position: 'relative',
165+
margin: 'auto',
166+
width: '16px',
167+
':before': {
168+
content: '""',
169+
position: 'absolute',
170+
bottom: 0,
171+
left: 0,
172+
borderBottom: `6px solid ${globalStyles.color.notificationItemColor}`,
173+
borderLeft: '8px solid transparent',
174+
borderRight: '8px solid transparent'
175+
}
145176
}
146177
})
147178

148-
module.exports = NotificationBar
179+
module.exports = {
180+
NotificationBar,
181+
NotificationBarCaret
182+
}

js/lib/urlutil.js

+9
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,15 @@ const UrlUtil = {
386386
*/
387387
isHttpOrHttps: function (url) {
388388
return url.startsWith('https://') || url.startsWith('http://')
389+
},
390+
391+
/**
392+
* Gets the origin of a given URL
393+
* @param {string} url The URL to get the origin from
394+
* @return {string} url The origin of the given URL
395+
*/
396+
getUrlOrigin: function (url) {
397+
return new window.URL(url).origin
389398
}
390399
}
391400

0 commit comments

Comments
 (0)