Skip to content

feat(CopySnippet, PrismCode): add an isWrapped prop to soft-wrap long content - #1335

Merged
tenphi merged 4 commits into
mainfrom
alena/cub-4032-copysnippet-wrap
Aug 20, 2026
Merged

feat(CopySnippet, PrismCode): add an isWrapped prop to soft-wrap long content#1335
tenphi merged 4 commits into
mainfrom
alena/cub-4032-copysnippet-wrap

Conversation

@solarrust

@solarrust solarrust commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

What

Adds an isWrapped prop to PrismCode and CopySnippet that soft-wraps long content onto multiple lines instead of scrolling it horizontally.

By default both components keep each line on one line and scroll sideways, which buries long error messages and logs off to the right. isWrapped lays the content out on multiple lines: unbreakable runs like URLs, tokens and identifiers break too (overflow-wrap: anywhere), not just spaces. On CopySnippet the block additionally grows vertically to fit — so even a single very long line is fully readable rather than clamped to the collapsed single-line height.

<PrismCode code={longErrorMessage} language="bash" isWrapped />
<CopySnippet code={longErrorMessage} language="bash" isWrapped />

Why

Cube Cloud CUB-4032 — long error messages shown in PrismCode / CopySnippet force horizontal scrolling. The wrap belongs in the components: the global Prism CSS pins white-space: pre on code[class*="language-"], so it cannot be reliably overridden from outside, and CopySnippet additionally clamps the single-line height.

Design

  • PrismCode owns the wrapping (white-space: pre-wrap + overflow-wrap: anywhere on its Code sub-element, keyed on a wrapped mod). CopySnippet forwards the prop to its inner PrismCode and only adds its own layout switch (auto height, multiline button placement).
  • isWrapped follows the library's is* boolean convention (isDisabled, isLoading, isClearable, …) and avoids reading as the opposite of CopySnippet's nowrap — the two are different axes: nowrap collapses real newlines into one scrolling line, isWrapped breaks long lines. nowrap wins when both are set.
  • Copy button and syntax highlighting are unchanged.
  • Adds Wrapped stories for both components, a unit test for the wrapped mod, and a changeset (minor).

Verified in a real browser (Storybook) across corner cases: short/empty code, nowrap conflict, multiline + long lines, no-space tokens (JWT), hideText bullets, prefix, explicit height (clamps + scrolls vertically), serif, custom actions, CRLF input.

🤖 Generated with Claude Code


Note

Cursor Bugbot is generating a summary for commit a860751. Configure here.

By default CopySnippet keeps each line on one line and scrolls
horizontally, which pushes long error messages and logs off to the
right. `wrap` lays the content out on multiple lines instead: the block
grows vertically to fit (so even a single very long line is fully
readable rather than clamped to the collapsed height), and unbreakable
runs like URLs, tokens and identifiers wrap too (overflow-wrap:
anywhere), not just spaces.

It reuses the existing multiline block layout and only adds white-space
handling on the inner <code>, so behaviour is unchanged when the prop is
unused. `nowrap` still wins. `wrap` is omitted from the inherited Card
container styles (it maps to flex-wrap, meaningless on this grid-based
component) so the name can carry the boolean prop.

Also fixes the docs, which showed a non-existent `multiline` prop.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a860751

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cube-dev/ui-kit Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
cube-ui-kit Ready Ready Preview Aug 20, 2026 2:20pm

Request Review

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

📦 NPM canary release

Deployed canary version 0.0.0-canary-f040419.

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🧪 Storybook is successfully deployed!

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🏋️ Size limit report

Name Size Passed?
All 492.23 KB (+0.01% 🔺) Yes 🎉
Tree shaking (just a Button) 120.73 KB (0% 🟰) Yes 🎉

Compared against main at ac2ec33run 32379233171, 2026-08-20T14:17:23Z.

To see which modules changed, download the size-limit-statoscope-report artifact from this run and open report.html.

@solarrust solarrust changed the title feat(CopySnippet): add a wrap prop to soft-wrap long content feat(CopySnippet): add an isWrapped prop to soft-wrap long content Aug 20, 2026
@solarrust
solarrust requested a review from tenphi August 20, 2026 13:08
@solarrust solarrust changed the title feat(CopySnippet): add an isWrapped prop to soft-wrap long content feat(CopySnippet, PrismCode): add an isWrapped prop to soft-wrap long content Aug 20, 2026
@tenphi
tenphi merged commit f777bbb into main Aug 20, 2026
16 checks passed
@tenphi
tenphi deleted the alena/cub-4032-copysnippet-wrap branch August 20, 2026 14:22
@tenphi tenphi mentioned this pull request Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants