Skip to content

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

TypeScript

fix(docsite): give Timestamp playground a valid default value (#3224)

Cindy Zhang2a05bd7eb8b1
diff --git a/.changeset/timestamp-playground-default-value.md b/.changeset/timestamp-playground-default-value.md
new file mode 100644
index 0000000000..61399cad32
--- /dev/null
+++ b/.changeset/timestamp-playground-default-value.md
@@ -0,0 +1,6 @@
+---
+'@astryxdesign/core': patch
+---
+
+[docs] Restore the Timestamp properties-tab preview on the docsite. `value` is a required prop with no semantic default, so the preview rendered "Invalid time value"; it now seeds a valid ISO 8601 date (#2877)
+@cixzhang
diff --git a/apps/docsite/src/__tests__/component-preview-state.test.ts b/apps/docsite/src/__tests__/component-preview-state.test.ts
index bec1eb6eea..a9d86e23b8 100644
--- a/apps/docsite/src/__tests__/component-preview-state.test.ts
+++ b/apps/docsite/src/__tests__/component-preview-state.test.ts
@@ -147,6 +147,29 @@ describe('component detail preview state', () => {
expect(getMissingRequiredProps(knobs, state)).toEqual([]);
});
+ it('gives Timestamp a valid date value via playground defaults', () => {
+ const knobs = pickPrimaryProps('Timestamp', [
+ prop({name: 'value', type: 'string | number', required: true}),
+ ]);
+
+ // Without a playground default, the required string `value` falls back to
+ // the prop's own name ("value"), which `new Date("value").toISOString()`
+ // rejects with "Invalid time value" — crashing the preview on load.
+ const fallback = buildInitialState(knobs).value;
+ expect(fallback).toBe('value');
+ expect(() => new Date(fallback as string).toISOString()).toThrow(
+ 'Invalid time value',
+ );
+
+ // The doc's playground default seeds a valid date the component can render.
+ const state = buildInitialState(knobs, {
+ defaults: {value: '2026-02-19T17:00:00Z'},
+ });
+ expect(state.value).toBe('2026-02-19T17:00:00Z');
+ expect(() => new Date(state.value as string).toISOString()).not.toThrow();
+ expect(getMissingRequiredProps(knobs, state)).toEqual([]);
+ });
+
it('gives Skeleton concrete preview dimensions via playground defaults', () => {
const knobs = pickPrimaryProps('Skeleton', [
prop({name: 'width', type: 'number | string', default: "'100%'"}),
diff --git a/packages/core/src/Timestamp/Timestamp.doc.mjs b/packages/core/src/Timestamp/Timestamp.doc.mjs
index fa7f409394..0b02fab0b8 100644
--- a/packages/core/src/Timestamp/Timestamp.doc.mjs
+++ b/packages/core/src/Timestamp/Timestamp.doc.mjs
@@ -7,6 +7,15 @@ export const docs = {
displayName: 'Timestamp',
category: 'Content',
keywords: ['date', 'time', 'datetime', 'relative', 'ago', 'clock', 'format', 'duration'],
+ playground: {
+ // `value` is required but has no semantic default, so the properties-tab
+ // preview fell back to the literal string "value" — which
+ // `new Date("value")` rejects, crashing the preview with "Invalid time
+ // value". Seed a valid ISO 8601 date so the interactive preview renders.
+ defaults: {
+ value: '2026-02-19T17:00:00Z',
+ },
+ },
props: [
{
name: 'value',