How styled-components/css-to-react-native works
Main Components
A. Input Processing Layer
• TokenStream component (from TokenStream.js)
• Property name transformer
• Value parser
B. Transform Layer (core functionality)
• Main transformer
• Specialized transform modules (from /transforms directory)
• Utility functions (from transforms/util.js)
C. Output Generation Layer
• React Native stylesheet object generator
• Type definitions (from index.d.ts)
┌─────────────────────────────────────┐
• Input Layer │
• ┌─────────────┐ ┌─────────────┐ │
• CSS Text │ -> │ TokenStream │ │
• ┘ └─────────────┘ │
• ┬─────────────────┘
• ↓
┌─────────────────────────────────────┐
• Transform Layer │
• ┌─────────────┐ ┌─────────────┐ │
• Property │ -> │ Value │ │
• Transforms │ │ Transforms │ │
• ┘ └─────────────┘ │
• ┌─────────────────────────────────┐ │
• Specialized Transformers │ │
• aspectRatio - border │ │
• boxShadow - flex │ │
• font - transform │ │
• ┘ │
• ┬─────────────────┘
• ↓
┌─────────────────────────────────────┐
• Output Layer │
• ┌─────────────────────────────────┐ │
• React Native Stylesheet Object │ │
• ┘ │
• ┘
Important Details
A. Input Processing:
• How CSS text is tokenized
• Property-value pair extraction
B. Transform Layer:
• Related transforms (e.g., font-related, border-related)
• Utility functions supporting transforms
• Special handling for shorthands
C. Output Generation:
• Type checking/validation
• React Native specific adaptations
Notes for Implementation Details
• How the transform array API works: [property, value]
• Special handling for number-like and string-like values
• Conversion of indirect values to React Native equivalents
• Handling of unsupported properties