From 12fabfdab2e99d97cfa1d3b3856a683cfb51305e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 22:02:12 +0000 Subject: [PATCH] Split SnippetViewer.tsx (158 LOC) into 2 focused components Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com> --- .../features/snippet-viewer/SnippetViewer.tsx | 128 +++--------------- .../snippet-viewer/SnippetViewerContent.tsx | 58 ++++++++ .../snippet-viewer/SnippetViewerHeader.tsx | 95 +++++++++++++ 3 files changed, 171 insertions(+), 110 deletions(-) create mode 100644 src/components/features/snippet-viewer/SnippetViewerContent.tsx create mode 100644 src/components/features/snippet-viewer/SnippetViewerHeader.tsx diff --git a/src/components/features/snippet-viewer/SnippetViewer.tsx b/src/components/features/snippet-viewer/SnippetViewer.tsx index 70d03b2..3815fe9 100644 --- a/src/components/features/snippet-viewer/SnippetViewer.tsx +++ b/src/components/features/snippet-viewer/SnippetViewer.tsx @@ -2,18 +2,12 @@ import { Dialog, DialogContent, DialogHeader, - DialogTitle, } from '@/components/ui/dialog' -import { Button } from '@/components/ui/button' -import { Badge } from '@/components/ui/badge' -import { Copy, Pencil, Check, SplitVertical } from '@phosphor-icons/react' import { Snippet } from '@/lib/types' -import { MonacoEditor } from '@/components/features/snippet-editor/MonacoEditor' -import { ReactPreview } from '@/components/features/snippet-editor/ReactPreview' -import { PythonOutput } from '@/components/features/python-runner/PythonOutput' -import { cn } from '@/lib/utils' import { useState } from 'react' -import { strings, appConfig, LANGUAGE_COLORS } from '@/lib/config' +import { appConfig } from '@/lib/config' +import { SnippetViewerHeader } from './SnippetViewerHeader' +import { SnippetViewerContent } from './SnippetViewerContent' interface SnippetViewerProps { snippet: Snippet | null @@ -47,110 +41,24 @@ export function SnippetViewer({ snippet, open, onOpenChange, onEdit, onCopy }: S diff --git a/src/components/features/snippet-viewer/SnippetViewerContent.tsx b/src/components/features/snippet-viewer/SnippetViewerContent.tsx new file mode 100644 index 0000000..5524219 --- /dev/null +++ b/src/components/features/snippet-viewer/SnippetViewerContent.tsx @@ -0,0 +1,58 @@ +import { Snippet } from '@/lib/types' +import { MonacoEditor } from '@/components/features/snippet-editor/MonacoEditor' +import { ReactPreview } from '@/components/features/snippet-editor/ReactPreview' +import { PythonOutput } from '@/components/features/python-runner/PythonOutput' + +interface SnippetViewerContentProps { + snippet: Snippet + canPreview: boolean + showPreview: boolean + isPython: boolean +} + +export function SnippetViewerContent({ + snippet, + canPreview, + showPreview, + isPython, +}: SnippetViewerContentProps) { + if (canPreview && showPreview) { + return ( + <> +
+ {snippet.description} +
+ )} ++ {strings.snippetViewer.lastUpdated}: {new Date(snippet.updatedAt).toLocaleString()} +
+