Skip to content

feat(blog): add table and mermaid components#9

Merged
CagesThrottleUs merged 3 commits intomainfrom
cages/add-support-for-mermaid
Nov 30, 2025
Merged

feat(blog): add table and mermaid components#9
CagesThrottleUs merged 3 commits intomainfrom
cages/add-support-for-mermaid

Conversation

@CagesThrottleUs
Copy link
Copy Markdown
Owner

Add two new blog components to enhance content presentation:

Table Component:

  • Supports JSX elements in cells (unlike markdown tables)
  • Enables use of Highlight, Redacted, and other components within table cells
  • Maintains classified document styling theme
  • Fully tested with 4 test cases

Mermaid Diagram Component:

  • Renders diagrams with Cold War classified color palette
  • Uses safe ref-based rendering via mermaid.run() instead of dangerouslySetInnerHTML
  • Configuration centralized in constants.ts for maintainability
  • Red borders, green connectors, blue accents match theme
  • Includes error handling with CallOut error display
  • Optional caption support for figure documentation
  • Fully tested with 4 test cases

Additional Changes:

  • Update CallOut info type to use blue (steel-500) instead of green for better semantic distinction from success callouts
  • Add mermaid dependency to package.json
  • Extend CSS with mermaid-specific styling that enforces classified theme colors on generated SVG elements

These components provide blog authors with powerful tools for creating technical documentation, architecture diagrams, and data tables while maintaining security best practices and the site's distinctive Cold War aesthetic.

Add two new blog components to enhance content presentation:

Table Component:
- Supports JSX elements in cells (unlike markdown tables)
- Enables use of Highlight, Redacted, and other components
  within table cells
- Maintains classified document styling theme
- Fully tested with 4 test cases

Mermaid Diagram Component:
- Renders diagrams with Cold War classified color palette
- Uses safe ref-based rendering via mermaid.run() instead of
  dangerouslySetInnerHTML
- Configuration centralized in constants.ts for maintainability
- Red borders, green connectors, blue accents match theme
- Includes error handling with CallOut error display
- Optional caption support for figure documentation
- Fully tested with 4 test cases

Additional Changes:
- Update CallOut info type to use blue (steel-500) instead of
  green for better semantic distinction from success callouts
- Add mermaid dependency to package.json
- Extend CSS with mermaid-specific styling that enforces
  classified theme colors on generated SVG elements

These components provide blog authors with powerful tools for
creating technical documentation, architecture diagrams, and
data tables while maintaining security best practices and the
site's distinctive Cold War aesthetic.

Signed-off-by: CagesThrottleUs <manstein.felix@gmail.com>
Updated the box-shadow property in BlogPostLayout.css to enhance the
visual presentation of blog posts, ensuring a more polished look while
maintaining the existing Cold War theme.

Signed-off-by: CagesThrottleUs <manstein.felix@gmail.com>
Implement lazy loading and code splitting to optimize bundle size
and improve initial page load performance.

Mermaid Component Lazy Loading:
- Use dynamic import() to load mermaid library only when needed
- Add cancellation token to prevent state updates after unmount
- Replace dangerouslySetInnerHTML with safe ref-based rendering
- Add loading state with visual feedback during library load
- Reduce main bundle by ~2.3 MB (mermaid loads on-demand)

Build Optimization:
- Configure manual chunks for mermaid, vendor, and UI libraries
- Separate React core (~456 kB) for better caching
- Isolate mermaid (~2,301 kB) into lazy-loaded chunk
- Increase chunk size warning to 1000 kB (acceptable for lazy load)
- Main bundle reduced from 1,568 kB to 622 kB (60% reduction)

Code Quality Improvements:
- Fix non-null assertion in main.tsx with proper error handling
- Replace dynamic delete with object destructuring pattern
- Add explanatory comments for necessary eslint disables
- Document MDX component type requirements
- Improve type safety in cache functions

Test Environment Enhancements:
- Mock window.scrollTo for jsdom compatibility
- Suppress expected React error boundary warnings in tests
- Suppress false-positive act() warnings (using waitFor properly)
- Clean up DOM manipulation error handling for mermaid

Performance Impact:
- Homepage: 0 kB mermaid (not loaded)
- Blog posts without diagrams: 0 kB mermaid
- Blog posts with diagrams: 644 kB gzipped (only when used)
- 60% smaller main bundle improves initial load time

All 191 tests passing with zero linter errors and clean console
output. Mermaid diagrams render with Cold War classified theme
using safe, production-ready code.

Signed-off-by: CagesThrottleUs <manstein.felix@gmail.com>
@CagesThrottleUs CagesThrottleUs merged commit 661ed4b into main Nov 30, 2025
2 checks passed
@CagesThrottleUs CagesThrottleUs deleted the cages/add-support-for-mermaid branch November 30, 2025 04:07
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.

1 participant