Skip to content
This repository was archived by the owner on Aug 5, 2026. It is now read-only.

[CLOV-1815][BpkText] Add underline and line clamp controls - #4978

Merged
IrinaWei merged 7 commits into
mainfrom
codex/clov-1815-bpk-text-controls
Jul 31, 2026
Merged

IrinaWei merged 7 commits into
mainfrom
codex/clov-1815-bpk-text-controls

Conversation

@IrinaWei

@IrinaWei IrinaWei commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds text decoration and truncation controls to BpkText.

  • Adds an underline boolean prop, including support for combining underline and strikethrough.
  • Adds a truncate boolean prop for no-wrap, single-line ellipsis truncation.
  • Adds a lineClamp prop for configurable single- or multi-line ellipsis truncation.
  • Accepts only positive integers for lineClamp; zero, negative, fractional, NaN, and infinite values are ignored.
  • Gives a valid lineClamp precedence when both truncation props are supplied.
  • Preserves consumer-provided inline styles while using a CSS custom property to configure the clamp count.
  • Allows long unbroken content to wrap within a clamped element instead of expanding its available width.
  • Adds Storybook examples comparing full text, truncate, and lineClamp at the same width, including flex-layout and unbroken-text cases.
  • Adds unit, accessibility, visual-test, and README coverage for the new behaviour.

Jira: CLOV-1815

snapshot

underline

image

truncate

image

lineclamp and comparison between truncate

image

Testing

  • pnpm exec jest packages/backpack-web/src/bpk-component-text/src/BpkText-test.tsx packages/backpack-web/src/bpk-component-text/src/accessibility-test.tsx --runInBand --watchman=false
  • pnpm exec eslint packages/backpack-web/src/bpk-component-text/src/BpkText.tsx packages/backpack-web/src/bpk-component-text/src/BpkText-test.tsx packages/backpack-web/src/bpk-component-text/src/BpkText.stories.tsx packages/backpack-web/src/bpk-component-text/src/accessibility-test.tsx
  • pnpm exec stylelint packages/backpack-web/src/bpk-component-text/src/BpkText.module.scss packages/backpack-web/src/bpk-component-text/src/BpkText.stories.module.scss
  • pnpm nx run backpack-web:typecheck
  • pnpm nx run backpack-web:build-sass

Checklist

  • PR title includes the component name.
  • Component README.md updated.
  • Unit and accessibility tests added.
  • Storybook and visual-test examples added.
  • Existing default typography and style pass-through behaviour preserved.
  • Manual keyboard, screen reader, and zoom checks.
  • Migration guide not required because the change is additive.

Copilot AI review requested due to automatic review settings July 29, 2026 08:54
@IrinaWei IrinaWei added the patch Patch production bug label Jul 29, 2026
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

skyscanner-backpack-bot Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor
Warnings
⚠️

Package source files (e.g. packages/package-name/src/Component.js) were updated, but snapshots weren't. Have you checked that the tests still pass?

Browser support

If this is a visual change, make sure you've tested it in multiple browsers.

Generated by 🚫 dangerJS against 9f87c09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds new text-decoration and truncation capabilities to BpkText, including underline support and configurable line clamping with invalid-value handling.

Changes:

  • Introduces underline prop and styling, including combined underline + strikethrough rendering.
  • Adds lineClamp prop with CSS-variable-driven clamping and guards for invalid values.
  • Updates Storybook, tests, and README documentation for the new props.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/backpack-web/src/bpk-component-text/src/BpkText.tsx Adds underline / lineClamp props, classnames, and style merging for clamp CSS variable.
