-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
react-searchkit: portals integration
* ID-assigned searchbar * remove double searchbar
- Loading branch information
Showing
4 changed files
with
59 additions
and
4 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
32 changes: 32 additions & 0 deletions
32
invenio_search_ui/assets/semantic-ui/js/invenio_search_ui/InvenioSearchUISearchBar.js
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,32 @@ | ||
/* | ||
* This file is part of Invenio. | ||
* Copyright (C) 2020 CERN. | ||
* | ||
* Invenio is free software; you can redistribute it and/or modify it | ||
* under the terms of the MIT License; see LICENSE file for more details. | ||
*/ | ||
|
||
import React, { Component } from "react"; | ||
import { SearchBar } from "react-searchkit"; | ||
import ReactDOM from "react-dom"; | ||
import PropTypes from "prop-types"; | ||
|
||
|
||
export default class InvenioSearchUISearchBar extends Component { | ||
|
||
render() { | ||
if (!this.props.searchBarUID){ | ||
return <SearchBar/> | ||
} | ||
const searchNode = document.getElementById(this.props.searchBarUID); | ||
searchNode.innerHTML = ""; | ||
if (searchNode) { | ||
return ReactDOM.createPortal(<SearchBar />, searchNode); | ||
} | ||
return <SearchBar/>; | ||
} | ||
} | ||
|
||
InvenioSearchUISearchBar.propTypes = { | ||
searchBarUID: PropTypes.string, | ||
} |
20 changes: 20 additions & 0 deletions
20
invenio_search_ui/templates/semantic-ui/invenio_search_ui/header.html
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,20 @@ | ||
{# -*- coding: utf-8 -*- | ||
|
||
This file is part of Invenio. | ||
Copyright (C) 2015-2018 CERN. | ||
|
||
Invenio is free software; you can redistribute it and/or modify it | ||
under the terms of the MIT License; see LICENSE file for more details. | ||
#} | ||
{%- block navbar_search %} | ||
<div class="ui basic segment" id="invenio-theme-searchbar"> | ||
<form class="ui form" action="{{url_for('invenio_search_ui.search')}}" | ||
role="search"> | ||
<div class="ui action icon input"> | ||
<input type="text" name="q" placeholder="{{_('Search')}}"> | ||
<button type="submit" class="ui icon button"><i class="icon search"></i> | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
{%- endblock navbar_search %} |
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