Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend/create room #98

Closed
wants to merge 28 commits into from
Closed

Frontend/create room #98

wants to merge 28 commits into from

Conversation

Irisloverain
Copy link
Collaborator

@Irisloverain Irisloverain commented Aug 10, 2023

resolves #42

@Irisloverain Irisloverain marked this pull request as ready for review August 13, 2023 10:02
<Routes>
<Route path='/' element={<Navigate to='/rooms' />} />
<Route path='/rooms' element={<RoomList />} />
<Route path='/game:roomId' element={<Game />} />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

game的路徑應該是path='/game/:roomId'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外webpack的output要幫我多加publicPath: '/',不然如果路徑有兩個以上的slash會有問題

  output: {
    path: path.resolve(__dirname, 'build'),
    filename: isProduction ? 'js/bundle.[chunkhash].js' : 'js/bundle.js',
    chunkFilename: isProduction ? 'js/[id].[chunkhash].js' : 'js/[name].js',
  + publicPath: '/'
  }

// eslint-disable-next-line object-shorthand
userName: userName,
// eslint-disable-next-line object-shorthand
userImage: userImage
Copy link
Collaborator

@dawnglede dawnglede Aug 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這裡物件的object-shorthand可以直接簡化成

{ 
 userName,
 userImage
}

eslint的disable就可以刪掉了

onClick={() => {
showModal()
}}
>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onClick裡面的callback函式如果沒有要傳特定的值進去,直接傳入函式名稱就好了:

onClick={showModal}

效果是一樣的

isErrorVisible={isErrorVisible}
onClose={() => setIsErrorVisible(false)}
errorText={errorText}
></ErrorModal>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我覺得這裡Modal的組件可以再簡化一下,甚至拆解成可以靈活更動的組件。
例如可以把Modal大致劃分為header、body、footer的區塊,每個區塊可以自由傳入自定義的children,可以根據每次不同的需求客製化,這樣同樣的Modal組件可以重複使用,就不用特地做成兩個。
建議可以去參考antd或MUI等元件庫的寫法,對以後自製元件會很有幫助。
我自己做的Modal大概會長下面這樣:

<Modal
  open={true}
  title={<div>title</div>}
  footer={<button>確認</button>} // footer的children
>
 <div>this is body</div>
</Modal>
// 沒有children的話,不需要close tag
<Modal open={true}/>

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

哦哦哦這樣彈性很多!謝謝!!!我再修改看看

@timt1028 timt1028 added the front-end front end issue label Sep 2, 2023
@Irisloverain Irisloverain mentioned this pull request Sep 24, 2023
@Irisloverain Irisloverain deleted the frontend/createRoom branch September 24, 2023 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
front-end front end issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

【前端】遊戲房間功能
3 participants