11import { mdxComponents } from "@kobalte/solidbase/client" ;
2+ import { createHighlighter } from "shiki" ;
23import type { Documentation } from "solid-docgen" ;
34import { stringifyType } from "solid-docgen/stringify" ;
4- import { Dynamic , For , Show } from "solid-js/web" ;
5+ import { Dynamic , For , NoHydration } from "solid-js/web" ;
6+ import "./PropsTable.css" ;
57
68interface PropsTableProps {
79 docgen : Documentation ;
810}
911
12+ const highlighter = await createHighlighter ( {
13+ themes : [ "github-dark" , "github-light" ] ,
14+ langs : [ "typescript" ] ,
15+ } ) ;
16+
1017export function PropsTable ( props : PropsTableProps ) {
1118 return (
1219 < >
@@ -16,8 +23,6 @@ export function PropsTable(props: PropsTableProps) {
1623 < thead >
1724 < tr >
1825 < th > Prop</ th >
19- < th > Type</ th >
20- < th > Default</ th >
2126 < th > Description</ th >
2227 </ tr >
2328 </ thead >
@@ -32,18 +37,23 @@ export function PropsTable(props: PropsTableProps) {
3237 </ Dynamic >
3338 </ td >
3439 < td >
35- < Dynamic component = { mdxComponents . code } >
36- { stringifyType ( propValue . type ) }
37- </ Dynamic >
38- </ td >
39- < td >
40- < Show when = { propValue . defaultValue } >
41- < Dynamic component = { mdxComponents . code } >
42- { stringifyType ( propValue . defaultValue ! , " " , "," ) }
43- </ Dynamic >
44- </ Show >
40+ < NoHydration >
41+ < span class = "props-table-type" innerHTML = { highlighter . codeToHtml (
42+ stringifyType ( propValue . type ) + ( propValue . defaultValue ? ` = ${ stringifyType ( propValue . defaultValue ! , " " , "," ) } ` : "" ) ,
43+ {
44+ lang : "typescript" ,
45+ themes : {
46+ 0 : "github-light" ,
47+ 1 : "github-dark" ,
48+ } ,
49+ defaultColor : "0" ,
50+ cssVariablePrefix : "--" ,
51+ }
52+ ) } />
53+ < br />
54+ </ NoHydration >
55+ { propValue . description }
4556 </ td >
46- < td > { propValue . description } </ td >
4757 </ tr >
4858 ) }
4959 </ For >
0 commit comments