Skip to content

Commit

Permalink
Use Shiki in ResponseContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
frankie567 committed Jun 20, 2024
1 parent 8618eaa commit 95d58f5
Showing 1 changed file with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
'use client'

import { useTheme } from 'next-themes'
import { OpenAPIV3_1 } from 'openapi-types'
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from 'polarkit/components/ui/atoms/tabs'
import SyntaxHighlighter from '../SyntaxHighlighter/SyntaxHighlighter'
import { Theme, polarDark, polarLight } from '../SyntaxHighlighter/themes'
import SyntaxHighlighterServer from '../SyntaxHighlighterAsync/SyntaxHighlighterServer'
import { generateSchemaExample } from './openapi'

export const ResponseContainer = ({
Expand All @@ -18,16 +14,6 @@ export const ResponseContainer = ({
responses: OpenAPIV3_1.ResponsesObject
}) => {
const triggerClassName = 'py-1'
const { resolvedTheme } = useTheme()
const baseTheme = resolvedTheme === 'dark' ? polarDark : polarLight
const syntaxHighlighterTheme: Theme = {
...baseTheme,
base: {
...baseTheme.base,
background: 'transparent',
maxHeight: '18rem',
},
}

return (
<div className="dark:border-polar-700 flex h-full w-full flex-col rounded-3xl bg-white shadow-sm dark:border dark:bg-transparent dark:shadow-none">
Expand Down Expand Up @@ -59,13 +45,12 @@ export const ResponseContainer = ({
<TabsContent
key={statusCode}
value={statusCode}
className="p-2 py-0 text-xs"
className="p-4 text-xs"
>
{schema ? (
<SyntaxHighlighter
language="json"
<SyntaxHighlighterServer
lang="json"
code={JSON.stringify(generateSchemaExample(schema), null, 2)}
theme={syntaxHighlighterTheme}
/>
) : undefined}
</TabsContent>
Expand Down

0 comments on commit 95d58f5

Please sign in to comment.