Skip to content

Commit d11ff59

Browse files
committed
feat: enhance card-group mobile responsive
1 parent 61c88e4 commit d11ff59

2 files changed

Lines changed: 19 additions & 65 deletions

File tree

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
---
2-
import { cn } from '@explainer/ui'
2+
const gridCols = {
3+
1: "md:grid-cols-1",
4+
2: "md:grid-cols-2",
5+
3: "md:grid-cols-3",
6+
4: "md:grid-cols-4",
7+
5: "md:grid-cols-5",
8+
6: "md:grid-cols-6",
9+
7: "md:grid-cols-7",
10+
8: "md:grid-cols-8",
11+
9: "md:grid-cols-9",
12+
10: "md:grid-cols-10",
13+
11: "md:grid-cols-11",
14+
12: "md:grid-cols-12",
15+
} as const;
316
417
interface Props {
5-
cols?: 1 | 2 | 3 | 4
6-
className?: string
7-
}
18+
cols?: keyof typeof gridCols
19+
};
820
9-
const { cols = 2, className } = Astro.props
21+
const { cols = 2 } = Astro.props as Props;
22+
const colClass = gridCols[cols as keyof typeof gridCols];
1023
---
11-
12-
<div
13-
class={cn('my-4 grid gap-5', className)}
14-
style={{ gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))` }}
15-
>
24+
<div class:list={["grid gap-5 sm:grid-cols-1", colClass]}>
1625
<slot />
1726
</div>

packages/mdx/src/components/card-group/card-group.tsx

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)