diff --git a/src/plugins/navigation/components/NavigationInfoBox.tsx b/src/plugins/navigation/components/NavigationInfoBox.tsx index ae2289587..875fafd4e 100644 --- a/src/plugins/navigation/components/NavigationInfoBox.tsx +++ b/src/plugins/navigation/components/NavigationInfoBox.tsx @@ -5,101 +5,200 @@ * @format */ -import {styled} from 'flipper'; -import {parseURIParameters} from '../util/uri'; -import IconButton from './IconButton'; -import FavoriteButton from './FavoriteButton'; +import { + styled, + colors, + ManagedTable, + TableBodyRow, + FlexCenter, + LoadingIndicator, + Button, + Glyph, +} from 'flipper'; +import {parseURIParameters, stripQueryParameters} from '../util/uri'; import React from 'react'; +const BOX_HEIGHT = 240; + type Props = { isBookmarked: boolean; uri: string | null; className: string | null; onNavigate: (query: string) => void; onFavorite: (query: string) => void; + screenshot: string | null; + date: Date | null; }; -const NavigationInfoBoxContainer = styled('div')({ - backgroundColor: '#FDFDEA', - maxWidth: 500, - height: 'fit-content', - padding: 20, - borderRadius: 10, - margin: 20, - width: 'fit-content', +const ScreenshotContainer = styled('div')({ + width: 200, + minWidth: 200, + overflow: 'hidden', + borderLeft: `1px ${colors.blueGreyTint90} solid`, position: 'relative', - '.nav-info-text': { - color: '#707070', - fontSize: '1.2em', - lineHeight: '1.25em', - wordWrap: 'break-word', - }, - '.nav-info-text.bold': { - fontWeight: 'bold', - marginTop: '10px', - }, - '.nav-info-text.selectable': { - userSelect: 'text', - cursor: 'text', - }, - '.icon-container': { - display: 'inline-flex', - padding: 5, - position: 'absolute', - top: 0, - right: 0, - '>*': { - marginRight: 2, - }, + img: { + width: '100%', }, }); +const NoData = styled('div')({ + color: colors.light30, + fontSize: 14, +}); + +const NavigationDataContainer = styled('div')({ + alignItems: 'flex-start', + flexGrow: 1, + position: 'relative', +}); + +const Footer = styled('div')({ + width: '100%', + padding: '10px', + borderTop: `1px ${colors.blueGreyTint90} solid`, + display: 'flex', + alignItems: 'center', +}); + +const Seperator = styled('div')({ + flexGrow: 1, +}); + +const TimeContainer = styled('div')({ + color: colors.light30, + fontSize: 14, +}); + +const NavigationInfoBoxContainer = styled('div')({ + display: 'flex', + height: BOX_HEIGHT, + borderRadius: 10, + flexGrow: 1, + overflow: 'hidden', + marginBottom: 10, + backgroundColor: colors.white, + boxShadow: '1px 1px 5px rgba(0,0,0,0.1)', +}); + +const Header = styled('div')({ + fontSize: 18, + fontWeight: 500, + userSelect: 'text', + cursor: 'text', + padding: 10, + borderBottom: `1px ${colors.blueGreyTint90} solid`, + display: 'flex', +}); + +const ClassNameContainer = styled('div')({ + color: colors.light30, +}); + +const ParametersContainer = styled('div')({ + height: 150, + '&>*': { + height: 150, + marginBottom: 20, + }, +}); + +const NoParamters = styled(FlexCenter)({ + fontSize: 18, + color: colors.light10, +}); + +const buildParameterTable = (parameters: Map) => { + const tableRows: Array = []; + let idx = 0; + parameters.forEach((parameter_value, parameter) => { + tableRows.push({ + key: idx.toString(), + columns: { + parameter: { + value: parameter, + }, + value: { + value: parameter_value, + }, + }, + }); + idx++; + }); + return ( + + ); +}; + export default (props: Props) => { - const {uri, isBookmarked, className} = props; + const { + uri, + isBookmarked, + className, + screenshot, + onNavigate, + onFavorite, + date, + } = props; if (uri == null && className == null) { - return ( - -
View has no URI information
-
- ); + return Unknown Navigation Event; } else { const parameters = uri != null ? parseURIParameters(uri) : null; return ( - {uri != null ? ( - <> -
- props.onFavorite(uri)} - /> - props.onNavigate(uri)} - /> -
-
uri:
-
{uri}
- {parameters != null && parameters.size > 0 ? ( + +
+ {uri != null ? stripQueryParameters(uri) : ''} + + {className != null ? ( <> -
parameters:
- {Array.from(parameters, ([key, value]) => ( -
- {key} - {value ? `: ${value}` : ''} -
- ))} + +   + + {className != null ? className : ''} + ) : null} - - ) : null} - {className != null ? ( - <> -
Class Name:
-
{className}
- +
+ + {parameters != null && parameters.size > 0 ? ( + buildParameterTable(parameters) + ) : ( + No Parameters for this Event + )} + +
+ {uri != null ? ( + <> + + + + ) : null} + + + {date != null ? date.toTimeString() : ''} + +
+
+ {uri != null || className != null ? ( + + {screenshot != null ? ( + + ) : ( + + + + )} + ) : null}
); diff --git a/src/plugins/navigation/components/Timeline.tsx b/src/plugins/navigation/components/Timeline.tsx index ac4822e59..a2979436b 100644 --- a/src/plugins/navigation/components/Timeline.tsx +++ b/src/plugins/navigation/components/Timeline.tsx @@ -5,10 +5,10 @@ * @format */ -import {colors, FlexCenter, styled, LoadingIndicator} from 'flipper'; +import {colors, FlexCenter, styled} from 'flipper'; import {NavigationInfoBox} from './'; import {Bookmark, NavigationEvent, URI} from '../types'; -import React from 'react'; +import React, {useRef} from 'react'; type Props = { bookmarks: Map; @@ -20,6 +20,8 @@ type Props = { const TimelineContainer = styled('div')({ overflowY: 'scroll', flexGrow: 1, + backgroundColor: colors.light02, + scrollBehavior: 'smooth', }); const NavigationEventContainer = styled('div')({ @@ -34,38 +36,16 @@ const NoData = styled(FlexCenter)({ color: colors.macOSTitleBarIcon, }); -const ScreenshotContainer = styled('div')({ - width: 200, - minWidth: 200, - margin: 10, - border: `1px solid ${colors.highlight}`, - borderRadius: '10px', - overflow: 'hidden', - img: { - width: '100%', - }, -}); - export default (props: Props) => { const {bookmarks, events, onNavigate, onFavorite} = props; + const timelineRef = useRef(null); return events.length === 0 ? ( No Navigation Events to Show ) : ( - + {events.map((event: NavigationEvent, idx: number) => { return ( - {event.uri != null || event.className != null ? ( - - {event.screenshot != null ? ( - - ) : ( - - - - )} - - ) : null} { } className={event.className} uri={event.uri} - onNavigate={onNavigate} + onNavigate={uri => { + if (timelineRef.current != null) { + timelineRef.current.scrollTo(0, 0); + } + onNavigate(uri); + }} onFavorite={onFavorite} + screenshot={event.screenshot} + date={event.date} /> ); diff --git a/src/plugins/navigation/util/uri.tsx b/src/plugins/navigation/util/uri.tsx index ed4f96aef..443905d5e 100644 --- a/src/plugins/navigation/util/uri.tsx +++ b/src/plugins/navigation/util/uri.tsx @@ -86,3 +86,7 @@ export const liveEdit = (uri: string, formValues: Array) => { } }); }; + +export const stripQueryParameters = (uri: string) => { + return uri.replace(/\?.*$/g, ''); +};