Skip to content

Commit

Permalink
[desk-tool] Render basic timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard authored and rexxars committed Oct 6, 2020
1 parent 0f4bbca commit 24a7a9b
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {Timeline} from './history/timeline'
import InspectView from './inspect/InspectView'
import {ChangesPanel} from './changesPanel/ChangesPanel'
import RevisionSummary from './RevisionSummary'
import HistoryTimeline from './HistoryTimeline'
import {HistoryTimelinePanel} from './historyTimelinePanel'
import FormView from './FormView'
import {Validation} from './Validation'
import {DocumentHeaderTitle} from './DocumentHeaderTitle'
Expand Down Expand Up @@ -314,7 +314,11 @@ function DocumentPane(props: Props) {

<div className={styles.container}>
{isHistoryOpen && (
<HistoryTimeline timeline={timeline} onSelect={time => toggleHistory(time)} />
<HistoryTimelinePanel
timeline={timeline}
onSelect={time => toggleHistory(time)}
startTimeId={startTimeId}
/>
)}

<div className={styles.editorContainer} key="editor">
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.root {
/* display: block; */
overflow: auto;
}

.header {
padding: 1em;
font-weight: 700;
}

.item {
padding: 1em;

@nest &:hover {
background: rgba(0, 0, 0, 0.1);
}

@nest &[data-selected='true'] {
background: #06f;
color: #fff;
}
}

.item__typeName {
/* display: block; */
}

.item__timestamp {
font-size: 13px;
line-height: 16px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react'
import {format} from 'date-fns'
import {Timeline, TimeRef} from '../history/timeline'

import styles from './historyTimelinePanel.css'

interface HistoryTimelinePanelProps {
timeline: Timeline
onSelect: (id: string) => void
startTimeId?: string
}

export function HistoryTimelinePanel(props: HistoryTimelinePanelProps) {
const {timeline, onSelect} = props

return (
<div className={styles.root}>
<div className={styles.header}>Timeline</div>

{timeline.mapChunks((chunk, idx) => {
const startTimeId = timeline.createTimeId(idx, chunk)
const isSelected = props.startTimeId === startTimeId

return (
<div
className={styles.item}
data-selected={isSelected}
key={chunk.id}
title={chunk.id}
onClick={evt => {
evt.preventDefault()
evt.stopPropagation()
onSelect(startTimeId)
}}
>
<div className={styles.item__typeName}>{chunk.type}</div>
<div className={styles.item__timestamp}>{format(chunk.startTimestamp)}</div>
</div>
)
})}
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './historyTimelinePanel'

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 24a7a9b

Please sign in to comment.