Skip to content

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

TypeScript

feat(docsite): improve the Shape tokens page (bigger swatches + separate Value/Example columns) (#2999)

rubyycheung9ef324ecb4cd
diff --git a/apps/docsite/src/components/tokens/ShapeTokenTable.tsx b/apps/docsite/src/components/tokens/ShapeTokenTable.tsx
index 5487a76507..22d2cc6898 100644
--- a/apps/docsite/src/components/tokens/ShapeTokenTable.tsx
+++ b/apps/docsite/src/components/tokens/ShapeTokenTable.tsx
@@ -3,22 +3,22 @@
'use client';
import * as stylex from '@stylexjs/stylex';
-import {VStack, HStack} from '@xds/core/Layout';
+import {VStack} from '@xds/core/Layout';
import {Text, Heading} from '@xds/core/Text';
-import {Table, pixel} from '@xds/core/Table';
+import {Table, pixel, proportional} from '@xds/core/Table';
import type {TokenTableProps} from './types';
import {resolveToken, getTokensByPrefix} from './helpers';
const styles = stylex.create({
radiusBox: {
- width: 32,
- height: 32,
+ width: 96,
+ height: 96,
backgroundColor: 'var(--color-accent-muted)',
border: '2px solid var(--color-accent)',
flexShrink: 0,
},
borderLine: {
- width: 32,
+ width: 96,
height: 0,
borderBottomStyle: 'solid',
borderBottomColor: 'var(--color-border-emphasized)',
@@ -41,16 +41,22 @@ export function RadiusTokenTable({theme}: TokenTableProps) {
{
key: 'value',
header: 'Value',
+ width: pixel(200),
renderCell: (item: Record<string, unknown>) => (
- <HStack gap={2} vAlign="center">
- <div
- {...stylex.props(styles.radiusBox)}
- style={{borderRadius: item.value as string}}
- />
- <Text type="code" color="secondary">
- {item.value as string}
- </Text>
- </HStack>
+ <Text type="code" color="secondary">
+ {item.value as string}
+ </Text>
+ ),
+ },
+ {
+ key: 'example',
+ header: 'Example',
+ width: proportional(1, {minWidth: 120}),
+ renderCell: (item: Record<string, unknown>) => (
+ <div
+ {...stylex.props(styles.radiusBox)}
+ style={{borderRadius: item.value as string}}
+ />
),
},
]}
@@ -80,16 +86,22 @@ export function BorderTokenTable({theme}: TokenTableProps) {
{
key: 'value',
header: 'Value',
+ width: pixel(200),
+ renderCell: (item: Record<string, unknown>) => (
+ <Text type="code" color="secondary">
+ {item.value as string}
+ </Text>
+ ),
+ },
+ {
+ key: 'example',
+ header: 'Example',
+ width: proportional(1, {minWidth: 120}),
renderCell: (item: Record<string, unknown>) => (
- <HStack gap={2} vAlign="center">
- <div
- {...stylex.props(styles.borderLine)}
- style={{borderBottomWidth: item.value as string}}
- />
- <Text type="code" color="secondary">
- {item.value as string}
- </Text>
- </HStack>
+ <div
+ {...stylex.props(styles.borderLine)}
+ style={{borderBottomWidth: item.value as string}}
+ />
),
},
]}
diff --git a/apps/sandbox/src/app/(sandbox)/pages/doc-preview/token-tables/ShapeTokenTable.tsx b/apps/sandbox/src/app/(sandbox)/pages/doc-preview/token-tables/ShapeTokenTable.tsx
index 87803e01f1..eadd90b155 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/doc-preview/token-tables/ShapeTokenTable.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/doc-preview/token-tables/ShapeTokenTable.tsx
@@ -3,7 +3,7 @@
'use client';
import * as stylex from '@stylexjs/stylex';
-import {VStack, HStack} from '@xds/core/Layout';
+import {VStack} from '@xds/core/Layout';
import {Text, Heading} from '@xds/core/Text';
import {Table} from '@xds/core/Table';
import type {TokenTableProps} from './types';
@@ -11,14 +11,14 @@ import {resolveToken, getTokensByPrefix} from './helpers';
const styles = stylex.create({
radiusBox: {
- width: 32,
- height: 32,
+ width: 96,
+ height: 96,
backgroundColor: 'var(--color-accent-muted)',
border: '2px solid var(--color-accent)',
flexShrink: 0,
},
borderLine: {
- width: 32,
+ width: 96,
height: 0,
borderBottomStyle: 'solid',
borderBottomColor: 'var(--color-border-emphasized)',
@@ -65,15 +65,19 @@ function RadiusTokenTable({theme}: TokenTableProps) {
key: 'value',
header: 'Value',
renderCell: (item: Record<string, unknown>) => (
- <HStack gap={2} align="center">
- <div
- {...stylex.props(styles.radiusBox)}
- style={{borderRadius: item.value as string}}
- />
- <Text type="code" color="secondary">
- {item.value as string}
- </Text>
- </HStack>
+ <Text type="code" color="secondary">
+ {item.value as string}
+ </Text>
+ ),
+ },
+ {
+ key: 'example',
+ header: 'Example',
+ renderCell: (item: Record<string, unknown>) => (
+ <div
+ {...stylex.props(styles.radiusBox)}
+ style={{borderRadius: item.value as string}}
+ />
),
},
]}
@@ -104,15 +108,19 @@ function BorderTokenTable({theme}: TokenTableProps) {
key: 'value',
header: 'Value',
renderCell: (item: Record<string, unknown>) => (
- <HStack gap={2} align="center">
- <div
- {...stylex.props(styles.borderLine)}
- style={{borderBottomWidth: item.value as string}}
- />
- <Text type="code" color="secondary">
- {item.value as string}
- </Text>
- </HStack>
+ <Text type="code" color="secondary">
+ {item.value as string}
+ </Text>
+ ),
+ },
+ {
+ key: 'example',
+ header: 'Example',
+ renderCell: (item: Record<string, unknown>) => (
+ <div
+ {...stylex.props(styles.borderLine)}
+ style={{borderBottomWidth: item.value as string}}
+ />
),
},
]}