Skip to content

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

TypeScript

Styling fixes for components overview page (#2439)

Kenton Quatman369e17368ae3
diff --git a/apps/docsite/src/app/(docs)/components/page.tsx b/apps/docsite/src/app/(docs)/components/page.tsx
index a8e4785b2e..7115aaf7e5 100644
--- a/apps/docsite/src/app/(docs)/components/page.tsx
+++ b/apps/docsite/src/app/(docs)/components/page.tsx
@@ -6,16 +6,14 @@
'use client';
-import {useMemo, useState} from 'react';
+import {Fragment, useMemo} from 'react';
import * as stylex from '@stylexjs/stylex';
-import {MagnifyingGlassIcon} from '@heroicons/react/24/outline';
import {XDSText} from '@xds/core/Text';
import {XDSHeading} from '@xds/core/Text';
import {XDSVStack} from '@xds/core/Layout';
import {XDSSection} from '@xds/core/Section';
import {XDSGrid} from '@xds/core/Grid';
import {XDSClickableCard} from '@xds/core/ClickableCard';
-import {XDSTextInput} from '@xds/core/TextInput';
import {XDSDivider} from '@xds/core/Divider';
import {components as componentRegistry} from '../../../generated/componentRegistry';
import {blocks} from '../../../generated/blockRegistry';
@@ -47,8 +45,8 @@ const styles = stylex.create({
heroTitle: {
textAlign: 'center' as const,
},
- categorySection: {
- paddingBlock: 'var(--spacing-4)',
+ section: {
+ marginInline: 'auto',
},
cardImage: {
display: 'block',
@@ -70,8 +68,6 @@ interface CategoryItem {
}
export default function ComponentsGalleryPage() {
- const [query, setQuery] = useState('');
-
/** All categorized components (excluding hidden, hooks, and utilities) */
const categorizedItems = useMemo(() => {
const coreComponents = componentRegistry['@xds/core'] ?? [];
@@ -102,34 +98,22 @@ export default function ComponentsGalleryPage() {
return items;
}, []);
- /** Filtered items based on search query */
- const filteredItems = useMemo(() => {
- const q = query.trim().toLowerCase();
- if (!q) {return categorizedItems;}
- return categorizedItems.filter(
- item =>
- item.name.toLowerCase().includes(q) ||
- item.displayName.toLowerCase().includes(q) ||
- item.description.toLowerCase().includes(q),
- );
- }, [categorizedItems, query]);
-
- /** Group filtered items by category */
+ /** Group items by category */
const groupedByCategory = useMemo(() => {
const map = new Map<string, CategoryItem[]>();
for (const cat of CATEGORIES) {
map.set(cat, []);
}
- for (const item of filteredItems) {
+ for (const item of categorizedItems) {
const list = map.get(item.category);
if (list) {list.push(item);}
}
return map;
- }, [filteredItems]);
+ }, [categorizedItems]);
return (
- <XDSSection maxWidth="xl" padding={6}>
- <XDSVStack gap={8}>
+ <XDSSection maxWidth={1200} padding={6} xstyle={styles.section}>
+ <XDSVStack gap={10}>
<XDSVStack gap={2} style={{alignItems: 'center'}}>
<XDSText type="display-2" xstyle={styles.heroTitle}>
Browse the library
@@ -140,51 +124,41 @@ export default function ComponentsGalleryPage() {
</XDSText>
</XDSVStack>
- <XDSTextInput
- label="Search components"
- isLabelHidden
- value={query}
- onChange={setQuery}
- placeholder="Search components…"
- startIcon={MagnifyingGlassIcon}
- hasClear
- />
-
{CATEGORIES.map(cat => {
const items = groupedByCategory.get(cat) ?? [];
if (items.length === 0) {return null;}
return (
- <XDSVStack key={cat} gap={4} xstyle={styles.categorySection}>
- <XDSHeading level={2}>{cat}</XDSHeading>
-
- <XDSGrid
- columns={{minWidth: 280, repeat: 'fill'}}
- gap={4}
- rowGap={6}>
- {items.map(item => (
- <XDSVStack key={item.name} gap={2}>
- <XDSClickableCard
- label={item.displayName}
- href={item.href}
- padding={0}
- variant="transparent">
- {item.showcase ? (
- <ShowcaseThumbnail
- dirName={item.showcase.dirName}
- category={item.showcase.category}
- />
- ) : (
- <div {...stylex.props(styles.cardImage)} />
- )}
- </XDSClickableCard>
- <XDSText type="supporting">{item.displayName}</XDSText>
- </XDSVStack>
- ))}
- </XDSGrid>
-
+ <Fragment key={cat}>
<XDSDivider />
- </XDSVStack>
+ <XDSVStack gap={4}>
+ <XDSHeading level={2}>{cat}</XDSHeading>
+ <XDSGrid
+ columns={{minWidth: 240, repeat: 'fill'}}
+ gap={3}
+ rowGap={4}>
+ {items.map(item => (
+ <XDSVStack key={item.name} gap={1}>
+ <XDSClickableCard
+ label={item.displayName}
+ href={item.href}
+ padding={0}
+ variant="transparent">
+ {item.showcase ? (
+ <ShowcaseThumbnail
+ dirName={item.showcase.dirName}
+ category={item.showcase.category}
+ />
+ ) : (
+ <div {...stylex.props(styles.cardImage)} />
+ )}
+ </XDSClickableCard>
+ <XDSText type="supporting">{item.displayName}</XDSText>
+ </XDSVStack>
+ ))}
+ </XDSGrid>
+ </XDSVStack>
+ </Fragment>
);
})}
</XDSVStack>