packages/backpack-web/src/bpk-component-text/src/BpkText.stories.tsx Adds Storybook examples for underline and line clamping, plus inclusion in visual test story.
packages/backpack-web/src/bpk-component-text/src/BpkText.stories.module.scss Adds layout constraint for the line clamp Storybook example container.
packages/backpack-web/src/bpk-component-text/src/BpkText.module.scss Adds underline and line clamp CSS classes, including combined underline+strikethrough.
packages/backpack-web/src/bpk-component-text/src/BpkText-test.tsx Adds tests for underline, combined decorations, and valid/invalid lineClamp behavior.
packages/backpack-web/src/bpk-component-text/README.md Documents new underline and lineClamp props with usage guidance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +107 to +112
export default () => (
<BpkText underline>Underlined text</BpkText>
<BpkText color={TEXT_COLORS.textError} underline>
Underlined error text
</BpkText>
);
Comment on lines +119 to +121
truncation or a larger value for multi-line truncation. The text must have a
constrained available width in order to wrap and truncate. Invalid values such
as `0`, negative numbers, and non-integers are ignored.
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@Supremeyh Ezreal Yang (Supremeyh) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three new public props (underline, truncate, lineClamp) and one new CSS custom property (--bpk-text-line-clamp) are introduced. New optional props are a backwards-compatible addition and require a minor bump. The current patch label will mis-categorise the changelog entry and produce incorrect version increments for consumers.

And it worth add some snapshots in PR description

constrained available width. Invalid `lineClamp` values are ignored, and a
valid `lineClamp` takes precedence when both props are provided.

```javascript

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

`false`. The underline uses the current text color, including when the `color`
prop or dark mode is used.

```javascript

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should use tsx instead

* Truncates overflowing text to a single line with an ellipsis.
*/
truncate?: boolean;
underline?: boolean;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lineClamp and truncate both carry TSDoc block comments. underline added in the same diff hunk has none. Constitution V requires JSDoc/TSDoc for all public props. Add a /** Renders the text with an underline. */ comment consistent with the truncate pattern.

Comment on lines 47 to 49
:where(.bpk-stories-text_flex-container) {
display: flex;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rule :where(.bpk-stories-text_flex-container) { display: flex; } uses a literal, unhashed class name. CSS Modules compiles all local class names to [local]-[hash:base64:5] at build time, so this selector never matches the runtime class. The display: flex declaration is dead code, meaning justify-content, align-items, and gap inside &_flex-container (lines 40–44) have no effect — the flex container story is silently broken. Additionally, the :where() rule is emitted as a global, unscoped selector.

Fix: move display: flex into the &_flex-container block and remove the :where() rule entirely:

&_flex-container {
  display: flex;           // ← add here
  justify-content: space-between;
  align-items: center;
  gap: tokens.bpk-spacing-sm();
}

render: () => <StrikethroughExample />,
};

export const Underline = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Underline and Strikethrough have standalone named story exports. truncate is only demonstrated as a comparison row inside LineClampExample, making the prop invisible in isolation in Storybook. A TruncateExample component + export const Truncate would follow the pattern set by every other BpkText prop.

// declarations above; revisit the display model when standard line-clamp
// support is broadly available.
line-clamp: var(--bpk-text-line-clamp);
overflow-wrap: anywhere;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here added overflow-wrap: anywhere (allowing for line breaks at any character), which changed the text arrangement behavior of the element, but the README did not mention it. It might come as a surprise to consumers who already have custom line-breaking rules

it can be suggested to add a note in the README to inform consumers that they need to pay attention to the minimum width shrinkage behavior when using Lineclamps on flex/grid sub-items

Comment on lines +138 to +143
const lineClampStyle = shouldClamp
? ({
...style,
'--bpk-text-line-clamp': lineClamp,
} as CSSProperties)
: style;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'--bpk-text-line-clamp': The lineClamp passes a number, not a string

CSS custom properties in the DOM layer only accepts a string, the React by internal element. The style.css. SetProperty (name, value) set the custom property, will reduce the number implicit coerce into a string, so no problem when running. However, the CSSProperties type does not accept the number value, so the as CSSProperties strong conversion was used to suppress the TS error and cover up the type mismatch.

A more explicit way of writing

const lineClampStyle = shouldClamp
  ? ({
    ... style,
    '--bpk-text-line-clamp': '${lineClamp}', // explicitly converts to string
    } as CSSProperties)
  : style;

@IrinaWei IrinaWei added minor Non breaking change and removed patch Patch production bug labels Jul 31, 2026
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@IrinaWei
IrinaWei merged commit df3191b into main Jul 31, 2026
14 of 15 checks passed
@IrinaWei
IrinaWei deleted the codex/clov-1815-bpk-text-controls branch July 31, 2026 09:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

minor Non breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants