diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-08-25 20:55:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-25 20:55:41 +0200 |
commit | f2adc0a50462a63f7e1901db2e58077001acd622 (patch) | |
tree | a0a21d3c99b2d8cbe77ebf95d865aabd36d6598f /plugins/base/frontend/src/main/components/navigationPaneSearch/navigationPaneSearch.tsx | |
parent | 939cbcd4d867961516da71f7c55d037ec88cb7f3 (diff) | |
parent | efc9f92b0ac083c73ac494c95b530305ac04115a (diff) | |
download | dokka-f2adc0a50462a63f7e1901db2e58077001acd622.tar.gz dokka-f2adc0a50462a63f7e1901db2e58077001acd622.tar.bz2 dokka-f2adc0a50462a63f7e1901db2e58077001acd622.zip |
Merge pull request #2066 from Kotlin/webhelp-like-frontend
Webhelp like frontend
Diffstat (limited to 'plugins/base/frontend/src/main/components/navigationPaneSearch/navigationPaneSearch.tsx')
-rw-r--r-- | plugins/base/frontend/src/main/components/navigationPaneSearch/navigationPaneSearch.tsx | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/plugins/base/frontend/src/main/components/navigationPaneSearch/navigationPaneSearch.tsx b/plugins/base/frontend/src/main/components/navigationPaneSearch/navigationPaneSearch.tsx deleted file mode 100644 index 152e7719..00000000 --- a/plugins/base/frontend/src/main/components/navigationPaneSearch/navigationPaneSearch.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import React, { useCallback, useState, useEffect } from 'react'; -import {Select, List } from '@jetbrains/ring-ui'; -import { DokkaFuzzyFilterComponent } from '../search/dokkaFuzzyFilter'; -import { IWindow, Option } from '../search/types'; -import './navigationPaneSearch.scss'; -import ClearIcon from 'react-svg-loader!./clear.svg'; -import { relativizeUrlForRequest } from '../utils/requests'; - -export const NavigationPaneSearch = () => { - const [navigationList, setNavigationList] = useState<Option[]>([]); - const [selected, onSelected] = useState<Option | null>(null); - const [filterValue, setFilterValue] = useState<string>('') - - const onChangeSelected = useCallback( - (element: Option) => { - window.location.replace(`${(window as IWindow).pathToRoot}${element.location}`) - onSelected(element); - }, - [selected] - ); - - const onFilter = (filterValue: string) => { - setFilterValue(filterValue) - } - - const onClearClick = () => { - setFilterValue('') - } - - const shouldShowPopup = (filterState: string): boolean => { - return filterState.trim().length !== 0 - } - - useEffect(() => { - fetch(relativizeUrlForRequest('scripts/navigation-pane.json')) - .then(response => response.json()) - .then((result) => { - setNavigationList(result.map((record: Option, idx: number) => { - return { - ...record, - key: idx, - rgItemType: List.ListProps.Type.CUSTOM - } - })) - }, - (error) => { - console.error('failed to fetch navigationPane data', error) - setNavigationList([]) - }) - }, []) - - - return <div className={"paneSearchInputWrapper"}> - <DokkaFuzzyFilterComponent - id="navigation-pane-search" - className="navigation-pane-search" - inputPlaceholder="Title filter" - clear={true} - type={Select.Type.INPUT_WITHOUT_CONTROLS} - filter={{fuzzy:true, value: filterValue}} - selected={selected} - data={navigationList} - popupClassName={"navigation-pane-popup"} - onSelect={onChangeSelected} - onFilter={onFilter} - shouldShowPopup={shouldShowPopup} - renderOptimization={false} - /> - <span className={"paneSearchInputClearIcon"} onClick={onClearClick}><ClearIcon /></span> - </div> -}
\ No newline at end of file |