Skip to content

Commit cc0cd23

Browse files
581: added ShikiHighlighter to LeaderboardMetadataWithId
1 parent 2d6698c commit cc0cd23

1 file changed

Lines changed: 22 additions & 8 deletions

File tree

js/src/app/leaderboard/[leaderboardId]/_components/LeaderboardMetadataWithId.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import PrettyCounter from "@/components/ui/pretty-counter/PrettyCounter";
2-
import SyntaxStrip, {
3-
SyntaxStripSize,
4-
} from "@/components/ui/syntax/SyntaxStrip";
2+
import { SyntaxStripSize } from "@/components/ui/syntax/SyntaxStrip";
53
import DocumentDescription from "@/components/ui/title/DocumentDescription";
64
import DocumentTitle from "@/components/ui/title/DocumentTitle";
75
import { useLeaderboardMetadataByIdQuery } from "@/lib/api/queries/leaderboard";
86
import useCountdown from "@/lib/hooks/useCountdown";
97
import { Center, Title, Skeleton, Button, Box } from "@mantine/core";
108
import { useEffect } from "react";
119
import { Link } from "react-router-dom";
10+
import ShikiHighlighter from "react-shiki";
1211

1312
type LeaderboardWithIdMetadataOptions = {
1413
showClock?: boolean;
@@ -19,7 +18,17 @@ type LeaderboardWithIdMetadataOptions = {
1918
export default function LeaderboardMetadataWithId(
2019
props: LeaderboardWithIdMetadataOptions,
2120
) {
22-
const { showClock = false, leaderboardId, syntaxStripSize } = props;
21+
const fontSize = (() => {
22+
switch (props.syntaxStripSize) {
23+
case "sm":
24+
return "0.62em";
25+
case "md":
26+
return "0.72em";
27+
case "lg":
28+
return "0.85em";
29+
}
30+
})();
31+
const { showClock = false, leaderboardId } = props;
2332

2433
const { data, status } = useLeaderboardMetadataByIdQuery(leaderboardId);
2534
const [countdown, reset] = useCountdown(-10);
@@ -93,11 +102,16 @@ export default function LeaderboardMetadataWithId(
93102
/>
94103
<Title order={4} ta={"center"} mb={"xs"}>
95104
{leaderboardData.syntaxHighlightingLanguage ?
96-
<SyntaxStrip
97-
size={syntaxStripSize}
98-
name={leaderboardData.name}
105+
<ShikiHighlighter
99106
language={leaderboardData.syntaxHighlightingLanguage}
100-
/>
107+
theme="github-dark-dimmed"
108+
showLanguage={false}
109+
structure="inline"
110+
as="span"
111+
style={{ fontSize }}
112+
>
113+
{leaderboardData.name}
114+
</ShikiHighlighter>
101115
: leaderboardData.name}
102116
</Title>
103117
<Title order={6} ta={"center"} mb={"xs"}>

0 commit comments

Comments
 (0)