Skip to content

docs(useTruncation): add hook docs and a live example - #10744

Closed
qq2514568380 wants to merge 1 commit into
meta:mainfrom
qq2514568380:docs/use-truncation-hook-example
Closed

qq2514568380 wants to merge 1 commit into
meta:mainfrom
qq2514568380:docs/use-truncation-hook-example

Conversation

@qq2514568380

@qq2514568380 qq2514568380 commented Nov 9, 2026 •

Copy link
Copy Markdown

Reader impact

useTruncation is a public hook with no docsite page and no runnable example, so a developer who needs truncation detection on their own clipped element has nothing to open. After this change the hook has a page that states what it measures and when to reach for it, plus a live Table example they can run.

Source of truth

  • Hook source: packages/core/src/Text/useTruncation.ts (UseTruncationOptions, UseTruncationReturn)
  • architecture:knowledge-contracts INV28 — every public hook has a minimal, runnable example that names it in exampleFor
  • packages/core/src/hooks/useClipboard.doc.mjs and packages/core/src/hooks/useStreamingText.doc.mjs for the HookDoc shape
  • packages/cli/assets/templates/blocks/components/Text/TextTruncation.doc.mjs for the block descriptor shape

Correction

The hook had no HookDoc, so it had no docsite page. It also had no block naming it in exampleFor, so its Examples section was empty. This adds:

  • packages/core/src/Text/useTruncation.doc.mjs — usage, params, returns, import path (@astryxdesign/core/Text) and best practices, including when to prefer Text/Heading maxLines instead.
  • packages/cli/assets/templates/blocks/components/Text/useTruncationHookUsage.tsx and .doc.mjs — a narrow Table column of long file paths. Each cell calls the hook; the Tooltip renders only while isTruncated is true. A short path and a roomy Owner column show no tooltip, and the Details column clamps to two lines to cover the multi-line path.

No runtime or API change: the hook source and its exports are untouched.

Evidence

  • pnpm -F @astryxdesign/docsite build — passed (Next build, template gallery and function-size checks passed).
  • pnpm -F @astryxdesign/docsite exec vitest run src/__tests__/example-coverage.test.ts — 5 passed; useTruncation no longer appears in the "no hook doc" or "no example block" lists.
  • pnpm check:knowledge — passed.
  • pnpm check:sync — passed.
  • pnpm build — passed.

Two pre-existing docsite tests fail in this snapshot for reasons unrelated to this change: data-extraction.test.ts finds no dashboard* templates, and template-preview-coverage.test.ts reports incident-console, messaging-shell, and theme-showcase missing preview components. Both fail on the same files with or without this change.

Scope

  • This PR changes documentation only, and names the one generated artifact it updates: internal/shadcn-registry/routes.lock.json.
  • Runtime, API, visual, and policy changes were removed or split.
  • Public text and artifacts contain no internal Meta context.

The route-lock refresh also records template-blank, which the current generator emits but the lock on main did not contain. I kept it because the lock is generated and checked as a whole; it is not related to useTruncation.

Testing

  • Docsite production build (above).
  • Example coverage test (above).
  • Knowledge-template check and SYNC check (above).

Closes #9561

Document useTruncation with a HookDoc, and add a Table example that
shows a Tooltip only when the hook reports the text is cut off. One
column clamps to two lines so the multi-line path is covered.

Refresh the reviewed ShadCN route lock for the new hook page and example.

Refs meta#9561
@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Error Error Nov 9, 2026 7:39am UTC

Request Review

@meta-cla

meta-cla Bot commented Nov 9, 2026

Copy link
Copy Markdown

Hi @qq2514568380!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@astracat-bot

astracat-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🔄 In progress (for maintainers only) Nov 9, 2026, 3:41 AM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review labels Nov 9, 2026
@qq2514568380

Copy link
Copy Markdown
Author

Closing as a duplicate of #10555, which was opened earlier for the same issue.

@cixzhang

cixzhang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

(Posted by Cindy's agent.) Welcome, @qq2514568380, and thank you for your first contribution to Astryx! Spotting that #10555 already covered useTruncation and closing this as a duplicate was exactly the right call. If you'd like another place to start, issues labeled good first issue are a great fit, and we'd love to see more from you.

This branch had an error being deployed

1 failed deployment
Preview — d34c08c7 Deployed Nov 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(useTruncation): add hook docs and a minimal live example

2 participants