Added navigation ability to bookmarks sidebar

Summary: I've added the ability to navigate to different pages in the app via the bookmarks sidebar. Still no way to add bookmarks yet.

Reviewed By: jknoxville

Differential Revision: D16438415

fbshipit-source-id: f7dcda1add701eba8655518fba7cb9a82cf49ca1
This commit is contained in:
Benjamin Elo
2019-07-23 09:45:16 -07:00
committed by Facebook Github Bot
parent 294d158869
commit 66bed16333
2 changed files with 54 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ import type {Bookmark} from '../';
type Props = {|
bookmarks: Array<Bookmark>,
onNavigate: string => void,
|};
const NoData = styled(FlexCenter)({
@@ -19,11 +20,61 @@ const NoData = styled(FlexCenter)({
color: colors.macOSTitleBarIcon,
});
const BookmarksList = styled('div')({
color: colors.macOSTitleBarIcon,
overflowY: 'scroll',
overflowX: 'hidden',
height: '100%',
'.bookmark-container': {
width: '100%',
padding: '5px 10px',
cursor: 'pointer',
},
'.bookmark-container:hover': {
backgroundColor: 'rgba(155, 155, 155, 0.2)',
},
'.bookmark-container:active': {
backgroundColor: '#4d84f5',
color: '#FFF',
},
'.bookmark-common-name': {
fontSize: 14,
overflowX: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
lineHeight: 1.2,
},
'.bookmark-uri': {
fontSize: 10,
overflowX: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
lineHeight: 1.2,
},
});
export default (props: Props) => {
const {bookmarks} = props;
const {bookmarks, onNavigate} = props;
return (
<DetailSidebar>
{bookmarks.length === 0 ? <NoData grow>No Bookmarks</NoData> : null}
{bookmarks.length === 0 ? (
<NoData grow>No Bookmarks</NoData>
) : (
<BookmarksList>
{bookmarks.map(bookmark => (
<div
className="bookmark-container"
role="button"
tabIndex={0}
onClick={() => {
onNavigate(bookmark.uri);
}}>
<div className="bookmark-common-name">{bookmark.commonName}</div>
<div className="bookmark-uri">{bookmark.uri}</div>
</div>
))}
</BookmarksList>
)}
</DetailSidebar>
);
};

View File

@@ -87,7 +87,7 @@ export default class extends FlipperPlugin<State, {}, PersistedState> {
onFavorite={(query: string) => {}}
/>
<Timeline events={navigationEvents} onNavigate={this.navigateTo} />
<BookmarksSidebar bookmarks={bookmarks} />
<BookmarksSidebar bookmarks={bookmarks} onNavigate={this.navigateTo} />
</ScrollableFlexColumn>
);
}