Skip to content

Commit 07eb557

Browse files
committed
add dynamic telemetry story for standings/relative for debug
1 parent 98377f2 commit 07eb557

File tree

3 files changed

+115
-1
lines changed

3 files changed

+115
-1
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import React from 'react';
2+
3+
// Predefined list of test data directories
4+
export const TEST_DATA_DIRS = [
5+
'1731637331038', // MultiClassPCCWithClio
6+
'1732274253573', // SupercarsRace
7+
'1732260478001', // AdvancedMX5
8+
'1732355190142', // GT3Practice
9+
'1735296198162', // PCCPacing
10+
'1731391056221', // MultiClassPCC
11+
'1732359661942', // GT3Race
12+
'1731732047131', // LegendsQualifying
13+
'1733030013074', // PCCRaceWithMicUse
14+
];
15+
16+
interface DynamicTelemetrySelectorProps {
17+
onPathChange: (path: string) => void;
18+
initialPath?: string;
19+
}
20+
21+
export const DynamicTelemetrySelector: React.FC<DynamicTelemetrySelectorProps> = ({
22+
onPathChange,
23+
initialPath = '/test-data/1735296198162',
24+
}) => {
25+
const [selectedPath, setSelectedPath] = React.useState(initialPath);
26+
const [isManualInput, setIsManualInput] = React.useState(false);
27+
28+
const handlePathChange = (newPath: string) => {
29+
setSelectedPath(newPath);
30+
onPathChange(newPath);
31+
};
32+
33+
return (
34+
<div style={{ marginBottom: '1rem', display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
35+
<div style={{ display: 'flex', gap: '0.5rem', alignItems: 'center' }}>
36+
<input
37+
type="checkbox"
38+
id="manual-input"
39+
checked={isManualInput}
40+
onChange={(e) => setIsManualInput(e.target.checked)}
41+
/>
42+
<label htmlFor="manual-input">Manual path input</label>
43+
</div>
44+
45+
{isManualInput ? (
46+
<input
47+
type="text"
48+
value={selectedPath}
49+
onChange={(e) => handlePathChange(e.target.value)}
50+
placeholder="Enter full telemetry path"
51+
style={{ padding: '0.5rem' }}
52+
/>
53+
) : (
54+
<select
55+
value={selectedPath}
56+
onChange={(e) => handlePathChange(e.target.value)}
57+
style={{ padding: '0.5rem' }}
58+
>
59+
{TEST_DATA_DIRS.map((dir) => (
60+
<option key={dir} value={`/test-data/${dir}`}>
61+
{dir}
62+
</option>
63+
))}
64+
</select>
65+
)}
66+
</div>
67+
);
68+
};

src/frontend/components/Standings/Relative.stories.tsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,45 @@
11
import { Meta, StoryObj } from '@storybook/react';
22
import { Relative } from './Relative';
33
import { TelemetryDecorator } from '../../../../.storybook/telemetryDecorator';
4+
import { DynamicTelemetrySelector, TEST_DATA_DIRS } from './DynamicTelemetrySelector';
5+
import { useState } from 'react';
46

57
export default {
68
component: Relative,
7-
} as Meta;
9+
parameters: {
10+
controls: {
11+
exclude: ['telemetryPath'],
12+
},
13+
},
14+
loaders: [
15+
async () => {
16+
return { testDataDirs: TEST_DATA_DIRS };
17+
},
18+
],
19+
} as Meta<typeof Relative>;
820

921
type Story = StoryObj<typeof Relative>;
1022

1123
export const Primary: Story = {
1224
decorators: [TelemetryDecorator()],
1325
};
1426

27+
export const DynamicTelemetry: Story = {
28+
decorators: [(Story, context) => {
29+
const [selectedPath, setSelectedPath] = useState('/test-data/1735296198162');
30+
31+
return (
32+
<>
33+
<DynamicTelemetrySelector
34+
onPathChange={setSelectedPath}
35+
initialPath={selectedPath}
36+
/>
37+
{TelemetryDecorator(selectedPath)(Story, context)}
38+
</>
39+
);
40+
}],
41+
};
42+
1543
export const MultiClassPCCWithClio: Story = {
1644
decorators: [TelemetryDecorator('/test-data/1731637331038')],
1745
};

src/frontend/components/Standings/Standings.stories.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Meta, StoryObj } from '@storybook/react';
22
import { Standings } from './Standings';
33
import { TelemetryDecorator } from '../../../../.storybook/telemetryDecorator';
4+
import { DynamicTelemetrySelector } from './DynamicTelemetrySelector';
5+
import { useState } from 'react';
46

57
export default {
68
component: Standings,
@@ -12,6 +14,22 @@ export const Primary: Story = {
1214
decorators: [TelemetryDecorator()],
1315
};
1416

17+
export const DynamicTelemetry: Story = {
18+
decorators: [(Story, context) => {
19+
const [selectedPath, setSelectedPath] = useState('/test-data/1735296198162');
20+
21+
return (
22+
<>
23+
<DynamicTelemetrySelector
24+
onPathChange={setSelectedPath}
25+
initialPath={selectedPath}
26+
/>
27+
{TelemetryDecorator(selectedPath)(Story, context)}
28+
</>
29+
);
30+
}],
31+
};
32+
1533
export const MultiClassPCC: Story = {
1634
decorators: [TelemetryDecorator('/test-data/1731391056221')],
1735
};

0 commit comments

Comments
 (0)