fix: active
This commit is contained in:
parent
53faa775be
commit
b6718927c7
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, createSignal, Show } from "solid-js";
|
import { Component, createMemo, createSignal, Show } from "solid-js";
|
||||||
import { type FileNode, type TocNode } from "../data-loader";
|
import { type FileNode, type TocNode } from "../data-loader";
|
||||||
import { useNavigate } from "@solidjs/router";
|
import { useNavigate } from "@solidjs/router";
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@ export const FileTreeNode: Component<{
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [isExpanded, setIsExpanded] = createSignal(true);
|
const [isExpanded, setIsExpanded] = createSignal(true);
|
||||||
const isDir = !!props.node.children;
|
const isDir = !!props.node.children;
|
||||||
const isActive = props.currentPath === props.node.path;
|
const isActive = createMemo(() => props.currentPath === props.node.path);
|
||||||
|
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
if (isDir) {
|
if (isDir) {
|
||||||
|
|
@ -32,7 +32,7 @@ export const FileTreeNode: Component<{
|
||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
class={`flex items-center py-1 px-2 cursor-pointer hover:bg-gray-100 rounded ${
|
class={`flex items-center py-1 px-2 cursor-pointer hover:bg-gray-100 rounded ${
|
||||||
isActive ? "bg-blue-50 text-blue-700" : "text-gray-700"
|
isActive() ? "bg-blue-50 text-blue-700" : "text-gray-700"
|
||||||
}`}
|
}`}
|
||||||
style={{ "padding-left": `${indent + 8}px` }}
|
style={{ "padding-left": `${indent + 8}px` }}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue