import { type FileContents, File, FileOptions, LineAnnotation } from "@pierre/precision-diffs" import { ComponentProps, createEffect, splitProps } from "solid-js" export type CodeProps = FileOptions & { file: FileContents annotations?: LineAnnotation[] class?: string classList?: ComponentProps<"div">["classList"] } export function Code(props: CodeProps) { let container!: HTMLDivElement const [local, others] = splitProps(props, ["file", "class", "classList", "annotations"]) createEffect(() => { const instance = new File({ theme: "OpenCode", overflow: "wrap", // or 'scroll' themeType: "system", // 'system', 'light', or 'dark' disableFileHeader: true, disableLineNumbers: false, // optional // lang: 'typescript', // optional - auto-detected from filename if not provided ...others, }) container.innerHTML = "" instance.render({ file: local.file, lineAnnotations: local.annotations, containerWrapper: container, }) }) return (
) }