turf 🌱

turf allows you to build SCSS to CSS during compile time and inject those styles into your binary.

Crates.io Docs.rs Build Status MIT licensed

Features

turf will:

Usage

For a complete runnable example project, you can check out the leptos-example / yew-example.

1. Create SCSS styles for your application.

```scss // file at scss/file/path.scss

.TopLevelClass { color: red;

.SomeClass {
    color: blue;
}

} ```

2. Use the style_sheet macro to include the resulting CSS in your code

rust turf::style_sheet!("scss/file/path.scss");

The macro from the above example will expand to the following code:

rust static STYLE_SHEET: &'static str = "<style_sheet>"; struct ClassName; impl ClassName { pub const TOP_LEVEL_CLASS: &'static str = "<unique_class_name>"; pub const SOME_CLASS: &'static str = "<another_unique_class_name>"; }

To access the generated class names, use the ClassName struct and its associated constants:

rust let top_level_class_name = ClassName::TOP_LEVEL_CLASS; let some_class_name = ClassName::SOME_CLASS;

3. Configuration

The configuration for turf can be specified in the Cargo.toml file using the [package.metadata.turf] key. This allows you to conveniently manage your SCSS compilation settings within your project's manifest.

Example configuration:

```toml [package.metadata.turf] minify = true loadpaths = ["path/to/scss/files", "path/to/other/scss/files"] classname_template = "custom--"

[package.metadata.turf.browser_targets] chrome = [80, 81, 82] firefox = 65 safari = [12, 13] ```

The following configuration options are available:

3.1 Browser Versions

The available browsers are as follows:

3.2 Browser Version Format

Three formats are supported:

  1. major:

  2. major.minor:

  3. major.minor.patch:

Contributions

Contributions to turf are always welcome! Whether you have ideas for new features or improvements, don't hesitate to open an issue or submit a pull request. 🤝

License

turf is licensed under the MIT license. For more details, please refer to the LICENSE file. 📄