Skip to content

Commit 8f0e385

Browse files
authored
fix markdown (#83)
* fix markdown * fix color * fix dev mode
1 parent cc8402e commit 8f0e385

File tree

7 files changed

+70
-87
lines changed

7 files changed

+70
-87
lines changed

Diff for: examples/agents-researcher/app/components/agent-block.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ export const AgentBlock = ({
1717
return (
1818
<button
1919
className={cx(
20-
' bg-white border-2 size-14 flex items-center justify-center text-opacity-60 rounded-xl',
21-
agentInfoDisplay === name ? 'border-purple-400' : 'border-gray-300'
20+
' bg-white border-2 size-16 flex items-center justify-center text-opacity-60 rounded-xl',
21+
agentInfoDisplay === name
22+
? 'border-purple-500 bg-purple-100'
23+
: 'border-gray-200'
2224
)}
2325
onClick={() => setAgentInfoDisplay(name)}
2426
disabled={isDisabled}

Diff for: examples/agents-researcher/app/components/agent-info.tsx

+33-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import cx from '../utils/cx';
33
import CodeBlock from './code-block';
44
import { IconCaretDownFilled } from '../icons/caret-dropdown';
55
import { AgentName, StepRecord } from '../types';
6+
import Markdown from 'markdown-to-jsx';
67

78
const CollapsibleText = ({
89
title,
@@ -22,7 +23,21 @@ const CollapsibleText = ({
2223
<label className="text-base font-semibold text-purple-500">
2324
{title}
2425
</label>
25-
<div className="whitespace-pre-wrap mt-2">{text}</div>
26+
<Markdown
27+
className="whitespace-pre-wrap mt-2 *:mb-2 text-sm"
28+
options={{
29+
overrides: {
30+
ol: ({ children }) => (
31+
<ol className="list-decimal list-inside">{children}</ol>
32+
),
33+
ul: ({ children }) => (
34+
<ol className="list-disc list-inside">{children}</ol>
35+
)
36+
}
37+
}}
38+
>
39+
{text}
40+
</Markdown>
2641
</div>
2742
);
2843

@@ -31,7 +46,21 @@ const CollapsibleText = ({
3146
return (
3247
<div className="border-gray-300 border-2 p-3 rounded-xl text-md font-mono break-words">
3348
<label className="text-base font-semibold text-purple-500">{title}</label>
34-
<div className="whitespace-pre-wrap mt-2">{displayText}</div>
49+
<Markdown
50+
className="whitespace-pre-wrap mt-2 *:mb-2 text-sm"
51+
options={{
52+
overrides: {
53+
ol: ({ children }) => (
54+
<ol className="list-decimal list-inside">{children}</ol>
55+
),
56+
ul: ({ children }) => (
57+
<ol className="list-disc list-inside">{children}</ol>
58+
)
59+
}
60+
}}
61+
>
62+
{displayText}
63+
</Markdown>
3564
<button
3665
onClick={() => setIsExpanded(!isExpanded)}
3766
className="text-purple-500 hover:text-purple-600 font-medium text-sm font-mono mt-2"
@@ -69,9 +98,7 @@ export const AgentInfo = ({
6998
<label className="">{name} Agent Code</label>
7099
</button>
71100
{displayCode && (
72-
<CodeBlock className="bg-zinc-800 p-3 rounded-xl !text-sm language-javascript">
73-
{code}
74-
</CodeBlock>
101+
<CodeBlock className="language-javascript">{code}</CodeBlock>
75102
)}
76103
</div>
77104
<div className="flex flex-col gap-4 w-full">
@@ -97,7 +124,7 @@ export const AgentInfo = ({
97124
displayOutput && 'rotate-180'
98125
)}
99126
/>
100-
<label className={'text-sm font-semibold'}>{name} Agent Output</label>
127+
<label className={''}>{name} Agent Output</label>
101128
</button>
102129
{displayOutput &&
103130
state &&

Diff for: examples/agents-researcher/app/components/code-block.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import React, { useEffect } from 'react';
44
import Prism from 'prismjs';
5+
import 'prismjs/themes/prism-twilight.css';
6+
import cx from '@/app/utils/cx';
57

68
export default function CodeBlock({
79
children,
10+
className,
811
...props
912
}: React.ComponentProps<'pre'>) {
1013
const ref = React.useRef<HTMLPreElement>(null);
@@ -16,7 +19,7 @@ export default function CodeBlock({
1619

1720
return (
1821
<pre
19-
className="!m-0 border-t border-t-zinc-800 !bg-transparent !p-4 !text-sm"
22+
className={cx('!p-4 !rounded-xl !border-0 !text-sm !m-0', className)}
2023
{...props}
2124
>
2225
<code ref={ref}>{children}</code>

Diff for: examples/agents-researcher/app/components/step-list.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-disable @typescript-eslint/no-empty-object-type */
22
import * as React from 'react';
33
import cx from '../utils/cx';
4-
import type {StepStatus} from '../types';
5-
import {IconLoader} from '../icons/loader';
4+
import type { StepStatus } from '../types';
5+
import { IconLoader2 } from '@tabler/icons-react';
66

77
export interface StepProps extends React.ComponentPropsWithoutRef<'div'> {}
88

@@ -21,10 +21,10 @@ const StepItem = ({ status, className, ...props }: StepItemProps) => {
2121
className={cx(
2222
'relative border-l-2 border-l-zinc-200 pb-16 pl-6 last:pb-0 sm:ml-4 sm:pl-8 dark:border-l-zinc-900',
2323
status === 'init'
24-
? 'border-l-zinc-200'
24+
? 'border-l-purple-100'
2525
: status === 'loading'
26-
? 'border-l-purple-500'
27-
: 'border-l-emerald-500',
26+
? 'border-l-zinc-300'
27+
: 'border-l-black',
2828
className
2929
)}
3030
{...props}
@@ -53,7 +53,7 @@ const StepNumber = ({
5353
'absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2',
5454
'flex size-8 items-center justify-center sm:size-10',
5555
'text-center rounded-full border-4 border-white',
56-
status === 'init' ? 'bg-zinc-100' : 'bg-emerald-500',
56+
status === 'init' ? 'bg-zinc-100' : 'bg-black',
5757
className
5858
)}
5959
{...props}
@@ -75,8 +75,8 @@ const StepNumber = ({
7575
'text-center rounded-full border-4 border-white'
7676
)}
7777
>
78-
<span className="bg-white">
79-
<IconLoader className="animate-spin size-8 text-purple-500" />
78+
<span className="bg-white size-8 flex items-center justify-center">
79+
<IconLoader2 className="animate-spin text-zinc-500" size={28} />
8080
</span>
8181
</span>
8282
)}
@@ -105,7 +105,7 @@ export interface StepContentProps
105105
extends React.ComponentPropsWithoutRef<'div'> {}
106106

107107
const StepContent = ({ className, ...props }: StepContentProps) => {
108-
return <div className={cx('mt-6', className)} {...props} />;
108+
return <div className={cx('mt-4', className)} {...props} />;
109109
};
110110
StepContent.displayName = 'StepContent';
111111

Diff for: examples/agents-researcher/app/icons/loader.tsx

-25
This file was deleted.

Diff for: examples/agents-researcher/app/page.tsx

+17-44
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client';
22

33
import Img from 'next/image';
4+
import * as React from 'react';
45
import { FormEvent, Suspense, useState } from 'react';
56
import {
67
Step,
@@ -15,7 +16,7 @@ import { WorkflowIcon } from './icons/workflow-icon';
1516
import { CODES } from './constants/codes';
1617
import type { AgentName, StepRecord } from './types';
1718
import { AgentBlock } from './components/agent-block';
18-
import { IconLoader } from './icons/loader';
19+
import { IconBrandGithub, IconFile, IconLoader2 } from '@tabler/icons-react';
1920

2021
export default function HomePage() {
2122
return (
@@ -187,74 +188,46 @@ const Page = () => {
187188
{progress && (
188189
<div className="fixed bottom-5 right-5 bg-purple-500/10 text-purple-500 border-purple-500 border-2 px-4 py-2 rounded-md font-semibold flex flex-row gap-2">
189190
<div>{progress}</div>
190-
<IconLoader className="animate-spin" />
191+
<IconLoader2 className="animate-spin" size={28} />
191192
</div>
192193
)}
193194

194195
<div className="pb-24">
195196
{/* header */}
196197
<header className="bg-purple-50 text-center">
197-
<div className="mx-auto max-w-screen-sm px-6 py-12">
198-
<h1 className="text-2xl font-bold">Cross Reference Agent</h1>
198+
<div className="mx-auto max-w-screen-sm px-8 py-12">
199+
<h1 className="text-3xl font-bold">Cross Reference Agent</h1>
199200

200-
<div className="mt-2 text-zinc-500">
201+
<div className="mt-2 text-lg opacity-60">
201202
This is a simple example to demonstrate how to use
202-
<WorkflowIcon size={18} className=" ml-2 inline-flex" /> Upstash
203+
<WorkflowIcon size={18} className="ml-2 inline-flex" /> Upstash
203204
Workflow Agents to cross-reference information from different
204205
sources.
205206
</div>
206207

207-
<div className="flex justify-center items-center gap-2 mt-4">
208+
<div className="flex justify-center items-center gap-6 mt-4">
208209
<a
209-
className="inline-flex items-center gap-1 h-8 pl-3 pr-4 bg-black text-white rounded-lg hover:opacity-80"
210+
className="inline-flex items-center font-medium gap-0.5 underline"
210211
href="https://upstash.com/docs/qstash/workflow/quickstarts/vercel-nextjs"
211212
target="_blank"
212213
>
213-
<svg
214-
xmlns="http://www.w3.org/2000/svg"
215-
width="20"
216-
height="20"
217-
viewBox="0 0 24 24"
218-
fill="none"
219-
stroke="currentColor"
220-
strokeWidth="1.5"
221-
strokeLinecap="round"
222-
strokeLinejoin="round"
223-
>
224-
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
225-
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
226-
<path d="M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z" />
227-
<path d="M10 13l-1 2l1 2" />
228-
<path d="M14 13l1 2l-1 2" />
229-
</svg>
214+
<IconFile size={18} />
230215
Docs
231216
</a>
232217
<a
233-
className="inline-flex items-center gap-1 h-8 pl-3 pr-4 bg-black text-white rounded-lg hover:opacity-80"
218+
className="inline-flex items-center gap-0.5 font-medium underline"
234219
href="https://github.com/upstash/workflow-js/tree/main/examples/agents-researcher"
220+
target="_blank"
235221
>
236-
<svg
237-
xmlns="http://www.w3.org/2000/svg"
238-
width="20"
239-
height="20"
240-
viewBox="0 0 24 24"
241-
fill="none"
242-
stroke="currentColor"
243-
strokeWidth="1.5"
244-
strokeLinecap="round"
245-
strokeLinejoin="round"
246-
>
247-
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
248-
<path d="M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" />
249-
</svg>
222+
<IconBrandGithub size={18} />
250223
Repository
251224
</a>
252225
</div>
253226
</div>
254227
</header>
255228

256229
{/* step-by-step */}
257-
<section className="px-6 mx-auto max-w-screen-sm">
230+
<section className="px-8 mx-auto max-w-screen-sm">
258231
<Step className="mt-16 md:mt-16">
259232
{/* step-1 */}
260233
<StepItem status={resolveStepStatus(1)}>
@@ -277,12 +250,12 @@ const Page = () => {
277250
value={query}
278251
onChange={(e) => setQuery(e.target.value)}
279252
disabled={loading}
280-
className="block w-full h-8 px-2 bg-white border border-gray-300 rounded-md"
253+
className="block w-full h-9 px-4 bg-white border border-gray-300 rounded-md"
281254
/>
282255

283256
<button
284257
disabled={loading}
285-
className={`h-8 rounded-md bg-purple-500 px-4 text-white ${
258+
className={`h-9 rounded-md bg-purple-500 px-4 text-white ${
286259
loading ? 'opacity-30' : ''
287260
}`}
288261
>
@@ -312,7 +285,7 @@ const Page = () => {
312285
question.
313286
</span>
314287
)}
315-
<div className="flex gap-4 w-full">
288+
<div className="flex gap-2 w-full">
316289
<AgentBlock
317290
name="Wikipedia"
318291
agentInfoDisplay={agentInfoDisplay}

Diff for: examples/agents-researcher/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
"@langchain/community": "^0.3.28",
1313
"@langchain/core": "^0.3.40",
1414
"@langchain/exa": "^0.1.0",
15+
"@tabler/icons-react": "^3.31.0",
1516
"@upstash/redis": "^1.34.4",
1617
"@upstash/workflow": "^0.2.6",
1718
"clsx": "^2.1.1",
19+
"exa-js": "^1.4.10",
20+
"markdown-to-jsx": "^7.7.4",
1821
"next": "15.1.6",
1922
"prismjs": "^1.29.0",
2023
"react": "^19.0.0",

0 commit comments

Comments
 (0)