Skip to content

Commit 086475f

Browse files
committed
chore(dev-hub) Improved Card component
1 parent c6d926d commit 086475f

File tree

3 files changed

+51
-33
lines changed

3 files changed

+51
-33
lines changed

apps/developer-hub/content/docs/entropy/index.mdx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,26 @@ Please see [How to Generate Random Numbers Using Pyth Entropy](generate-random-n
4040

4141
## Start Building
4242

43-
<Cards className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
44-
<Card
43+
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
44+
<IntegrationCard
4545
href="/entropy/create-your-first-entropy-app"
4646
title="Build Your First App"
47-
icon={<RocketLaunch size={16} fill="unset" weight="duotone" />}
48-
>
49-
Step-by-step tutorial to deploy a coin flip using Entropy v2.
50-
</Card>
51-
<Card
47+
description="Step-by-step tutorial to deploy a coin flip using Entropy v2."
48+
icon={<RocketLaunch size={16} />}
49+
colorScheme="blue"
50+
/>
51+
<IntegrationCard
5252
href="/entropy/generate-random-numbers-evm"
5353
title="Generate Random Numbers"
54-
icon={<DiceSix size={16} fill="unset" />}
55-
>
56-
How-to guide for reading fees and requesting randomness on EVM.
57-
</Card>
58-
<Card
54+
description="How-to guide for reading fees and requesting randomness on EVM."
55+
icon={<DiceSix size={16} />}
56+
colorScheme="green"
57+
/>
58+
<IntegrationCard
5959
href="/entropy/contract-addresses"
6060
title="Contracts & Providers"
61-
icon={<FileText size={16} fill="unset" />}
62-
>
63-
Find Entropy addresses, reveal delays, gas limits, and fees.
64-
</Card>
65-
</Cards>
61+
description="Find Entropy addresses, reveal delays, gas limits, and fees."
62+
icon={<FileText size={16} />}
63+
colorScheme="purple"
64+
/>
65+
</div>
Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
import Link from "next/link";
2+
13
type IntegrationCardProps = {
24
href: string;
35
icon: React.ReactNode;
46
title: string;
57
description: string;
68
colorScheme?: "blue" | "green" | "purple";
9+
external?: boolean;
10+
showArrow?: boolean;
711
};
812

913
const colorClasses = {
@@ -24,33 +28,44 @@ const colorClasses = {
2428
},
2529
};
2630

27-
export const IntegrationCard = ({
31+
export function IntegrationCard({
2832
href,
2933
icon,
3034
title,
3135
description,
3236
colorScheme = "blue",
33-
}: IntegrationCardProps) => {
37+
external,
38+
showArrow = true,
39+
}: IntegrationCardProps) {
3440
const colors = colorClasses[colorScheme];
41+
const Wrapper = external ? "a" : Link;
42+
const wrapperProps = external
43+
? { href, target: "_blank", rel: "noopener noreferrer" }
44+
: { href };
3545

3646
return (
37-
<a
38-
href={href}
39-
className="block group bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg p-6 hover:border-gray-300 dark:hover:border-gray-600 transition-colors"
47+
<Wrapper
48+
{...(wrapperProps as { href: string } | { href: string; target: string; rel: string })}
49+
className="not-prose group no-underline grid h-full grid-rows-[auto_1fr] gap-3 rounded-xl border bg-[var(--color-fd-card)] border-[var(--color-fd-border)] p-5 md:p-6 shadow-sm outline-none transition-colors hover:border-[var(--color-fd-accent)] focus-visible:ring-2 focus-visible:ring-[var(--color-fd-accent)]"
50+
aria-label={title}
4051
>
41-
<div className="flex items-center gap-3 mb-3">
52+
<div className="flex items-center gap-3">
4253
<div
43-
className={`w-8 h-8 rounded-lg ${colors.bg} flex items-center justify-center`}
54+
className={`flex h-8 w-8 items-center justify-center rounded-md ${colors.bg}`}
4455
>
45-
<div className={`w-4 h-4 ${colors.text}`}>{icon}</div>
56+
<div className={`h-4 w-4 ${colors.text}`}>{icon}</div>
4657
</div>
47-
<h3
48-
className={`text-lg font-semibold text-gray-900 dark:text-white ${colors.hoverText}`}
49-
>
50-
{title}
51-
</h3>
58+
<h3 className={`m-0 text-base font-semibold text-[var(--color-fd-foreground)] ${colors.hoverText}`}>{title}</h3>
59+
{showArrow && (
60+
<span
61+
className="ml-auto translate-x-0 opacity-0 transition-all duration-200 ease-out group-hover:translate-x-1 group-hover:opacity-100"
62+
aria-hidden="true"
63+
>
64+
65+
</span>
66+
)}
5267
</div>
53-
<p className="text-gray-600 dark:text-gray-400">{description}</p>
54-
</a>
68+
<p className="m-0 text-sm text-[var(--color-fd-muted-foreground)] line-clamp-2">{description}</p>
69+
</Wrapper>
5570
);
56-
};
71+
}

apps/developer-hub/src/mdx-components.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ import { Tab, Tabs } from "fumadocs-ui/components/tabs";
33
import defaultMdxComponents from "fumadocs-ui/mdx";
44
import type { MDXComponents } from "mdx/types";
55

6+
import { IntegrationCard } from "./components/IntegrationCard";
7+
68
export function getMDXComponents(components?: MDXComponents): MDXComponents {
79
return {
810
...defaultMdxComponents,
911
Tabs,
1012
Tab,
1113
...components,
1214
InfoBox: InfoBox,
15+
IntegrationCard,
1316
// Fuma has a Callout component in `defaultMdxComponents` which we still want to overwrite
1417
Callout: InfoBox,
1518
};

0 commit comments

Comments
 (0)