@@ -35,7 +35,6 @@ export default function MetaDataForm({
3535 const [ tagInput , setTagInput ] = useState ( "" ) ;
3636 const [ tags , setTags ] = useState < string [ ] > ( [ ] ) ;
3737
38- // 從 data 初始化 tags
3938 useEffect ( ( ) => {
4039 if ( data ?. hashtag ) {
4140 setTags ( Array . isArray ( data . hashtag ) ? data . hashtag : [ ] ) ;
@@ -55,12 +54,7 @@ export default function MetaDataForm({
5554 const handleDragOver = ( e : React . DragEvent ) => {
5655 e . preventDefault ( ) ;
5756 e . stopPropagation ( ) ;
58-
59- // 檢查登入狀態
60- if ( status !== "authenticated" ) {
61- return ;
62- }
63-
57+ if ( status !== "authenticated" ) return ;
6458 setIsDragging ( true ) ;
6559 } ;
6660
@@ -75,57 +69,43 @@ export default function MetaDataForm({
7569 e . stopPropagation ( ) ;
7670 setIsDragging ( false ) ;
7771
78- // 檢查登入狀態
7972 if ( status !== "authenticated" ) {
8073 showLoginAlert ( ) ;
8174 return ;
8275 }
8376
8477 if ( e . dataTransfer . files && e . dataTransfer . files [ 0 ] && handleFileChange ) {
8578 const mockEvent = {
86- target : {
87- files : e . dataTransfer . files ,
88- } ,
79+ target : { files : e . dataTransfer . files } ,
8980 } as any ;
9081 handleFileChange ( mockEvent ) ;
9182 }
9283 } ;
9384
9485 const handleInputChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
95- // 檢查登入狀態
9686 if ( status !== "authenticated" ) {
9787 showLoginAlert ( ) ;
98- e . target . value = "" ; // 清空 input
88+ e . target . value = "" ;
9989 return ;
10090 }
101-
102- // console.log("File input changed:", e.target.files);
103- if ( handleFileChange ) {
104- handleFileChange ( e ) ;
105- }
91+ if ( handleFileChange ) handleFileChange ( e ) ;
10692 } ;
10793
10894 const handleFileInputClick = ( e : React . MouseEvent < HTMLLabelElement > ) => {
109- // 檢查登入狀態
11095 if ( status !== "authenticated" ) {
11196 e . preventDefault ( ) ;
11297 showLoginAlert ( ) ;
113- return ;
11498 }
11599 } ;
116100
117101 const handleRemoveCover = ( e : React . MouseEvent ) => {
118102 e . preventDefault ( ) ;
119103 e . stopPropagation ( ) ;
120-
121104 if ( handleFormEventFunction ) {
122105 handleFormEventFunction ( { target : { name : "cover" , value : "" } } ) ;
123106 }
124-
125107 const fileInput = document . getElementById ( "file" ) as HTMLInputElement ;
126- if ( fileInput ) {
127- fileInput . value = "" ;
128- }
108+ if ( fileInput ) fileInput . value = "" ;
129109 } ;
130110
131111 const handleAddTag = ( ) => {
@@ -134,8 +114,6 @@ export default function MetaDataForm({
134114 const newTags = [ ...tags , trimmedTag ] ;
135115 setTags ( newTags ) ;
136116 setTagInput ( "" ) ;
137-
138- // 更新父組件的 data
139117 if ( handleFormEventFunction ) {
140118 handleFormEventFunction ( {
141119 target : { name : "hashtag" , value : newTags } ,
@@ -147,8 +125,6 @@ export default function MetaDataForm({
147125 const handleRemoveTag = ( tagToRemove : string ) => {
148126 const newTags = tags . filter ( ( tag ) => tag !== tagToRemove ) ;
149127 setTags ( newTags ) ;
150-
151- // 更新父組件的 data
152128 if ( handleFormEventFunction ) {
153129 handleFormEventFunction ( { target : { name : "hashtag" , value : newTags } } ) ;
154130 }
@@ -161,26 +137,24 @@ export default function MetaDataForm({
161137 }
162138 } ;
163139
164- if ( status === "loading" ) {
165- return < div > </ div > ;
166- }
140+ if ( status === "loading" ) return < div > </ div > ;
167141
168142 return (
169- < div className = "flex flex-col h-full" >
170- { /* Main Content - 佔據剩餘空間 */ }
171- < div className = "bg-white rounded-2xl p-4 flex flex-col gap-4 flex-1 overflow-auto " >
143+ < div className = "flex flex-col h-full gap-1 " >
144+ { /* 白色卡片 - 只有 Cover 和 Hashtag */ }
145+ < div className = "flex-1 min-h-0 bg-white rounded-2xl p-4 overflow-y-auto scrollbar-hide " >
172146 { /* Cover Section */ }
173- < div className = "flex flex-col flex-1 min-h-0 max-h-[10rem] " >
174- < label className = "font-semibold text-gray-700 text-lg mb-2" >
147+ < div className = "mb-6 " >
148+ < label className = "font-semibold text-gray-700 text-lg mb-2 block " >
175149 Cover
176150 </ label >
177151
178152 { data ?. cover && data . cover !== "" ? (
179- < div className = "flex flex-col flex-1 relative group min-h-[10.5rem] " >
153+ < div className = "relative group h-40 " >
180154 < label
181155 htmlFor = "file"
182156 onClick = { handleFileInputClick }
183- className = "flex-1 bg-cover bg-center bg-no-repeat rounded-lg h-full cursor-pointer relative overflow-hidden"
157+ className = "block w-full h-full bg-cover bg-center bg-no-repeat rounded-lg cursor-pointer relative overflow-hidden"
184158 style = { {
185159 backgroundImage : ( data . cover . includes ( "http" )
186160 ? `url(${ data . cover } )`
@@ -218,7 +192,7 @@ export default function MetaDataForm({
218192 htmlFor = "file"
219193 onClick = { handleFileInputClick }
220194 className = { `
221- flex-1 border-2 border-dashed rounded-lg cursor-pointer transition-all
195+ w-full h-40 border-2 border-dashed rounded-lg cursor-pointer transition-all
222196 flex flex-col justify-center items-center gap-2 p-8
223197 ${ isDragging
224198 ? "border-[#4ab8e0] bg-blue-100 scale-[0.98]"
@@ -249,7 +223,7 @@ export default function MetaDataForm({
249223 </ div >
250224
251225 { /* Hashtag Section */ }
252- < div className = "flex flex-col gap-2 mt-12 " >
226+ < div className = "flex flex-col gap-2" >
253227 < label
254228 className = "font-semibold text-gray-700 text-lg"
255229 htmlFor = "tagInput"
@@ -281,7 +255,7 @@ export default function MetaDataForm({
281255
282256 { /* Tags Display */ }
283257 { tags . length > 0 && (
284- < div className = "max-h-[12rem] small-scrollbar flex overflow-auto" >
258+ < div className = "max-h-48 overflow-y -auto" >
285259 < div className = "flex flex-wrap gap-2" >
286260 { tags . map ( ( tag , index ) => (
287261 < span
@@ -304,8 +278,8 @@ export default function MetaDataForm({
304278 </ div >
305279 </ div >
306280
307- { /* Buttons - 固定在底部 */ }
308- < div >
281+ { /* 按鈕區域 - 獨立在下方 */ }
282+ < div className = "flex-shrink-0" >
309283 < Buttons
310284 discardFunction = { discardFunction }
311285 postFunction = { postFunction }
@@ -315,4 +289,4 @@ export default function MetaDataForm({
315289 </ div >
316290 </ div >
317291 ) ;
318- }
292+ }
0 commit comments