-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
443 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use client'; | ||
|
||
import { Box, Button, Flex, HStack, Heading, VStack } from '@chakra-ui/react'; | ||
import type { NextPage } from 'next'; | ||
|
||
import { SyntaxHighlighter } from '../../../../components/organisms/SyntaxHighlighter'; | ||
import { TurtleGraphics } from '../../../../components/organisms/TurtleGraphics'; | ||
import { programIdToName, generateProgram, getDescription } from '../../../../problems/problemData'; | ||
|
||
const GRID_COLUMNS = 12; | ||
const GRID_ROWS = 8; | ||
const GRID_SIZE = 40; | ||
|
||
const ProblemPage: NextPage<{ params: { problemId: string } }> = ({ params }) => { | ||
// TODO: 一旦Java固定 言語選択機能実装時に変更する | ||
const programmingLanguageId = 'java'; | ||
|
||
return ( | ||
<main> | ||
<VStack spacing="4"> | ||
<Heading as="h1">{programIdToName[params.problemId]}</Heading> | ||
<Flex gap="6" w="100%"> | ||
<VStack spacing="10" w={GRID_COLUMNS * GRID_SIZE}> | ||
<Box>{getDescription(params.problemId)}</Box> | ||
<Box> | ||
<TurtleGraphics characters={[]} gridColumns={GRID_COLUMNS} gridRows={GRID_ROWS} gridSize={GRID_SIZE} /> | ||
</Box> | ||
</VStack> | ||
<VStack align="end" minW="50%" overflow="hidden"> | ||
<Button colorScheme="gray">解説</Button> | ||
{/* 画面に収まる高さに設定 */} | ||
<Box h="calc(100vh - 370px)" w="100%"> | ||
<SyntaxHighlighter | ||
code={generateProgram(params.problemId, programmingLanguageId)} | ||
programmingLanguageId={programmingLanguageId} | ||
/> | ||
</Box> | ||
<HStack> | ||
<Button colorScheme="gray">リセット</Button> | ||
<Button colorScheme="gray">解答</Button> | ||
</HStack> | ||
</VStack> | ||
</Flex> | ||
</VStack> | ||
</main> | ||
); | ||
}; | ||
|
||
export default ProblemPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { CharacterColor } from './Character'; | ||
|
||
type Color = (typeof CharacterColor)[keyof typeof CharacterColor]; | ||
|
||
export class TurtleGraphicsCell { | ||
id: number; | ||
x: number; | ||
y: number; | ||
backgroundColor: string; | ||
|
||
constructor(id: number, x: number, y: number, backgroundColor: string) { | ||
this.id = id; | ||
this.x = x; | ||
this.y = y; | ||
this.backgroundColor = backgroundColor; | ||
} | ||
|
||
setBackgroundColor(color: Color): void { | ||
this.backgroundColor = color; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Box } from '@chakra-ui/react'; | ||
import React from 'react'; | ||
import { Prism } from 'react-syntax-highlighter'; | ||
import { vscDarkPlus } from 'react-syntax-highlighter/dist/cjs/styles/prism'; | ||
|
||
interface SyntaxHighlighterProps { | ||
code: string; | ||
programmingLanguageId: string; | ||
} | ||
|
||
export const SyntaxHighlighter: React.FC<SyntaxHighlighterProps> = ({ | ||
code: code, | ||
programmingLanguageId: programmingLanguageId, | ||
}) => { | ||
return ( | ||
<Box h="100%"> | ||
<Prism | ||
codeTagProps={{ style: { fontSize: '1rem' } }} | ||
customStyle={{ | ||
backgroundColor: '#011627', | ||
marginTop: 0, | ||
overflow: 'auto', | ||
padding: 10, | ||
height: '100%', | ||
}} | ||
language={programmingLanguageId === 'c' ? 'cpp' : programmingLanguageId} | ||
lineNumberStyle={{ paddingRight: 0, marginRight: 16, minWidth: '1rem' }} | ||
// lineProps={(lineNumber) => { | ||
lineProps={() => { | ||
const style = { | ||
padding: 0, | ||
}; | ||
// TODO: チェックポイント問題・ステップ問題のハイライト | ||
// if (isStepPage && problem && lineNumber === problem.traceList[highlightedLineCount].row + 1) { | ||
// style.backgroundColor = '#744210'; | ||
// } | ||
return { style }; | ||
}} | ||
showLineNumbers={true} | ||
style={vscDarkPlus} | ||
wrapLines={true} | ||
> | ||
{code ?? ''} | ||
</Prism> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.