Skip to content

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

TypeScript

docs(core): reconcile API contract props across structural components (#4163) (#4317)

Ojas Mutreja297921949f90
diff --git a/.changeset/structural-component-contract-docs-tjsk.md b/.changeset/structural-component-contract-docs-tjsk.md
new file mode 100644
index 0000000000..2153c231e8
--- /dev/null
+++ b/.changeset/structural-component-contract-docs-tjsk.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[docs] document missing props across structural components (CodeBlock, Toolbar) (#4163)
+
+@HelloOjasMutreja
diff --git a/packages/core/src/CodeBlock/CodeBlock.doc.mjs b/packages/core/src/CodeBlock/CodeBlock.doc.mjs
index b2b0d13dfb..918da14481 100644
--- a/packages/core/src/CodeBlock/CodeBlock.doc.mjs
+++ b/packages/core/src/CodeBlock/CodeBlock.doc.mjs
@@ -95,6 +95,12 @@ export const docs = {
type: 'SyntaxThemeDefinition',
description: 'Per-instance syntax theme override. Shorthand for wrapping the block in <SyntaxTheme theme={...}>. Accepts a preset from @astryxdesign/core/theme/syntax or a theme created with defineSyntaxTheme(). Defaults to the nearest SyntaxTheme ancestor or the theme-level syntax colors.',
},
+ {
+ name: 'highlightMode',
+ type: "'auto' | 'ranges' | 'spans'",
+ description: 'Syntax highlighting rendering mode.',
+ default: "'auto'",
+ },
{
name: 'isCollapsible',
type: 'boolean',
diff --git a/packages/core/src/Toolbar/Toolbar.doc.mjs b/packages/core/src/Toolbar/Toolbar.doc.mjs
index 9d0f20db76..eebd60781f 100644
--- a/packages/core/src/Toolbar/Toolbar.doc.mjs
+++ b/packages/core/src/Toolbar/Toolbar.doc.mjs
@@ -133,6 +133,11 @@ export const docs = {
description: 'Visual variant passed to Section.',
default: "'transparent'",
},
+ {
+ name: 'dividers',
+ type: "Array<'top' | 'bottom' | 'start' | 'end'>",
+ description: 'Borders/dividers rendered around the toolbar.',
+ },
{
name: 'xstyle',
type: 'StyleXStyles',
diff --git a/packages/core/src/__tests__/structuralComponentContract.test.tsx b/packages/core/src/__tests__/structuralComponentContract.test.tsx
new file mode 100644
index 0000000000..3c20f5a3cd
--- /dev/null
+++ b/packages/core/src/__tests__/structuralComponentContract.test.tsx
@@ -0,0 +1,39 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {describe, it, expect} from 'vitest';
+
+import {docs as CodeBlockDocs} from '../CodeBlock/CodeBlock.doc.mjs';
+import {docs as StackDocs} from '../Stack/Stack.doc.mjs';
+import {docs as ToolbarDocs} from '../Toolbar/Toolbar.doc.mjs';
+
+// `docs` is the ComponentDoc union (single vs multi component); narrow it
+// for structural access to either the top-level props or the first
+// sub-component's props.
+function getProps(docs: unknown): {name: string}[] {
+ const doc = docs as {
+ props?: {name: string}[];
+ components?: {props?: {name: string}[]}[];
+ };
+ return doc.props || doc.components?.[0]?.props || [];
+}
+
+describe('Structural Component API Contract Drift (#4163)', () => {
+ it('documents CodeBlock highlightMode prop', () => {
+ const props = getProps(CodeBlockDocs).map(p => p.name);
+ expect(props).toContain('highlightMode');
+ });
+
+ it('documents Toolbar dividers prop', () => {
+ const props = getProps(ToolbarDocs).map(p => p.name);
+ expect(props).toContain('dividers');
+ });
+
+ it('documents Stack direction and base props', () => {
+ const props = getProps(StackDocs).map(p => p.name);
+ expect(props).toContain('direction');
+ expect(props).toContain('gap');
+ expect(props).toContain('padding');
+ expect(props).toContain('width');
+ expect(props).toContain('height');
+ });
+});