summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam <[email protected]>2025-10-30 08:37:47 -0500
committerAdam <[email protected]>2025-10-30 12:02:50 -0500
commit3b2093595957d988ef39a3f2b66d9e37feac8c26 (patch)
treef671c11ce74b76e614531fb8e47b8506d59703f5
parent30f4c2cf4c6c01339434c617fb9d930f6e960883 (diff)
downloadopencode-3b2093595957d988ef39a3f2b66d9e37feac8c26.tar.gz
opencode-3b2093595957d988ef39a3f2b66d9e37feac8c26.zip
wip: desktop work
-rw-r--r--packages/desktop/src/components/progress-circle.tsx48
-rw-r--r--packages/desktop/src/pages/index.tsx4
-rw-r--r--packages/ui/src/components/index.ts1
-rw-r--r--packages/ui/src/components/progress-circle.css12
-rw-r--r--packages/ui/src/components/progress-circle.tsx63
-rw-r--r--packages/ui/src/styles/index.css1
6 files changed, 79 insertions, 50 deletions
diff --git a/packages/desktop/src/components/progress-circle.tsx b/packages/desktop/src/components/progress-circle.tsx
deleted file mode 100644
index d56197ed3..000000000
--- a/packages/desktop/src/components/progress-circle.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-import { Component, createMemo } from "solid-js"
-
-interface ProgressCircleProps {
- percentage: number
- size?: number
- strokeWidth?: number
-}
-
-export const ProgressCircle: Component<ProgressCircleProps> = (props) => {
- // --- Set default values for props ---
- const size = () => props.size || 16
- const strokeWidth = () => props.strokeWidth || 3
-
- // --- Constants for SVG calculation ---
- const viewBoxSize = 16
- const center = viewBoxSize / 2
- const radius = () => center - strokeWidth() / 2
- const circumference = createMemo(() => 2 * Math.PI * radius())
-
- // --- Reactive Calculation for the progress offset ---
- const offset = createMemo(() => {
- const clampedPercentage = Math.max(0, Math.min(100, props.percentage || 0))
- const progress = clampedPercentage / 100
- return circumference() * (1 - progress)
- })
-
- return (
- <svg
- width={size()}
- height={size()}
- viewBox={`0 0 ${viewBoxSize} ${viewBoxSize}`}
- fill="none"
- class="transform -rotate-90"
- >
- <circle cx={center} cy={center} r={radius()} class="stroke-border-weak-base" stroke-width={strokeWidth()} />
- <circle
- cx={center}
- cy={center}
- r={radius()}
- class="stroke-border-active"
- stroke-width={strokeWidth()}
- stroke-dasharray={circumference().toString()}
- stroke-dashoffset={offset()}
- style={{ transition: "stroke-dashoffset 0.35s cubic-bezier(0.65, 0, 0.35, 1)" }}
- />
- </svg>
- )
-}
diff --git a/packages/desktop/src/pages/index.tsx b/packages/desktop/src/pages/index.tsx
index 2a6761623..30635a5ec 100644
--- a/packages/desktop/src/pages/index.tsx
+++ b/packages/desktop/src/pages/index.tsx
@@ -10,6 +10,8 @@ import {
Diff,
Collapsible,
Part,
+ DiffChanges,
+ ProgressCircle,
} from "@opencode-ai/ui"
import { FileIcon } from "@/ui"
import FileTree from "@/components/file-tree"
@@ -33,10 +35,8 @@ import type { JSX } from "solid-js"
import { Code } from "@/components/code"
import { useSync } from "@/context/sync"
import { useSDK } from "@/context/sdk"
-import { ProgressCircle } from "@/components/progress-circle"
import { Message } from "@/components/message"
import { type AssistantMessage as AssistantMessageType } from "@opencode-ai/sdk"
-import { DiffChanges } from "@opencode-ai/ui"
import { Markdown } from "@/components/markdown"
export default function Page() {
diff --git a/packages/ui/src/components/index.ts b/packages/ui/src/components/index.ts
index 4b60ddabc..63be24d58 100644
--- a/packages/ui/src/components/index.ts
+++ b/packages/ui/src/components/index.ts
@@ -11,6 +11,7 @@ export * from "./input"
export * from "./fonts"
export * from "./list"
export * from "./message-part"
+export * from "./progress-circle"
export * from "./select"
export * from "./select-dialog"
export * from "./tabs"
diff --git a/packages/ui/src/components/progress-circle.css b/packages/ui/src/components/progress-circle.css
new file mode 100644
index 000000000..591825183
--- /dev/null
+++ b/packages/ui/src/components/progress-circle.css
@@ -0,0 +1,12 @@
+[data-component="progress-circle"] {
+ transform: rotate(-90deg);
+
+ [data-slot="background"] {
+ stroke: var(--border-weak-base);
+ }
+
+ [data-slot="progress"] {
+ stroke: var(--border-active);
+ transition: stroke-dashoffset 0.35s cubic-bezier(0.65, 0, 0.35, 1);
+ }
+}
diff --git a/packages/ui/src/components/progress-circle.tsx b/packages/ui/src/components/progress-circle.tsx
new file mode 100644
index 000000000..a659c0f2e
--- /dev/null
+++ b/packages/ui/src/components/progress-circle.tsx
@@ -0,0 +1,63 @@
+import { type ComponentProps, createMemo, splitProps } from "solid-js"
+
+export interface ProgressCircleProps extends Pick<ComponentProps<"svg">, "class" | "classList"> {
+ percentage: number
+ size?: number
+ strokeWidth?: number
+}
+
+export function ProgressCircle(props: ProgressCircleProps) {
+ const [split, rest] = splitProps(props, [
+ "percentage",
+ "size",
+ "strokeWidth",
+ "class",
+ "classList",
+ ])
+
+ const size = () => split.size || 16
+ const strokeWidth = () => split.strokeWidth || 3
+
+ const viewBoxSize = 16
+ const center = viewBoxSize / 2
+ const radius = () => center - strokeWidth() / 2
+ const circumference = createMemo(() => 2 * Math.PI * radius())
+
+ const offset = createMemo(() => {
+ const clampedPercentage = Math.max(0, Math.min(100, split.percentage || 0))
+ const progress = clampedPercentage / 100
+ return circumference() * (1 - progress)
+ })
+
+ return (
+ <svg
+ {...rest}
+ width={size()}
+ height={size()}
+ viewBox={`0 0 ${viewBoxSize} ${viewBoxSize}`}
+ fill="none"
+ data-component="progress-circle"
+ classList={{
+ ...(split.classList ?? {}),
+ [split.class ?? ""]: !!split.class,
+ }}
+ >
+ <circle
+ cx={center}
+ cy={center}
+ r={radius()}
+ data-slot="background"
+ stroke-width={strokeWidth()}
+ />
+ <circle
+ cx={center}
+ cy={center}
+ r={radius()}
+ data-slot="progress"
+ stroke-width={strokeWidth()}
+ stroke-dasharray={circumference().toString()}
+ stroke-dashoffset={offset()}
+ />
+ </svg>
+ )
+}
diff --git a/packages/ui/src/styles/index.css b/packages/ui/src/styles/index.css
index 3ebe6e9ea..9742caa0a 100644
--- a/packages/ui/src/styles/index.css
+++ b/packages/ui/src/styles/index.css
@@ -17,6 +17,7 @@
@import "../components/input.css" layer(components);
@import "../components/list.css" layer(components);
@import "../components/message-part.css" layer(components);
+@import "../components/progress-circle.css" layer(components);
@import "../components/select.css" layer(components);
@import "../components/select-dialog.css" layer(components);
@import "../components/tabs.css" layer(components);