Skip to content

Commit 62b59d6

Browse files
committed
Update style
- Add a color palatte - Create css color variables - Fix hide/show sticky arrow for c-source - Update fonts - Make GotoStart and GotoEnd arrow buttons in the main log panel - Remove "Show Full Log" button and instead show all C lines in the main log panel if someone closes the c-source view - Fix a lot of alignment issues
1 parent bf467bf commit 62b59d6

File tree

7 files changed

+718
-573
lines changed

7 files changed

+718
-573
lines changed

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
["Long Program", "https://gist.githubusercontent.com/theihor/1bea72b50f6834c00b67a3087304260e/raw/9c0cb831a4924e5f0f63cc1e0d9620aec771d31f/pyperf600-v1.log"],
1818
];
1919
</script>
20+
<link rel="preconnect" href="https://fonts.googleapis.com">
21+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
22+
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&family=Roboto:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
2023
<link rel="manifest" href="manifest.json" />
2124
<title>BPF Verifier Visualizer</title>
2225
</head>

src/App.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe("App", () => {
7272
);
7373

7474
// Need to show all log lines
75-
const checkboxEl = document.getElementById("show-full-log");
75+
const checkboxEl = document.getElementById("csource-toggle");
7676
if (!checkboxEl) {
7777
throw new Error(DOM_EL_FAIL);
7878
}

src/App.tsx

Lines changed: 60 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
VisualLogState,
2323
LogLineState,
2424
HoveredLineHint,
25-
LoadStatus,
2625
MainContent,
2726
SelectedLineHint,
2827
ToolTip,
@@ -37,6 +36,7 @@ function getEmptyVisualLogState(): VisualLogState {
3736
logLineIdxToVisualIdx: new Map(),
3837
cLines: [],
3938
cLineIdToVisualIdx: new Map(),
39+
showFullLog: false,
4040
};
4141
}
4242

