Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
atrincas authored and andresgnlez committed Sep 11, 2024
1 parent ed96186 commit 44ebaed
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 87 deletions.
2 changes: 1 addition & 1 deletion client/src/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const buttonVariants = cva(
"border border-bluish-gray-500/35 text-primary bg-transparent hover:border-bluish-gray-500 disabled:border-bluish-gray-500/35 disabled:text-primary/20 disabled:bg-transparent",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-foreground underline-offset-[3px] underline",
transparent: "",
clean: "",
},
size: {
default: "h-10 px-4 py-2",
Expand Down
4 changes: 2 additions & 2 deletions client/src/containers/content-section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ const ContentSection: FC<PropsWithChildren<ContentSectionProps>> = ({
children,
}) => {
return (
<div>
<>
<div className="rounded-2xl bg-secondary p-6">
<h2 className="text-xl font-semibold">{title}</h2>
<div>{description}</div>
</div>
{children}
</div>
</>
);
};

Expand Down
86 changes: 36 additions & 50 deletions client/src/containers/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,72 +17,58 @@ import {
import { Button } from "@/components/ui/button";

const Sidebar: FC = () => {
const currentPage = usePathname().startsWith("/sandbox")
? "sandbox"
: "explore";
let AccordionComponent = null;
const isExplore = usePathname().startsWith("/explore");

if (currentPage === "explore") {
AccordionComponent = (
<SidebarAccordion
key="sidebar-accordion-explore"
defaultValue={["explore-sections"]}
>
<AccordionItem value="explore-filters">
<AccordionTrigger>Filters</AccordionTrigger>
<AccordionContent>filters here...</AccordionContent>
</AccordionItem>
<AccordionItem value="explore-sections">
<AccordionTrigger>Sections</AccordionTrigger>
<AccordionContent></AccordionContent>
</AccordionItem>
</SidebarAccordion>
);
}

if (currentPage === "sandbox") {
AccordionComponent = (
<SidebarAccordion
key="sidebar-accordion-sandbox"
defaultValue={["sandbox-settings", "sandbox-filters"]}
>
<AccordionItem value="sandbox-settings">
<AccordionTrigger>Settings</AccordionTrigger>
<AccordionContent>settings here...</AccordionContent>
</AccordionItem>
<AccordionItem value="sandbox-filters">
<AccordionTrigger>Filters</AccordionTrigger>
<AccordionContent>filters here...</AccordionContent>
</AccordionItem>
</SidebarAccordion>
);
}
return (
<>
<Header />
<div className="flex rounded-2xl bg-primary">
<Button
variant="transparent"
className={cn(
"w-full",
currentPage === "explore" && "bg-white text-primary",
)}
variant="clean"
className={cn("w-full", isExplore && "bg-white text-primary")}
asChild
>
<Link href="/explore">Explore</Link>
</Button>
<Button
variant="transparent"
className={cn(
"w-full",
currentPage === "sandbox" && "bg-white text-primary",
)}
variant="clean"
className={cn("w-full", !isExplore && "bg-white text-primary")}
asChild
>
<Link href="/sandbox">Sandbox</Link>
</Button>
</div>
{AccordionComponent}
<SidebarAccordion
defaultValue={
isExplore
? ["explore-sections"]
: ["sandbox-settings", "sandbox-filters"]
}
>
{isExplore ? (
<>
<AccordionItem value="explore-filters">
<AccordionTrigger>Filters</AccordionTrigger>
<AccordionContent>filters here...</AccordionContent>
</AccordionItem>
<AccordionItem value="explore-sections">
<AccordionTrigger>Sections</AccordionTrigger>
<AccordionContent></AccordionContent>
</AccordionItem>
</>
) : (
<>
<AccordionItem value="sandbox-settings">
<AccordionTrigger>Settings</AccordionTrigger>
<AccordionContent>settings here...</AccordionContent>
</AccordionItem>
<AccordionItem value="sandbox-filters">
<AccordionTrigger>Filters</AccordionTrigger>
<AccordionContent>filters here...</AccordionContent>
</AccordionItem>
</>
)}
</SidebarAccordion>
</>
);
};
Expand Down
7 changes: 6 additions & 1 deletion client/src/containers/sidebar/sidebar-accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, PropsWithChildren, useState } from "react";
import { FC, PropsWithChildren, useEffect, useState } from "react";

import { Accordion } from "@/components/ui/accordion";

Expand All @@ -12,6 +12,11 @@ const SidebarAccordion: FC<PropsWithChildren<SidebarAccordionProps>> = ({
}) => {
const [value, setValue] = useState(defaultValue || undefined);

useEffect(() => {
if (value === defaultValue) return;
setValue(defaultValue);
}, [defaultValue, setValue]);

return (
<Accordion
type="multiple"
Expand Down
1 change: 0 additions & 1 deletion client/src/hooks/index.ts

This file was deleted.

32 changes: 0 additions & 32 deletions client/src/hooks/useHash.ts

This file was deleted.

0 comments on commit 44ebaed

Please sign in to comment.