Skip to content

Conversation

croatialu
Copy link

feat(ptw): add background color prefix support with comprehensive test suite

Summary

Adds background color utility support to the PTW (PixiJS Tailwind) system and includes a comprehensive test suite to ensure reliability.

Changes Made

✨ New Features

  • Background Color Support: Added bg- prefix support for setting backgroundColor in PixiJS Layout components
  • Color Value Conversion: Implemented convertColorValue() method to handle color strings
  • Color Parsing Logic: Added parseColor() method to integrate color utilities into the parsing pipeline

🛠️ Technical Implementation

  • Added COLOR_MAP to map bg prefix to backgroundColor property
  • Imported ColorSource type from pixi.js for type safety
  • Extended TailwindParser.parse() to handle color utilities alongside existing spacing, size, and flex utilities

🧪 Testing

  • Comprehensive Test Suite: Added 313 test cases covering:
    • Spacing utilities (padding, margin, gap)
    • Size utilities (width, height, min/max dimensions)
    • Flex utilities (direction, wrap, grow/shrink, alignment)
    • Color utilities (background colors) - NEW
    • Multiple utilities combinations
    • Template literal functionality with interpolation
    • Edge cases and error handling
    • Base unit conversion and px values

Usage Examples

// Background color utilities
const styles = tw`bg-red`; // { backgroundColor: 'red' }
const styles = tw`bg-blue`; // { backgroundColor: 'blue' }

// Combined with other utilities
const styles = tw`p-4 w-full flex-row items-center bg-red`;
// {
//   padding: 16,
//   width: '100%',
//   flexDirection: 'row',
//   alignItems: 'center',
//   backgroundColor: 'red'
// }

// With template literals
const color = 'blue';
const styles = tw`p-${spacing} bg-${color} flex-row`;

Testing Coverage

  • ✅ All existing PTW functionality
  • ✅ New background color utilities
  • ✅ Template literal interpolation
  • ✅ Edge cases and error handling
  • ✅ Multiple utility combinations
  • ✅ Type safety with PixiJS ColorSource

Breaking Changes

None. This is a purely additive feature that maintains backward compatibility.

Files Changed

  • src/tailwind/ptw.ts - Added color support functionality
  • tests/__tests__/ptw.test.ts - Added comprehensive test suite (NEW)

Type: Feature
Scope: PTW (PixiJS Tailwind)
Impact: Adds background color support to Tailwind-like styling in PixiJS Layout system

- Add COLOR_MAP to support bg- prefix for backgroundColor
- Implement convertColorValue() and parseColor() methods
- Integrate color parsing logic into TailwindParser.parse()
- Import ColorSource type from pixi.js for type safety

This enables Tailwind-like background color utilities in PixiJS Layout system.
- Add tests for spacing utilities (padding, margin, gap)
- Add tests for size utilities (width, height, min/max dimensions)
- Add tests for flex utilities (direction, wrap, grow/shrink, alignment)
- Add tests for color utilities (background colors)
- Add tests for multiple utilities combinations
- Add tests for template literal functionality with interpolation
- Add tests for edge cases and error handling
- Add tests for base unit conversion and px values

Covers all existing PTW functionality with 313 test cases to ensure reliability.
@croatialu croatialu requested a review from Zyie as a code owner October 5, 2025 09:16
Copy link

pkg-pr-new bot commented Oct 5, 2025

layout-jslayout-react

npm i https://pkg.pr.new/pixijs/layout/@pixi/layout@122

commit: 791d311

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