forked from rage/java-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDropdownMenu.js
More file actions
63 lines (57 loc) · 2.1 KB
/
DropdownMenu.js
File metadata and controls
63 lines (57 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import React, { useState, useRef, useEffect } from "react"
import ReactDOM from "react-dom"
import styled from "styled-components"
import OutlinedInput from "@material-ui/core/OutlinedInput"
import InputLabel from "@material-ui/core/InputLabel"
import MenuItem from "@material-ui/core/MenuItem"
import FormControl from "@material-ui/core/FormControl"
import Select from "@material-ui/core/Select"
import withSimpleErrorBoundary from "../../util/withSimpleErrorBoundary"
const StyledFormControl = styled(FormControl)`
width: 100%;
`
const DropdownMenu = ({ selectedVariant, setSelectedVariant }) => {
const [labelWidth, setLabelWidth] = useState(0)
const inputLabelRef = useRef(null)
useEffect(() => {
setLabelWidth(ReactDOM.findDOMNode(inputLabelRef.current).offsetWidth)
})
const handleChange = event => {
setSelectedVariant(event.target.value)
}
return (
<StyledFormControl variant="outlined">
<InputLabel ref={inputLabelRef} htmlFor="course-variant-select">
Minkä kurssin version pisteet, deadlinet ja kolikot haluat nähdä?
</InputLabel>
<Select
value={selectedVariant}
onChange={handleChange}
input={
<OutlinedInput
labelWidth={labelWidth}
name="course-variant"
id="course-variant-select"
/>
}
>
<MenuItem value={"dl"}>Aikataulutettu Ohjelmoinnin MOOC</MenuItem>
<MenuItem value={"nodl"}>Aikatauluton Ohjelmoinnin MOOC</MenuItem>
<MenuItem value={"ohja-dl"}>
Aloitan kurssin aikataulutettuna osasta 8 (Ohjelmoinnin jatkokurssi)
</MenuItem>
<MenuItem value={"ohja-nodl"}>
Aloitan kurssin aikatauluttomana osasta 8 (Ohjelmoinnin jatkokurssi)
</MenuItem>
<MenuItem value={"kesa-dl"}>
Kesä: Aikataulutettu Ohjelmoinnin MOOC
</MenuItem>
<MenuItem value={"kesa-ohja-dl"}>
Kesä: Aloitan kurssin aikataulutettuna osasta 8 (Ohjelmoinnin
jatkokurssi)
</MenuItem>
</Select>
</StyledFormControl>
)
}
export default withSimpleErrorBoundary(DropdownMenu)