Skip to content

Commit 141f010

Browse files
authored
docs: improve site page (#6826)
1 parent 6ced156 commit 141f010

File tree

5 files changed

+43
-15
lines changed

5 files changed

+43
-15
lines changed

site/src/layouts/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<Header />
3-
<div v-if="headers.length" class="toc-affix" :style="y > 60 ? 'position:fixed; top: 16px;' : ''">
3+
<div v-if="headers.length" class="toc-affix" :style="y > 102 ? 'position:fixed; top: 16px;' : ''">
44
<a-anchor style="width: 160px" :items="headers">
55
<template #customTitle="item">
66
<LinkOutlined v-if="item.target" />

site/src/theme/static/common.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ a {
1919

2020
.main-wrapper {
2121
position: relative;
22-
padding: 40px 0 0;
22+
padding: 0;
2323
background: var(--component-background);
2424
}
2525

2626
.main-container {
2727
position: relative;
2828
min-height: 500px;
29-
padding: 0 170px 32px 64px;
29+
padding: 40px 170px 32px 64px;
3030
background: var(--component-background);
3131

3232
.ant-row-rtl & {

site/src/theme/static/toc.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ ul.toc > li {
6969

7070
.toc-affix {
7171
position: absolute;
72-
top: 80px;
72+
top: 118px;
7373
right: 0px;
7474
width: 160px;
7575
padding: 8px 8px 8px 4px;

site/src/views/ComponentOverview.less

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@
2323
box-shadow: var(--shadow-2);
2424
}
2525
}
26+
27+
&-affix {
28+
transition: all 0.25s;
29+
}
30+
31+
&-affixed {
32+
padding: 12px;
33+
margin: -8px;
34+
border-radius: 6px;
35+
border: 1px solid var(--border-color-base);
36+
background-color: var(--body-background);
37+
}
2638
}
2739

2840
.components-overview-search {

site/src/views/ComponentOverview.vue

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,25 @@
1212
</p>
1313
</section>
1414
<a-divider></a-divider>
15-
<a-input
16-
ref="inputRef"
17-
v-model:value="search"
18-
:placeholder="$t('app.components.overview.search')"
19-
class="components-overview-search"
20-
auto-focus
21-
>
22-
<template #suffix>
23-
<SearchOutlined />
24-
</template>
25-
</a-input>
15+
<a-affix :offset-top="32" @change="handleAffixChange">
16+
<div
17+
class="components-overview-affix"
18+
:class="{ 'components-overview-affixed': searchBarAffixed }"
19+
>
20+
<a-input
21+
ref="inputRef"
22+
v-model:value="search"
23+
:placeholder="$t('app.components.overview.search')"
24+
class="components-overview-search"
25+
auto-focus
26+
:style="{ fontSize: searchBarAffixed ? '18px' : '' }"
27+
>
28+
<template #suffix>
29+
<SearchOutlined />
30+
</template>
31+
</a-input>
32+
</div>
33+
</a-affix>
2634
<a-divider></a-divider>
2735
<template v-for="group in menuItems" :key="group.title">
2836
<div class="components-overview">
@@ -84,6 +92,12 @@ export default defineComponent({
8492
const search = ref('');
8593
const inputRef = ref();
8694
const { dataSource } = useMenus();
95+
96+
const searchBarAffixed = ref(false);
97+
function handleAffixChange(affixed?: boolean) {
98+
searchBarAffixed.value = affixed;
99+
}
100+
87101
const menuItems = computed(() => {
88102
return [
89103
{
@@ -144,6 +158,8 @@ export default defineComponent({
144158
inputRef,
145159
isZhCN: globalConfig?.isZhCN,
146160
isDark,
161+
searchBarAffixed,
162+
handleAffixChange,
147163
};
148164
},
149165
});

0 commit comments

Comments
 (0)