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

Commit 2d7d7fa

Browse files
author
Suguru Hirahara
committed
Polish PublisherToggle
- Set navigationBarButtonContainer for PublisherToogle in the same way as for the other buttons on navigationBar.js - Rename publisherButton to publisherToggle
1 parent c1b8416 commit 2d7d7fa

File tree

3 files changed

+41
-37
lines changed

3 files changed

+41
-37
lines changed

app/renderer/components/navigation/navigationBar.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,13 @@ class NavigationBar extends React.Component {
174174
<UrlBar titleMode={this.props.titleMode} />
175175
{
176176
this.props.showPublisherToggle
177-
? <PublisherToggle />
177+
? (
178+
<NavigationBarButtonContainer isSquare isNested
179+
containerFor={styles.navigationBar__urlBarEnd}
180+
>
181+
<PublisherToggle />
182+
</NavigationBarButtonContainer>
183+
)
178184
: null
179185
}
180186
</div>
@@ -213,10 +219,23 @@ const styles = StyleSheet.create({
213219
},
214220

215221
// Applies for the first urlBar nested button
222+
// currently for BookmarkButton
216223
navigationBar__urlBarStart: {
217224
borderRight: 'none',
218225
borderTopRightRadius: 0,
219226
borderBottomRightRadius: 0
227+
},
228+
229+
// Applies for the end urlBar nested button
230+
// currently for PublisherToggle
231+
navigationBar__urlBarEnd: {
232+
borderLeft: 'none',
233+
borderTopLeftRadius: 0,
234+
borderBottomLeftRadius: 0,
235+
236+
// TODO (Suguru): Refactor navigationBar.less to remove !important.
237+
// See the wildcard style under '#navigationBar'.
238+
animation: 'none !important'
220239
}
221240
})
222241

app/renderer/components/navigation/publisherToggle.js

+18-33
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const {StyleSheet} = require('aphrodite/no-important')
88

99
// Components
1010
const ReduxComponent = require('../reduxComponent')
11-
const NavigationBarButtonContainer = require('./buttons/navigationBarButtonContainer')
1211
const {NormalizedButton} = require('../common/browserButton')
1312

1413
// Actions
@@ -67,57 +66,43 @@ class PublisherToggle extends React.Component {
6766
}
6867

6968
render () {
70-
return <NavigationBarButtonContainer isSquare isNested
71-
containerFor={styles.publisherButtonContainer}>
72-
<NormalizedButton custom={[
73-
(!this.props.isEnabledForPaymentsPublisher && this.props.isVerifiedPublisher) && styles.publisherButtonContainer__button_noFundVerified,
74-
(this.props.isEnabledForPaymentsPublisher && this.props.isVerifiedPublisher) && styles.publisherButtonContainer__button_fundVerified,
75-
(!this.props.isEnabledForPaymentsPublisher && !this.props.isVerifiedPublisher) && styles.publisherButtonContainer__button_noFundUnverified,
76-
(this.props.isEnabledForPaymentsPublisher && !this.props.isVerifiedPublisher) && styles.publisherButtonContainer__button_fundUnverified,
77-
styles.publisherButtonContainer__button
78-
]}
79-
l10nId={this.l10nString}
80-
testId='publisherButton'
81-
testAuthorized={this.props.isEnabledForPaymentsPublisher}
82-
testVerified={this.props.isVerifiedPublisher}
83-
onClick={this.onAuthorizePublisher}
84-
/>
85-
</NavigationBarButtonContainer>
69+
return <NormalizedButton custom={[
70+
(!this.props.isEnabledForPaymentsPublisher && this.props.isVerifiedPublisher) && styles.publisherToggle_noFundVerified,
71+
(this.props.isEnabledForPaymentsPublisher && this.props.isVerifiedPublisher) && styles.publisherToggle_fundVerified,
72+
(!this.props.isEnabledForPaymentsPublisher && !this.props.isVerifiedPublisher) && styles.publisherToggle_noFundUnverified,
73+
(this.props.isEnabledForPaymentsPublisher && !this.props.isVerifiedPublisher) && styles.publisherToggle_fundUnverified,
74+
styles.publisherToggle
75+
]}
76+
l10nId={this.l10nString}
77+
testId='publisherToggle'
78+
testAuthorized={this.props.isEnabledForPaymentsPublisher}
79+
testVerified={this.props.isVerifiedPublisher}
80+
onClick={this.onAuthorizePublisher}
81+
/>
8682
}
8783
}
8884

