Files
flipper/desktop/plugins/navigation/components/Timeline.tsx
Pascal Hartig fc9ed65762 prettier 2
Summary:
Quick notes:

- This looks worse than it is. It adds mandatory parentheses to single argument lambdas. Lots of outrage on Twitter about it, personally I'm {emoji:1f937_200d_2642} about it.
- Space before function, e.g. `a = function ()` is now enforced. I like this because both were fine before.
- I added `eslint-config-prettier` to the config because otherwise a ton of rules conflict with eslint itself.

Close https://github.com/facebook/flipper/pull/915

Reviewed By: jknoxville

Differential Revision: D20594929

fbshipit-source-id: ca1c65376b90e009550dd6d1f4e0831d32cbff03
2020-03-24 09:38:11 -07:00

96 lines
2.4 KiB
TypeScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {colors, FlexCenter, styled} from 'flipper';
import {NavigationInfoBox} from './';
import {Bookmark, NavigationEvent, URI} from '../types';
import React, {useRef} from 'react';
type Props = {
bookmarks: Map<string, Bookmark>;
events: Array<NavigationEvent>;
onNavigate: (uri: URI) => void;
onFavorite: (uri: URI) => void;
};
const TimelineLine = styled.div({
width: 2,
backgroundColor: colors.highlight,
position: 'absolute',
top: 38,
bottom: 0,
});
const TimelineContainer = styled.div({
position: 'relative',
paddingLeft: 25,
overflowY: 'scroll',
flexGrow: 1,
backgroundColor: colors.light02,
scrollBehavior: 'smooth',
'&>div': {
position: 'relative',
minHeight: '100%',
'&:last-child': {
paddingBottom: 25,
},
},
});
const NavigationEventContainer = styled.div({
display: 'flex',
paddingTop: 25,
paddingLeft: 25,
marginRight: 25,
});
const NoData = styled(FlexCenter)({
height: '100%',
fontSize: 18,
backgroundColor: colors.macOSTitleBarBackgroundBlur,
color: colors.macOSTitleBarIcon,
});
export default (props: Props) => {
const {bookmarks, events, onNavigate, onFavorite} = props;
const timelineRef = useRef<HTMLDivElement>(null);
return events.length === 0 ? (
<NoData>No Navigation Events to Show</NoData>
) : (
<TimelineContainer ref={timelineRef}>
<div>
<TimelineLine />
{events.map((event: NavigationEvent, idx: number) => {
return (
<NavigationEventContainer>
<NavigationInfoBox
key={idx}
isBookmarked={
event.uri != null ? bookmarks.has(event.uri) : false
}
className={event.className}
uri={event.uri}
onNavigate={(uri) => {
if (timelineRef.current != null) {
timelineRef.current.scrollTo(0, 0);
}
onNavigate(uri);
}}
onFavorite={onFavorite}
screenshot={event.screenshot}
date={event.date}
/>
</NavigationEventContainer>
);
})}
</div>
</TimelineContainer>
);
};