Skip to content

Commit

Permalink
Add counters to buttons in supporters section
Browse files Browse the repository at this point in the history
  • Loading branch information
damianstasik committed Aug 31, 2023
1 parent bae2f54 commit c158a23
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
46 changes: 40 additions & 6 deletions src/components/Supporters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,67 @@ type ToggleButtonProps = {
children: React.ReactNode;
isActive: boolean;
onClick: () => void;
count?: number;
};

function ToggleButton({ children, isActive, onClick }: ToggleButtonProps) {
function ToggleButton({
children,
isActive,
count,
...rest
}: ToggleButtonProps) {
return (
<button
type="button"
className={clsx(
"border font-semibold text-white h-12 px-6 flex items-center hover:no-underline",
"border text-white h-12 px-6 flex items-center hover:no-underline",
isActive ? "border-white" : "border-white/20"
)}
{...rest}
>
{children}
{count && (
<sup className="ml-2 mt-2 text-brandLight text-base font-bold">
{count}
</sup>
)}
</button>
);
}

export default function Supporters() {
const [activeTab, setActiveTab] = React.useState("all");
return (
<section className="py-12 mx-auto container">
<h3 className="text-center text-5xl font-bold mb-7">Supporters</h3>
<div className="flex gap-6 justify-center">
<ToggleButton isActive onClick={() => {}}>
<ToggleButton
isActive={activeTab === "all"}
onClick={() => setActiveTab("all")}
>
All
</ToggleButton>
<ToggleButton onClick={() => {}}>Companies</ToggleButton>
<ToggleButton onClick={() => {}}>Individuals</ToggleButton>
<ToggleButton onClick={() => {}}>Projects</ToggleButton>
<ToggleButton
isActive={activeTab === "companies"}
onClick={() => setActiveTab("companies")}
count={12}
>
Companies
</ToggleButton>
<ToggleButton
isActive={activeTab === "individuals"}
onClick={() => setActiveTab("individuals")}
count={34}
>
Individuals
</ToggleButton>
<ToggleButton
isActive={activeTab === "projects"}
onClick={() => setActiveTab("projects")}
count={56}
>
Projects
</ToggleButton>
</div>
</section>
);
Expand Down
1 change: 1 addition & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
colors: {
brand: "#933EFF",
brandMuted: "#AA4EE7",
brandLight: "#AA67FF",
dark1: "#0C192B",
dark2: "#14253D",
light1: "#E5E6E6",
Expand Down

0 comments on commit c158a23

Please sign in to comment.