File size: 4,095 Bytes
bcce530
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"use client"

import { useState } from 'react'
import { Framework } from '@/lib/frameworks'
import { Target } from 'lucide-react'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { Label } from '@/components/ui/label'
import { Input } from '@/components/ui/input'
import { Textarea } from '@/components/ui/textarea'
import { Badge } from '@/components/ui/badge'

interface FrameworkScaffoldProps {
    framework: Framework
    sections: Record<string, string>
    onSectionsChange: (sections: Record<string, string>) => void
    className?: string
}

export function FrameworkScaffold({ framework, sections, onSectionsChange, className = '' }: FrameworkScaffoldProps) {
    const updateSection = (sectionId: string, value: string) => {
        onSectionsChange({
            ...sections,
            [sectionId]: value,
        })
    }

    return (
        <div className={`space-y-4 ${className}`}>
            <div className="flex items-center gap-2 mb-4">
                <h3 className="text-lg font-semibold">Fill in {framework.name} Framework</h3>
                <Badge variant="outline" className="gap-1"><Target className="h-3 w-3" /> Structured</Badge>
            </div>

            <Card>
                <CardHeader>
                    <CardTitle className="text-sm text-muted-foreground">
                        {framework.description}
                    </CardTitle>
                </CardHeader>
                <CardContent className="space-y-6">
                    {framework.sections.map((section) => (
                        <div key={section.id} className="space-y-2">
                            <div className="flex items-center gap-2">
                                <Label htmlFor={section.id} className="font-medium">
                                    {section.label}
                                    {section.required && (
                                        <span className="text-destructive ml-1">*</span>
                                    )}
                                </Label>
                                <span className="text-xs text-muted-foreground">
                                    {section.description}
                                </span>
                            </div>

                            {section.label.toLowerCase().includes('example') ||
                                section.label.toLowerCase().includes('steps') ||
                                section.id === 'context' ||
                                section.id === 'instructions' ? (
                                <Textarea
                                    id={section.id}
                                    placeholder={section.placeholder}
                                    value={sections[section.id] || ''}
                                    onChange={(e) => updateSection(section.id, e.target.value)}
                                    rows={3}
                                    className="resize-none"
                                />
                            ) : (
                                <Input
                                    id={section.id}
                                    placeholder={section.placeholder}
                                    value={sections[section.id] || ''}
                                    onChange={(e) => updateSection(section.id, e.target.value)}
                                />
                            )}
                        </div>
                    ))}
                </CardContent>
            </Card>

            {framework.example && (
                <Card className="bg-muted/50">
                    <CardHeader>
                        <CardTitle className="text-sm">Example Output</CardTitle>
                    </CardHeader>
                    <CardContent>
                        <p className="text-sm text-muted-foreground italic">
                            {framework.example}
                        </p>
                    </CardContent>
                </Card>
            )}
        </div>
    )
}