From ddc4e893598b7aeb54d8476e97332ab97c02002f Mon Sep 17 00:00:00 2001 From: adamelmore <2363879+adamdottv@users.noreply.github.com> Date: Sun, 25 Jan 2026 06:20:44 -0600 Subject: fix(app): cleanup comment component usage --- packages/ui/src/components/line-comment.css | 61 +++++++++++++++ packages/ui/src/components/line-comment.tsx | 105 +++++++++++++++++++++++++- packages/ui/src/components/session-review.css | 62 --------------- packages/ui/src/components/session-review.tsx | 94 +++++------------------ 4 files changed, 185 insertions(+), 137 deletions(-) (limited to 'packages/ui/src/components') diff --git a/packages/ui/src/components/line-comment.css b/packages/ui/src/components/line-comment.css index 36fb14c64..9dc8eb74f 100644 --- a/packages/ui/src/components/line-comment.css +++ b/packages/ui/src/components/line-comment.css @@ -52,3 +52,64 @@ padding: 8px; border-radius: 14px; } + +[data-component="line-comment"] [data-slot="line-comment-content"] { + display: flex; + flex-direction: column; + gap: 6px; +} + +[data-component="line-comment"] [data-slot="line-comment-text"] { + font-family: var(--font-family-sans); + font-size: var(--font-size-base); + font-weight: var(--font-weight-regular); + line-height: var(--line-height-x-large); + letter-spacing: var(--letter-spacing-normal); + color: var(--text-strong); + white-space: pre-wrap; +} + +[data-component="line-comment"] [data-slot="line-comment-label"], +[data-component="line-comment"] [data-slot="line-comment-editor-label"] { + font-family: var(--font-family-sans); + font-size: var(--font-size-small); + font-weight: var(--font-weight-medium); + line-height: var(--line-height-large); + letter-spacing: var(--letter-spacing-normal); + color: var(--text-weak); + white-space: nowrap; +} + +[data-component="line-comment"] [data-slot="line-comment-editor"] { + display: flex; + flex-direction: column; + gap: 8px; +} + +[data-component="line-comment"] [data-slot="line-comment-textarea"] { + width: 100%; + resize: vertical; + padding: 8px; + border-radius: var(--radius-md); + background: var(--surface-base); + border: 1px solid var(--border-base); + color: var(--text-strong); + font-family: var(--font-family-sans); + font-size: var(--font-size-small); + line-height: var(--line-height-large); +} + +[data-component="line-comment"] [data-slot="line-comment-textarea"]:focus { + outline: none; + box-shadow: var(--shadow-xs-border-select); +} + +[data-component="line-comment"] [data-slot="line-comment-actions"] { + display: flex; + align-items: center; + gap: 8px; +} + +[data-component="line-comment"] [data-slot="line-comment-editor-label"] { + margin-right: auto; +} diff --git a/packages/ui/src/components/line-comment.tsx b/packages/ui/src/components/line-comment.tsx index 41462fa8e..f8869748c 100644 --- a/packages/ui/src/components/line-comment.tsx +++ b/packages/ui/src/components/line-comment.tsx @@ -1,4 +1,5 @@ -import { Show, type JSX } from "solid-js" +import { onMount, Show, splitProps, type JSX } from "solid-js" +import { Button } from "./button" import { Icon } from "./icon" export type LineCommentVariant = "default" | "editor" @@ -52,3 +53,105 @@ export const LineCommentAnchor = (props: LineCommentAnchorProps) => { ) } + +export type LineCommentProps = Omit & { + comment: JSX.Element + selection: JSX.Element +} + +export const LineComment = (props: LineCommentProps) => { + const [split, rest] = splitProps(props, ["comment", "selection"]) + + return ( + +
+
{split.comment}
+
Comment on {split.selection}
+
+
+ ) +} + +export type LineCommentEditorProps = Omit & { + value: string + selection: JSX.Element + onInput: (value: string) => void + onCancel: VoidFunction + onSubmit: (value: string) => void + placeholder?: string + rows?: number + autofocus?: boolean + cancelLabel?: string + submitLabel?: string +} + +export const LineCommentEditor = (props: LineCommentEditorProps) => { + const [split, rest] = splitProps(props, [ + "value", + "selection", + "onInput", + "onCancel", + "onSubmit", + "placeholder", + "rows", + "autofocus", + "cancelLabel", + "submitLabel", + ]) + + const refs = { + textarea: undefined as HTMLTextAreaElement | undefined, + } + + const focus = () => refs.textarea?.focus() + + const submit = () => { + const value = split.value.trim() + if (!value) return + split.onSubmit(value) + } + + onMount(() => { + if (split.autofocus === false) return + requestAnimationFrame(focus) + }) + + return ( + focus()}> +
+