TCSS - Thematic CSS
A powerful CSS preprocessor that adds functions, variables, and expressions to CSS with Python-style indentation.
๐ฏ Project Status
Version 1.0.0 - Production Ready! ๐
All 12 Phases: COMPLETE โ
Completed Features โ
- โ Lexer & Parser - Full TCSS syntax support
- โ Executor - Function execution and variable resolution
- โ CSS Generator - Optimized CSS output with minification
- โ CLI Tool - Command-line interface with watch mode
- โ WASM Bindings - Browser support via WebAssembly
- โ JavaScript Integration - npm package and browser loader
- โ 24 Built-in Functions - Colors, math, and string utilities
- โ Import System - File imports with circular detection and caching
- โ Comprehensive Tests - 150+ tests with 80%+ code coverage
- โ Complete Documentation - 2,000+ lines of documentation
- โ Performance Optimization - Benchmarks and optimized builds
- โ Publishing Ready - Prepared for crates.io and npm
โจ Features
- โ Variables - Define reusable values
- โ Functions - Create custom functions with parameters
- โ Expressions - Perform calculations in CSS
- โ 24 Built-in Functions - Colors, math, and string utilities
- โ Import System - Split code across multiple files
- โ Python-style Indentation - Clean, readable syntax
- โ Type Safety - Compile-time type checking
- โ Zero Runtime - Compiles to pure CSS
- โ WASM Support - Run in the browser
- โ Fast - Written in Rust for maximum performance
๐ฆ Project Structure
TCSS/
โโโ tcss-core/ # Core compiler library โ
โ โโโ src/
โ โ โโโ lexer.rs # Tokenizer โ
โ โ โโโ parser.rs # AST parser โ
โ โ โโโ executor.rs # Function executor โ
โ โ โโโ generator.rs # CSS generator โ
โ โ โโโ import.rs # Import processor โ
โ โ โโโ resolver.rs # Path resolver โ
โ โ โโโ builtins/ # Built-in functions โ
โ โโโ tests/ # Comprehensive test suite โ
โโโ tcss-cli/ # Command-line interface โ
โโโ tcss-wasm/ # WebAssembly bindings โ
โโโ tcss-js/ # JavaScript wrapper โ
โโโ docs/ # Complete documentation โ
โโโ examples/ # Example projects โ
๐ Quick Start
Installation
# Using Cargo
# Using npm
Your First TCSS File
styles.tcss:
@var primary: #3498db
@var spacing: 16px
@fn button-padding(size):
return size * spacing
.button:
background: primary
padding: button-padding(1)
border-radius: 4px
color: white
.button:hover:
background: lighten(primary, 10)
Compile
Output
}
}
๐ Documentation
Getting Started
- Quick Reference - Quick syntax reference
- User Guide - Complete user documentation
- Examples - Example TCSS files
API & Reference
- API Documentation - Rust and JavaScript API
- Built-in Functions - Function reference
- Import System - Import documentation
Development
- Testing Guide - How to run and write tests
- Contributing Guide - How to contribute
- Optimization Guide - Performance optimization
Publishing
- Publishing Guide - How to publish releases
- Changelog - Version history
- Project Summary - Complete project overview
๐ก Examples
Variables & Functions
@var primary-color: #3498db
@var base-spacing: 16px
@fn spacing(multiplier):
return multiplier * base-spacing
.card:
padding: spacing(2)
background: primary-color
Built-in Functions
// Color manipulation
.button:
background: darken(#3498db, 10)
border-color: lighten(#3498db, 10)
color: rgba(255, 255, 255, 0.9)
// Math operations
.box:
width: max(100px, 50%)
padding: clamp(16px, 2vw, 32px)
// String utilities
.text:
font-family: uppercase("arial")
Imports
@import './colors.tcss'
@import './theme/base.tcss'
@import '@tcss/core'
.button:
background: primary
๐งช Testing
Run the comprehensive test suite:
# Run all tests
# Run specific test suite
# Run with coverage
Test Coverage: 80%+
- โ Unit Tests - All core modules (lexer, parser, executor, generator, etc.)
- โ Integration Tests - End-to-end compilation workflows
- โ E2E Tests - File I/O, imports, and complete workflows
- โ Built-in Function Tests - All 24 built-in functions
- โ Import System Tests - Circular detection, caching, resolution
๐ ๏ธ Usage
CLI
# Compile a file
# Compile with minification
# Watch for changes
Rust API
use ;
let source = r#"
@var primary: #3498db
.button:
background: primary
"#;
let mut lexer = new;
let tokens = lexer.tokenize?;
let mut parser = new;
let program = parser.parse?;
let mut executor = new;
let executed = executor.execute?;
let mut generator = new;
let css = generator.generate?;
JavaScript API
import from 'tcss-js';
const tcss = `
@var primary: #3498db
.button:
background: primary
`;
const css = ;
Browser
๐ Development Roadmap
- Phase 1: Core Lexer/Tokenizer โ
- Phase 2: AST Parser โ
- Phase 3: Expression Evaluator โ
- Phase 4: CSS Generator โ
- Phase 5: Error Handling โ
- Phase 6: CLI Tool โ
- Phase 7: WebAssembly Bindings โ
- Phase 8: JavaScript Integration โ
- Phase 9: Built-in Functions Library โ
- Phase 10: Import System โ
- Phase 11: Testing & Documentation โ
- Phase 12: Optimization & Publishing โ
๐ ๏ธ Technology Stack
- Rust - Core implementation language
- wasm-bindgen - WebAssembly bindings
- serde - Serialization framework
- clap - CLI argument parsing
- tempfile - Testing utilities
๐ค Contributing
Contributions are welcome! Please read our Contributing Guide for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Inspired by Sass, Less, and Stylus
- Built with Rust for performance and safety
- Uses wasm-bindgen for WebAssembly support
๐ฌ Support
- GitHub Issues: Report bugs or request features
- Documentation: Read the docs
- Examples: See examples
Made with โค๏ธ by TCSS Contributors
Current Version: 1.0.0 - Production Ready! ๐