Skip to content

Commit

Permalink
Add 16bit rgb context values for mustache templates
Browse files Browse the repository at this point in the history
  • Loading branch information
JamyGolden committed Sep 7, 2024
1 parent c70ff21 commit 62e8aa5
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.11.0] - 2024-09-07

## Added

- Add support for proposed 0.12.0 builder spec by adding 16bit rgb
colour variables to the mustache context

## [0.10.1] - 2024-09-03

## Fixed
Expand Down Expand Up @@ -169,6 +176,7 @@
- `sync` subcommand support to sync with latest Tinted Theming schemes
- `build` subcommand to trigger theme template build

[0.11.0]: https://github.com/tinted-theming/tinted-builder-rust/compare/v0.10.1...v0.11.0
[0.10.1]: https://github.com/tinted-theming/tinted-builder-rust/compare/v0.10.0...v0.10.1
[0.10.0]: https://github.com/tinted-theming/tinted-builder-rust/compare/v0.9.5...v0.10.0
[0.9.5]: https://github.com/tinted-theming/tinted-builder-rust/compare/v0.9.3...v0.9.5
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions THIRD_PARTY_LICENSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1683,8 +1683,8 @@ limitations under the License.

#### Used by

- [tinted-builder 0.6.0](https://github.com/tinted-theming/tinted-builder-rust)
- [tinted-builder-rust 0.10.1](https://github.com/tinted-theming/tinted-builder-rust)
- [tinted-builder 0.7.0](https://github.com/tinted-theming/tinted-builder-rust)
- [tinted-builder-rust 0.11.0](https://github.com/tinted-theming/tinted-builder-rust)
- [ribboncurls 0.2.1](https://github.com/tinted-theming/ribboncurls)

```
Expand Down
4 changes: 2 additions & 2 deletions tinted-builder-rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tinted-builder-rust"
version = "0.10.1"
version = "0.11.0"
edition = "2021"
authors = ["Jamy Golden <[email protected]>", "Tinted Theming <[email protected]>"]
license = "MIT OR Apache-2.0"
Expand All @@ -24,7 +24,7 @@ strip-ansi-escapes = "0.2.0"

[dependencies.tinted-builder]
path = "../tinted-builder"
version = "0.6.0"
version = "0.7.0"

[[bin]]
name = "tinted-builder-rust"
Expand Down
7 changes: 7 additions & 0 deletions tinted-builder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.7.0 - 2024-09-07

## Added

- Add support for proposed 0.12.0 builder spec by adding 16bit rgb
colour variables to the mustache context

## 0.6.0 - 2024-08-28

## Added
Expand Down
2 changes: 1 addition & 1 deletion tinted-builder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tinted-builder"
description = "A Tinted Theming template builder which uses yaml color schemes to generate theme files."
version = "0.6.0"
version = "0.7.0"
edition = "2021"
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
12 changes: 12 additions & 0 deletions tinted-builder/src/template/base16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ pub(crate) fn to_template_context(scheme: &Base16Scheme) -> HashMap<String, Stri
context.insert(format!("{}-rgb-r", name), rgb.0.to_string());
context.insert(format!("{}-rgb-g", name), rgb.1.to_string());
context.insert(format!("{}-rgb-b", name), rgb.2.to_string());
context.insert(
format!("{}-rgb16-r", name),
(rgb.0 as u16 * 257_u16).to_string(),
);
context.insert(
format!("{}-rgb16-g", name),
(rgb.1 as u16 * 257_u16).to_string(),
);
context.insert(
format!("{}-rgb16-b", name),
(rgb.2 as u16 * 257_u16).to_string(),
);
context.insert(
format!("{}-dec-r", name),
format!("{:.8}", rgb.0 as f64 / 255.),
Expand Down
12 changes: 12 additions & 0 deletions tinted-builder/tests/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ fn render_rgb() -> Result<()> {
Ok(())
}

#[test]
fn render_rgb16() -> Result<()> {
let template_source = "{{base0A-rgb16-r}} {{base0A-rgb16-g}} {{base0A-rgb16-b}}";
let scheme = Scheme::Base16(serde_yaml::from_str(SCHEME_SILK_LIGHT)?);
let template = Template::new(template_source.to_string(), scheme);

let output = template.render()?;

assert_eq!(output, "53199 44461 9509");
Ok(())
}

#[test]
fn render_dec() -> Result<()> {
let template_source = "{{base0A-dec-r}} {{base0A-dec-g}} {{base0A-dec-b}}";
Expand Down

0 comments on commit 62e8aa5

Please sign in to comment.