[opt] layout

This commit is contained in:
xaoxuu 2024-02-06 23:39:51 +08:00
parent cb717580a0
commit c58fc191e8
12 changed files with 121 additions and 88 deletions

View File

@ -63,7 +63,7 @@ site_tree:
# 主页配置 # 主页配置
home: home:
leftbar: welcome, recent leftbar: welcome, recent
rightbar: welcome rightbar:
# 博客列表页配置 # 博客列表页配置
index_blog: index_blog:
base_dir: blog # 只影响自动生成的页面路径 base_dir: blog # 只影响自动生成的页面路径
@ -80,7 +80,7 @@ site_tree:
index_wiki: index_wiki:
base_dir: wiki # 只影响自动生成的页面路径 base_dir: wiki # 只影响自动生成的页面路径
menu_id: wiki # 未在 front-matter 中指定 menu_id 时layout 为 wiki 的页面默认使用这里配置的 menu_id menu_id: wiki # 未在 front-matter 中指定 menu_id 时layout 为 wiki 的页面默认使用这里配置的 menu_id
leftbar: ghissues, related, recent # for wiki leftbar: related, recent # for wiki
rightbar: rightbar:
nav_tabs: nav_tabs:
# 'more': https://github.com/xaoxuu # 'more': https://github.com/xaoxuu
@ -88,7 +88,7 @@ site_tree:
# 博客文章内页配置 # 博客文章内页配置
post: post:
menu_id: post # 未在 front-matter 中指定 menu_id 时layout 为 post 的页面默认使用这里配置的 menu_id menu_id: post # 未在 front-matter 中指定 menu_id 时layout 为 post 的页面默认使用这里配置的 menu_id
leftbar: related, ghrepo, ghissues, recent # for pages using 'layout:post' leftbar: related, recent # for pages using 'layout:post'
rightbar: ghrepo, toc rightbar: ghrepo, toc
# 博客专栏文章内页配置 # 博客专栏文章内页配置
topic: topic:
@ -96,7 +96,7 @@ site_tree:
# 文档内页配置 # 文档内页配置
wiki: wiki:
menu_id: wiki # 未在 front-matter 中指定 menu_id 时layout 为 wiki 的页面默认使用这里配置的 menu_id menu_id: wiki # 未在 front-matter 中指定 menu_id 时layout 为 wiki 的页面默认使用这里配置的 menu_id
leftbar: tree, ghissues, related, recent # for wiki leftbar: tree, related, recent # for wiki
rightbar: ghrepo, toc rightbar: ghrepo, toc
# 作者信息配置 # 作者信息配置
author: author:

View File

@ -49,8 +49,10 @@ if (typeof page.rightbar == 'string') {
} }
function layoutWidgets() { function layoutWidgets() {
var el = ''; if (page.rightbar == null || page.rightbar.length == 0) {
el += '<div class="widgets">'; return ''
}
var el = ''
if (page.rightbar) { if (page.rightbar) {
page.rightbar.forEach((w, i) => { page.rightbar.forEach((w, i) => {
let name = '' let name = ''
@ -71,8 +73,11 @@ function layoutWidgets() {
} }
}); });
} }
el += '</div>'; if (el.trim().length > 0) {
return el; return `<div class="widgets">${el}</div>`
} else {
return ''
}
} }
%> %>

View File

