Skip to content

Commit

Permalink
chore: move accordion to one level
Browse files Browse the repository at this point in the history
  • Loading branch information
harish-sethuraman committed Oct 28, 2024
1 parent d8bc2f7 commit ec3211e
Showing 1 changed file with 43 additions and 20 deletions.
63 changes: 43 additions & 20 deletions src/components/scope/scope-item.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Scope, Variable, Reference } from "eslint-scope";
import { TreeEntry } from "../tree-entry";
import type { FC } from "react";
import {
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion";
import { TreeEntry } from "../tree-entry";
import type { FC } from "react";
} from "../ui/accordion";

type ScopeItemProperties = {
isArray: boolean;
Expand Down Expand Up @@ -41,25 +41,48 @@ export const ScopeItem: FC<ScopeItemProperties> = ({
([name]) => !name.startsWith("__"),
);

if (path.length === 1) {
return (
<AccordionItem
value={path + "." + index + "." + key}
className="border border-card rounded-lg overflow-hidden"
>
<AccordionTrigger className="text-sm bg-card px-4 py-3 capitalize">
{isArray && `${Math.max(index, 0)}.`} {key}
</AccordionTrigger>
<AccordionContent className="p-4 border-t">
<div className="space-y-1">
{properties.map((item, index) => (
<TreeEntry
key={item[0]}
data={item}
path={path + "." + index}
/>
))}
</div>
</AccordionContent>
</AccordionItem>
);
}

return (
<AccordionItem
value={path + "." + index + "." + key}
className="border border-card rounded-lg overflow-hidden"
>
<AccordionTrigger className="text-sm bg-card px-4 py-3 capitalize">
<div className="border border-card rounded-lg overflow-hidden">
<button className="flex items-center font-medium text-sm bg-card px-4 py-3 capitalize w-full">
{isArray && `${Math.max(index, 0)}.`} {key}
</AccordionTrigger>
<AccordionContent className="p-4 border-t">
<div className="space-y-1">
{properties.map((item, index) => (
<TreeEntry
key={item[0]}
data={item}
path={path + "." + index}
/>
))}
</button>
<div className="overflow-hidden text-sm">
<div className="p-4 border-t">
<div className="space-y-1">
{properties.map((item, index) => (
<TreeEntry
key={item[0]}
data={item}
path={path + "." + index}
/>
))}
</div>
</div>
</AccordionContent>
</AccordionItem>
</div>
</div>
);
};

0 comments on commit ec3211e

Please sign in to comment.