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

Commit 64d6c15

Browse files
jonathansampsoncezaraugusto
authored andcommitted
Moves bar, adds caret per tab
1 parent 855edd1 commit 64d6c15

File tree

7 files changed

+77
-10
lines changed

7 files changed

+77
-10
lines changed

app/renderer/components/styles/global.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ const globalStyles = {
6767
statsBlue: '#0796fa',
6868
statsLightGray: '#999999',
6969
defaultIconBackground: '#F7F7F7',
70-
almostInvisible: 'rgba(255,255,255,0.01)'
70+
almostInvisible: 'rgba(255,255,255,0.01)',
71+
notificationItemColor: '#ffefc0'
7172
},
7273
radius: {
7374
borderRadius: '4px',
@@ -117,7 +118,8 @@ const globalStyles = {
117118
dialogTopOffset: '30px',
118119
paymentsMargin: '20px',
119120
modalPanelHeaderMarginBottom: '.5em',
120-
paddingHorizontal: '30px'
121+
paddingHorizontal: '30px',
122+
caretSize: '20px'
121123
},
122124
shadow: {
123125
switchShadow: 'inset 0 1px 4px rgba(0, 0, 0, 0.35)',

js/components/main.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const TabPages = require('./tabPages')
2323
const TabsToolbar = require('./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 Button = require('./button')
2929
const BrowserActionButton = require('../../app/renderer/components/browserActionButton')
@@ -936,6 +936,7 @@ class Main extends ImmutableComponent {
936936

937937
const appStateSites = this.props.appState.get('sites')
938938
const activeTabShowingMessageBox = !!(activeTab && activeTab.get('messageBoxDetail'))
939+
const notificationBarOrigin = this.props.appState.get('notifications').map(bar => bar.get('frameOrigin'))
939940

940941
return <div id='window'
941942
className={cx({
@@ -1172,12 +1173,6 @@ class Main extends ImmutableComponent {
11721173
}
11731174

11741175
<UpdateBar updates={this.props.appState.get('updates')} />
1175-
{
1176-
this.props.appState.get('notifications') && this.props.appState.get('notifications').size && activeFrame
1177-
? <NotificationBar notifications={this.props.appState.get('notifications')}
1178-
activeFrame={activeFrame} />
1179-
: null
1180-
}
11811176
{
11821177
showBookmarksToolbar
11831178
? <BookmarksToolbar
@@ -1221,12 +1216,19 @@ class Main extends ImmutableComponent {
12211216
key='tab-bar'
12221217
activeFrameKey={activeFrame && activeFrame.get('key') || undefined}
12231218
onMenu={this.onHamburgerMenu}
1219+
notificationBarActive={notificationBarOrigin}
12241220
hasTabInFullScreen={
12251221
sortedFrames
12261222
.map((frame) => frame.get('isFullScreen'))
12271223
.some(fullScreenMode => fullScreenMode === true)
12281224
}
12291225
/>
1226+
{
1227+
this.props.appState.get('notifications') && this.props.appState.get('notifications').size && activeFrame
1228+
? <NotificationBar notifications={this.props.appState.get('notifications')}
1229+
activeFrame={activeFrame} />
1230+
: null
1231+
}
12301232

12311233
{
12321234
activeFrame && activeFrame.get('findbarShown') && !activeFrame.get('isFullScreen')

js/components/notificationBar.js

+53-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const ipc = require('electron').ipcRenderer
99
const messages = require('../constants/messages')
1010
const getOrigin = require('../state/siteUtil').getOrigin
1111

12+
const {StyleSheet, css} = require('aphrodite/no-important')
13+
const globalStyles = require('../../app/renderer/components/styles/global')
14+
1215
class NotificationItem extends ImmutableComponent {
1316
clickHandler (buttonIndex, e) {
1417
const nonce = this.props.detail.get('options').get('nonce')
@@ -93,4 +96,53 @@ class NotificationBar extends ImmutableComponent {
9396
}
9497
}
9598

96-
module.exports = NotificationBar
99+
class NotificationBarCaret extends ImmutableComponent {
100+
render () {
101+
return <div className={css(styles.caretWrapper)}>
102+
<div className={css(styles.caret)} />
103+
</div>
104+
}
105+
}
106+
107+
const caret = (size, color) => `${Number.parseInt(size, 10) / 2}px solid ${color}`
108+
109+
const styles = StyleSheet.create({
110+
caretWrapper: {
111+
position: 'absolute',
112+
bottom: 0,
113+
left: 0,
114+
right: 0,
115+
zIndex: globalStyles.zindex.zindexTabs
116+
},
117+
118+
caret: {
119+
position: 'relative',
120+
margin: 'auto',
121+
width: globalStyles.spacing.caretSize,
122+
123+
':before': {
124+
content: '""',
125+
position: 'absolute',
126+
bottom: 0,
127+
left: 0,
128+
borderBottom: caret(globalStyles.spacing.caretSize, globalStyles.color.notificationItemColor),
129+
borderLeft: caret(globalStyles.spacing.caretSize, 'transparent'),
130+
borderRight: caret(globalStyles.spacing.caretSize, 'transparent')
131+
},
132+
133+
':after': {
134+
content: '""',
135+
position: 'absolute',
136+
bottom: globalStyles.spacing.caretSize,
137+
left: globalStyles.spacing.caretSize,
138+
borderBottom: caret(0, '#eeeeee'),
139+
borderLeft: caret(0, 'transparent'),
140+
borderRight: caret(0, 'transparent')
141+
}
142+
}
143+
})
144+
145+
module.exports = {
146+
NotificationBar,
147+
NotificationBarCaret
148+
}

js/components/tab.js

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const {Favicon, AudioTabIcon, NewSessionIcon,
2626
PrivateIcon, TabTitle, CloseTabIcon} = require('../../app/renderer/components/tabContent')
2727
const {getTabBreakpoint, tabUpdateFrameRate} = require('../../app/renderer/lib/tabUtil')
2828
const {isWindows} = require('../../app/common/lib/platformUtil')
29+
const {NotificationBarCaret} = require('./notificationBar.js')
2930

3031
class Tab extends ImmutableComponent {
3132
constructor () {
@@ -230,6 +231,8 @@ class Tab extends ImmutableComponent {
230231

231232
render () {
232233
const playIndicatorBreakpoint = this.mediumView || this.narrowView
234+
const urlOrigin = new window.URL(this.props.tab.get('location')).origin
235+
const notificationBar = this.props.isActive && this.props.notificationBarActive.includes(urlOrigin)
233236
const perPageStyles = StyleSheet.create({
234237
themeColor: {
235238
color: this.themeColor ? getTextColorForBackground(this.themeColor) : 'inherit',
@@ -252,6 +255,11 @@ class Tab extends ImmutableComponent {
252255
style={this.props.tabWidth ? { flex: `0 0 ${this.props.tabWidth}px` } : {}}
253256
onMouseEnter={this.onMouseEnter}
254257
onMouseLeave={this.onMouseLeave}>
258+
{
259+
notificationBar
260+
? <NotificationBarCaret />
261+
: null
262+
}
255263
<div className={css(
256264
styles.tab,
257265
// Windows specific style

js/components/tabs.js

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class Tabs extends ImmutableComponent {
143143
onTabClosedWithMouse={this.onTabClosedWithMouse}
144144
tabWidth={this.props.fixTabWidth}
145145
hasTabInFullScreen={this.props.hasTabInFullScreen}
146+
notificationBarActive={this.props.notificationBarActive}
146147
totalTabs={this.props.tabs.size}
147148
partOfFullPageSet={this.props.partOfFullPageSet} />)
148149
}

js/components/tabsToolbar.js

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class TabsToolbar extends ImmutableComponent {
7272
startingFrameIndex={startingFrameIndex}
7373
partOfFullPageSet={currentTabs.size === this.props.tabsPerTabPage}
7474
fixTabWidth={this.props.fixTabWidth}
75+
notificationBarActive={this.props.notificationBarActive}
7576
/>
7677
<TabsToolbarButtons
7778
noFrames={currentTabs.size === 0}

less/notificationBar.less

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
width: 100%;
1111
cursor: default;
1212
-webkit-user-select: none;
13+
-webkit-filter: drop-shadow(0 4px 3px #000);
1314

1415
.notificationItem {
1516
background-color: #ffefc0;

0 commit comments

Comments
 (0)