[dyad] Added field-specific edit buttons - wrote 1 file(s)
This commit is contained in:
@@ -20,7 +20,9 @@ export function MetaForm() {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [metaData, setMetaData] = useState<MetaData | null>(null);
|
const [metaData, setMetaData] = useState<MetaData | null>(null);
|
||||||
const [isEditing, setIsEditing] = useState(false);
|
|
||||||
|
const [isEditingTitle, setIsEditingTitle] = useState(false);
|
||||||
|
const [isEditingDescription, setIsEditingDescription] = useState(false);
|
||||||
|
|
||||||
const [editableTitle, setEditableTitle] = useState("");
|
const [editableTitle, setEditableTitle] = useState("");
|
||||||
const [editableDescription, setEditableDescription] = useState("");
|
const [editableDescription, setEditableDescription] = useState("");
|
||||||
@@ -37,7 +39,8 @@ export function MetaForm() {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
setMetaData(null);
|
setMetaData(null);
|
||||||
setIsEditing(false);
|
setIsEditingTitle(false);
|
||||||
|
setIsEditingDescription(false);
|
||||||
|
|
||||||
const formData = new FormData(event.currentTarget);
|
const formData = new FormData(event.currentTarget);
|
||||||
const url = formData.get("url") as string;
|
const url = formData.get("url") as string;
|
||||||
@@ -89,28 +92,9 @@ export function MetaForm() {
|
|||||||
{metaData && (
|
{metaData && (
|
||||||
<Card className="w-full shadow-lg rounded-lg">
|
<Card className="w-full shadow-lg rounded-lg">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<div className="flex justify-between items-center">
|
|
||||||
<CardTitle className="text-xl text-card-foreground">
|
<CardTitle className="text-xl text-card-foreground">
|
||||||
Extraction Results
|
Extraction Results
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => setIsEditing(!isEditing)}
|
|
||||||
>
|
|
||||||
{isEditing ? (
|
|
||||||
<>
|
|
||||||
<Check className="mr-2 h-4 w-4" />
|
|
||||||
Done
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<Edit className="mr-2 h-4 w-4" />
|
|
||||||
Edit
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-6">
|
<CardContent className="space-y-6">
|
||||||
{metaData.image && (
|
{metaData.image && (
|
||||||
@@ -138,9 +122,24 @@ export function MetaForm() {
|
|||||||
type="title"
|
type="title"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex items-center">
|
||||||
<CopyButton textToCopy={editableTitle} />
|
<CopyButton textToCopy={editableTitle} />
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
onClick={() => setIsEditingTitle(!isEditingTitle)}
|
||||||
|
className="h-8 w-8"
|
||||||
|
>
|
||||||
|
{isEditingTitle ? (
|
||||||
|
<Check className="h-4 w-4" />
|
||||||
|
) : (
|
||||||
|
<Edit className="h-4 w-4" />
|
||||||
|
)}
|
||||||
|
<span className="sr-only">{isEditingTitle ? "Done editing" : "Edit"}</span>
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{isEditing ? (
|
</div>
|
||||||
|
{isEditingTitle ? (
|
||||||
<Input
|
<Input
|
||||||
value={editableTitle}
|
value={editableTitle}
|
||||||
onChange={(e) => setEditableTitle(e.target.value)}
|
onChange={(e) => setEditableTitle(e.target.value)}
|
||||||
@@ -164,9 +163,24 @@ export function MetaForm() {
|
|||||||
type="description"
|
type="description"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex items-center">
|
||||||
<CopyButton textToCopy={editableDescription} />
|
<CopyButton textToCopy={editableDescription} />
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
onClick={() => setIsEditingDescription(!isEditingDescription)}
|
||||||
|
className="h-8 w-8"
|
||||||
|
>
|
||||||
|
{isEditingDescription ? (
|
||||||
|
<Check className="h-4 w-4" />
|
||||||
|
) : (
|
||||||
|
<Edit className="h-4 w-4" />
|
||||||
|
)}
|
||||||
|
<span className="sr-only">{isEditingDescription ? "Done editing" : "Edit"}</span>
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{isEditing ? (
|
</div>
|
||||||
|
{isEditingDescription ? (
|
||||||
<Textarea
|
<Textarea
|
||||||
value={editableDescription}
|
value={editableDescription}
|
||||||
onChange={(e) => setEditableDescription(e.target.value)}
|
onChange={(e) => setEditableDescription(e.target.value)}
|
||||||
|
|||||||
Reference in New Issue
Block a user