Skip to content

Commit

Permalink
refactor: add styles
Browse files Browse the repository at this point in the history
  • Loading branch information
gurtatiLND committed Dec 9, 2024
1 parent 217d862 commit 7948e4b
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 34 deletions.
112 changes: 79 additions & 33 deletions src/app/toolkit/components/CategoriesBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function CategoriesBar({ openModal, refreshCategories }: CategoriesBarProps) {
}
};
fetchCategories();
}, [refreshCategories]);
}, [refreshCategories, database]);

const handleCategoriesClick = (category: string) => {
setSelectedCategories(
Expand All @@ -46,39 +46,85 @@ function CategoriesBar({ openModal, refreshCategories }: CategoriesBarProps) {
};

return (
<div className={categoriesBarClass} data-testid="categories-bar">
<Button label="+" onClick={openModal} />
<Button
key={"All"}
label={"All"}
className={`${
selectedCategories.length == 0
? "bg-twd-secondary-purple text-white"
: "bg-twd-background text-white"
}`}
onClick={() => setSelectedCategories([])}
ariaPressed={selectedCategories.length == 0}
/>

{categories.map((categories) => {
const isActive = selectedCategories.includes(categories);

return (
<Button
key={categories}
label={categories}
className={`${
isActive
? "bg-twd-secondary-purple text-white"
: "bg-twd-background text-white"
}`}
onClick={() => handleCategoriesClick(categories)}
ariaPressed={isActive}
/>
);
})}
<div
className={categoriesBarClass}
data-testid="categories-bar"
>
{/* Fixed "+" Button */}
<div className="flex-shrink-0">
<Button label="+" onClick={openModal} className="bg-twd-primary-purple"/>
</div>

{/* Scrollable Categories */}
<div className="flex overflow-x-auto whitespace-nowrap space-x-2 flex-grow">
<Button
key={"All"}
label={"All"}
className={`${
selectedCategories.length === 0
? "bg-twd-secondary-purple text-white"
: "bg-twd-background text-white"
}`}
onClick={() => setSelectedCategories([])}
ariaPressed={selectedCategories.length === 0}
/>

{categories.map((category) => {
const isActive = selectedCategories.includes(category);

return (
<Button
key={category}
label={category}
className={`${
isActive
? "bg-twd-secondary-purple text-white"
: "bg-twd-background text-white"
}`}
onClick={() => handleCategoriesClick(category)}
ariaPressed={isActive}
/>
);
})}
</div>
</div>
);
};
}

// return (
// <div className={categoriesBarClass} data-testid="categories-bar">
// <Button label="+" onClick={openModal} />
// <Button
// key={"All"}
// label={"All"}
// className={`${
// selectedCategories.length == 0
// ? "bg-twd-secondary-purple text-white"
// : "bg-twd-background text-white"
// }`}
// onClick={() => setSelectedCategories([])}
// ariaPressed={selectedCategories.length == 0}
// />

// {categories.map((categories) => {
// const isActive = selectedCategories.includes(categories);

// return (
// <Button
// key={categories}
// label={categories}
// className={`${
// isActive
// ? "bg-twd-secondary-purple text-white"
// : "bg-twd-background text-white"
// }`}
// onClick={() => handleCategoriesClick(categories)}
// ariaPressed={isActive}
// />
// );
// })}
// </div>
// );
// };

export default CategoriesBar;
2 changes: 1 addition & 1 deletion src/app/toolkit/components/ToolList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function ToolkitList() {
}
};
fetchData();
}, []);
}, [database]);

// Toggle item `checked` state
const handleToggle = (id: string) => {
Expand Down

0 comments on commit 7948e4b

Please sign in to comment.