Skip to content

Commit c9700d3

Browse files
committed
style: make leftbar scrollable, make homepage recent updates nowrap
1 parent 14718a9 commit c9700d3

File tree

3 files changed

+68
-48
lines changed

3 files changed

+68
-48
lines changed

src/assets/css/markdown.styl

+5
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,11 @@ schemer(--quote-background-invert, 0, 1);
331331
/* .fold.home-recent-updates 标签 */
332332
.fold.home-recent-updates
333333
.fold-height-listener
334+
p
335+
text-wrap: nowrap;
336+
text-overflow: ellipsis;
337+
overflow: hidden;
338+
334339
a
335340
color: unset;
336341
text-decoration: none;

src/components/LeftBar.vue

+61-44
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from "vue";
1010
import { render_list } from "@/assets/ts/leftbar";
1111
import { LEFTBAR_STATUS } from "@/assets/ts/types";
12+
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
1213
import hotkeys from "hotkeys-js";
1314
import Search from "./Search.vue";
1415
@@ -19,12 +20,18 @@ import config from "@cache/config";
1920
import type { Ref } from "vue";
2021
import type { JSX } from "vue/jsx-runtime";
2122
import type { HotkeysEvent } from "hotkeys-js";
23+
import type { PartialOptions } from "overlayscrollbars";
2224
2325
const props = defineProps<{
2426
status: LEFTBAR_STATUS;
2527
currentCategory: string;
2628
}>();
2729
30+
const osOptions: PartialOptions = {
31+
scrollbars: { autoHide: "move" },
32+
overflow: { x: "hidden" },
33+
};
34+
2835
/** Attributes attached to a category */
2936
interface Category {
3037
name: string;
@@ -194,9 +201,16 @@ watchEffect(() => {
194201
</template>
195202
</div>
196203

197-
<Transition name="content">
198-
<component class="content" :is="VBody" v-if="do_show_detail" />
199-
</Transition>
204+
<OverlayScrollbarsComponent
205+
element="div"
206+
class="content-wrapper"
207+
:options="(osOptions as any)"
208+
defer
209+
>
210+
<Transition name="content">
211+
<component class="content" :is="VBody" v-if="do_show_detail" />
212+
</Transition>
213+
</OverlayScrollbarsComponent>
200214

201215
<!-- https://cn.vuejs.org/guide/built-ins/teleport.html -->
202216
<Teleport to="body">
@@ -326,51 +340,54 @@ $width = $toc-offset-left + $toc-width;
326340
text-decoration-style: wavy;
327341
text-decoration-color: $item-underline-color;
328342
329-
.content
343+
.content-wrapper
330344
position: absolute;
331345
left: $toc-offset-left;
332346
top: $toc-offset-top;
333347
width: $toc-width;
334-
display: block;
335-
border-radius: $background-radius;
336-
padding: 15px 0;
337-
338-
.content .title
339-
color: var(--toc-color);
340-
font-size: 0.95rem;
341-
line-height: $toc-title-height;
342-
margin-bottom: 5px;
343-
padding-right: 10px;
344-
display: flex;
345-
gap: 8px;
346-
transition: color 0.2s;
347-
348-
.content .title.router-link-exact-active .text
349-
color: $theme-color;
350-
351-
.content .title .sign
352-
color: $theme-color;
353-
opacity: 0;
354-
transition: opacity 0.1s;
355-
font-size: 0.7rem;
356-
display: block;
357-
animation: shake-x 1s infinite ease-in-out;
358-
359-
.content .title .text
360-
text-indent: 0 - $toc-title-indent;
361-
padding-left: $toc-title-indent;
362-
363-
.content .title:hover .text
364-
color: $theme-color;
365-
366-
.content .title:hover .sign
367-
opacity: 1;
368-
369-
.content .children
370-
margin-left: 1rem;
371-
372-
.content > .children
373-
margin: 0;
348+
bottom: 0;
349+
350+
.content
351+
position: absolute;
352+
border-radius: $background-radius;
353+
padding: 15px 0;
354+
355+
.title
356+
color: var(--toc-color);
357+
font-size: 0.95rem;
358+
line-height: $toc-title-height;
359+
margin-bottom: 5px;
360+
padding-right: 10px;
361+
display: flex;
362+
gap: 8px;
363+
transition: color 0.2s;
364+
365+
.title.router-link-exact-active .text
366+
color: $theme-color;
367+
368+
.title .sign
369+
color: $theme-color;
370+
opacity: 0;
371+
transition: opacity 0.1s;
372+
font-size: 0.7rem;
373+
display: block;
374+
animation: shake-x 1s infinite ease-in-out;
375+
376+
.title .text
377+
text-indent: 0 - $toc-title-indent;
378+
padding-left: $toc-title-indent;
379+
380+
.title:hover .text
381+
color: $theme-color;
382+
383+
.title:hover .sign
384+
opacity: 1;
385+
386+
.children
387+
margin-left: 1rem;
388+
389+
&> .children
390+
margin: 0;
374391
375392
.content-enter-active,
376393
.content-leave-active

todo.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
## 近期
22

3-
- LeftBar 添加折叠
3+
- LeftBar 添加折叠(?)
44
- 深色模式切换按钮(切换的时候给所有元素设置临时的 transition !important?)(放 rightbar?或者不要也可以)
55
- index comp,hover 范围广一点
66
- 中文字体 cdn,目前加载太慢了
77
- 添加 backtotop 按钮
8-
- 侧边栏(左右),允许折叠 / 滚动
98

109
## 灵感
1110

@@ -46,8 +45,7 @@
4645

4746
## 暂时不重要的 TODO
4847

49-
- 添加 HTML `<meta>` 那一堆属性
50-
- Typst 添加中文字体的支持
48+
- 添加 HTML `<meta>` 那一堆属性
5149
- 代码块换行
5250
- Command + P 打印样式
5351
- 想办法过滤掉 \`[公式]\` 等 slot 内容

0 commit comments

Comments
 (0)