aboutsummaryrefslogtreecommitdiff
path: root/search-component/src/main/js/search/search.js
diff options
context:
space:
mode:
authorBłażej Kardyś <bkardys@virtuslab.com>2020-04-01 02:19:40 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-04-06 13:15:51 +0200
commita1866dd98d291a6a2a538e88348c53ff08c812eb (patch)
tree93e6c483c05e9f2a8eca8ca35934043534de5bd4 /search-component/src/main/js/search/search.js
parent03cc02db833b1ad91b3e96c533c44c725efeb36b (diff)
downloaddokka-a1866dd98d291a6a2a538e88348c53ff08c812eb.tar.gz
dokka-a1866dd98d291a6a2a538e88348c53ff08c812eb.tar.bz2
dokka-a1866dd98d291a6a2a538e88348c53ff08c812eb.zip
Integrating fuzzy search into dokka
Diffstat (limited to 'search-component/src/main/js/search/search.js')
-rw-r--r--search-component/src/main/js/search/search.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/search-component/src/main/js/search/search.js b/search-component/src/main/js/search/search.js
new file mode 100644
index 00000000..ea51b9a7
--- /dev/null
+++ b/search-component/src/main/js/search/search.js
@@ -0,0 +1,53 @@
+import React, {Component} from 'react';
+import {Select} from '@jetbrains/ring-ui/components/select/select';;
+import '@jetbrains/ring-ui/components/input-size/input-size.scss';
+
+class WithFuzzySearchFilterComponent extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {selected: props.data[0]};
+ }
+
+ clearSelection = () => {
+ this.setState({selected: null});
+ };
+
+ onSelect = option => {
+ window.location.href = `${window.pathToRoot}${option.location}?query${option.name}`;
+ this.setState({selected: option});
+ debugger
+ };
+
+ render() {
+ return (
+ <div className="search-container">
+ <div className="search">
+ <Select
+ selectedLabel="Search"
+ label="Please type page name"
+ filter={{fuzzy: true}}
+ clear
+ selected={this.state.selected}
+ data={this.props.data}
+ onSelect={this.onSelect}
+ />
+ </div>
+ </div>
+ );
+ }
+}
+
+export const WithFuzzySearchFilter = () => {
+ let data = [];
+ if (window.pages) {
+ data = window.pages.map((page, i) => ({
+ ...page,
+ label: page.name,
+ key: i + 1,
+ type: page.kind,
+ icon: `${window.pathToRoot}${window.iconsFolderName}${page.kind}.png`
+ }));
+ }
+
+ return <WithFuzzySearchFilterComponent data={data}/>;
+};