tcss-core 1.0.0

Core library for TCSS (Thematic CSS) - CSS with functions, variables, and expressions
Documentation
# TCSS - Thematic CSS

A powerful CSS preprocessor that adds functions, variables, and expressions to CSS with Python-style indentation.

[![Build Status](https://img.shields.io/badge/build-passing-brightgreen)]()
[![License](https://img.shields.io/badge/license-MIT-blue)]()
[![Rust](https://img.shields.io/badge/rust-1.70+-orange)]()

## ๐ŸŽฏ 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! ๐ŸŽ‰