mirror of
https://github.com/lingke-net/koring-space.git
synced 2026-09-12 05:45:17 +08:00
feat: 隐藏手机端暗黑模式切换按钮
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
This commit is contained in:
@@ -242,10 +242,6 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-toggle {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-nav-content {
|
.card-nav-content {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ const CardNav: React.FC<CardNavProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const [isHamburgerOpen, setIsHamburgerOpen] = useState(false);
|
const [isHamburgerOpen, setIsHamburgerOpen] = useState(false);
|
||||||
const [isExpanded, setIsExpanded] = useState(false);
|
const [isExpanded, setIsExpanded] = useState(false);
|
||||||
|
const [isMobile, setIsMobile] = useState(false);
|
||||||
const navRef = useRef<HTMLElement>(null);
|
const navRef = useRef<HTMLElement>(null);
|
||||||
const cardsRef = useRef<HTMLDivElement[]>([]);
|
const cardsRef = useRef<HTMLDivElement[]>([]);
|
||||||
const tlRef = useRef<gsap.core.Timeline | null>(null);
|
const tlRef = useRef<gsap.core.Timeline | null>(null);
|
||||||
@@ -147,6 +148,14 @@ const CardNav: React.FC<CardNavProps> = ({
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [isExpanded]);
|
}, [isExpanded]);
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
const mql = window.matchMedia("(max-width: 768px)");
|
||||||
|
const update = () => setIsMobile(mql.matches);
|
||||||
|
update();
|
||||||
|
mql.addEventListener("change", update);
|
||||||
|
return () => mql.removeEventListener("change", update);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const toggleMenu = () => {
|
const toggleMenu = () => {
|
||||||
const tl = tlRef.current;
|
const tl = tlRef.current;
|
||||||
if (!tl) return;
|
if (!tl) return;
|
||||||
@@ -207,6 +216,7 @@ const CardNav: React.FC<CardNavProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
|
{!isMobile && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="theme-toggle"
|
className="theme-toggle"
|
||||||
@@ -231,6 +241,7 @@ const CardNav: React.FC<CardNavProps> = ({
|
|||||||
</svg>
|
</svg>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user