8985
const styles = StyleSheet.create({
90-
// cf: navigationBar__buttonContainer_bookmarkButtonContainer on navigationBar.js
91-
publisherButtonContainer: {
92-
borderLeft: 'none',
93-
borderTopLeftRadius: 0,
94-
borderBottomLeftRadius: 0,
95-
96-
// TODO (Suguru): Refactor navigationBar.less to remove !important.
97-
// See the wildcard style under '#navigationBar'.
98-
animation: 'none !important'
99-
},
100-
101-
publisherButtonContainer__button: {
86+
publisherToggle: {
10287
backgroundSize: '18px 18px',
10388
width: '100%',
10489
height: '100%'
10590
},
10691

107-
publisherButtonContainer__button_noFundVerified: {
92+
publisherToggle_noFundVerified: {
10893
// 1px added due to the check mark
10994
background: `url(${noFundVerifiedPublisherImage}) calc(50% + 1px) no-repeat`
11095
},
11196

112-
publisherButtonContainer__button_fundVerified: {
97+
publisherToggle_fundVerified: {
11398
background: `url(${fundVerifiedPublisherImage}) calc(50% + 1px) no-repeat`
11499
},
115100

116-
publisherButtonContainer__button_noFundUnverified: {
101+
publisherToggle_noFundUnverified: {
117102
background: `url(${noFundUnverifiedPublisherImage}) 50% no-repeat`
118103
},
119104

120-
publisherButtonContainer__button_fundUnverified: {
105+
publisherToggle_fundUnverified: {
121106
background: `url(${fundUnverifiedPublisherImage}) 50% no-repeat`
122107
}
123108
})

test/unit/app/renderer/components/navigation/publisherToggleTest.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ describe('PublisherToggle component', function () {
9292
appStore.state = fakeAppState.setIn(['locationInfo', 'https://brave.com', 'exclude'], true)
9393

9494
const wrapper = mount(<PublisherToggle />)
95-
assert.equal(wrapper.find('[data-test-id="publisherButton"]').length, 1)
95+
assert.equal(wrapper.find('[data-test-id="publisherToggle"]').length, 1)
9696
assert.equal(wrapper.find('button').props()['data-test-authorized'], false)
9797
})
9898

9999
it('Show as verified if publisher is shown as verified on locationInfo list', function () {
100100
windowStore.state = defaultWindowStore
101101
appStore.state = fakeAppState
102102
const wrapper = mount(<PublisherToggle />)
103-
assert.equal(wrapper.find('[data-test-id="publisherButton"]').length, 1)
103+
assert.equal(wrapper.find('[data-test-id="publisherToggle"]').length, 1)
104104
assert.equal(wrapper.find('button').props()['data-test-verified'], true)
105105
})
106106
})
@@ -111,7 +111,7 @@ describe('PublisherToggle component', function () {
111111
appStore.state = fakeAppState.setIn(['siteSettings', 'https?://brave.com', 'ledgerPayments'], true)
112112

113113
const wrapper = mount(<PublisherToggle />)
114-
assert.equal(wrapper.find('[data-test-id="publisherButton"]').length, 1)
114+
assert.equal(wrapper.find('[data-test-id="publisherToggle"]').length, 1)
115115
assert.equal(wrapper.find('button').props()['data-test-authorized'], true)
116116
})
117117

0 commit comments

Comments
 (0)