Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(docsite): stop blog card grids overflowing on small screens (#3394)

rubyycheungdd4784a10ec5
diff --git a/apps/docsite/src/app/(site)/_landing/BlogShowcase.tsx b/apps/docsite/src/app/(site)/_landing/BlogShowcase.tsx
index 0585e94b5d..4909803cce 100644
--- a/apps/docsite/src/app/(site)/_landing/BlogShowcase.tsx
+++ b/apps/docsite/src/app/(site)/_landing/BlogShowcase.tsx
@@ -63,6 +63,16 @@ const styles = stylex.create({
'@media (min-width: 900px)': 'span 1',
},
},
+ // Two equal cards, side by side when there's room and stacked otherwise.
+ // `min(480px, 100%)` clamps the track to the container so it never forces a
+ // 480px column wider than a small viewport (which overflowed the page).
+ twoUpGrid: {
+ display: 'grid',
+ gridTemplateColumns: 'repeat(auto-fit, minmax(min(480px, 100%), 1fr))',
+ gap: spacingVars['--spacing-8'],
+ width: '100%',
+ alignItems: 'start',
+ },
});
// Section shell shared by both layouts:
@@ -96,14 +106,10 @@ export function BlogShowcase() {
const [first, second] = blogPosts;
return (
<BlogSection>
- <Grid
- columns={{minWidth: 480, repeat: 'fit'}}
- gap={8}
- width="100%"
- align="start">
+ <div {...stylex.props(styles.twoUpGrid)}>
<BlogCard post={first} feature />
<BlogCard post={second} feature />
- </Grid>
+ </div>
</BlogSection>
);
}
diff --git a/apps/docsite/src/components/blog/BlogIndex.tsx b/apps/docsite/src/components/blog/BlogIndex.tsx
index 08b0e79588..81e67bcc31 100644
--- a/apps/docsite/src/components/blog/BlogIndex.tsx
+++ b/apps/docsite/src/components/blog/BlogIndex.tsx
@@ -12,7 +12,7 @@ import * as stylex from '@stylexjs/stylex';
import {Text, Heading} from '@astryxdesign/core/Text';
import {VStack} from '@astryxdesign/core/Layout';
import {Section} from '@astryxdesign/core/Section';
-import {Grid} from '@astryxdesign/core/Grid';
+import {spacingVars} from '@astryxdesign/core/theme/tokens.stylex';
import {ToggleButton, ToggleButtonGroup} from '@astryxdesign/core/ToggleButton';
import {EmptyState} from '@astryxdesign/core/EmptyState';
import type {BlogPost, BlogPostType} from '../../lib/blog/schema';
@@ -24,6 +24,14 @@ const styles = stylex.create({
flexWrap: 'wrap',
justifyContent: 'center',
},
+ // Responsive card grid. `min(320px, 100%)` clamps the track to the container
+ // so a 320px column never overflows a narrower viewport (e.g. small phones).
+ postGrid: {
+ display: 'grid',
+ gridTemplateColumns: 'repeat(auto-fill, minmax(min(320px, 100%), 1fr))',
+ columnGap: spacingVars['--spacing-5'],
+ rowGap: spacingVars['--spacing-10'],
+ },
});
export interface BlogIndexProps {
@@ -94,14 +102,11 @@ export function BlogIndex({posts, availableTypes}: BlogIndexProps) {
<VStack gap={10}>
{featurePost ? <BlogCard post={featurePost} feature /> : null}
{restPosts.length > 0 ? (
- <Grid
- columns={{minWidth: 320, repeat: 'fill'}}
- gap={5}
- rowGap={10}>
+ <div {...stylex.props(styles.postGrid)}>
{restPosts.map(post => (
<BlogCard key={post.slug} post={post} />
))}
- </Grid>
+ </div>
) : null}
</VStack>
)}