-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
240 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,47 @@ | ||
import '../../styles/lapTimes.css'; | ||
import React from 'react'; | ||
|
||
const SIGFIGS = 3; | ||
|
||
const LapTimes = ({ laps, gotoTimeCallback }) => { | ||
if (laps.length === 0) { | ||
return ( | ||
<> | ||
<p className='laptimes_helptext'> | ||
if (laps.length === 0) { | ||
return ( | ||
<> | ||
<p className='laptimes_helptext'> | ||
Right click and drag to draw gates<br /> | ||
Choose the gate type at the top <br /> | ||
Place a start and end to show lap times<br /> | ||
</p> | ||
</> | ||
) | ||
} | ||
return ( | ||
<div className="laptimes_container"> | ||
<a className="laptimes_download" download="laps.json" href={URL.createObjectURL(new Blob([JSON.stringify(laps.toSorted((a, b) => a.start - b.start), null, 4)], { type: `application/json` }))}>Download lap data</a> | ||
{laps.toSorted((a, b) => a.start - b.start).map((lap, index) => { | ||
return ( | ||
<div key={[lap, index]} className="laptimes_lap"> | ||
<button className="laptimes_accordion" onClick={() => gotoTimeCallback(lap.start)}>Lap {index}: {((lap.end - lap.start) / 1000).toFixed(SIGFIGS)}s <span className="laptimes_drilldown">V</span></button> | ||
<div className="laptimes_panel"> | ||
<table> | ||
<tbody> | ||
{lap.checkpoints.map((checkpoint, index) => { | ||
return ( | ||
<tr className="laptimes_tr" key={[checkpoint, index]}> | ||
<td>Checkpoint {index}</td> | ||
<td>{((checkpoint - lap.start) / 1000).toFixed(SIGFIGS)}s</td> | ||
</tr> | ||
) | ||
})} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
) | ||
})} | ||
</div> | ||
) | ||
</p> | ||
</> | ||
); | ||
} | ||
return ( | ||
<div className="laptimes_container"> | ||
<a className="laptimes_download" download="laps.json" href={URL.createObjectURL(new Blob([JSON.stringify(laps.toSorted((a, b) => a.start - b.start), null, 4)], { type: 'application/json' }))}>Download lap data</a> | ||
{laps.toSorted((a, b) => a.start - b.start).map((lap, index) => { | ||
return ( | ||
<div key={[lap, index]} className="laptimes_lap"> | ||
<button className="laptimes_accordion" onClick={() => gotoTimeCallback(lap.start)}>Lap {index}: {((lap.end - lap.start) / 1000).toFixed(SIGFIGS)}s <span className="laptimes_drilldown">V</span></button> | ||
<div className="laptimes_panel"> | ||
<table> | ||
<tbody> | ||
{lap.checkpoints.map((checkpoint, index) => { | ||
return ( | ||
<tr className="laptimes_tr" key={[checkpoint, index]}> | ||
<td>Checkpoint {index}</td> | ||
<td>{((checkpoint - lap.start) / 1000).toFixed(SIGFIGS)}s</td> | ||
</tr> | ||
); | ||
})} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
|
||
} | ||
}; | ||
|
||
export default LapTimes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import { useState } from 'react'; | ||
import React, { useState } from 'react'; | ||
import '../../styles/mapChart.css'; | ||
import MapDisplay from './MapDisplay'; | ||
import LapTimes from './LapTimes'; | ||
|
||
const MapChart = () => { | ||
const [laps, setLaps] = useState([]); | ||
const [gotoTime, setGotoTime] = useState(0); | ||
return ( | ||
<div className="map_container"> | ||
<div className="map_display_container"> | ||
<MapDisplay setLapsCallback={setLaps} gotoTime={gotoTime} /> | ||
</div> | ||
<div className="map_laptime_container"> | ||
<LapTimes laps={laps} gotoTimeCallback={setGotoTime} /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
const [laps, setLaps] = useState([]); | ||
const [gotoTime, setGotoTime] = useState(0); | ||
return ( | ||
<div className="map_container"> | ||
<div className="map_display_container"> | ||
<MapDisplay setLapsCallback={setLaps} gotoTime={gotoTime} /> | ||
</div> | ||
<div className="map_laptime_container"> | ||
<LapTimes laps={laps} gotoTimeCallback={setGotoTime} /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default MapChart; |
Oops, something went wrong.