Skip to content

feat: add dynamic font sizing to event storming sticky notes (fixes #40)#41

Merged
poulainpi merged 3 commits intomainfrom
fix/issue-40-dynamic-font-sizing
Oct 8, 2025
Merged

feat: add dynamic font sizing to event storming sticky notes (fixes #40)#41
poulainpi merged 3 commits intomainfrom
fix/issue-40-dynamic-font-sizing

Conversation

@poulainpi
Copy link
Copy Markdown
Owner

Summary

Implements real-time dynamic font sizing for event storming sticky notes to prevent text overflow (fixes #40). The font size automatically scales between 10px and 16px based on text length and available space, similar to how Miro handles text in cards.

Changes

  • Add calculateFontSize() helper function: Estimates optimal font size based on character width and available space
  • Real-time font calculation: Font size is computed during render (no stored state) for immediate feedback while typing
  • Consistent padding: Uses 8px horizontal and 16px vertical padding values
  • Dynamic textWidth: Uses availableWidth variable for consistency with font size calculations

Implementation Details

The calculateFontSize function:

  • Iterates through font sizes from 16px (max) to 10px (min)
  • Estimates characters per line using a 0.5 ratio for the 'draw' font
  • Calculates total text height with line height factor of 1.2
  • Returns the largest font size that fits within available space

Test Plan

  • TypeScript compilation passes
  • ESLint checks pass
  • Test with short text (should use 16px)
  • Test with long text (should auto-reduce to fit)
  • Verify real-time updates while typing

Behavior

  • Short text: Uses maximum font size (16px) for readability
  • Long text: Automatically reduces font size to prevent overflow
  • Real-time: Font size adjusts as you type, no lag or delay
  • No state storage: Font size is computed on-the-fly, making the implementation simple and maintainable

Closes #40

Implements real-time font size adjustment to prevent text overflow
in sticky notes (fixes #40). Font size automatically scales between
10px and 16px based on text length and available space.

- Add calculateFontSize() function with character width estimation
- Calculate font size dynamically in component render (no stored state)
- Use consistent padding values (8px horizontal, 16px vertical)
- Update textWidth to use availableWidth for consistency

The implementation follows Miro-style behavior where text shrinks
to fit the card rather than overflowing or expanding the card.
@cloudflare-workers-and-pages
Copy link
Copy Markdown
Contributor

cloudflare-workers-and-pages bot commented Oct 8, 2025

Deploying ddd-toolbox with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1302f37
Status: ✅  Deploy successful!
Preview URL: https://e4f84cad.ddd-toolbox.pages.dev
Branch Preview URL: https://fix-issue-40-dynamic-font-si.ddd-toolbox.pages.dev

View logs

@poulainpi poulainpi merged commit dc18b00 into main Oct 8, 2025
2 checks passed
@poulainpi poulainpi deleted the fix/issue-40-dynamic-font-sizing branch October 9, 2025 22:19
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.

Handle text overflow

1 participant