Bookmarks UI overhaul

Summary: I've made some slight changes to how bookmarks are displayed in the app, and added the ability to remove them from the tab.

Reviewed By: danielbuechele

Differential Revision: D17154083

fbshipit-source-id: 587e1e0f6f79f461c92e4866f4a59608a6173ccb
This commit is contained in:
Benjamin Elo
2019-09-02 06:34:23 -07:00
committed by Facebook Github Bot
parent 74562148f8
commit ffb505ce4c
2 changed files with 53 additions and 21 deletions

View File

@@ -7,11 +7,13 @@
import {DetailSidebar, FlexCenter, styled, colors} from 'flipper'; import {DetailSidebar, FlexCenter, styled, colors} from 'flipper';
import {Bookmark, URI} from '../types'; import {Bookmark, URI} from '../types';
import {IconButton} from './';
import React from 'react'; import React from 'react';
type Props = { type Props = {
bookmarks: Map<string, Bookmark>; bookmarks: Map<string, Bookmark>;
onNavigate: (uri: URI) => void; onNavigate: (uri: URI) => void;
onRemove: (uri: URI) => void;
}; };
const NoData = styled(FlexCenter)({ const NoData = styled(FlexCenter)({
@@ -20,21 +22,25 @@ const NoData = styled(FlexCenter)({
}); });
const BookmarksList = styled('div')({ const BookmarksList = styled('div')({
color: colors.macOSTitleBarIcon,
overflowY: 'scroll', overflowY: 'scroll',
overflowX: 'hidden', overflowX: 'hidden',
height: '100%', height: '100%',
backgroundColor: colors.white,
'.bookmark-container': { '.bookmark-container': {
width: '100%', width: '100%',
padding: '5px 10px', padding: '10px',
cursor: 'pointer', cursor: 'pointer',
}, borderBottom: `1px ${colors.greyTint} solid`,
'.bookmark-container:hover': {
backgroundColor: 'rgba(155, 155, 155, 0.2)',
}, },
'.bookmark-container:active': { '.bookmark-container:active': {
backgroundColor: '#4d84f5', backgroundColor: colors.highlight,
color: '#FFF', color: colors.white,
},
'.bookmarks-title': {
backgroundColor: colors.light02,
padding: '10px',
borderBottom: `1px ${colors.greyTint} solid`,
fontWeight: 'bold',
}, },
'.bookmark-common-name': { '.bookmark-common-name': {
fontSize: 14, fontSize: 14,
@@ -42,6 +48,10 @@ const BookmarksList = styled('div')({
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
textOverflow: 'ellipsis', textOverflow: 'ellipsis',
lineHeight: 1.2, lineHeight: 1.2,
fontWeight: 'bold',
},
'.bookmark-container:active>.bookmark-uri': {
color: colors.white,
}, },
'.bookmark-uri': { '.bookmark-uri': {
fontSize: 10, fontSize: 10,
@@ -49,24 +59,41 @@ const BookmarksList = styled('div')({
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
textOverflow: 'ellipsis', textOverflow: 'ellipsis',
lineHeight: 1.2, lineHeight: 1.2,
color: colors.greyTint3,
}, },
}); });
const DeleteButton = styled('div')({
padding: 10,
float: 'right',
});
const alphabetizeBookmarkCompare = (b1: Bookmark, b2: Bookmark) => { const alphabetizeBookmarkCompare = (b1: Bookmark, b2: Bookmark) => {
return b1.uri < b2.uri ? -1 : b1.uri > b2.uri ? 1 : 0; return b1.uri < b2.uri ? -1 : b1.uri > b2.uri ? 1 : 0;
}; };
export default (props: Props) => { export default (props: Props) => {
const {bookmarks, onNavigate} = props; const {bookmarks, onNavigate, onRemove} = props;
return ( return (
<DetailSidebar> <DetailSidebar>
{bookmarks.size === 0 ? ( {bookmarks.size === 0 ? (
<NoData grow>No Bookmarks</NoData> <NoData grow>No Bookmarks</NoData>
) : ( ) : (
<BookmarksList> <BookmarksList>
<div className="bookmarks-title">Bookmarks</div>
{[...bookmarks.values()] {[...bookmarks.values()]
.sort(alphabetizeBookmarkCompare) .sort(alphabetizeBookmarkCompare)
.map((bookmark, idx) => ( .map((bookmark, idx) => (
<>
<DeleteButton>
<IconButton
color={colors.macOSTitleBarButtonBackgroundActive}
outline={false}
icon="cross-circle"
size={16}
onClick={() => onRemove(bookmark.uri)}
/>
</DeleteButton>
<div <div
key={idx} key={idx}
className="bookmark-container" className="bookmark-container"
@@ -80,6 +107,7 @@ export default (props: Props) => {
</div> </div>
<div className="bookmark-uri">{bookmark.uri}</div> <div className="bookmark-uri">{bookmark.uri}</div>
</div> </div>
</>
))} ))}
</BookmarksList> </BookmarksList>
)} )}

View File

@@ -206,7 +206,11 @@ export default class extends FlipperPlugin<State, {}, PersistedState> {
onNavigate={this.navigateTo} onNavigate={this.navigateTo}
onFavorite={this.onFavorite} onFavorite={this.onFavorite}
/> />
<BookmarksSidebar bookmarks={bookmarks} onNavigate={this.navigateTo} /> <BookmarksSidebar
bookmarks={bookmarks}
onRemove={this.removeBookmark}
onNavigate={this.navigateTo}
/>
<SaveBookmarkDialog <SaveBookmarkDialog
shouldShow={shouldShowSaveBookmarkDialog} shouldShow={shouldShowSaveBookmarkDialog}
uri={saveBookmarkURI} uri={saveBookmarkURI}