From 4c5271ffbf7072ccd21fb19271389633ae913e4b Mon Sep 17 00:00:00 2001 From: varutasu <104105839+varutasu@users.noreply.github.com> Date: Wed, 3 Jun 2026 17:29:11 -0500 Subject: [PATCH] refactor(card-editor): extract preview and form components (Brief 2) (#92) Move the sticky preview column and edit form into CardEditorPreview and CardEditorForm; page composer drops to ~275 lines. Co-authored-by: Cursor --- components/CardEditorForm.js | 390 ++++++++++++++++++++++++++++ components/CardEditorPreview.js | 62 +++++ pages/admin/card-editor.js | 445 +------------------------------- 3 files changed, 463 insertions(+), 434 deletions(-) create mode 100644 components/CardEditorForm.js create mode 100644 components/CardEditorPreview.js diff --git a/components/CardEditorForm.js b/components/CardEditorForm.js new file mode 100644 index 0000000..d329ac8 --- /dev/null +++ b/components/CardEditorForm.js @@ -0,0 +1,390 @@ +/* eslint-disable @next/next/no-img-element -- External card image URLs; next/image migration is out of scope. */ + +const RARITY_OPTIONS = [ + 'common', 'uncommon', 'rare', 'mythic', 'legendary', + 'holographic', 'enchanted', 'super rare', 'ultra rare', +]; + +const GAME_OPTIONS = ['MTG', 'Pokemon', 'Lorcana']; + +const COLOR_OPTIONS = ['White', 'Blue', 'Black', 'Red', 'Green', 'Colorless']; + +export default function CardEditorForm({ + formData, + onInputChange, + onColorChange, + onSave, + saving, + message, +}) { + return ( + <> +
+

+ Edit Card Details +

+ +
+ + {message && ( +
+ {message} +
+ )} + +
+ {/* Basic Information */} +
+

+ Basic Information +

+
+
+ + onInputChange('name', e.target.value)} + className="w-full p-3 rounded-lg border transition-all duration-200" + style={{ + backgroundColor: 'var(--bg-primary)', + borderColor: 'var(--border)', + color: 'var(--text-primary)' + }} + /> +
+
+ + +
+
+ + onInputChange('set_name', e.target.value)} + className="w-full p-3 rounded-lg border transition-all duration-200" + style={{ + backgroundColor: 'var(--bg-primary)', + borderColor: 'var(--border)', + color: 'var(--text-primary)' + }} + /> +
+
+ + onInputChange('set_code', e.target.value)} + className="w-full p-3 rounded-lg border transition-all duration-200" + style={{ + backgroundColor: 'var(--bg-primary)', + borderColor: 'var(--border)', + color: 'var(--text-primary)' + }} + /> +
+
+ + onInputChange('card_number', e.target.value)} + className="w-full p-3 rounded-lg border transition-all duration-200" + style={{ + backgroundColor: 'var(--bg-primary)', + borderColor: 'var(--border)', + color: 'var(--text-primary)' + }} + /> +
+
+ + +
+
+
+ + {/* Game Mechanics */} +
+

+ Game Mechanics +

+
+
+ + onInputChange('card_type', e.target.value)} + placeholder="e.g., Creature, Instant, Pokemon, Character" + className="w-full p-3 rounded-lg border transition-all duration-200" + style={{ + backgroundColor: 'var(--bg-primary)', + borderColor: 'var(--border)', + color: 'var(--text-primary)' + }} + /> +
+
+ + onInputChange('mana_cost', e.target.value)} + placeholder="e.g., {2}{U}{U}, 3, etc." + className="w-full p-3 rounded-lg border transition-all duration-200" + style={{ + backgroundColor: 'var(--bg-primary)', + borderColor: 'var(--border)', + color: 'var(--text-primary)' + }} + /> +
+
+ + onInputChange('cmc', e.target.value)} + className="w-full p-3 rounded-lg border transition-all duration-200" + style={{ + backgroundColor: 'var(--bg-primary)', + borderColor: 'var(--border)', + color: 'var(--text-primary)' + }} + /> +
+
+ + onInputChange('power', e.target.value)} + placeholder="e.g., 2, *, X" + className="w-full p-3 rounded-lg border transition-all duration-200" + style={{ + backgroundColor: 'var(--bg-primary)', + borderColor: 'var(--border)', + color: 'var(--text-primary)' + }} + /> +
+
+ + onInputChange('toughness', e.target.value)} + placeholder="e.g., 2, *, X" + className="w-full p-3 rounded-lg border transition-all duration-200" + style={{ + backgroundColor: 'var(--bg-primary)', + borderColor: 'var(--border)', + color: 'var(--text-primary)' + }} + /> +
+
+ + {/* Colors */} +
+ +
+ {COLOR_OPTIONS.map(color => ( + + ))} +
+
+
+ + {/* Card Text */} +
+

+ Card Text +

+
+ +