调整Scheme内容页面布局以及测试标题的编辑。
This commit is contained in:
		
							
								
								
									
										5
									
								
								src/pages/SchemeDetail.module.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/pages/SchemeDetail.module.css
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| @layer pages { | ||||
|   .scheme_detail_layout { | ||||
|     padding: calc(var(--spacing) * 4) calc(var(--spacing) * 8); | ||||
|   } | ||||
| } | ||||
| @@ -1,12 +1,25 @@ | ||||
| import { isNil } from 'lodash-es'; | ||||
| import { useEffect } from 'react'; | ||||
| import { isNil, set } from 'lodash-es'; | ||||
| import { useCallback, useEffect } from 'react'; | ||||
| import { useNavigate, useParams } from 'react-router-dom'; | ||||
| import { useScheme } from '../stores/schemes'; | ||||
| import { EditableTitle } from '../components/EditableTitle'; | ||||
| import { useScheme, useUpdateScheme } from '../stores/schemes'; | ||||
| import styles from './SchemeDetail.module.css'; | ||||
|  | ||||
| export function SchemeDetail() { | ||||
|   const { id } = useParams(); | ||||
|   const scheme = useScheme(id); | ||||
|   const navigate = useNavigate(); | ||||
|   const updateScheme = useUpdateScheme(id); | ||||
|  | ||||
|   const updateTitle = useCallback( | ||||
|     (newTitle: string) => { | ||||
|       updateScheme((prev) => { | ||||
|         set(prev, 'name', newTitle); | ||||
|         return prev; | ||||
|       }); | ||||
|     }, | ||||
|     [id], | ||||
|   ); | ||||
|  | ||||
|   useEffect(() => { | ||||
|     if (isNil(scheme)) { | ||||
| @@ -15,8 +28,8 @@ export function SchemeDetail() { | ||||
|   }, [scheme, navigate]); | ||||
|  | ||||
|   return ( | ||||
|     <div> | ||||
|       <h3>{scheme?.name}</h3> | ||||
|     <div className={styles.scheme_detail_layout}> | ||||
|       <EditableTitle title={scheme?.name} onChange={updateTitle} /> | ||||
|       <p>{scheme?.description}</p> | ||||
|     </div> | ||||
|   ); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user