UI: use container media queries on Cards

This commit is contained in:
Fuma Nama
2025-03-03 19:17:20 +08:00
parent 70d715d190
commit 0e5e14d458
2 changed files with 10 additions and 12 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-ui': patch
---
Use container media queries on Cards
+5 -12
View File
@@ -2,20 +2,18 @@ import Link from 'fumadocs-core/link';
import type { HTMLAttributes, ReactNode } from 'react';
import { cn } from '@/utils/cn';
export function Cards(
props: HTMLAttributes<HTMLDivElement>,
): React.ReactElement {
export function Cards(props: HTMLAttributes<HTMLDivElement>) {
return (
<div
{...props}
className={cn('grid grid-cols-1 gap-4 sm:grid-cols-2', props.className)}
className={cn('grid grid-cols-2 gap-4 @container', props.className)}
>
{props.children}
</div>
);
}
export type CardProps = HTMLAttributes<HTMLElement> & {
export type CardProps = Omit<HTMLAttributes<HTMLElement>, 'title'> & {
icon?: ReactNode;
title: ReactNode;
description?: ReactNode;
@@ -24,12 +22,7 @@ export type CardProps = HTMLAttributes<HTMLElement> & {
external?: boolean;
};
export function Card({
icon,
title,
description,
...props
}: CardProps): React.ReactElement {
export function Card({ icon, title, description, ...props }: CardProps) {
const E = props.href ? Link : 'div';
return (
@@ -37,7 +30,7 @@ export function Card({
{...props}
data-card
className={cn(
'block rounded-lg border bg-fd-card p-4 text-fd-card-foreground shadow-md transition-colors',
'block rounded-lg border bg-fd-card p-4 text-fd-card-foreground shadow-md transition-colors @max-lg:col-span-full',
props.href && 'hover:bg-fd-accent/80',
props.className,
)}