@ -47,7 +47,6 @@ function layoutDiv(fallback) {
return '' return ''
} }
var el = '' var el = ''
el += `<widget class="widget-wrapper${scrollreveal(' ')} post-list">`
for (let sec of proj.sections) { for (let sec of proj.sections) {
if (sec.pages.length == 0) { if (sec.pages.length == 0) {
continue continue
@ -55,12 +54,16 @@ function layoutDiv(fallback) {
if (sec.title?.length > 0) { if (sec.title?.length > 0) {
el += layoutTocHeader(sec.title) el += layoutTocHeader(sec.title)
} }
el += `<div class="widget-body fs14">` const docTree = layoutDocTree(sec.pages)
el += layoutDocTree(sec.pages) if (docTree.trim().length > 0) {
el += `</div>` el += `<div class="widget-body fs14">${docTree}</div>`
}
}
if (el.trim().length > 0) {
return `<widget class="widget-wrapper${scrollreveal(' ')} post-list">${el}</widget>`
} else {
return ''
} }
el += `</widget>`
return el
} }
%> %>

View File

@ -16,9 +16,11 @@
z-index: 10 z-index: 10
display: flex display: flex
flex-direction: column flex-direction: column
border-radius: 0.5rem border-radius: $border-bar
margin-left: auto margin-left: auto
margin-right: 1rem margin-right: 1rem
@media screen and (min-width: $device-mobile-max)
margin-right: 2rem
overflow: hidden overflow: hidden
--blur-px: 16px --blur-px: 16px
--blur-bg: alpha(#fff, .4) --blur-bg: alpha(#fff, .4)
@ -47,9 +49,10 @@
// //
.l_body[leftbar] .float-panel, .l_body[rightbar] .float-panel .l_body[leftbar] .float-panel, .l_body[rightbar] .float-panel
box-shadow: 0 0 4px -2px $color-theme, 0 0 16px -8px $color-theme, 0 0 32px -16px $color-theme box-shadow: 0 0 4px -1px $color-theme, 0 0 16px -4px $color-theme, 0 0 32px -12px $color-theme, 0 0 128px -32px $color-theme
.l_body[leftbar] .float-panel button
background: var(--card) .l_body[leftbar] .float-panel button.leftbar-toggle
background: var(--alpha100)
.l_body[leftbar] .float-panel button.leftbar-toggle .l_body[leftbar] .float-panel button.leftbar-toggle
color: $color-theme color: $color-theme
@ -61,8 +64,12 @@
transform: translateX(2px) transform: translateX(2px)
.l_body[rightbar] .float-panel button //
background: var(--card) .l_body .l_right:empty+.float-panel button.rightbar-toggle
display: none !important
.l_body[rightbar] .float-panel button.rightbar-toggle
background: var(--alpha100)
.l_body[rightbar] .float-panel button.rightbar-toggle .l_body[rightbar] .float-panel button.rightbar-toggle
color: $color-theme color: $color-theme

View File

@ -67,32 +67,35 @@ $border-button = 4px
// //
:root :root
--width-sidebar: 288px
--width-main: 720px --width-main: 720px
--fsp: $fs-body --fsp: $fs-body
--fsh2: 'calc(%s + 11px)' % var(--fsp) --fsh2: 'calc(%s + 11px)' % var(--fsp)
--fsh3: 'calc(%s + 7px)' % var(--fsp) --fsh3: 'calc(%s + 7px)' % var(--fsp)
--fsh4: 'calc(%s + 4px)' % var(--fsp) --fsh4: 'calc(%s + 4px)' % var(--fsp)
//
--side-content-width: 224px
//
--gap-margin: 16px --gap-margin: 16px
//
--gap-padding: 16px --gap-padding: 16px
--gap-max: calc(var(--gap-margin) + var(--gap-padding))
--gap-p: 'calc(%s + 4px)' % $fs-body // gap for paragraph --gap-p: 'calc(%s + 4px)' % $fs-body // gap for paragraph
--gap-p-compact: 'calc(%s * 0.75)' % $fs-body --gap-p-compact: 'calc(%s * 0.75)' % $fs-body
// desktop 2k or larger // desktop 2k or larger
@media screen and (min-width: $device-2k) @media screen and (min-width: $device-2k)
--width-sidebar: 352px
--width-main: 780px --width-main: 780px
// desktop 4k or larger // desktop 4k or larger
@media screen and (min-width: $device-4k) @media screen and (min-width: $device-4k)
--width-main: 860px --width-main: 860px
// iPad // iPad
@media screen and (max-width: $device-tablet) @media screen and (max-width: $device-tablet)
--width-sidebar: 252px --side-content-width: 188px
// iPad
@media screen and (max-width: $device-mobile-max) //
--width-sidebar: 288px :root
//
--gap-max: calc(var(--gap-margin) + var(--gap-padding))
// //
.l_body.story .l_body.story

View File

@ -7,21 +7,27 @@
.l_body aside .l_body aside
z-index: 8 z-index: 8
width: var(--width-sidebar)
flex-shrink: 0 flex-shrink: 0
position: sticky position: sticky
position: -webkit-sticky position: -webkit-sticky
//
--width-sidebar: calc(var(--gap-margin) * 2 + var(--gap-padding) * 2 + var(--side-content-width))
width: var(--width-sidebar)
.l_body .l_left .l_body .l_left
justify-self: right
top: 8px top: 8px
.l_body .l_right .l_body .l_right
width: calc(var(--width-sidebar) - var(--gap-max) + var(--gap-padding)) justify-self: left
--gap-margin: 0px
.widgets .widgets
height: 100% height: 100%
overflow visible overflow visible
// //
@media screen and (max-width: $device-laptop) @media screen and (max-width: $device-laptop)
.l_body .l_right
--gap-margin: 16px
.laptop-only .laptop-only
display: block !important display: block !important
.l_body .l_body
@ -43,7 +49,7 @@
.l_right .l_right
transform: translateX(0px) transform: translateX(0px)
.main-mask .main-mask
opacity 1 // opacity 1
pointer-events: inherit pointer-events: inherit
// //

View File

@ -3,8 +3,10 @@
align-items: center align-items: center
overflow: hidden overflow: hidden
min-height: 48px min-height: 48px
img img.avatar
object-fit: cover object-fit: cover
img.icon
object-fit: contain
.icon .icon
width: 48px width: 48px
height: 48px height: 48px

View File

@ -1,18 +1,15 @@
.l_left .l_left
margin: 8px 0 8px 8px margin: 8px
height: 'calc(%s - 16px)' % 100vh height: 'calc(%s - 16px)' % 100vh
border-radius: $border-card-l border-radius: $border-card-l
overflow: hidden overflow: hidden
.header .header
margin: var(--gap-max) var(--gap-margin) 0 margin: var(--gap-max) var(--gap-margin) 0
// @media screen and (min-width: $device-mobile-max)
// >.widgets:first-child>.widget-wrapper:first-child
// margin-top: calc(2 * var(--gap-max))
.l_right .l_right
margin: 8px 8px 8px 0 margin: 8px
border-radius: $border-card-l border-radius: $border-card-l
@media screen and (min-width: 1400px) @media screen and (min-width: $device-2k)
.l_left .l_left
margin-left: auto margin-left: auto
margin-right: calc(2 * var(--gap-max)) margin-right: calc(2 * var(--gap-max))

View File

@ -6,7 +6,7 @@
background: var(--card) background: var(--card)
border-radius: $border-card border-radius: $border-card
padding: 1rem padding: 1rem
hoverable-card() box-shadow: $boxshadow-card
.widgets .widget-wrapper.user-card .widgets .widget-wrapper.user-card
.avatar .avatar
@ -17,6 +17,7 @@
overflow: hidden overflow: hidden
img img
display: block display: block
aspect-ratio: 1
@media screen and (max-width: $device-tablet) @media screen and (max-width: $device-tablet)
max-width: 50% max-width: 50%

View File

@ -1,10 +1,17 @@
.widget-wrapper.toc .widget-wrapper.toc
background: var(--site-bg) background: var(--site-bg)
z-index 1 z-index 1
.widget-body
.l_right .widgets .widget-wrapper.toc .widget-header position relative
padding-left: var(--gap-max) &:before
padding-right: var(--gap-max) content: ''
position absolute
top: 4px
bottom: 4px
left: 0
width: 4px
background: var(--block)
border-radius: 4px
// //
.widget-wrapper.toc .toc .widget-wrapper.toc .toc
@ -13,46 +20,42 @@
margin: 0 margin: 0
position relative position relative
list-style: none list-style: none
.toc-child
padding-left: 1em
li li
margin: 2px 0 margin: 0
list-style: none list-style: none
a a
padding: 4px var(--gap-max) --padding: calc(var(--gap-padding) / 2)
--padding-offset: calc(0 - var(--padding))
padding: 6px var(--padding)
margin: 0 var(--padding)
color: var(--text-p3) color: var(--text-p3)
display: block display: block
overflow: hidden
text-overflow: ellipsis
white-space: nowrap
position relative position relative
&:before,&:after border-radius: $border-bar
position: absolute trans1 all
left: 'calc(%s * 0.5)' % var(--gap-max) &.active:before
width: 8px content: ''
height: 8px position absolute
top: 'calc(%s - 4px)' % 50% top: 4px
border-radius: 8px bottom: 4px
background: var(--block) left: -8px
width: 4px
background: $color-theme background: $color-theme
&:after border-radius: 4px
opacity 0 &:hover
animation: wave 1s linear infinite background: var(--block-hover)
@keyframes wave color: var(--text)
from
transform: scale(1)
opacity 1
to
transform: scale(2)
opacity 0
// //
.l_right .widgets .widget-wrapper.toc .l_right .widgets .widget-wrapper.toc
margin-top: 0
position: sticky position: sticky
position: -webkit-sticky position: -webkit-sticky
top: 0 top: 0
margin-top: 0
padding: 16px 0 padding: 16px 0
&:first-child
top: 8px
padding-top: 8px
.widget-body .toc .widget-body .toc
max-height: 70vh max-height: 70vh
@media screen and (max-width: $device-laptop) @media screen and (max-width: $device-laptop)
@ -67,14 +70,23 @@
.toc-item .toc-item
font-weight: 500 font-weight: 500
--fsp: $fsp1 --fsp: $fsp1
.toc-item .toc-item .toc-item .toc-item
font-weight: 400 font-weight: 400
--fsp: $fsp2 --fsp: $fsp2
ol
padding-left: 0
.toc-child .toc-link
padding-left: 1.5rem
.toc-child .toc-child .toc-link
padding-left: 2.5rem
.toc-child .toc-child .toc-child .toc-link
padding-left: 3.5rem
.toc-child .toc-child .toc-child .toc-child .toc-link
padding-left: 4.5rem
.toc-child .toc-child .toc-child .toc-child .toc-child .toc-link
padding-left: 5rem
// //
.widget-wrapper.toc .toc a.toc-link:hover
color: $color-theme
.widget-wrapper.toc .toc a.toc-link.active .widget-wrapper.toc .toc a.toc-link.active
color: var(--text) color: var(--text)
&:before,&:after &:before,&:after
@ -127,8 +139,8 @@
background: var(--block-border) background: var(--block-border)
top: 0 top: 0
height: 1px height: 1px
left: var(--gap-max) left: var(--gap-padding)
right: var(--gap-max) right: var(--gap-padding)
.widget-wrapper.toc .widget-footer .widget-wrapper.toc .widget-footer
margin-top: 8px margin-top: 8px
color: var(--text-p2) color: var(--text-p2)
@ -139,9 +151,9 @@
align-items: center align-items: center
color: inherit color: inherit
font-size: $fs-14 font-size: $fs-14
padding: 8px 16px padding: 8px var(--gap-padding)
margin: 0 calc(var(--gap-max) - 16px) border-radius: $border-bar
border-radius: 4px trans1 all
svg,img svg,img
height: 16px height: 16px
width: auto width: auto
@ -157,14 +169,14 @@
.l_right .l_right
blur-effect() blur-effect()
.widgets .widgets
padding: 8px
.widget-wrapper.toc .widget-wrapper.toc
background: var(--alpha100) position: static
background: none
.widget-wrapper.toc .toc .widget-wrapper.toc .toc
a a
color: var(--text-p2) color: var(--text-p2)
.widget-wrapper.toc .widget-footer .widget-wrapper.toc .widget-footer
a a
background: var(--block) background: var(--alpha100)
a+a a+a
margin-top: 4px margin-top: 4px

View File

@ -10,6 +10,7 @@
scrollbar(0, 0) scrollbar(0, 0)
z-index: 1 z-index: 1
line-height: 1.2 line-height: 1.2
margin: 0 var(--gap-margin)
.widget-wrapper .widget-wrapper
.widget-header .widget-header
padding-left: var(--gap-padding) padding-left: var(--gap-padding)
@ -61,21 +62,17 @@
padding-bottom: 32px padding-bottom: 32px
.l_left .widgets .l_left .widgets
margin: 0 var(--gap-margin)
.widget-wrapper .widget-wrapper
&:first-child &:first-child
margin-top: 32px margin-top: 32px
.l_right
--gap-margin: 0
.l_right .widgets .l_right .widgets
&:empty
display: none
.widget-wrapper .widget-wrapper
.widget-header .widget-header
padding-left: var(--gap-padding) padding-left: var(--gap-padding)
padding-right: var(--gap-padding) padding-right: var(--gap-padding)
&:not(.toc)
margin-left: var(--gap-margin)
margin-right: var(--gap-margin)
@media screen and (max-width: $device-laptop) @media screen and (max-width: $device-laptop)
.widget-wrapper .widget-wrapper
margin-top: var(--gap-margin) margin-top: var(--gap-margin)

View File

@ -159,7 +159,7 @@ const init = {
if(timeout !== null) clearTimeout(timeout); if(timeout !== null) clearTimeout(timeout);
timeout = setTimeout(function() { timeout = setTimeout(function() {
scrollTOC(); scrollTOC();
}.bind(this), 300); }.bind(this), 50);
}); });
}) })
}, },