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

Commit 8694192

Browse files
author
Suguru Hirahara
committed
Refactor navigationBar (part 3)
Full changelog: 8997c76 Test Plan: available on #9299 (comment)
1 parent ca189d4 commit 8694192

File tree

7 files changed

+276
-219
lines changed

7 files changed

+276
-219
lines changed

app/renderer/components/navigation/homeButton.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ class HomeButton extends ImmutableComponent {
5656
}
5757

5858
render () {
59+
// BEM Level: navigator__navigationButtonContainer
5960
return <span className='navigationButtonContainer'>
6061
<button className={cx({
6162
normalizeButton: true,
62-
[css(styles.navigator__navigationButtonContainer__navigationButton, styles.navigator__navigationButtonContainer__navigationButton_homeButton)]: true
63+
[css(styles.navigationButton, styles.navigationButton_homeButton)]: true
6364
})}
6465
data-test-id='homeButton'
6566
data-l10n-id='homeButton'
@@ -71,7 +72,7 @@ class HomeButton extends ImmutableComponent {
7172
}
7273

7374
const styles = StyleSheet.create({
74-
navigator__navigationButtonContainer__navigationButton: {
75+
navigationButton: {
7576
// cf: https://github.com/brave/browser-laptop/blob/b161b37cf5e9f59be64855ebbc5d04816bfc537b/less/navigationBar.less#L550-L553
7677
backgroundColor: globalStyles.color.buttonColor,
7778
display: 'inline-block',
@@ -83,7 +84,7 @@ const styles = StyleSheet.create({
8384
padding: 0
8485
},
8586

86-
navigator__navigationButtonContainer__navigationButton_homeButton: {
87+
navigationButton_homeButton: {
8788
background: `url(${homeButton}) center no-repeat`,
8889
backgroundSize: `16px 16px`
8990
}

app/renderer/components/navigation/navigationBar.js

+22-24
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,25 @@ class NavigationBar extends React.Component {
134134
/>
135135
}
136136

137+
// BEM Level: navigator
138+
get bookmarkButtonContainer () {
139+
return <span className={css(
140+
commonStyles.navigator__buttonContainer,
141+
commonStyles.navigator__buttonContainer_outsideOfURLbar,
142+
styles.navigator__buttonContainer_bookmarkButtonContainer
143+
)}>
144+
<button className={cx({
145+
normalizeButton: true,
146+
withHomeButton: getSetting(settings.SHOW_HOME_BUTTON),
147+
[css(styles.navigator__buttonContainer_bookmarkButtonContainer__bookmarkButton, this.bookmarked && styles.navigator__buttonContainer_bookmarkButtonContainer__bookmarkButton_removeBookmarkButton)]: true
148+
})}
149+
data-l10n-id={this.bookmarked ? 'removeBookmarkButton' : 'addBookmarkButton'}
150+
data-test-id={this.bookmarked ? 'bookmarked' : 'notBookmarked'}
151+
onClick={this.onToggleBookmark}
152+
/>
153+
</span>
154+
}
155+
137156
componentDidMount () {
138157
ipc.on(messages.SHORTCUT_ACTIVE_FRAME_BOOKMARK, () => this.onToggleBookmark())
139158
ipc.on(messages.SHORTCUT_ACTIVE_FRAME_REMOVE_BOOKMARK, () => this.onToggleBookmark())
@@ -233,20 +252,7 @@ class NavigationBar extends React.Component {
233252
}
234253
{
235254
!this.props.titleMode
236-
? <span className={cx({
237-
bookmarkButtonContainer: true,
238-
[css(commonStyles.navigator__buttonContainer, commonStyles.navigator__buttonContainer_outsideOfURLbar, styles.navigator__buttonContainer_bookmarkButtonContainer)]: true
239-
})}>
240-
<button className={cx({
241-
normalizeButton: true,
242-
withHomeButton: getSetting(settings.SHOW_HOME_BUTTON),
243-
[css(styles.navigator__buttonContainer_bookmarkButtonContainer__bookmarkButton, this.bookmarked && styles.navigator__buttonContainer_bookmarkButtonContainer__bookmarkButton_removeBookmarkButton)]: true
244-
})}
245-
data-l10n-id={this.bookmarked ? 'removeBookmarkButton' : 'addBookmarkButton'}
246-
data-test-id={this.bookmarked ? 'bookmarked' : 'notBookmarked'}
247-
onClick={this.onToggleBookmark}
248-
/>
249-
</span>
255+
? this.bookmarkButtonContainer
250256
: null
251257
}
252258
<UrlBar
@@ -339,20 +345,12 @@ const styles = StyleSheet.create({
339345
navigator__buttonContainer_bookmarkButtonContainer__bookmarkButton: {
340346
background: `url(${bookmarkButton}) center no-repeat`,
341347
backgroundSize: '14px 14px',
342-
width: globalStyles.navigationBar.urlbarForm.height, // #6704
343-
height: globalStyles.navigationBar.urlbarForm.height // #6704
348+
width: '100%',
349+
height: '100%'
344350
},
345351

346352
navigator__buttonContainer_bookmarkButtonContainer__bookmarkButton_removeBookmarkButton: {
347353
background: `url(${bookmarkedButton}) center no-repeat`
348-
},
349-
350-
navigator__endButtons_titleMode: {
351-
display: 'none'
352-
},
353-
354-
navigator__endButtons_notTitleMode: {
355-
display: 'flex'
356354
}
357355
})
358356

0 commit comments

Comments
 (0)