Skip to content

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

TypeScript

Fixed card styling for Sandbox (#1430)

Kenton Quatman3e4a2ce1a9f5
diff --git a/apps/sandbox/src/app/(sandbox)/page.tsx b/apps/sandbox/src/app/(sandbox)/page.tsx
index 66ebdfdfea..f81cbc7583 100644
--- a/apps/sandbox/src/app/(sandbox)/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/page.tsx
@@ -92,32 +92,19 @@ export default function Home() {
startIcon={SearchIcon}
size="lg"
/>
- <XDSHStack vAlign="center" hAlign="between">
- <div {...stylex.props(styles.hideOnSmall)}>
- <XDSToggleButtonGroup
- label="Filter by category"
- value={activeTab}
- onChange={v => setActiveTab(v ?? 'All')}>
- {CATEGORY_FILTERS.map(cat => (
- <XDSToggleButton
- key={cat}
- label={cat}
- value={cat}
- size="lg"
- />
- ))}
- </XDSToggleButtonGroup>
- </div>
- <div {...stylex.props(styles.hideOnLarge)}>
- <XDSDropdownMenu
- button={{label: activeTab, size: 'lg'}}
- items={CATEGORY_FILTERS.map(cat => ({
- label: cat,
- onClick: () => setActiveTab(cat),
- }))}
+ <XDSToggleButtonGroup
+ label="Filter by category"
+ value={activeTab}
+ onChange={v => setActiveTab(v ?? 'All')}>
+ {CATEGORY_FILTERS.map(cat => (
+ <XDSToggleButton
+ key={cat}
+ label={cat}
+ value={cat}
+ size="lg"
/>
- </div>
- </XDSHStack>
+ ))}
+ </XDSToggleButtonGroup>
</XDSVStack>
{filtered.length === 0 ? (
diff --git a/apps/sandbox/src/app/ProjectCard.tsx b/apps/sandbox/src/app/ProjectCard.tsx
index c79ea643db..87416e5e10 100644
--- a/apps/sandbox/src/app/ProjectCard.tsx
+++ b/apps/sandbox/src/app/ProjectCard.tsx
@@ -1,21 +1,37 @@
'use client';
import Link from 'next/link';
-import {XDSText} from '@xds/core/Text';
+import * as stylex from '@stylexjs/stylex';
+import {XDSHeading, XDSText} from '@xds/core/Text';
import {XDSCard} from '@xds/core/Card';
import {XDSVStack} from '@xds/core/Stack';
+import {shadowVars} from '@xds/core/theme/tokens.stylex';
import type {SandboxPage} from './sandboxPages';
+const styles = stylex.create({
+ link: {
+ textDecoration: 'none',
+ color: 'inherit',
+ display: 'flex',
+ },
+ cardStyles: {
+ width: '100%',
+ cursor: 'pointer',
+ boxShadow: {
+ default: 'none',
+ ':hover': shadowVars['--shadow-med'],
+ },
+ },
+});
+
export function ProjectCard({page}: {page: SandboxPage}) {
return (
- <Link
- href={page.href}
- style={{textDecoration: 'none', color: 'inherit', display: 'flex'}}>
- <XDSCard padding={4} style={{width: '100%'}}>
+ <Link href={page.href} {...stylex.props(styles.link)}>
+ <XDSCard xstyle={styles.cardStyles}>
<XDSVStack gap={1}>
- <XDSText type="body" weight="semibold" maxLines={1}>
+ <XDSHeading level={3} maxLines={1}>
{page.name}
- </XDSText>
+ </XDSHeading>
<XDSText type="body" size="sm" color="secondary" maxLines={2}>
{page.description}
</XDSText>
diff --git a/apps/sandbox/src/app/SandboxNav.tsx b/apps/sandbox/src/app/SandboxNav.tsx
index 66eebc03d0..2a05af87fc 100644
--- a/apps/sandbox/src/app/SandboxNav.tsx
+++ b/apps/sandbox/src/app/SandboxNav.tsx
@@ -17,6 +17,7 @@ import {
MoonIcon,
BoxIcon,
AppWindowIcon,
+ BlocksIcon,
} from './icons';
import {spacingVars, colorVars} from '@xds/core/theme/tokens.stylex';
@@ -26,6 +27,7 @@ const categoryIcons: Record<
> = {
'components-patterns': BoxIcon,
templates: AppWindowIcon,
+ blocks: BlocksIcon,
tools: WrenchIcon,
};
diff --git a/apps/sandbox/src/app/icons.tsx b/apps/sandbox/src/app/icons.tsx
index b21406bdd0..9bf76ab15e 100644
--- a/apps/sandbox/src/app/icons.tsx
+++ b/apps/sandbox/src/app/icons.tsx
@@ -157,6 +157,22 @@ export const AppWindowIcon = (props: IconProps) => (
</svg>
);
+export const BlocksIcon = (props: IconProps) => (
+ <svg
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth={2}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ {...props}>
+ <rect x="2" y="2" width="8.5" height="8.5" rx="1" />
+ <rect x="13.5" y="2" width="8.5" height="8.5" rx="1" />
+ <rect x="2" y="13.5" width="8.5" height="8.5" rx="1" />
+ <rect x="13.5" y="13.5" width="8.5" height="8.5" rx="1" />
+ </svg>
+);
+
export const SearchIcon = (props: IconProps) => (
<svg
viewBox="0 0 24 24"