# 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
```bash
# Using Cargo
cargo install tcss-cli
# Using npm
npm install tcss-js
```
### Your First TCSS File
**styles.tcss:**
```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
```bash
tcss compile styles.tcss -o styles.css
```
### Output
```css
.button {
background: #3498db;
padding: 16px;
border-radius: 4px;
color: white;
}
.button:hover {
background: #5dade2;
}
```
## ๐ Documentation
### Getting Started
- [Quick Reference](docs/QUICK_REFERENCE.md) - Quick syntax reference
- [User Guide](docs/USER_GUIDE.md) - Complete user documentation
- [Examples](examples/) - Example TCSS files
### API & Reference
- [API Documentation](docs/API.md) - Rust and JavaScript API
- [Built-in Functions](docs/BUILTIN_FUNCTIONS.md) - Function reference
- [Import System](docs/IMPORT_SYSTEM.md) - Import documentation
### Development
- [Testing Guide](docs/TESTING.md) - How to run and write tests
- [Contributing Guide](CONTRIBUTING.md) - How to contribute
- [Optimization Guide](docs/OPTIMIZATION.md) - Performance optimization
### Publishing
- [Publishing Guide](docs/PUBLISHING.md) - How to publish releases
- [Changelog](CHANGELOG.md) - Version history
- [Project Summary](docs/PROJECT_SUMMARY.md) - Complete project overview
## ๐ก Examples
### Variables & Functions
```tcss
@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
```tcss
// 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
```tcss
@import './colors.tcss'
@import './theme/base.tcss'
@import '@tcss/core'
.button:
background: primary
```
## ๐งช Testing
Run the comprehensive test suite:
```bash
# Run all tests
cargo test
# Run specific test suite
cargo test --test integration_tests
cargo test --test e2e_tests
# Run with coverage
cargo tarpaulin --out Html
```
**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
```bash
# Compile a file
tcss compile input.tcss -o output.css
# Compile with minification
tcss compile input.tcss -o output.css --minify
# Watch for changes
tcss watch input.tcss -o output.css
```
### Rust API
```rust
use tcss_core::{Lexer, Parser, Executor, Generator};
let source = r#"
@var primary: #3498db
.button:
background: primary
"#;
let mut lexer = Lexer::new(source);
let tokens = lexer.tokenize()?;
let mut parser = Parser::new(tokens);
let program = parser.parse()?;
let mut executor = Executor::new();
let executed = executor.execute(&program)?;
let mut generator = Generator::new();
let css = generator.generate(&executed)?;
```
### JavaScript API
```javascript
import { compile } from 'tcss-js';
const tcss = `
@var primary: #3498db
.button:
background: primary
`;
const css = compile(tcss);
```
### Browser
```html
<link rel="tcss" href="styles.tcss">
<script type="module">
import { init } from './tcss-js/index.js';
await init();
</script>
```
## ๐ Development Roadmap
- [x] **Phase 1: Core Lexer/Tokenizer** โ
- [x] **Phase 2: AST Parser** โ
- [x] **Phase 3: Expression Evaluator** โ
- [x] **Phase 4: CSS Generator** โ
- [x] **Phase 5: Error Handling** โ
- [x] **Phase 6: CLI Tool** โ
- [x] **Phase 7: WebAssembly Bindings** โ
- [x] **Phase 8: JavaScript Integration** โ
- [x] **Phase 9: Built-in Functions Library** โ
- [x] **Phase 10: Import System** โ
- [x] **Phase 11: Testing & Documentation** โ
- [x] **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.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. 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](https://github.com/tosiiko/TCSS/issues)
- Documentation: [Read the docs](https://github.com/tosiiko/TCSS/tree/main/docs)
- Examples: [See examples](https://github.com/tosiiko/TCSS/tree/main/examples)
---
Made with โค๏ธ by TCSS Contributors
**Current Version:** 1.0.0 - Production Ready! ๐