-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathexercise5-typeahead.html
More file actions
46 lines (42 loc) · 1.74 KB
/
exercise5-typeahead.html
File metadata and controls
46 lines (42 loc) · 1.74 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
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/JSXTransformer.js"></script>
</head>
<body>
<div id="root"></div>
<script type="text/jsx">
var carBrands = [ "Alfa Romeo", "Audi", "BMW", "Chevrolet", "Chrysler", "Dodge", "Ferrari",
"Fiat", "Ford", "Honda", "Hyundai", "Jaguar", "Jeep", "Kia", "Mazda", "Mercedez-Benz",
"Mitsubishi", "Nissan", "Peugeot", "Porsche", "SAAB", "Subaru", "Suzuki", "Toyota",
"Volkswagen", "Volvo"];
/**
* EXERCISE
*
* Create a Typeahead Input
* ------------------------
* Requirements:
* - As the user types in the input, a list of options should appear below it.
* - The list should contain items from `carBrands` that *start* with the user entered value.
* - Every new character typed should filter the list.
* - Ignore case when matching, and don't worry about styling the typeahead.
*
* Exercise goals:
* 1. List should only appear when input is not empty.
* 2. Clicking on a list item should populate the input with the selected value and hide the list.
*
* Stretch goals:
* 1. For each result, wrap the text that matches the search result in bold.
* 2. When the user is hovering over a result, highlight the text in yellow.
*/
var Typeahead = React.createClass({
});
ReactDOM.render(
<Typeahead list={carBrands} />,
document.getElementById('root')
);
</script>
</body>
</html>