Skip to content

Commit

Permalink
Change CSS class names and refactor highlight style
Browse files Browse the repository at this point in the history
  • Loading branch information
yoonieaj committed Nov 6, 2024
1 parent 57c8a3d commit 5307e1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
16 changes: 6 additions & 10 deletions webstepper/src/CodeDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@ type CodeDisplayPropTypes = {
};

export default function CodeDisplay(props: CodeDisplayPropTypes) {
const lineClass = (lineNumber: number) => {
if (lineNumber == props.highlightLine) {
return "HighlightedLine";
}
};

return (
<Box className="CodeBox">
<Box className="code-box">
<SyntaxHighlighter
data-testid="code-box"
language="python"
Expand All @@ -28,9 +22,11 @@ export default function CodeDisplay(props: CodeDisplayPropTypes) {
wrapLongLines={true}
style={a11yLight}
customStyle={{ backgroundColor: "transparent" }}
lineProps={(lineNumber) => ({
className: lineClass(lineNumber),
})}
lineProps={(lineNumber: number) => {
if (lineNumber == props.highlightLine) {
return { className: "line-highlighted" };
}
}}
>
{props.text}
</SyntaxHighlighter>
Expand Down
4 changes: 2 additions & 2 deletions webstepper/src/css/styles.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.CodeBox {
.code-box {
width: 100%;
height: 100%;
background-color: white;
}

.HighlightedLine {
.line-highlighted {
background-color: yellow;
}

Expand Down

0 comments on commit 5307e1a

Please sign in to comment.