@@ -50,11 +50,11 @@ function getEmptyLogLineState(): LogLineState {
5050

5151
function getVisualLogState(
5252
verifierLogState: VerifierLogState,
53-
fullLogView: boolean,
53+
showFullLog: boolean,
5454
): VisualLogState {
5555
const [logLines, logLineIdxToVisualIdx] = getVisibleLogLines(
5656
verifierLogState,
57-
fullLogView,
57+
showFullLog,
5858
);
5959
const [cLines, cLineIdToVisualIdx] = getVisibleCLines(verifierLogState);
6060
return {
@@ -63,6 +63,7 @@ function getVisualLogState(
6363
logLineIdxToVisualIdx,
6464
cLines,
6565
cLineIdToVisualIdx,
66+
showFullLog,
6667
};
6768
}
6869

@@ -79,6 +80,9 @@ const ContentRaw = ({
7980
handleLogLinesOver,
8081
handleLogLinesOut,
8182
handleStateRowClick,
83+
handleFullLogToggle,
84+
onGotoStart,
85+
onGotoEnd,
8286
}: {
8387
loadError: string | null;
8488
visualLogState: VisualLogState;
@@ -92,6 +96,9 @@ const ContentRaw = ({
9296
handleLogLinesOver: (event: React.MouseEvent<HTMLDivElement>) => void;
9397
handleLogLinesOut: (event: React.MouseEvent<HTMLDivElement>) => void;
9498
handleStateRowClick: (event: React.MouseEvent<HTMLDivElement>) => void;
99+
handleFullLogToggle: () => void;
100+
onGotoStart: () => void;
101+
onGotoEnd: () => void;
95102
}) => {
96103
if (loadError) {
97104
return <div>{loadError}</div>;
@@ -108,14 +115,17 @@ const ContentRaw = ({
108115
handleLogLinesOver={handleLogLinesOver}
109116
handleLogLinesOut={handleLogLinesOut}
110117
handleStateRowClick={handleStateRowClick}
118+
handleFullLogToggle={handleFullLogToggle}
119+
onGotoStart={onGotoStart}
120+
onGotoEnd={onGotoEnd}
111121
/>
112122
);
113123
} else {
114124
return (
115125
<textarea
116126
id="input-text"
117127
onPaste={handlePaste}
118-
placeholder="Paste a verifier log here or choose a file"
128+
placeholder="Paste a verifier log here, choose a file, or load an example log"
119129
/>
120130
);
121131
}
@@ -134,7 +144,6 @@ function App() {
134144
getEmptyLogLineState(),
135145
);
136146
const [loadError, setLoadError] = useState<string | null>(null);
137-
const [fullLogView, setfullLogView] = useState<boolean>(false);
138147
const [isLoading, setIsLoading] = useState<boolean>(false);
139148

140149
const fileInputRef = useRef<HTMLInputElement>(null);
@@ -220,20 +229,20 @@ function App() {
220229
}
221230
}, []);
222231

223-
const onLogToggle = useCallback(() => {
224-
setfullLogView((prev) => !prev);
225-
const [newLogLines, newLogLineIdToVisualIdx] = getVisibleLogLines(
226-
verifierLogState,
227-
!fullLogView,
228-
);
232+
const handleFullLogToggle = useCallback(() => {
229233
setVisualLogState((prev) => {
234+
const [newLogLines, newLogLineIdToVisualIdx] = getVisibleLogLines(
235+
verifierLogState,
236+
!prev.showFullLog,
237+
);
230238
return {
231239
...prev,
232240
logLines: newLogLines,
233241
logLineIdxToVisualIdx: newLogLineIdToVisualIdx,
242+
showFullLog: !prev.showFullLog,
234243
};
235244
});
236-
}, [fullLogView, verifierLogState]);
245+
}, [verifierLogState]);
237246

238247
useEffect(() => {
239248
const handleKeyDown = (e: KeyboardEvent) => {
@@ -347,14 +356,11 @@ function App() {
347356
);
348357
}, [verifierLogState]);
349358

350-
const loadInputText = useCallback(
351-
(text: string) => {
352-
const newVerifierLogState = processRawLines(text.split("\n"));
353-
setVisualLogState(getVisualLogState(newVerifierLogState, fullLogView));
354-
setIsLoading(false);
355-
},
356-
[fullLogView],
357-
);
359+
const loadInputText = useCallback((text: string) => {
360+
const newVerifierLogState = processRawLines(text.split("\n"));
361+
setVisualLogState(getVisualLogState(newVerifierLogState, false));
362+
setIsLoading(false);
363+
}, []);
358364

359365
const prepareNewLog = useCallback(() => {
360366
setSelectedState(getEmptyLogLineState());
@@ -625,58 +631,48 @@ function App() {
625631
rawLines = rawLines.concat(lines);
626632
}
627633
const newVerifierLogState = processRawLines(rawLines);
628-
setVisualLogState(getVisualLogState(newVerifierLogState, fullLogView));
634+
setVisualLogState(
635+
getVisualLogState(newVerifierLogState, visualLogState.showFullLog),
636+
);
629637
setIsLoading(false);
630638
}
631639
},
632-
[],
640+
[visualLogState],
633641
);
634642

635643
return (
636644
<div className="App">
637645
<div className="container">
638646
<div className="navigation-panel">
639647
<h1>BPF Verifier Visualizer</h1>
640-
<LoadStatus lineCount={verifierLogState.lines.length} />
641-
<button
642-
id="goto-start"
643-
className="line-nav-item"
644-
onClick={onGotoStart}
645-
>
646-
Start
647-
</button>
648-
<button id="goto-end" className="line-nav-item" onClick={onGotoEnd}>
649-
End
650-
</button>
651-
<button id="clear" className="line-nav-item" onClick={onClear}>
652-
Clear
653-
</button>
654-
<label>
655-
<input
656-
type="checkbox"
657-
checked={fullLogView}
658-
onChange={onLogToggle}
659-
id="show-full-log"
660-
/>
661-
Show Full Log
662-
</label>
663-
<div className="file-input-container">
664-
<input
665-
type="file"
666-
id="file-input"
667-
onChange={onFileInputChange}
668-
ref={fileInputRef}
669-
/>
648+
<div className="line-nav-item">
649+
<button id="clear" className="nav-button" onClick={onClear}>
650+
Clear
651+
</button>
652+
</div>
653+
<div className="line-nav-item">
654+
<Examples handleLoadExample={handleLoadExample} />
655+
</div>
656+
<div className="line-nav-item">
657+
<div className="file-input-container">
658+
<input
659+
type="file"
660+
id="file-input"
661+
onChange={onFileInputChange}
662+
ref={fileInputRef}
663+
/>
664+
</div>
665+
</div>
666+
<div className="howto-container">
667+
<a
668+
href="https://github.com/theihor/bpfvv/blob/master/HOWTO.md"
669+
className="nav-button howto-link"
670+
target="_blank"
671+
rel="noreferrer"
672+
>
673+
How To Use
674+
</a>
670675
</div>
671-
<Examples handleLoadExample={handleLoadExample} />
672-
<a
673-
href="https://github.com/theihor/bpfvv/blob/master/HOWTO.md"
674-
className="howto-link"
675-
target="_blank"
676-
rel="noreferrer"
677-
>
678-
How To Use
679-
</a>
680676
</div>
681677
<Content
682678
loadError={loadError}
@@ -691,6 +687,9 @@ function App() {
691687
handleLogLinesOver={handleLogLinesOver}
692688
handleLogLinesOut={handleLogLinesOut}
693689
handleStateRowClick={handleStateRowClick}
690+
handleFullLogToggle={handleFullLogToggle}
691+
onGotoStart={onGotoStart}
692+
onGotoEnd={onGotoEnd}
694693
/>
695694
<div id="hint">
696695
<SelectedLineHint

0 commit comments

Comments
 (0)