File tree Expand file tree Collapse file tree 9 files changed +105
-28
lines changed Expand file tree Collapse file tree 9 files changed +105
-28
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,7 @@ search.addWidget(
199199 container: ' #search-box' ,
200200 placeholder: ' Search for products' ,
201201 // cssClass
202+ // poweredBy: boolean
202203 })
203204);
204205```
Original file line number Diff line number Diff line change 1+ .as-powered-by {
2+ text-align : right;
3+ line-height : 18px ;
4+ font-size : 12px ;
5+ }
6+
7+ .as-powered-by--image {
8+ height : 16px ;
9+ margin-bottom : 2px ;
10+ }
Original file line number Diff line number Diff line change 1+ var React = require ( 'react' ) ;
2+ var bem = require ( '../BemHelper' ) ( 'as-powered-by' ) ;
3+ var logo = require ( 'url?limit=10000!./algolia_logo.png' ) ;
4+
5+ require ( 'style?prepend!raw!./index.css' ) ;
6+
7+ class PoweredBy extends React . Component {
8+ render ( ) {
9+ var poweredByDisplay = ( this . props . display === true ) ? 'block' : 'none' ;
10+
11+ return (
12+ < div
13+ className = { bem ( ) }
14+ style = { { display : poweredByDisplay } }
15+ >
16+ Powered by
17+ < a href = "https://www.algolia.com/" >
18+ < img
19+ className = { bem ( 'image' ) }
20+ src = { logo }
21+ />
22+ </ a >
23+ </ div >
24+ ) ;
25+ }
26+ }
27+
28+ PoweredBy . propTypes = {
29+ display : React . PropTypes . bool
30+ } ;
31+
32+ module . exports = PoweredBy ;
Original file line number Diff line number Diff line change 11var React = require ( 'react' ) ;
2+ var PoweredBy = require ( './PoweredBy' ) ;
23var bem = require ( './BemHelper' ) ( 'as-search-box' ) ;
34var cx = require ( 'classnames' ) ;
45
@@ -12,15 +13,18 @@ class SearchBox {
1213 var classNames = cx ( bem ( 'input' ) , this . props . inputClass ) ;
1314
1415 return (
15- < input type = "text"
16- placeholder = { this . props . placeholder }
17- name = "algolia-query"
18- className = { classNames }
19- autoComplete = "off"
20- autoFocus = "autofocus"
21- onChange = { this . handleChange . bind ( this ) }
22- role = "textbox"
23- />
16+ < div >
17+ < input type = "text"
18+ placeholder = { this . props . placeholder }
19+ name = "algolia-query"
20+ className = { classNames }
21+ autoComplete = "off"
22+ autoFocus = "autofocus"
23+ onChange = { this . handleChange . bind ( this ) }
24+ role = "textbox"
25+ />
26+ < PoweredBy display = { this . props . poweredBy } />
27+ </ div >
2428 ) ;
2529 }
2630}
@@ -31,6 +35,7 @@ SearchBox.propTypes = {
3135 React . PropTypes . string ,
3236 React . PropTypes . array
3337 ] ) ,
38+ poweredBy : React . PropTypes . bool ,
3439 setQuery : React . PropTypes . func ,
3540 search : React . PropTypes . func
3641} ;
Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ search.addWidget(
1111 instantsearch . widgets . searchBox ( {
1212 container : '#search-box' ,
1313 placeholder : 'Search for products' ,
14- cssClass : 'form-control'
14+ cssClass : 'form-control' ,
15+ poweredBy : true
1516 } )
1617) ;
1718
Original file line number Diff line number Diff line change 4242 "tap-spec" : " 4.1.0" ,
4343 "tape" : " 4.2.0" ,
4444 "uglifyjs" : " 2.4.10" ,
45+ "url-loader" : " ^0.5.6" ,
4546 "webpack" : " 1.12.2" ,
4647 "webpack-dev-server" : " 1.11.0"
4748 },
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ function searchbox(params) {
1515 search = { helper . search . bind ( helper ) }
1616 placeholder = { params . placeholder }
1717 inputClass = { params . cssClass }
18+ poweredBy = { params . poweredBy }
1819 /> ,
1920 container
2021 ) ;
You can’t perform that action at this time.
0 commit comments