MCPcopy Create free account
hub / github.com/AlexErrant/Pentive / MergeComp

Function MergeComp

app/src/components/diffCss.tsx:37–69  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

35 before: string
36 after: string
37}> = (props) => {
38 let ref!: HTMLDivElement
39 onMount(() => {
40 const [theme] = useThemeContext()
41 const view = new MergeView({
42 parent: ref,
43 a: createConfig(props.before, theme()),
44 b: createConfig(props.after, theme()),
45 })
46 createEffect(
47 on(
48 // Only run this effect when the theme changes
49 theme,
50 (t) => {
51 view.a.setState(EditorState.create(createConfig(props.before, t)))
52 view.b.setState(EditorState.create(createConfig(props.after, t)))
53 },
54 { defer: true },
55 ),
56 )
57 onCleanup(() => {
58 view.destroy()
59 })
60 })
61 return (
62 <fieldset class='border-black border p-2'>
63 <legend>
64 <span class='p-2 px-4 font-bold'>CSS</span>
65 </legend>
66 <div class='max-h-[500px] resize-y overflow-auto' ref={ref} />
67 </fieldset>
68 )
69}
70
71function createConfig(doc: string, theme: 'light' | 'dark') {
72 const maybeDark = theme === 'dark' ? [oneDark] : []

Callers

nothing calls this directly

Calls 3

useThemeContextFunction · 0.90
createConfigFunction · 0.70
destroyMethod · 0.45

Tested by

no test coverage detected