aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorFilip Zybała <fzybala@virtuslab.com>2020-07-07 13:22:09 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-07-08 10:05:48 +0200
commit4a360b13c6d2c175aed57d7af878e06ab6a044a7 (patch)
tree85fda012bd95150f97db5653b84daca82f0795d0 /plugins
parent7d08a539c1c59e4c5a0cbc26a5fbe363242e7936 (diff)
downloaddokka-4a360b13c6d2c175aed57d7af878e06ab6a044a7.tar.gz
dokka-4a360b13c6d2c175aed57d7af878e06ab6a044a7.tar.bz2
dokka-4a360b13c6d2c175aed57d7af878e06ab6a044a7.zip
Separated search key and display level in search component
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/frontend/src/main/components/search/search.scss22
-rw-r--r--plugins/base/frontend/src/main/components/search/search.tsx22
-rw-r--r--plugins/base/frontend/src/main/components/search/types.ts5
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt6
4 files changed, 49 insertions, 6 deletions
diff --git a/plugins/base/frontend/src/main/components/search/search.scss b/plugins/base/frontend/src/main/components/search/search.scss
index c3b1ab3b..cc5a61ac 100644
--- a/plugins/base/frontend/src/main/components/search/search.scss
+++ b/plugins/base/frontend/src/main/components/search/search.scss
@@ -12,4 +12,26 @@
.popup-wrapper {
min-width: calc(100% - 360px) !important;
+}
+
+.indented {
+ text-indent: 10px;
+}
+
+.disabled {
+ color: gray;
+}
+
+.template-wrapper {
+ display: grid;
+ grid-template-columns: auto auto;
+}
+
+.template-name {
+ justify-self: start;
+}
+
+.template-description {
+ color: gray;
+ justify-self: end;
} \ No newline at end of file
diff --git a/plugins/base/frontend/src/main/components/search/search.tsx b/plugins/base/frontend/src/main/components/search/search.tsx
index b0fdd96a..c7b36654 100644
--- a/plugins/base/frontend/src/main/components/search/search.tsx
+++ b/plugins/base/frontend/src/main/components/search/search.tsx
@@ -1,8 +1,9 @@
import React, {useCallback, useState} from 'react';
import {Select} from '@jetbrains/ring-ui';
+import {List} from '@jetbrains/ring-ui';
import '@jetbrains/ring-ui/components/input-size/input-size.scss';
import './search.scss';
-import {IWindow, Option, Props} from "./types";
+import {IWindow, Option, Props, Page} from "./types";
const WithFuzzySearchFilterComponent: React.FC<Props> = ({data}: Props) => {
const [selected, onSelected] = useState<Option>(data[0]);
@@ -43,15 +44,30 @@ const WithFuzzySearchFilterComponent: React.FC<Props> = ({data}: Props) => {
)
}
+const templateGenerator = (page:Page) => {
+ let classGenerator = (page:Page) => {
+ let classes = ""
+ if(page.level !== undefined) classes = classes + " indented"
+ if(page.disabled) classes = classes + " disabled"
+ return classes
+ }
+ return <div className="template-wrapper">
+ <span className= {classGenerator(page)}>{page.name}</span>
+ <span className="template-description">{page.description}</span>
+ </div>
+}
+
export const WithFuzzySearchFilter = () => {
let data: Option[] = [];
const pages = (window as IWindow).pages;
if (pages) {
data = pages.map((page, i) => ({
...page,
- label: page.name,
+ label: page.searchKey,
key: i + 1,
- type: page.kind
+ type: page.kind,
+ template: templateGenerator(page),
+ rgItemType: List.ListProps.Type.CUSTOM
}));
}
diff --git a/plugins/base/frontend/src/main/components/search/types.ts b/plugins/base/frontend/src/main/components/search/types.ts
index 2900153a..881a16d8 100644
--- a/plugins/base/frontend/src/main/components/search/types.ts
+++ b/plugins/base/frontend/src/main/components/search/types.ts
@@ -2,6 +2,11 @@ export type Page = {
name: string;
kind: string;
location: string;
+ searchKey: string;
+ level: number;
+ index: string;
+ description: string;
+ disabled: boolean;
}
export type Option = Page & {
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index f8fa3b2e..a950667f 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -605,14 +605,14 @@ open class HtmlRenderer(
.mapIndexed { topLevelIndex, entry ->
if (entry.value.size > 1) {
listOf(
- "{\'name\': \'${entry.key}\', \'index\': \'$topLevelIndex\', \'disabled\': true}"
+ "{\'name\': \'${entry.key}\', \'index\': \'$topLevelIndex\', \'disabled\': true, \'searchKey\':\'${entry.key}\' }"
) + entry.value.mapIndexed { index, subentry ->
- "{\'name\': \'${subentry.value.first}\', \'level\': 1, \'index\': \'$topLevelIndex.$index\', \'description\':\'${subentry.key}\', \'location\':\'${subentry.value.second}\'}"
+ "{\'name\': \'${subentry.value.first}\', \'level\': 1, \'index\': \'$topLevelIndex.$index\', \'description\':\'${subentry.key}\', \'location\':\'${subentry.value.second}\', 'searchKey':'${entry.key}'}"
}
} else {
val subentry = entry.value.single()
listOf(
- "{\'name\': \'${subentry.value.first}\', \'index\': \'$topLevelIndex\', \'description\':\'${subentry.key}\', \'location\':\'${subentry.value.second}\'}"
+ "{\'name\': \'${subentry.value.first}\', \'index\': \'$topLevelIndex\', \'description\':\'${subentry.key}\', \'location\':\'${subentry.value.second}\', 'searchKey':'${entry.key}'}"
)
}
}