Skip to content

Commit 17f9d9f

Browse files
authored
Merge pull request tangly1024#2176 from lxw15337674/fix/style
修复夜间模式折叠按钮看不到,折叠按钮适配右边栏
2 parents 67613d6 + 5ca46e2 commit 17f9d9f

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

themes/fukasawa/components/AsideLeft.js

+22-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { AdSlot } from '@/components/GoogleAdsense'
1414
import { siteConfig } from '@/lib/config'
1515
import MailChimpForm from './MailChimpForm'
1616
import { useGlobal } from '@/lib/global'
17-
import { useEffect, useState } from 'react'
17+
import { useEffect, useMemo, useState } from 'react'
1818
import { isBrowser } from '@/lib/utils'
1919
import { debounce } from 'lodash'
2020

@@ -45,6 +45,23 @@ function AsideLeft(props) {
4545
}
4646
}, [isCollapsed])
4747

48+
const position = useMemo(() => {
49+
const isReverse = JSON.parse(siteConfig('LAYOUT_SIDEBAR_REVERSE'))
50+
if (isCollapsed) {
51+
if (isReverse) {
52+
return 'right-2'
53+
} else {
54+
return 'left-2'
55+
}
56+
} else {
57+
if (isReverse) {
58+
return 'right-80'
59+
} else {
60+
return 'left-80'
61+
}
62+
}
63+
}, [isCollapsed])
64+
4865
// 折叠侧边栏
4966
const toggleOpen = () => {
5067
setIsCollapse(!isCollapsed)
@@ -75,14 +92,15 @@ function AsideLeft(props) {
7592
}
7693
}
7794
}, [])
78-
95+
96+
7997
return <div className={`sideLeft relative ${isCollapsed ? 'w-0' : 'w-80'} duration-300 transition-all bg-white dark:bg-hexo-black-gray min-h-screen hidden lg:block z-20`}>
8098
{/* 折叠按钮 */}
81-
{siteConfig('FUKASAWA_SIDEBAR_COLLAPSE_BUTTON', null, CONFIG) && <div className={`${isCollapsed ? '' : 'ml-80'} hidden lg:block sticky top-0 mx-2 cursor-pointer hover:scale-110 duration-300 px-3 py-2`} onClick={toggleOpen}>
99+
{siteConfig('FUKASAWA_SIDEBAR_COLLAPSE_BUTTON', null, CONFIG) && <div className={`${position} hidden lg:block fixed top-0 cursor-pointer hover:scale-110 duration-300 px-3 py-2 dark:text-white`} onClick={toggleOpen}>
82100
{isCollapsed ? <i className="fa-solid fa-indent text-xl"></i> : <i className='fas fa-bars text-xl'></i>}
83101
</div>}
84102

85-
<div className={`h-full ${isCollapsed ? 'hidden' : 'px-8'}`}>
103+
<div className={`h-full ${isCollapsed ? 'hidden' : 'p-8'}`}>
86104

87105
<Logo {...props} />
88106

0 commit comments

Comments
 (0)