-
Notifications
You must be signed in to change notification settings - Fork 484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make left column adjustable in trace detail #74
Changes from 2 commits
dc8f2d4
41eaff4
00e83d3
3cc8d8d
b76d79e
65e8085
ae4c69e
b83dedd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// @flow | ||
|
||
// Copyright (c) 2017 Uber Technologies, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
|
@@ -18,42 +20,52 @@ | |
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import * as React from 'react'; | ||
|
||
import { formatDuration } from './utils'; | ||
|
||
import './Ticks.css'; | ||
|
||
export default function Ticks(props) { | ||
const { labels, ticks } = props; | ||
type TicksProps = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seeing a mixture of flowTypes and propTypes in this review. Let's stick with one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok gotcha |
||
endTime: number, | ||
numTicks: number, | ||
showLabels?: boolean, | ||
startTime: number, | ||
}; | ||
|
||
export default function Ticks(props: TicksProps) { | ||
const { endTime, numTicks, showLabels, startTime } = props; | ||
|
||
let labels: string[]; | ||
if (showLabels) { | ||
labels = []; | ||
const viewingDuration = endTime - startTime; | ||
for (let i = 0; i < numTicks; i++) { | ||
const durationAtTick = startTime + i / (numTicks - 1) * viewingDuration; | ||
labels.push(formatDuration(durationAtTick)); | ||
} | ||
} | ||
const ticks: React.Node[] = []; | ||
for (let i = 0; i < numTicks; i++) { | ||
const portion = i / (numTicks - 1); | ||
ticks.push( | ||
<div | ||
key={portion} | ||
className="span-row-tick" | ||
style={{ | ||
left: `${portion * 100}%`, | ||
}} | ||
> | ||
{labels && | ||
<span className={`span-row-tick-label ${portion >= 1 ? 'is-end-anchor' : ''}`}> | ||
{labels[i]} | ||
</span>} | ||
</div> | ||
); | ||
} | ||
return ( | ||
<div> | ||
{ticks.map( | ||
(tick, i) => | ||
i | ||
? <div | ||
key={tick} | ||
className="span-row-tick" | ||
style={{ | ||
left: `${tick * 100}%`, | ||
}} | ||
> | ||
{labels && | ||
<span className={`span-row-tick-label ${tick >= 1 ? 'is-end-anchor' : ''}`}> | ||
{labels[i]} | ||
</span>} | ||
</div> | ||
: null | ||
)} | ||
{ticks} | ||
</div> | ||
); | ||
} | ||
|
||
Ticks.propTypes = { | ||
ticks: PropTypes.arrayOf(PropTypes.number).isRequired, | ||
labels: PropTypes.arrayOf(PropTypes.string), | ||
}; | ||
|
||
Ticks.defaultProps = { | ||
labels: null, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this is better with
width