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

Commit

Permalink
Update UI spec for private tabs
Browse files Browse the repository at this point in the history
- Close #7943
- Auditors: @bsclifton
  • Loading branch information
cezaraugusto authored and bsclifton committed Mar 29, 2017
1 parent df35e1c commit b00c5d9
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 18 deletions.
32 changes: 32 additions & 0 deletions app/extensions/brave/img/tabs/private.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 1 addition & 8 deletions app/renderer/components/styles/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,9 @@ const styles = StyleSheet.create({

activePrivateTab: {
background: globalStyles.color.privateTabBackgroundActive,
color: '#fff'
},

private: {
background: globalStyles.color.privateTabBackground,
color: '#fff',

':hover': {
background: globalStyles.color.privateTabBackgroundActive,
color: '#fff'
background: globalStyles.color.privateTabBackgroundActive
}
},

Expand Down
18 changes: 16 additions & 2 deletions app/renderer/components/tabContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {tabs} = require('../../../js/constants/config')
const {hasBreakpoint, hasRelativeCloseIcon, hasFixedCloseIcon} = require('../lib/tabUtil')

const newSessionSvg = require('../../extensions/brave/img/tabs/new_session.svg')
const privateSvg = require('../../extensions/brave/img/tabs/private.svg')
const closeTabSvg = require('../../extensions/brave/img/tabs/close_btn_normal.svg')
const closeTabHoverSvg = require('../../extensions/brave/img/tabs/close_btn_hover.svg')

Expand Down Expand Up @@ -142,8 +143,15 @@ class PrivateIcon extends ImmutableComponent {
}

render () {
const privateStyles = StyleSheet.create({
icon: {
WebkitMaskImage: `url(${privateSvg})`,
backgroundColor: this.props.isActive ? globalStyles.color.white100 : globalStyles.color.black100
}
})
return this.props.tab.get('isPrivate') && !this.props.tab.get('hoverState') && !this.narrowView
? <TabIcon className={css(styles.icon)} symbol={globalStyles.appIcons.private} />
? <TabIcon data-test-id='privateIcon'
className={css(styles.icon, styles.secondaryIcon, privateStyles.icon)} />
: null
}
}
Expand Down Expand Up @@ -214,8 +222,9 @@ class TabTitle extends ImmutableComponent {

get themeColor () {
const themeColor = this.props.tab.get('themeColor') || this.props.tab.get('computedThemeColor')
const defaultColor = this.props.tab.get('isPrivate') ? globalStyles.color.white100 : globalStyles.color.black100
const activeNonPrivateTab = !this.props.tab.get('isPrivate') && this.props.isActive
const activePrivateTab = this.props.tab.get('isPrivate') && this.props.isActive
const defaultColor = activePrivateTab ? globalStyles.color.white100 : globalStyles.color.black100

return activeNonPrivateTab && this.props.paintTabs && !!themeColor
? getTextColorForBackground(themeColor)
Expand Down Expand Up @@ -296,6 +305,11 @@ const styles = StyleSheet.create({
fontSize: '16px'
},

secondaryIcon: {
WebkitMaskRepeat: 'no-repeat',
WebkitMaskPosition: 'center'
},

newSession: {
position: 'relative',
backgroundImage: `url(${newSessionSvg})`,
Expand Down
10 changes: 6 additions & 4 deletions js/components/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ class Tab extends ImmutableComponent {

render () {
const playIndicatorBreakpoint = this.mediumView || this.narrowView
const perPageStyles = StyleSheet.create({
// we don't want themeColor if tab is private
const perPageStyles = !this.props.tab.get('isPrivate') && StyleSheet.create({
themeColor: {
color: this.themeColor ? getTextColorForBackground(this.themeColor) : 'inherit',
background: this.themeColor ? this.themeColor : 'inherit',
Expand Down Expand Up @@ -260,8 +261,6 @@ class Tab extends ImmutableComponent {
isWindows() && styles.tabForWindows,
this.isPinned && styles.isPinned,
this.props.isActive && styles.active,
this.props.tab.get('isPrivate') && styles.private,
this.props.isActive && this.props.tab.get('isPrivate') && styles.activePrivateTab,
playIndicatorBreakpoint && this.canPlayAudio && styles.narrowViewPlayIndicator,
this.props.isActive && this.themeColor && perPageStyles.themeColor,
// Private color should override themeColor
Expand Down Expand Up @@ -306,7 +305,10 @@ class Tab extends ImmutableComponent {
pageTitle={this.displayValue}
/>
</div>
<PrivateIcon tab={this.props.tab} />
<PrivateIcon
tab={this.props.tab}
isActive={this.props.isActive}
/>
<NewSessionIcon
isActive={this.props.isActive}
paintTabs={this.props.paintTabs}
Expand Down
9 changes: 5 additions & 4 deletions test/unit/app/renderer/tabContentTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('tabContent components', function () {
mockery.registerMock('../../extensions/brave/img/tabs/new_session.svg')
mockery.registerMock('../../extensions/brave/img/tabs/close_btn_normal.svg')
mockery.registerMock('../../extensions/brave/img/tabs/close_btn_hover.svg')
mockery.registerMock('../../extensions/brave/img/tabs/private.svg')
mockery.enable({
warnOnReplace: false,
warnOnUnregistered: false,
Expand Down Expand Up @@ -167,7 +168,7 @@ describe('tabContent components', function () {
})}
/>
)
assert.equal(wrapper.props().symbol, globalStyles.appIcons.private)
assert.equal(wrapper.props()['data-test-id'], 'privateIcon')
})
it('should not show private icon if current tab is not private', function () {
const wrapper = shallow(
Expand All @@ -178,7 +179,7 @@ describe('tabContent components', function () {
})}
/>
)
assert.notEqual(wrapper.props().symbol, globalStyles.appIcons.private)
assert.notEqual(wrapper.props()['data-test-id'], 'privateIcon')
})
it('should not show private icon if mouse is over tab (avoid icon overflow)', function () {
const wrapper = shallow(
Expand All @@ -190,7 +191,7 @@ describe('tabContent components', function () {
})}
/>
)
assert.notEqual(wrapper.props().symbol, globalStyles.appIcons.private)
assert.notEqual(wrapper.props()['data-test-id'], 'privateIcon')
})
it('should not show private icon if tab size is too small', function () {
const wrapper = shallow(
Expand All @@ -203,7 +204,7 @@ describe('tabContent components', function () {
})}
/>
)
assert.notEqual(wrapper.props().symbol, globalStyles.appIcons.private)
assert.notEqual(wrapper.props()['data-test-id'], 'privateIcon')
})
})

Expand Down

0 comments on commit b00c5d9

Please sign in to comment.