From 3d43214075b1f4ba0a3c71d5fea799532bbb7bd9 Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Mon, 3 Nov 2025 14:44:25 -0600 Subject: wip: desktop work --- packages/ui/src/components/code.tsx | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 packages/ui/src/components/code.tsx (limited to 'packages/ui/src/components/code.tsx') diff --git a/packages/ui/src/components/code.tsx b/packages/ui/src/components/code.tsx new file mode 100644 index 000000000..f1c7efada --- /dev/null +++ b/packages/ui/src/components/code.tsx @@ -0,0 +1,52 @@ +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"]) + const file = () => local.file + + createEffect(() => { + const instance = new File({ + theme: { dark: "oc-1-dark", light: "oc-1-light" }, // or any Shiki theme + overflow: "wrap", // or 'scroll' + themeType: "system", // 'system', 'light', or 'dark' + disableLineNumbers: false, // optional + // lang: 'typescript', // optional - auto-detected from filename if not provided + ...others, + }) + + instance.render({ + file: file(), + lineAnnotations: local.annotations, + containerWrapper: container, + }) + }) + + return ( +
+ ) +} -- cgit v1.2.3