1
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
4
5
5
const React = require ( 'react' )
6
6
const { StyleSheet, css} = require ( 'aphrodite/no-important' )
@@ -9,68 +9,61 @@ const {StyleSheet, css} = require('aphrodite/no-important')
9
9
const ReduxComponent = require ( '../../reduxComponent' )
10
10
const TabIcon = require ( './tabIcon' )
11
11
12
- // State
13
- const tabUIState = require ( '../../../../common/state/tabUIState' )
14
-
15
- // Utils
12
+ // State helpers
13
+ const privateState = require ( '../../../../common/state/tabContentState/privateState' )
16
14
const frameStateUtil = require ( '../../../../../js/state/frameStateUtil' )
15
+ const tabState = require ( '../../../../common/state/tabState' )
17
16
18
17
// Styles
18
+ const { theme} = require ( '../../styles/theme' )
19
19
const globalStyles = require ( '../../styles/global' )
20
20
const privateSvg = require ( '../../../../extensions/brave/img/tabs/private.svg' )
21
21
22
22
class PrivateIcon extends React . Component {
23
23
mergeProps ( state , ownProps ) {
24
24
const currentWindow = state . get ( 'currentWindow' )
25
- const frameKey = ownProps . frameKey
26
- const hasSeconardImage = tabUIState . hasVisibleSecondaryIcon ( currentWindow , ownProps . frameKey )
25
+ const tabId = ownProps . tabId
26
+ const frameKey = frameStateUtil . getFrameKeyByTabId ( currentWindow , tabId )
27
27
28
28
const props = { }
29
- // used in renderer
29
+ props . isPinned = tabState . isTabPinned ( state , tabId )
30
30
props . isActive = frameStateUtil . isFrameKeyActive ( currentWindow , frameKey )
31
-
32
- // used in functions
33
- props . showPrivateIcon = ownProps . isPrivateTab && hasSeconardImage
34
- props . frameKey = frameKey
31
+ props . showPrivateIcon = privateState . showPrivateIcon ( currentWindow , frameKey )
32
+ props . tabId = tabId
35
33
36
34
return props
37
35
}
38
36
39
37
render ( ) {
40
- if ( ! this . props . showPrivateIcon ) {
38
+ if ( this . props . isPinned || ! this . props . showPrivateIcon ) {
41
39
return null
42
40
}
43
- const privateStyles = StyleSheet . create ( {
44
- icon : {
45
- backgroundColor : this . props . isActive ? globalStyles . color . white100 : globalStyles . color . black100
41
+
42
+ const privateProps = StyleSheet . create ( {
43
+ private__icon_color : {
44
+ backgroundColor : this . props . isActive
45
+ ? theme . tab . content . icon . private . background . active
46
+ : theme . tab . content . icon . private . background . notActive
46
47
}
47
48
} )
48
49
49
50
return < TabIcon
50
51
data-test-id = 'privateIcon'
51
- className = { css ( styles . icon , styles . secondaryIcon , privateStyles . icon ) }
52
+ className = { css ( styles . private__icon , privateProps . private__icon_color ) }
52
53
/>
53
54
}
54
55
}
55
56
56
57
module . exports = ReduxComponent . connect ( PrivateIcon )
57
58
58
59
const styles = StyleSheet . create ( {
59
- icon : {
60
- width : globalStyles . spacing . iconSize ,
61
- minWidth : globalStyles . spacing . iconSize ,
62
- height : globalStyles . spacing . iconSize ,
63
- backgroundSize : globalStyles . spacing . iconSize ,
64
- fontSize : globalStyles . fontSize . tabIcon ,
65
- backgroundPosition : 'center' ,
66
- backgroundRepeat : 'no-repeat' ,
67
- paddingLeft : globalStyles . spacing . defaultIconPadding ,
68
- paddingRight : globalStyles . spacing . defaultIconPadding
69
- } ,
70
-
71
- secondaryIcon : {
60
+ private__icon : {
61
+ boxSizing : 'border-box' ,
72
62
WebkitMaskRepeat : 'no-repeat' ,
73
63
WebkitMaskPosition : 'center' ,
74
- WebkitMaskImage : `url(${ privateSvg } )`
64
+ WebkitMaskImage : `url(${ privateSvg } )` ,
65
+ WebkitMaskSize : globalStyles . spacing . sessionIconSize ,
66
+ width : globalStyles . spacing . sessionIconSize ,
67
+ height : globalStyles . spacing . sessionIconSize
75
68
}
76
69
} )
0 commit comments