Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean Up ProductToggle Component #251

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions src/components/pricing/product-toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@ import IconQStash from "@/components/icon-qstash";
import IconRedis from "@/components/icon-redis";
import IconVector from "@/components/icon-vector";

export default function ProductToggle({ product }: { product: string }) {
const productConfig = {
"/redis": { name: "Redis", Icon: IconRedis },
"/vector": { name: "Vector", Icon: IconVector },
"/qstash": { name: "QStash", Icon: IconQStash },
} as const;

type Product = keyof typeof productConfig;

export default function ProductToggle({ product }: { product: Product }) {
return (
<div className="flex justify-center">
<div className="flex gap-3 rounded-xl border border-white/5 p-2">
{["/redis", "/vector", "/qstash"].map((key) => {
{(Object.keys(productConfig) as Product[]).map((key) => {
const isActive = product === key;

const isRedis = key === "/redis";
const isVector = key === "/vector";
const isQStash = key === "/qstash";
const { name, Icon } = productConfig[key];

return (
<Link
Expand All @@ -40,15 +45,9 @@ export default function ProductToggle({ product }: { product: string }) {
/>
)}
<>
{isRedis && <IconRedis width={20} />}
{isVector && <IconVector width={20} />}
{isQStash && <IconQStash width={20} />}
<Icon width={20} />
</>
<span className="grow px-1 font-medium">
{isRedis && "Redis"}
{isVector && "Vector"}
{isQStash && "QStash"}
</span>
<span className="grow px-1 font-medium">{name}</span>
</Link>
);
})}
Expand Down