generated from uclaacm/teach-la-ts-react-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
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
3 changed files
with
66 additions
and
0 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
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,42 @@ | ||
import * as React from 'react'; | ||
import Box from '@mui/material/Box'; | ||
import MenuItem from '@mui/material/MenuItem'; | ||
import FormControl from '@mui/material/FormControl'; | ||
import Select, { SelectChangeEvent } from '@mui/material/Select'; | ||
|
||
import { useState } from "react" | ||
|
||
interface SelectCodeProps{ | ||
choices: string[]; | ||
handleClick: (value: string) => void; | ||
} | ||
|
||
const SelectCode:React.FC<SelectCodeProps> = ( | ||
{ choices, handleClick }) => { | ||
const [display, setDisplay] = useState(choices[0] || "") | ||
|
||
const handleChange = (e: SelectChangeEvent) => { | ||
setDisplay(e.target.value) | ||
handleClick(e.target.value) | ||
} | ||
|
||
return ( | ||
<Box sx={{ width: '37.5vw', height: '5vh', fontFamily: 'monospace' }}> | ||
<FormControl fullWidth> | ||
<Select | ||
value={display} | ||
onChange={handleChange} | ||
displayEmpty | ||
inputProps={{ 'aria-label': 'Without label' }} | ||
sx={{ fontFamily: "monospace", borderColor: "#CFCFCF", border: '12px' }} | ||
> | ||
{choices.map((choice, index) => ( | ||
<MenuItem value={choice} key={index} sx={{fontFamily: "monospace"}}>{choice}</MenuItem> | ||
))} | ||
</Select> | ||
</FormControl> | ||
</Box> | ||
); | ||
} | ||
|
||
export default SelectCode |
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,22 @@ | ||
import SelectCode from "../components/SelectCode" | ||
|
||
const data = [ | ||
'Basketball **basketballPtrPtr = basketballPtr;', | ||
'Basketball **basketballPtrPtr = &basketballPtr;', | ||
'Basketball *basketballPtrPtr = *basketballPtr;', | ||
'Basketball *basketballPtrPtr = basketballPtr;' | ||
] | ||
|
||
const Exercise2: React.FC = () => { | ||
const handleClick = () => { | ||
return | ||
} | ||
|
||
return( | ||
<div style={{display: 'flex', justifyContent: "center", alignItems: "center", minHeight: '100vh'}}> | ||
<SelectCode choices={data} handleClick={handleClick}/> | ||
</div> | ||
) | ||
} | ||
|
||
export default Exercise2 |