File size: 3,825 Bytes
9b906ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import React from "react";
import { cn } from "#/utils/utils";

interface ElementProps {
  children?: React.ReactNode;
  className?: string;
}

interface ListProps extends ElementProps {
  start?: number;
}

interface AnchorProps extends ElementProps {
  href?: string;
}

/**
 * Creates custom markdown components for plan views with reduced font sizes and tighter spacing.
 * Accepts an optional extraClassName that will be applied to all elements.
 */
export function createPlanComponents(extraClassName?: string) {
  return {
    h1: ({ children, className }: ElementProps) => (
      <h1
        className={cn(
          "text-lg text-white font-bold leading-6 mb-1.5 mt-3 first:mt-0",
          className,
          extraClassName,
        )}
      >
        {children}
      </h1>
    ),
    h2: ({ children, className }: ElementProps) => (
      <h2
        className={cn(
          "text-base font-semibold leading-5 text-white mb-1 mt-2.5 first:mt-0",
          className,
          extraClassName,
        )}
      >
        {children}
      </h2>
    ),
    h3: ({ children, className }: ElementProps) => (
      <h3
        className={cn(
          "text-sm font-semibold text-white mb-1 mt-2 first:mt-0",
          className,
          extraClassName,
        )}
      >
        {children}
      </h3>
    ),
    h4: ({ children, className }: ElementProps) => (
      <h4
        className={cn(
          "text-sm font-semibold text-white mb-1 mt-2 first:mt-0",
          className,
          extraClassName,
        )}
      >
        {children}
      </h4>
    ),
    h5: ({ children, className }: ElementProps) => (
      <h5
        className={cn(
          "text-xs font-semibold text-white mb-0.5 mt-1.5 first:mt-0",
          className,
          extraClassName,
        )}
      >
        {children}
      </h5>
    ),
    h6: ({ children, className }: ElementProps) => (
      <h6
        className={cn(
          "text-xs font-medium text-[var(--oh-text-tertiary)] mb-0.5 mt-1.5 first:mt-0",
          className,
          extraClassName,
        )}
      >
        {children}
      </h6>
    ),
    p: ({ children, className }: ElementProps) => (
      <p
        className={cn("py-2.5 first:pt-0 last:pb-0", className, extraClassName)}
      >
        {children}
      </p>
    ),
    ul: ({ children, className }: ElementProps) => (
      <ul
        className={cn(
          "list-disc ml-5 pl-2 whitespace-normal",
          className,
          extraClassName,
        )}
      >
        {children}
      </ul>
    ),
    ol: ({ children, className, start }: ListProps) => (
      <ol
        className={cn(
          "list-decimal ml-5 pl-2 whitespace-normal",
          className,
          extraClassName,
        )}
        start={start}
      >
        {children}
      </ol>
    ),
    li: ({ children, className }: ElementProps) => (
      <li className={cn(className, extraClassName)}>{children}</li>
    ),
    a: ({ children, className, href }: AnchorProps) => (
      <a
        className={cn(
          "text-blue-500 hover:underline",
          className,
          extraClassName,
        )}
        href={href}
        target="_blank"
        rel="noopener noreferrer"
      >
        {children}
      </a>
    ),
    code: ({ children, className }: ElementProps) => (
      <code
        className={cn(
          "bg-[var(--oh-surface-raised)] px-1.5 py-0.5 rounded text-[var(--oh-foreground)] border border-[var(--oh-border-subtle)]",
          className,
          extraClassName,
        )}
      >
        {children}
      </code>
    ),
  };
}

// Default plan components without extra className (for backward compatibility)
export const planComponents = createPlanComponents();

/**
 * @deprecated Use planComponents instead
 */
export const planHeadings = planComponents;