-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from manojVivek/improvement/bookmarks
Bookmarks UX improvement
- Loading branch information
Showing
15 changed files
with
444 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,10 @@ body { | |
overflow: hidden; | ||
} | ||
|
||
svg { | ||
pointer-events: none; | ||
} | ||
|
||
/*h2 { | ||
margin: 0; | ||
font-size: 2.25rem; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,112 @@ | ||
// @flow | ||
import React, { useState } from 'react'; | ||
import React, {useState} from 'react'; | ||
import Grid from '@material-ui/core/Grid'; | ||
import Button from '@material-ui/core/Button'; | ||
import Menu from '@material-ui/core/Menu'; | ||
import MenuItem from '@material-ui/core/MenuItem'; | ||
import BookmarkEditDialog from './BookmarkEditDialog' | ||
import styles from './style.css'; | ||
import BookmarkEditDialog from './BookmarkEditDialog'; | ||
import styles from './style.module.css'; | ||
import Globe from '../icons/Globe'; | ||
|
||
export const BookmarksBar = function ({bookmarks, onBookmarkClick, onBookmarkDelete, onBookmarkEdit}) { | ||
return <Grid container direction="row" justify="flex-start" alignItems="center" className={styles.bookmarks} spacing={1}> | ||
{bookmarks.map((bookmark, k) => ( | ||
<BookmarkItem bookmark={bookmark} onClick={onBookmarkClick} key={'bookmark' + k} onDelete={onBookmarkDelete} onEdit={onBookmarkEdit}/> | ||
))} | ||
</Grid> | ||
export const BookmarksBar = function({ | ||
bookmarks, | ||
onBookmarkClick, | ||
onBookmarkDelete, | ||
onBookmarkEdit, | ||
}) { | ||
return ( | ||
<div className={styles.bookmarks}> | ||
{bookmarks.map((bookmark, k) => ( | ||
<BookmarkItem | ||
bookmark={bookmark} | ||
onClick={onBookmarkClick} | ||
key={'bookmark' + k} | ||
onDelete={onBookmarkDelete} | ||
onEdit={onBookmarkEdit} | ||
/> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
const useToggle = function () { | ||
const [value, setValue] = useState(false) | ||
const useToggle = function() { | ||
const [value, setValue] = useState(false); | ||
return [ | ||
value, | ||
function () { setValue(true) }, | ||
function () { setValue(false) } | ||
] | ||
} | ||
function() { | ||
setValue(true); | ||
}, | ||
function() { | ||
setValue(false); | ||
}, | ||
]; | ||
}; | ||
|
||
function BookmarkItem ({bookmark, onClick, onDelete, onEdit}) { | ||
function BookmarkItem({bookmark, onClick, onDelete, onEdit}) { | ||
const [anchorEl, setAnchorEl] = useState(null); | ||
const [renameDialog, openRenameDialog, closeRenameDialog] = useToggle(null) | ||
const [renameDialog, openRenameDialog, closeRenameDialog] = useToggle(null); | ||
|
||
const handleContextMenu = function (event) { | ||
const handleContextMenu = function(event) { | ||
event.preventDefault(); | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
|
||
const handleClose = function () { | ||
const handleClose = function() { | ||
setAnchorEl(null); | ||
}; | ||
|
||
const handleClick = function () { | ||
onClick(bookmark) | ||
const handleClick = function() { | ||
onClick(bookmark); | ||
}; | ||
|
||
const handleDelete = function () { | ||
onDelete(bookmark) | ||
const handleDelete = function() { | ||
setAnchorEl(null); | ||
onDelete(bookmark); | ||
}; | ||
|
||
const handleRename = function (title, url) { | ||
onEdit(bookmark, {title, url}) | ||
setAnchorEl(null) | ||
} | ||
const handleRename = function(title, url) { | ||
onEdit(bookmark, {title, url}); | ||
setAnchorEl(null); | ||
}; | ||
|
||
const closeDialog = function () { | ||
closeRenameDialog() | ||
setAnchorEl(null) | ||
} | ||
const closeDialog = function() { | ||
closeRenameDialog(); | ||
setAnchorEl(null); | ||
}; | ||
|
||
return <Grid item key={bookmark.url}> | ||
<Button aria-controls="bookmark-menu" aria-haspopup="true" onClick={handleClick} onContextMenu={handleContextMenu}> | ||
{bookmark.title} | ||
</Button> | ||
<Menu | ||
id="bookmark-menu" | ||
anchorEl={anchorEl} | ||
keepMounted | ||
open={Boolean(anchorEl)} | ||
onClose={handleClose} | ||
> | ||
<MenuItem onClick={openRenameDialog}>Rename</MenuItem> | ||
<MenuItem onClick={handleDelete}>Delete</MenuItem> | ||
</Menu> | ||
<BookmarkEditDialog open={renameDialog} onSubmit={handleRename} onClose={closeDialog} bookmark={bookmark}/> | ||
</Grid> | ||
return ( | ||
<> | ||
<div | ||
className={styles.bookmarkItem} | ||
key={bookmark.url} | ||
onClick={handleClick} | ||
onContextMenu={handleContextMenu} | ||
> | ||
<Globe height={10} className={styles.icon} /> | ||
<span>{bookmark.title}</span> | ||
</div> | ||
<Menu | ||
id="bookmark-menu" | ||
anchorEl={anchorEl} | ||
keepMounted | ||
open={Boolean(anchorEl)} | ||
onClose={handleClose} | ||
anchorOrigin={{ | ||
vertical: 'bottom', | ||
horizontal: 'center', | ||
}} | ||
getContentAnchorEl={null} | ||
onContextMenu={handleClose} | ||
> | ||
<MenuItem onClick={openRenameDialog}>Edit</MenuItem> | ||
<MenuItem onClick={handleDelete}>Delete</MenuItem> | ||
</Menu> | ||
<BookmarkEditDialog | ||
open={renameDialog} | ||
onSubmit={handleRename} | ||
onClose={closeDialog} | ||
bookmark={bookmark} | ||
/> | ||
</> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.bookmarks { | ||
padding: 0 10px; | ||
display: flex; | ||
margin-top: 4px; | ||
} | ||
|
||
.bookmarkItem { | ||
color: #ffffffcc; | ||
fill: #ffffffcc; | ||
cursor: default; | ||
padding: 2px 10px; | ||
border-radius: 15px; | ||
font-size: 13px; | ||
min-width: 100px; | ||
max-width: 150px; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
|
||
.bookmarkItem:hover { | ||
background-color: #6075ef; | ||
fill: #fff; | ||
} | ||
|
||
.icon { | ||
margin-right: 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.