style(file-tree): Reformat JSX and fix class name
This commit is contained in:
parent
53c8ce0677
commit
9794184e98
|
|
@ -7,7 +7,7 @@ import { useNavigate } from "@solidjs/router";
|
|||
*/
|
||||
function isPathInDir(currentPath: string, dirPath: string): boolean {
|
||||
// 确保 dirPath 以 / 结尾,用于前缀匹配
|
||||
const dirPathPrefix = dirPath.endsWith('/') ? dirPath : dirPath + '/';
|
||||
const dirPathPrefix = dirPath.endsWith("/") ? dirPath : dirPath + "/";
|
||||
return currentPath.startsWith(dirPathPrefix);
|
||||
}
|
||||
|
||||
|
|
@ -25,7 +25,9 @@ export const FileTreeNode: Component<{
|
|||
const isDir = !!props.node.children;
|
||||
const isActive = createMemo(() => props.currentPath === props.node.path);
|
||||
// 默认收起,除非当前文件在该文件夹内
|
||||
const [isExpanded, setIsExpanded] = createSignal(isDir && isPathInDir(props.currentPath, props.node.path));
|
||||
const [isExpanded, setIsExpanded] = createSignal(
|
||||
isDir && isPathInDir(props.currentPath, props.node.path),
|
||||
);
|
||||
|
||||
const handleClick = () => {
|
||||
if (isDir) {
|
||||
|
|
@ -112,11 +114,16 @@ export const HeadingNode: Component<{
|
|||
return (
|
||||
<div>
|
||||
<div class="flex flex-row">
|
||||
<span class={`cursor-pointer mr-1 text-gray-400 text-xs w-3 flex-shrink-0`}
|
||||
<span
|
||||
class={`cursor-pointer mr-1 text-gray-400 text-xs w-3 shrink-0`}
|
||||
style={{ "margin-left": `${indent + 8}px` }}
|
||||
onClick={handleExpand}
|
||||
>
|
||||
<span class={`${hasChildren ? "" : "invisible" } ${isExpanded() ? "rotate-90" : ""} mt-1 inline-block transition-transform `}>▶</span>
|
||||
<span
|
||||
class={`${hasChildren ? "" : "invisible"} ${isExpanded() ? "rotate-90" : ""} mt-1 inline-block transition-transform `}
|
||||
>
|
||||
▶
|
||||
</span>
|
||||
</span>
|
||||
<a
|
||||
href={href}
|
||||
|
|
|
|||
Loading…
Reference in New Issue