Skip to content

Commit 19dc50c

Browse files
committed
removed tabs
1 parent e818de0 commit 19dc50c

File tree

2 files changed

+56
-88
lines changed

2 files changed

+56
-88
lines changed

docs/.vuepress/theme/drawer/Drawer.vue

Lines changed: 18 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,15 @@
1111
<p @click="onCloseDrawer" class="drawer-cross__text">close</p>
1212
</div>
1313
</div>
14-
<DrawerTabs v-model="selectedTabIndex" :data="tabs"/>
1514
<main>
16-
<div class="drawer-main">
17-
<div class="drawer-main__wrapper">
18-
<div class="drawer-main__breadcrumb">
19-
<!--
20-
<p v-if="drawerArticleResult.length" class="drawer-main__breadcrumb__text">Home
21-
<img :src="withBase('/arrows/arrow-right-breadcrumb.svg')" alt="breadcrumb icon"/>
22-
Documentation
23-
</p>
24-
-->
25-
</div>
26-
<DrawerSearchResult :modelValue="modelValue" :data="drawerArticleResult"/>
27-
</div>
28-
</div>
15+
<div class="drawer-main">
16+
<div class="drawer-main__wrapper">
17+
<div class="drawer-main__breadcrumb">
18+
<!-- Optional breadcrumb can stay here -->
19+
</div>
20+
<DrawerSearchResult :modelValue="modelValue" :data="drawerArticleResult"/>
21+
</div>
22+
</div>
2923
<Footer v-if="isOpenDrawer && isMobileWidth" class="drawer-footer__mobile"/>
3024
</main>
3125
</div>
@@ -34,10 +28,9 @@
3428
</template>
3529

3630
<script setup>
37-
import {withBase} from "@vuepress/client";
31+
import { withBase } from "@vuepress/client";
3832
import Footer from "../footer/Footer.vue";
39-
import {computed, ref, watch} from "vue";
40-
import DrawerTabs from "./DrawerTabs.vue";
33+
import { computed, ref, watch } from "vue";
4134
import DrawerSearchResult from "./DrawerSearchResult.vue";
4235
4336
const props = defineProps({
@@ -46,7 +39,7 @@ const props = defineProps({
4639
required: true,
4740
default: false
4841
},
49-
isMobileWidth:{
42+
isMobileWidth: {
5043
type: Boolean,
5144
required: true,
5245
default: false
@@ -61,39 +54,21 @@ const props = defineProps({
6154
required: true,
6255
default: () => []
6356
}
64-
})
65-
66-
67-
const emit = defineEmits(['closeDrawer', 'update:modelValue'])
68-
69-
const selectedTabIndex = ref(0);
70-
71-
const tabs = computed(() => {
72-
const uniqueTitles = props.homeLayoutSearchResult.reduce((unique, result) => {
73-
const title = result.hierarchy?.lvl0;
74-
unique[title] = unique[title] || { title, numberResults: 0 };
75-
unique[title].numberResults++;
76-
return unique;
77-
}, {});
78-
return Object.values(uniqueTitles);
7957
});
8058
59+
const emit = defineEmits(['closeDrawer', 'update:modelValue']);
60+
8161
const drawerArticleResult = computed(() => {
82-
if (selectedTabIndex.value === -1) {
83-
return props.homeLayoutSearchResult || [];
84-
}
85-
const selectedTab = tabs.value[selectedTabIndex.value];
86-
return props.homeLayoutSearchResult.filter(result => result.hierarchy.lvl0 === selectedTab?.title);
87-
})
62+
return props.homeLayoutSearchResult; // Now directly returning all results since there are no tabs
63+
});
8864
8965
const onCloseDrawer = () => {
90-
emit('closeDrawer')
91-
selectedTabIndex.value = 0
66+
emit('closeDrawer');
9267
}
9368
9469
watch(() => props.isOpenDrawer, () => {
95-
document.body.classList.toggle('disable-scroll', props.isOpenDrawer)
96-
})
70+
document.body.classList.toggle('disable-scroll', props.isOpenDrawer);
71+
});
9772
</script>
9873

9974
<style lang="stylus">

docs/.vuepress/theme/drawer/DrawerSearchResult.vue

Lines changed: 38 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<template>
22
<section v-if="data.length" class="drawer-main__search-results">
3-
<template v-for="(i) in visibleResults" :key="i">
4-
<div class="search-result" @click="gotTo(parseUrl(i.url))">
5-
<div class="search-result__title" v-html="getTitleForArticle(i.title)"></div>
6-
<div class="search-result__breadcrumb" v-html="getBreadcrumbsForArticle(i.title)"></div>
7-
<div class="search-result__text" v-html="formatPreviewMarkdown(i.preview)"></div>
3+
<template v-for="(item, index) in visibleResults" :key="item.objectID || index">
4+
<div class="search-result" @click="gotTo(parseUrl(item.url))">
5+
<div class="search-result__title" v-html="getTitleForArticle(item.title)"></div>
6+
<div class="search-result__breadcrumb" v-html="getBreadcrumbsForArticle(item.title)"></div>
7+
<div class="search-result__text" v-html="formatPreviewMarkdown(item.preview)"></div>
88
</div>
99
</template>
10+
<div v-if="countOfHiddenResults > 0" class="show-more" @click="showAllHiddenResult">
11+
<p>Show {{ countOfHiddenResults }} more results</p>
12+
</div>
1013
</section>
1114
<div v-else>
1215
<p v-if="!modelValue.length" class="no_results">Write your search query, then press Enter or click the search button.</p>
@@ -17,10 +20,8 @@
1720
import { computed, inject, ref } from "vue";
1821
import { marked } from "marked";
1922
20-
// Create a new renderer instance
2123
const renderer = new marked.Renderer();
2224
23-
// Redefine how headers are processed
2425
renderer.heading = function (text) {
2526
// check if text is a string
2627
if (typeof text !== "string") {
@@ -29,13 +30,15 @@ renderer.heading = function (text) {
2930
return `<strong>${text}</strong>`;
3031
};
3132
32-
// Define image rendering to exclude images
3333
renderer.image = function () {
34-
return ""; // Exclude image tags by returning an empty string
34+
return "";
3535
};
3636
3737
const formatPreviewMarkdown = (markdown) => {
38-
return marked(markdown, { renderer });
38+
let md = marked(markdown, { renderer });
39+
// remove all <br> tags
40+
md = md.replace(/<br>/g, "");
41+
return md;
3942
};
4043
4144
const props = defineProps({
@@ -49,7 +52,7 @@ const props = defineProps({
4952
},
5053
});
5154
52-
const { MAX_VISIBLE_RESULT, MAX_VISIBLE_ROWS } = inject('themeConfig');
55+
const { MAX_VISIBLE_RESULT } = inject('themeConfig');
5356
const isShowAllResult = ref(false);
5457
5558
const gotTo = (url) => {
@@ -82,10 +85,6 @@ const showAllHiddenResult = () => {
8285
isShowAllResult.value = true;
8386
};
8487
85-
const collapseResults = () => {
86-
isShowAllResult.value = false;
87-
};
88-
8988
const getTitleForArticle = (title) => {
9089
let sliced = title.split("->").map((part) => part.trim());
9190
return sliced.pop();
@@ -102,35 +101,26 @@ const getBreadcrumbsForArticle = (title) => {
102101
<style lang="stylus">
103102
@import "../../styles/config.styl";
104103
105-
.algolia-docsearch-suggestion--highlight {
106-
background: $drawerHighlightTextBgColor !important;
107-
color: $drawerHighlightTextColor !important;
108-
}
109-
110104
.drawer-main__search-results {
111105
display: grid;
112-
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
113-
column-gap: $drawerSearchColumnGap;
114-
row-gap: $drawerSearchRowGap;
106+
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); // Flexible grid with min width
107+
gap: 1.5rem; // Increased gap for better spacing
108+
padding: 1rem; // Padding around the results area
115109
}
116110
117111
.search-result {
118112
padding: 1rem;
119113
border: 1px solid $drawerSearchBorderColor;
120-
border-radius: 8px;
121-
display: flex;
122-
flex-direction: column;
123-
align-items: flex-start;
124-
justify-content: flex-start;
125-
gap: $drawerOneSearchResultGap;
126-
width: 100%;
127-
cursor: pointer;
114+
border-radius: 10px; // More rounded corners
115+
background: $searchResultBackgroundColor; // Added background color for better visibility
116+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); // Shadow for elevation
128117
transition: box-shadow 0.3s ease, transform 0.3s ease;
118+
cursor: pointer;
119+
overflow: hidden;
129120
130121
&:hover {
131-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
122+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); // Increased shadow on hover
132123
transform: translateY(-2px);
133-
134124
.search-result__title {
135125
color: $mainColor;
136126
text-decoration: underline;
@@ -140,51 +130,54 @@ const getBreadcrumbsForArticle = (title) => {
140130
&__title {
141131
font-size: $drawerSearchResultTitleFontSize;
142132
font-weight: $drawerSearchResultTitleWeight;
143-
line-height: $drawerSearchResultTitleLineHeight;
144133
color: $drawerSearchResultTitleColor;
145134
margin: 0;
135+
line-height: 1.4; // Increased line height for better readability
146136
}
147137
148138
&__text {
149139
font-size: $drawerSearchResultTextFontSize;
150140
line-height: $drawerSearchResultTextLineHeight;
151141
color: $drawerSearchResultTextColor;
152-
margin: 0;
142+
margin: 0.5rem 0; // Added margin for spacing
153143
overflow: hidden;
154144
display: -webkit-box;
155145
-webkit-box-orient: vertical;
156-
-webkit-line-clamp: v-bind(MAX_VISIBLE_ROWS);
146+
-webkit-line-clamp: 3; // Limit preview text lines for coherence
157147
-webkit-box-decoration-break: clone;
158148
box-decoration-break: clone;
159149
}
160150
161151
&__breadcrumb {
162152
font-size: $drawerSearchResultBreadcrumbTextSize;
163-
line-height: $drawerSearchResultBreadcrumbLineHeight;
164153
color: $drawerSearchResultBreadcrumbColor;
165154
margin: 0;
166155
}
167156
}
168157
169-
.no_results {
170-
font-size: 1.5625rem;
158+
.show-more {
171159
text-align: center;
160+
margin: 1rem 0;
161+
cursor: pointer;
172162
173-
&__link {
163+
p {
174164
color: $mainColor;
175-
&:hover {
176-
text-decoration: underline;
177-
}
165+
font-weight: bold;
178166
}
179167
}
180168
169+
.no_results {
170+
font-size: 1.5625rem;
171+
text-align: center;
172+
}
173+
181174
@media (max-width: $mobileBreakpoint) {
182175
.drawer-main__search-results {
183-
grid-template-columns: repeat(1, 1fr);
176+
grid-template-columns: 1fr; // Single column on mobile
184177
}
185178
186179
.no_results {
187180
font-size: 1.25rem;
188181
}
189182
}
190-
</style>
183+
</style>

0 commit comments

Comments
 (0)