UNPKG

1.93 kBHTMLView Raw
1<!DOCTYPE HTML>
2<html>
3 <head>
4 <meta charset="utf-8">
5 <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/topcoat/0.8.0/css/topcoat-mobile-dark.css" />
6 <meta name="viewport" content="width=device-width, initial-scale=1">
7 <script src="../node_modules/react/dist/react-with-addons.js"></script>
8 <script src="../node_modules/react/dist/JSXTransformer.js"></script>
9 <script src="../dist/react-typeahead.js"></script>
10 </head>
11 <body>
12 <style>
13
14 #main {
15 width: 100%;
16 max-width: 600px;
17 margin: 0 auto;
18 }
19
20 h1 {
21 color: #F0F1F1;
22 }
23
24 a {
25 color: #288EDF;
26 }
27
28 .topcoat-text-input {
29 width: 100%;
30 }
31
32 li.hover {
33 background: #585858;
34 }
35
36
37 </style>
38
39 <div id="main">
40 <h1>Topcoat + React.Typeahead (custom options)</h1>
41 <div id="typeahead"></div>
42 </div>
43
44 <script type="text/jsx">
45/** @jsx React.DOM */
46
47var options = [
48 {
49 firstName: 'John',
50 lastName: 'Lennon',
51 birthYear: 1940
52 },
53 {
54 firstName: 'Paul',
55 lastName: 'McCartney',
56 birthYear: 1942
57 },
58 {
59 firstName: 'George',
60 lastName: 'Harrison',
61 birthYear: 1943
62 },
63 {
64 firstName: 'Ringo',
65 lastName: 'Starr',
66 birthYear: 1940
67 }
68].map(function(option) {
69 option.fullName = option.firstName + ' ' + option.lastName;
70 return option;
71});
72
73var displayOption = function(option) {
74 return option.firstName + " (" + option.birthYear + ")";
75};
76
77window.onload = function() {
78 React.render(
79 <ReactTypeahead.Typeahead
80 defaultValue="a"
81 options={options}
82 filterOption='fullName'
83 displayOption={ displayOption }
84 className="topcoat-list"
85 customClasses={{
86 input: "topcoat-text-input",
87 results: "topcoat-list__container",
88 listItem: "topcoat-list__item"
89 }} />,
90 document.getElementById("typeahead")
91 );
92};
93
94 </script>
95
96 </body>
97</html>
98