Skip to content

Add Mark component for semantic text highlighting#75

Merged
jalexw merged 2 commits into
mainfrom
claude/determined-feynman-eCO5Z
Jun 8, 2026
Merged

Add Mark component for semantic text highlighting#75
jalexw merged 2 commits into
mainfrom
claude/determined-feynman-eCO5Z

Conversation

@jalexw

@jalexw jalexw commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Introduces a new Mark component for semantic text highlighting, along with a companion HighlightedText component for auto-highlighting search terms. The component supports multiple visual styles (solid, soft, underline, outline), color variants, sizes, and optional animations.

Changes

  • New Mark component (src/components/ui/mark/mark.tsx)

    • Renders as semantic <mark> element (or <span> if needed)
    • Four distinct visual styles: solid (highlighter feel), soft (subtle tint), underline (bottom border), and outline (border only)
    • Eight color variants: default, primary, secondary, info, success, warning, destructive, accent
    • Three size presets: sm, default, lg
    • Optional rounded corners and CSS-based fade-in animation
    • Full dark mode support with explicit color choices
  • New HighlightedText component (src/components/ui/mark/mark.tsx)

    • Auto-wraps matches of a search term inside longer text with <Mark> elements
    • Accepts string, RegExp, or array of strings as match patterns
    • Supports case-sensitive and whole-word matching options
    • Memoized regex building and segment computation for performance
    • Defensive guards against zero-width regex matches
  • Variant definitions (src/components/ui/mark/mark-variants.ts)

    • Exported type-safe variant IDs for use in controls and iteration
  • Comprehensive Storybook stories (src/components/ui/mark/Mark.stories.tsx)

    • Individual stories for each style and variant combination
    • Size and rounded corner examples
    • Animated reveal demonstration
    • Heading integration example
    • Interactive search highlight example with case/whole-word toggles
    • Multi-token and RegExp pattern examples
    • Interactive variant × style matrix
  • Public API exports (src/components/ui/mark/index.ts and src/components/ui/index.ts)

    • Exported Mark, HighlightedText, variant types, and CVA utilities
    • Updated main package index to include mark exports
  • Version bump (package.json)

    • Bumped from 0.71.1 to 0.72.1

Implementation Details

  • Uses class-variance-authority for variant management with compound variants for style × color combinations
  • Leverages useMemo in HighlightedText to prevent unnecessary regex rebuilds
  • Supports React 19 ref-as-prop pattern via ref parameter
  • Includes data-slot and data-variant attributes for testing and styling hooks
  • Inherits font size from parent element, making it suitable for use in headings and various text contexts

https://claude.ai/code/session_019pT5j22ZTko2muB44ohBd1

claude added 2 commits June 8, 2026 07:58
New `<Mark>` component renders a semantic <mark> element with 8 color
variants (default/primary/secondary/info/success/warning/destructive/accent),
4 style treatments (solid/soft/underline/outline), 3 sizes, optional rounded
corners, and an `animate` reveal flag. Ships alongside a `HighlightedText`
helper that auto-wraps every occurrence of a search token (string, array,
or RegExp) within a longer string — useful for search-result highlighting,
diff views, log scanners, and documentation.

Includes a comprehensive Storybook story covering every style/variant
combo, sizes, an interactive search-highlight playground, multi-token
highlighting, RegExp matching, and a variant × style matrix.
@vercel

vercel Bot commented Jun 8, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
ui Ready Ready Preview, Comment Jun 8, 2026 3:10pm

Request Review

@jalexw jalexw self-assigned this Jun 8, 2026
@jalexw jalexw merged commit 3cb7314 into main Jun 8, 2026
8 checks passed
@jalexw jalexw deleted the claude/determined-feynman-eCO5Z branch June 8, 2026 15:11
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