@@ -36,6 +36,13 @@ const {getSetting} = require('../../../../js/settings')
36
36
const contextMenus = require ( '../../../../js/contextMenus' )
37
37
38
38
const { StyleSheet, css} = require ( 'aphrodite/no-important' )
39
+ const globalStyles = require ( '../styles/global' )
40
+ const commonStyles = require ( '../styles/commonStyles' )
41
+
42
+ const stopLoadingButton = require ( '../../../../img/toolbar/stoploading_btn.svg' )
43
+ const reloadButton = require ( '../../../../img/toolbar/reload_btn.svg' )
44
+ const bookmarkButton = require ( '../../../../img/toolbar/bookmark_btn.svg' )
45
+ const bookmarkedButton = require ( '../../../../img/toolbar/bookmark_marked.svg' )
39
46
40
47
class NavigationBar extends React . Component {
41
48
constructor ( props ) {
@@ -141,7 +148,7 @@ class NavigationBar extends React.Component {
141
148
data-frame-key = { this . props . activeFrameKey }
142
149
className = { cx ( {
143
150
titleMode : this . props . titleMode ,
144
- [ css ( styles . navigator_wide ) ] : this . props . isWideUrlBarEnabled
151
+ [ css ( styles . navigator , this . props . isWideUrlBarEnabled && styles . navigator_wide ) ] : true
145
152
} ) } >
146
153
{
147
154
this . props . showBookmarkHanger
@@ -153,14 +160,22 @@ class NavigationBar extends React.Component {
153
160
? null
154
161
: this . props . isLoading
155
162
? < span className = 'navigationButtonContainer' >
156
- < button data-l10n-id = 'stopButton'
157
- className = 'normalizeButton navigationButton stopButton'
158
- onClick = { this . onStop } />
163
+ < button className = { cx ( {
164
+ normalizeButton : true ,
165
+ [ css ( styles . navigator__navigationButtonContainer__navigationButton , styles . navigator__navigationButtonContainer__navigationButton_stopButton ) ] : true
166
+ } ) }
167
+ data-l10n-id = 'stopButton'
168
+ onClick = { this . onStop }
169
+ />
159
170
</ span >
160
171
: < span className = 'navigationButtonContainer' >
161
172
< LongPressButton
162
173
l10nId = 'reloadButton'
163
- className = 'normalizeButton navigationButton reloadButton'
174
+ testId = 'reloadButton'
175
+ className = { cx ( {
176
+ normalizeButton : true ,
177
+ [ css ( styles . navigator__navigationButtonContainer__navigationButton , styles . navigator__navigationButtonContainer__navigationButton_reloadButton ) ] : true
178
+ } ) }
164
179
onClick = { this . onReload }
165
180
onLongPress = { this . onReloadLongPress } />
166
181
</ span >
@@ -170,27 +185,31 @@ class NavigationBar extends React.Component {
170
185
? < HomeButton activeTabId = { this . props . activeTabId } />
171
186
: null
172
187
}
173
- < div className = 'startButtons' >
174
- {
175
- ! this . props . titleMode
176
- ? < span className = 'bookmarkButtonContainer' >
177
- < button data-l10n-id = { this . props . isBookmarked ? 'removeBookmarkButton' : 'addBookmarkButton' }
178
- className = { cx ( {
179
- navigationButton : true ,
180
- bookmarkButton : true ,
181
- removeBookmarkButton : this . props . isBookmarked ,
182
- withHomeButton : getSetting ( settings . SHOW_HOME_BUTTON ) ,
183
- normalizeButton : true
184
- } ) }
185
- onClick = { this . onToggleBookmark } />
186
- </ span >
187
- : null
188
- }
189
- </ div >
188
+ {
189
+ ! this . props . titleMode
190
+ ? < span className = { cx ( {
191
+ bookmarkButtonContainer : true ,
192
+ [ css ( commonStyles . navigator__buttonContainer , styles . navigator__buttonContainer_bookmarkButtonContainer ) ] : true
193
+ } ) } >
194
+ < button className = { cx ( {
195
+ normalizeButton : true ,
196
+ withHomeButton : getSetting ( settings . SHOW_HOME_BUTTON ) ,
197
+ [ css ( styles . navigator__buttonContainer_bookmarkButtonContainer__bookmarkButton , this . bookmarked && styles . navigator__buttonContainer_bookmarkButtonContainer__bookmarkButton_removeBookmarkButton ) ] : true
198
+ } ) }
199
+ data-l10n-id = { this . bookmarked ? 'removeBookmarkButton' : 'addBookmarkButton' }
200
+ data-test-id = { this . bookmarked ? 'bookmarked' : 'notBookmarked' }
201
+ onClick = { this . onToggleBookmark }
202
+ />
203
+ </ span >
204
+ : null
205
+ }
190
206
< UrlBar titleMode = { this . props . titleMode } />
191
207
{
192
208
this . props . showPublisherToggle
193
- ? < div className = 'endButtons' >
209
+ ? < div className = { css (
210
+ this . props . titleMode && styles . navigator__endButtons_titleMode ,
211
+ ! this . props . titleMode && styles . navigator__endButtons_notTitleMode
212
+ ) } >
194
213
< PublisherToggle />
195
214
</ div >
196
215
: null
@@ -199,13 +218,78 @@ class NavigationBar extends React.Component {
199
218
}
200
219
}
201
220
221
+ const rightMargin = `calc(${ globalStyles . spacing . navbarLeftMarginDarwin } / 2)`
222
+
202
223
const styles = StyleSheet . create ( {
224
+
225
+ navigator : {
226
+ boxSizing : 'border-box' ,
227
+ display : 'flex' ,
228
+ flexGrow : 1 ,
229
+ alignItems : 'center' ,
230
+ justifyContent : 'center' ,
231
+ fontSize : '20px' ,
232
+ minWidth : '0%' , // allow the navigator to shrink
233
+ maxWidth : '900px' ,
234
+ marginRight : rightMargin ,
235
+ padding : 0 ,
236
+ position : 'relative' ,
237
+ userSelect : 'none' ,
238
+ zIndex : globalStyles . zindex . zindexNavigationBar
239
+ } ,
240
+
203
241
navigator_wide : {
242
+ maxWidth : '100%' ,
243
+ marginRight : '0' ,
244
+ justifyContent : 'initial'
245
+ } ,
246
+
247
+ navigator__navigationButtonContainer__navigationButton : {
248
+ // cf: https://github.com/brave/browser-laptop/blob/b161b37cf5e9f59be64855ebbc5d04816bfc537b/less/navigationBar.less#L550-L553
249
+ backgroundColor : globalStyles . color . buttonColor ,
250
+ display : 'inline-block' ,
251
+ width : '100%' ,
252
+ height : '100%' ,
253
+
254
+ // cf: https://github.com/brave/browser-laptop/blob/b161b37cf5e9f59be64855ebbc5d04816bfc537b/less/navigationBar.less#L584-L585
255
+ margin : 0 ,
256
+ padding : 0
257
+ } ,
258
+
259
+ navigator__navigationButtonContainer__navigationButton_stopButton : {
260
+ background : `url(${ stopLoadingButton } ) center no-repeat` ,
261
+ backgroundSize : '11px 11px'
262
+ } ,
263
+
264
+ navigator__navigationButtonContainer__navigationButton_reloadButton : {
265
+ background : `url(${ reloadButton } ) center no-repeat` ,
266
+ backgroundSize : '13px 13px'
267
+ } ,
268
+
269
+ // cf: navigator__buttonContainer_addPublisherButtonContainer on publisherToggle.js
270
+ navigator__buttonContainer_bookmarkButtonContainer : {
271
+ borderRight : 'none' ,
272
+ borderTopRightRadius : 0 ,
273
+ borderBottomRightRadius : 0
274
+ } ,
275
+
276
+ navigator__buttonContainer_bookmarkButtonContainer__bookmarkButton : {
277
+ background : `url(${ bookmarkButton } ) center no-repeat` ,
278
+ backgroundSize : '14px 14px' ,
279
+ width : globalStyles . navigationBar . urlbarForm . height , // #6704
280
+ height : globalStyles . navigationBar . urlbarForm . height // #6704
281
+ } ,
282
+
283
+ navigator__buttonContainer_bookmarkButtonContainer__bookmarkButton_removeBookmarkButton : {
284
+ background : `url(${ bookmarkedButton } ) center no-repeat`
285
+ } ,
286
+
287
+ navigator__endButtons_titleMode : {
288
+ display : 'none'
289
+ } ,
204
290
205
- // TODO: Refactor navigationBar.js to remove !important
206
- maxWidth : '100% !important' ,
207
- marginRight : '0 !important' ,
208
- justifyContent : 'initial !important'
291
+ navigator__endButtons_notTitleMode : {
292
+ display : 'flex'
209
293
}
210
294
} )
211
295
0 commit comments