An open source design system that's fully customizable and agent ready
TypeScript
fix(docsite): seed DropdownMenu properties-tab preview with defaults (#4138)
Cindy Zhang2228f00bdba8
diff --git a/.changeset/dropdown-menu-properties-preview.md b/.changeset/dropdown-menu-properties-preview.mdnew file mode 100644index 0000000000..27921ab735--- /dev/null+++ b/.changeset/dropdown-menu-properties-preview.md@@ -0,0 +1,6 @@+---+'@astryxdesign/core': patch+---++[docs] DropdownMenu and DropdownMenuItem: seed playground defaults so the docsite properties-tab preview renders real content instead of an empty trigger.+@cixzhangdiff --git a/apps/docsite/src/__tests__/component-preview-state.test.ts b/apps/docsite/src/__tests__/component-preview-state.test.tsindex ba0a5cb9af..0ca7c5be9a 100644--- a/apps/docsite/src/__tests__/component-preview-state.test.ts+++ b/apps/docsite/src/__tests__/component-preview-state.test.ts@@ -128,6 +128,40 @@ describe('component detail preview state', () => {expect(getMissingRequiredProps(knobs, state)).toEqual([]);});+ it('seeds DropdownMenu items from playground defaults so the preview is not empty', () => {+ const knobs = pickPrimaryProps('DropdownMenu', [+ prop({name: 'button', type: 'DropdownMenuButtonProps'}),+ prop({name: 'items', type: 'DropdownMenuOption[]', required: true}),+ ]);++ const state = buildInitialState(knobs, {+ defaults: {+ button: {label: 'Actions'},+ items: [{label: 'Edit'}, {label: 'Duplicate'}, {label: 'Delete'}],+ },+ });++ expect(Array.isArray(state.items)).toBe(true);+ expect((state.items as unknown[]).length).toBe(3);+ expect(getMissingRequiredProps(knobs, state)).toEqual([]);+ });++ it('seeds DropdownMenuItem label and description from playground defaults', () => {+ const knobs = pickPrimaryProps('DropdownMenuItem', [+ prop({name: 'icon', type: 'IconType'}),+ prop({name: 'label', type: 'ReactNode'}),+ prop({name: 'description', type: 'ReactNode'}),+ ]);++ const state = buildInitialState(knobs, {+ defaults: {label: 'Edit', description: 'Modify this item'},+ });++ expect(state.label).toBe('Edit');+ expect(state.description).toBe('Modify this item');+ expect(getMissingRequiredProps(knobs, state)).toEqual([]);+ });+it("satisfies Icon's required, non-generatable icon prop via playground defaults", () => {const knobs = pickPrimaryProps('Icon', [prop({diff --git a/packages/core/src/DropdownMenu/DropdownMenu.doc.mjs b/packages/core/src/DropdownMenu/DropdownMenu.doc.mjsindex c982652c56..0a55bd569b 100644--- a/packages/core/src/DropdownMenu/DropdownMenu.doc.mjs+++ b/packages/core/src/DropdownMenu/DropdownMenu.doc.mjs@@ -8,6 +8,19 @@ export const docs = {group: 'DropdownMenu',category: 'Action',keywords: ["dropdown","menu","popover","select","actions","contextmenu","overflow","kebab","menubutton"],+ playground: {+ // `items` is required; without seeded entries the properties-tab preview+ // renders an empty trigger button. Provide a few actions so the preview+ // is meaningful.+ defaults: {+ button: {label: 'Actions'},+ items: [+ {label: 'Edit'},+ {label: 'Duplicate'},+ {label: 'Delete'},+ ],+ },+ },theming: {targets: [{className: 'astryx-dropdown-menu'},diff --git a/packages/core/src/DropdownMenu/DropdownMenuItem.doc.mjs b/packages/core/src/DropdownMenu/DropdownMenuItem.doc.mjsindex 779feed31b..dbb739ed02 100644--- a/packages/core/src/DropdownMenu/DropdownMenuItem.doc.mjs+++ b/packages/core/src/DropdownMenu/DropdownMenuItem.doc.mjs@@ -8,6 +8,12 @@ export const docs = {displayName: 'Dropdown Menu Item',isHiddenFromOverview: true,description: 'Helper component for custom item rendering with consistent styling.',+ playground: {+ // Standalone DropdownMenuItem has no required props, so the properties-tab+ // preview renders an empty row without seeded content. Seed a label and+ // description so the preview is meaningful.+ defaults: {label: 'Edit', description: 'Modify this item'},+ },props: [{name: 'icon',