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

[Refactor] UI 개선 - Code 길이 #323

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/GamePage/GameCode/CodeContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const CodeContainer = ({ codeItem }: CodeContainerProps) => {
return (
<>
<div className='w-[60rem] select-none grow'>
<Highlight className='javascript'>{codeItem}</Highlight>
<Highlight className={'javascript' || 'java'}>{codeItem}</Highlight>
Copy link
Member

@yejinleee yejinleee Apr 29, 2024

Choose a reason for hiding this comment

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

오옷 이렇게 하면 알아서 js거나 java로 하이라이팅이 되나요!!? 따로 인자를 넘긴다거나 하는 작업 없이 ?

</div>
</>
);
Expand Down
14 changes: 13 additions & 1 deletion src/pages/GamePage/GameCode/GameCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,19 @@ const GameCode = ({ publishIngame, userId }: GameCodeProps) => {
const codeList = useRef<I_Question[]>(ingameRoomRes.questions!);

const convertedCodeList = codeList.current.map(({ question }) =>
question.split('\n').map((code) => code.trim())
question.split('\n').flatMap((code) => {
const trimedCode = code.trim();
const splitedTrimedCode = trimedCode.split(' ');
const SPLIT_INDEX = Math.floor((splitedTrimedCode.length - 1) / 2);

if (splitedTrimedCode.length > 1 && trimedCode.length > 65) {
return [
splitedTrimedCode.slice(0, SPLIT_INDEX).join(' '),
splitedTrimedCode.slice(SPLIT_INDEX).join(' '),
];
}
return [trimedCode];
})
);

const handleNextRound = useCallback(() => {
Expand Down