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

Commit

Permalink
Improve UI/UX of bookmark popup
Browse files Browse the repository at this point in the history
  • Loading branch information
jkup committed Oct 13, 2016
1 parent 66774ae commit 8865ba7
Show file tree
Hide file tree
Showing 12 changed files with 168 additions and 59 deletions.
6 changes: 3 additions & 3 deletions app/extensions/brave/locales/en-US/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ allowFlashPlayer=Allow {{origin}} to run Flash Player?
ledgerBackupText=Your ledger keys are {{paymentId}} and {{passphrase}}
error=Error
caseSensitivity=Match case
nameField=Title:
locationField=Location:
parentFolderField=Folder:
nameField=Title
locationField=Location
parentFolderField=Folder
save=Save
rememberDecision=Remember this decision
bookmarksToolbar=Bookmarks Toolbar
Expand Down
5 changes: 4 additions & 1 deletion app/extensions/brave/locales/en-US/menu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ closeTab=Close
closeOtherTabs=Close other Tabs
bookmarkPage=Bookmark Page
bookmarkLink=Bookmark This Link
bookmarkAdded=Bookmark Added
openFile=Open File…
openLocation=Open Location…
openSearch=Search for "{{selectedVariable}}"
Expand All @@ -19,7 +20,8 @@ paste=Paste
pasteAndGo=Paste and Go
pasteAndSearch=Paste and Search
pasteWithoutFormatting=Paste without formatting
delete=Delete
done=Done
remove=Remove
selectAll=Select All
findNext=Find Next
findPrevious=Find Previous
Expand Down Expand Up @@ -50,6 +52,7 @@ clearSiteData=Clear All Cookies and Site Data…
recentlyClosed=Recently Closed
recentlyVisited=Recently Visited
bookmarks=Bookmarks
viewBookmarks=View all bookmarks
addToFavoritesBar=Add to Favorites Bar
window=Window
minimize=Minimize
Expand Down
1 change: 1 addition & 0 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ WindowStore
bookmarkDetail: {
currentDetail: Object, // Detail of the current bookmark which is in add/edit mode
originalDetails: Object // Detail of the original bookmark to edit
shouldShowLocation: Boolean // Whether or not to show the URL input
},
braveryPanelDetail: {
advancedControls: boolean, // If specified, indicates if advanced controls should be shown
Expand Down
4 changes: 3 additions & 1 deletion docs/windowActions.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ Dispatches a message to set the find-in-page details.



### setBookmarkDetail(currentDetail, originalDetail, destinationDetail)
### setBookmarkDetail(currentDetail, originalDetail, destinationDetail, shouldShowLocation)

Dispatches a message to set add/edit bookmark details
If set, also indicates that add/edit is shown
Expand All @@ -480,6 +480,8 @@ If set, also indicates that add/edit is shown

**destinationDetail**: `Object`, Will move the added bookmark to the specified position

**shouldShowLocation**: `Object`, Whether or not to show the URL input



### setContextMenuDetail(detail)
Expand Down
6 changes: 4 additions & 2 deletions js/actions/windowActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,13 +643,15 @@ const windowActions = {
* @param {Object} currentDetail - Properties of the bookmark to change to
* @param {Object} originalDetail - Properties of the bookmark to edit
* @param {Object} destinationDetail - Will move the added bookmark to the specified position
* @param {Object} shouldShowLocation - Whether or not to show the URL input
*/
setBookmarkDetail: function (currentDetail, originalDetail, destinationDetail) {
setBookmarkDetail: function (currentDetail, originalDetail, destinationDetail, shouldShowLocation) {
dispatch({
actionType: WindowConstants.WINDOW_SET_BOOKMARK_DETAIL,
currentDetail,
originalDetail,
destinationDetail
destinationDetail,
shouldShowLocation
})
},

Expand Down
78 changes: 48 additions & 30 deletions js/components/addEditBookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class AddEditBookmark extends ImmutableComponent {
this.onClose = this.onClose.bind(this)
this.onClick = this.onClick.bind(this)
this.onSave = this.onSave.bind(this)
this.onViewBookmarks = this.onViewBookmarks.bind(this)
this.onRemoveBookmark = this.onRemoveBookmark.bind(this)
}

Expand Down Expand Up @@ -51,6 +52,10 @@ class AddEditBookmark extends ImmutableComponent {
}
}
componentDidMount () {
// Automatically save if this is triggered by the url star
if (!this.props.shouldShowLocation) {
this.onSave(false)
}
this.bookmarkName.select()
this.bookmarkName.focus()
}
Expand Down Expand Up @@ -95,7 +100,7 @@ class AddEditBookmark extends ImmutableComponent {
)
appActions.changeSetting(settings.SHOW_BOOKMARKS_TOOLBAR, !isFirstBookmark || showBookmarksToolbar)
}
onSave () {
onSave (closeDialog = true) {
// First check if the title of the currentDetail is set
if (!this.bookmarkNameValid) {
return false
Expand All @@ -104,54 +109,67 @@ class AddEditBookmark extends ImmutableComponent {
this.showToolbarOnFirstBookmark()
const tag = this.isFolder ? siteTags.BOOKMARK_FOLDER : siteTags.BOOKMARK
appActions.addSite(this.props.currentDetail, tag, this.props.originalDetail, this.props.destinationDetail)
this.onClose()
if (closeDialog) {
this.onClose()
}
}
onRemoveBookmark () {
const tag = this.isFolder ? siteTags.BOOKMARK_FOLDER : siteTags.BOOKMARK
appActions.removeSite(this.props.currentDetail, tag)
this.onClose()
}
onViewBookmarks () {
this.onClose()
windowActions.newFrame({location: 'about:bookmarks'}, true)
}
get displayBookmarkName () {
if (this.props.currentDetail.get('customTitle') !== undefined) {
return this.props.currentDetail.get('customTitle')
}
return this.props.currentDetail.get('title') || ''
}
render () {
return <Dialog onHide={this.onClose} isClickDismiss>
<div className='genericForm' onClick={this.onClick}>
<div className='genericFormTable'>
<div id='bookmarkName' className='formRow'>
<label data-l10n-id='nameField' htmlFor='bookmarkName' />
<input spellCheck='false' onKeyDown={this.onKeyDown} onChange={this.onNameChange} value={this.displayBookmarkName} ref={(bookmarkName) => { this.bookmarkName = bookmarkName }} />
</div>
{
!this.isFolder
? <div id='bookmarkLocation' className='formRow'>
<label data-l10n-id='locationField' htmlFor='bookmarkLocation' />
<input spellCheck='false' onKeyDown={this.onKeyDown} onChange={this.onLocationChange} value={this.props.currentDetail.get('location')} />
return <Dialog onHide={this.onClose} className='bookmarkDialog' isClickDismiss>
<div className='bookmarkForm' onClick={this.onClick}>
<div className='arrowUp' />
<div className='bookmarkFormInner'>
<h2 data-l10n-id='bookmarkAdded' />
<div className='bookmarkFormTable'>
<div id='bookmarkName' className='bookmarkFormRow'>
<label data-l10n-id='nameField' htmlFor='bookmarkName' />
<input spellCheck='false' onKeyDown={this.onKeyDown} onChange={this.onNameChange} value={this.displayBookmarkName} ref={(bookmarkName) => { this.bookmarkName = bookmarkName }} />
</div>
: null
}
<div id='bookmarkParentFolder' className='formRow'>
<label data-l10n-id='parentFolderField' htmlFor='bookmarkParentFolderk' />
<select value={this.props.currentDetail.get('parentFolderId')}
onChange={this.onParentFolderChange} >
<option value='0' data-l10n-id='bookmarksToolbar' />
{
this.folders.map((folder) => <option value={folder.folderId}>{folder.label}</option>)
}
</select>
</div>
<div className='formRow'>
{
this.props.originalDetail
? <a data-l10n-id='delete' className='removeBookmarkLink link' onClick={this.onRemoveBookmark} />
!this.isFolder && this.props.shouldShowLocation
? <div id='bookmarkLocation' className='bookmarkFormRow'>
<label data-l10n-id='locationField' htmlFor='bookmarkLocation' />
<input spellCheck='false' onKeyDown={this.onKeyDown} onChange={this.onLocationChange} value={this.props.currentDetail.get('location')} />
</div>
: null
}
<Button l10nId='save' disabled={!this.bookmarkNameValid} className='primaryButton' onClick={this.onSave} />
<div id='bookmarkParentFolder' className='bookmarkFormRow'>
<label data-l10n-id='parentFolderField' htmlFor='bookmarkParentFolderk' />
<select value={this.props.currentDetail.get('parentFolderId')}
onChange={this.onParentFolderChange} >
<option value='0' data-l10n-id='bookmarksToolbar' />
{
this.folders.map((folder) => <option value={folder.folderId}>{folder.label}</option>)
}
</select>
</div>
<div className='bookmarkButtons'>
{
this.props.originalDetail
? <Button l10nId='remove' className='primaryButton whiteButton inlineButton' onClick={this.onRemoveBookmark} />
: null
}
<Button l10nId='done' disabled={!this.bookmarkNameValid} className='primaryButton' onClick={this.onSave} />
</div>
</div>
</div>
<div className='bookmarkFormFooter'>
<Button l10nId='viewBookmarks' onClick={this.onViewBookmarks} />
</div>
</div>
</Dialog>
}
Expand Down
10 changes: 1 addition & 9 deletions js/components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const ClearBrowsingDataPanel = require('./clearBrowsingDataPanel')
const ImportBrowserDataPanel = require('../../app/renderer/components/importBrowserDataPanel')
const AutofillAddressPanel = require('./autofillAddressPanel')
const AutofillCreditCardPanel = require('./autofillCreditCardPanel')
const AddEditBookmark = require('./addEditBookmark')
const LoginRequired = require('./loginRequired')
const ReleaseNotes = require('./releaseNotes')
const BookmarksToolbar = require('../../app/renderer/components/bookmarksToolbar')
Expand Down Expand Up @@ -909,6 +908,7 @@ class Main extends ImmutableComponent {
startLoadTime={activeFrame && activeFrame.get('startLoadTime') || undefined}
endLoadTime={activeFrame && activeFrame.get('endLoadTime') || undefined}
loading={activeFrame && activeFrame.get('loading')}
bookmarkDetail={this.props.windowState.get('bookmarkDetail')}
mouseInTitlebar={this.props.windowState.getIn(['ui', 'mouseInTitlebar'])}
searchDetail={this.props.windowState.get('searchDetail')}
enableNoScript={this.enableNoScript(activeSiteSettings)}
Expand Down Expand Up @@ -993,14 +993,6 @@ class Main extends ImmutableComponent {
? <LoginRequired loginRequiredDetail={loginRequiredDetail} tabId={activeFrame.get('tabId')} />
: null
}
{
this.props.windowState.get('bookmarkDetail')
? <AddEditBookmark sites={this.props.appState.get('sites')}
currentDetail={this.props.windowState.getIn(['bookmarkDetail', 'currentDetail'])}
originalDetail={this.props.windowState.getIn(['bookmarkDetail', 'originalDetail'])}
destinationDetail={this.props.windowState.getIn(['bookmarkDetail', 'destinationDetail'])} />
: null
}
{
noScriptIsVisible
? <NoScriptInfo frameProps={activeFrame}
Expand Down
29 changes: 20 additions & 9 deletions js/components/navigationBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const messages = require('../constants/messages')
const settings = require('../constants/settings')
const ipc = global.require('electron').ipcRenderer
const {isSourceAboutUrl} = require('../lib/appUrlUtil')
const AddEditBookmark = require('./addEditBookmark')
const siteUtil = require('../state/siteUtil')
const eventUtil = require('../lib/eventUtil')
const getSetting = require('../settings').getSetting
Expand All @@ -40,7 +41,7 @@ class NavigationBar extends ImmutableComponent {
onToggleBookmark () {
// trigger the AddEditBookmark modal; saving/deleting takes place there
const siteDetail = siteUtil.getDetailFromFrame(this.activeFrame, siteTags.BOOKMARK)
windowActions.setBookmarkDetail(siteDetail, siteDetail)
windowActions.setBookmarkDetail(siteDetail, siteDetail, null, false)
}

onReload (e) {
Expand Down Expand Up @@ -73,6 +74,7 @@ class NavigationBar extends ImmutableComponent {

get titleMode () {
return this.props.mouseInTitlebar === false &&
!this.props.bookmarkDetail &&
this.props.title &&
!['about:blank', 'about:newtab'].includes(this.props.location) &&
!this.loading &&
Expand Down Expand Up @@ -112,6 +114,15 @@ class NavigationBar extends ImmutableComponent {
className={cx({
titleMode: this.titleMode
})}>
{
this.props.bookmarkDetail
? <AddEditBookmark sites={this.props.sites}
currentDetail={this.props.bookmarkDetail.get('currentDetail')}
originalDetail={this.props.bookmarkDetail.get('originalDetail')}
destinationDetail={this.props.bookmarkDetail.get('destinationDetail')}
shouldShowLocation={this.props.bookmarkDetail.get('shouldShowLocation')} />
: null
}
<div className='startButtons'>
{
isSourceAboutUrl(this.props.location) || this.titleMode
Expand All @@ -134,6 +145,14 @@ class NavigationBar extends ImmutableComponent {
onClick={this.onHome} />
: null
}
<Button iconClass={this.bookmarked ? 'fa-star' : 'fa-star-o'}
className={cx({
navbutton: true,
bookmarkButton: true,
removeBookmarkButton: this.bookmarked
})}
l10nId={this.bookmarked ? 'removeBookmarkButton' : 'addBookmarkButton'}
onClick={this.onToggleBookmark} />
</div>
<UrlBar ref='urlBar'
sites={this.props.sites}
Expand Down Expand Up @@ -168,14 +187,6 @@ class NavigationBar extends ImmutableComponent {
})}
onClick={this.onNoScript} />
}
<Button iconClass={this.bookmarked ? 'fa-star' : 'fa-star-o'}
className={cx({
navbutton: true,
bookmarkButton: true,
removeBookmarkButton: this.bookmarked
})}
l10nId={this.bookmarked ? 'removeBookmarkButton' : 'addBookmarkButton'}
onClick={this.onToggleBookmark} />
</div>
}
</div>
Expand Down
6 changes: 3 additions & 3 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const addBookmarkMenuItem = (label, siteDetail, closestDestinationDetail, isPare
if (isParent) {
siteDetail = siteDetail.set('parentFolderId', closestDestinationDetail && (closestDestinationDetail.get('folderId') || closestDestinationDetail.get('parentFolderId')))
}
windowActions.setBookmarkDetail(siteDetail, siteDetail, closestDestinationDetail)
windowActions.setBookmarkDetail(siteDetail, siteDetail, closestDestinationDetail, false)
}
}
}
Expand All @@ -62,7 +62,7 @@ const addFolderMenuItem = (closestDestinationDetail, isParent) => {
if (isParent) {
emptyFolder = emptyFolder.set('parentFolderId', closestDestinationDetail && (closestDestinationDetail.get('folderId') || closestDestinationDetail.get('parentFolderId')))
}
windowActions.setBookmarkDetail(emptyFolder, undefined, closestDestinationDetail)
windowActions.setBookmarkDetail(emptyFolder, undefined, closestDestinationDetail, false)
}
}
}
Expand Down Expand Up @@ -278,7 +278,7 @@ function siteDetailTemplateInit (siteDetail, activeFrame) {
template.push(
{
label: locale.translation(isFolder ? 'editFolder' : 'editBookmark'),
click: () => windowActions.setBookmarkDetail(siteDetail, siteDetail)
click: () => windowActions.setBookmarkDetail(siteDetail, siteDetail, null, true)
},
CommonMenu.separatorMenuItem)
}
Expand Down
3 changes: 2 additions & 1 deletion js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ const doAction = (action) => {
windowState = windowState.mergeIn(['bookmarkDetail'], {
currentDetail: action.currentDetail,
originalDetail: action.originalDetail,
destinationDetail: action.destinationDetail
destinationDetail: action.destinationDetail,
shouldShowLocation: action.shouldShowLocation
})
}
// Since the input values of bookmarks are bound, we need to notify the controls sync.
Expand Down
Loading

0 comments on commit 8865ba7

Please sign in to comment.