Skip to content

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

TypeScript

fix(cli): keep the theme-showcase checkout from clipping its own fields (#5539)

rubyycheung5dda94ca32a1
diff --git a/.changeset/theme-showcase-checkout-clipping.md b/.changeset/theme-showcase-checkout-clipping.md
new file mode 100644
index 0000000000..b65163c8c2
--- /dev/null
+++ b/.changeset/theme-showcase-checkout-clipping.md
@@ -0,0 +1,15 @@
+---
+'@astryxdesign/cli': patch
+---
+
+[fix] The theme-showcase page no longer clips its own controls. In the store's product cards the quantity field and "Add to cart" button spilled out of both sides of the card; in the checkout card the card number truncated mid-number (`1234 1234 12`), the country selector ellipsized, and the pay button was left with only a few pixels of slack.
+
+@rubyycheung
+
+The product-card row is the more visible of the two. It had no width of its own — the enclosing stack centers rather than stretches its children — so it sized to its contents and, being centered, overflowed the card at both edges once those contents outgrew it. That stayed hidden while the quantity field was narrow, and surfaced when `NumberInput` moved to `type="text"` for formatted display: a text input's default `size=20` made the field ~200px instead of ~65px, and the template was pinning it with a `style` `minWidth` (a floor, not a cap) plus `flexShrink: 0`. The field now uses `NumberInput`'s `width` prop, which is what actually sizes a field, and the row is pinned to the card width and allowed to wrap so the button drops to its own full-width line instead of ellipsizing on a narrow card.
+
+The checkout sat in a grid track with a 200px minimum, so its width was a fraction of however many tracks happened to fit — it swung between 208px and 328px as the viewport resized, and the narrow end is well under what the form needs. Themes with a large spacing scale suffered most: Matcha's `--spacing-5` card padding alone spends 60px of that budget.
+
+The checkout and chat panels are now a wrapping flex row. They share a row at roughly 1:2 while both flex bases fit, then the chat drops to its own full-width row, which makes 300px a floor for the checkout rather than an accident of the track count. Raising the track minimum instead would have left a tall gap beside the checkout at mid widths, since a two-track row can't hold a two-track span.
+
+Two narrower fixes ride along, both text the card was breaking rather than fitting: the payment-method grid's minimum goes 70px to 80px so "Google" stops breaking mid-word on Matcha and Y2K, and on phones the card drops one padding step and sheds the card number's decorative start icon, which together buy back the room a 16-digit number needs at 360px.
diff --git a/packages/cli/assets/templates/pages/theme-showcase/page.tsx b/packages/cli/assets/templates/pages/theme-showcase/page.tsx
index 1090469483..63ada9ee82 100644
--- a/packages/cli/assets/templates/pages/theme-showcase/page.tsx
+++ b/packages/cli/assets/templates/pages/theme-showcase/page.tsx
@@ -153,14 +153,16 @@ const styles: Record<string, CSSProperties> = {
flex: 1,
},
quantityInput: {
- // minWidth (not a hard width) so the field grows to fit the digit + the
- // theme's input padding. A fixed 40px was too tight on themes with larger
- // padding / bigger type scale (e.g. Matcha, Y2K), clipping the value.
- minWidth: 64,
flexShrink: 0,
},
+ // `auto` basis so the button wraps to its own line rather than ellipsizing.
cartButton: {
- flex: 1,
+ flex: '1 1 auto',
+ minWidth: 0,
+ },
+ cartRow: {
+ width: '100%',
+ minWidth: 0,
},
};
@@ -236,6 +238,18 @@ const inlineStyles: Record<string, CSSProperties> = {
display: 'flex',
flexDirection: 'column',
},
+ // Flex bases, not grid tracks: the checkout form needs a width floor, and the
+ // chat wraps to its own row rather than squeezing it under one.
+ checkoutColumn: {
+ flex: '1 1 300px',
+ minWidth: 0,
+ display: 'grid',
+ },
+ chatColumn: {
+ flex: '2 1 520px',
+ minWidth: 0,
+ display: 'grid',
+ },
};
const PRODUCT_IMAGE_KEYS = ['watch', 'headphones', 'backpack'];
@@ -284,8 +298,7 @@ const DEFAULT_PRODUCTS: ProductSpec[] = [
// scaffolded template renders real imagery without needing local public assets.
const DEFAULT_IMAGES: Record<string, string> = {
watch: '/template-assets/Neutral-Watch.png',
- headphones:
- '/template-assets/Neutral-Headphones.png',
+ headphones: '/template-assets/Neutral-Headphones.png',
backpack: '/template-assets/Neutral-Backpack.png',
wallet: '/template-assets/Neutral-Wallet.png',
tumbler: '/template-assets/Neutral-Tumbler.png',
@@ -350,14 +363,14 @@ function CardShowcase({
return (
<VStack gap={8}>
- <Grid columns={columns} gap={4}>
- <GridSpan columns={1}>
+ <HStack gap={4} wrap="wrap">
+ <div style={inlineStyles.checkoutColumn}>
<CheckoutCard isMobile={isMobile} />
- </GridSpan>
- <GridSpan columns={isMobile ? 1 : 2}>
+ </div>
+ <div style={inlineStyles.chatColumn}>
<ChatCard />
- </GridSpan>
- </Grid>
+ </div>
+ </HStack>
<Grid columns={columns} gap={4}>
<GridSpan columns={isMobile ? 1 : 3}>
<InventoryCard images={images} inventory={inventory} />
@@ -472,7 +485,12 @@ function StorePreview({
}}>
{p.description}
</Text>
- <HStack gap={2} vAlign="center" hAlign="center">
+ <HStack
+ gap={2}
+ vAlign="center"
+ hAlign="center"
+ wrap="wrap"
+ style={styles.cartRow}>
<NumberInput
label="Quantity"
isLabelHidden
@@ -481,6 +499,7 @@ function StorePreview({
min={1}
max={99}
size="sm"
+ width={72}
style={styles.quantityInput}
/>
<Button
@@ -506,7 +525,7 @@ function StorePreview({
function CheckoutCard({isMobile}: {isMobile: boolean}) {
return (
- <Card padding={5} style={styles.card}>
+ <Card padding={isMobile ? 4 : 5} style={styles.card}>
<VStack gap={4} style={styles.checkoutStack}>
<Heading level={2}>Checkout</Heading>
@@ -560,7 +579,7 @@ function CheckoutCard({isMobile}: {isMobile: boolean}) {
<Text type="supporting" weight="bold">
Payment method
</Text>
- <Grid columns={isMobile ? 1 : {minWidth: 70, max: 3}} gap={2}>
+ <Grid columns={isMobile ? 1 : {minWidth: 80, max: 3}} gap={2}>
<SelectableCard
label="Pay with card"
isSelected={true}
@@ -614,7 +633,7 @@ function CheckoutCard({isMobile}: {isMobile: boolean}) {
placeholder="1234 1234 1234 1234"
value=""
onChange={() => {}}
- startIcon={<CreditCard size={16} />}
+ startIcon={isMobile ? undefined : <CreditCard size={16} />}
size="lg"
/>