ratatui-org / ratatui

Rust library that's all about cooking up terminal user interfaces (TUIs) 👨‍🍳🐀
https://ratatui.rs
MIT License
8.82k stars 263 forks source link

feat(style): add conversions from the palette crate colors #1172

Closed joshka closed 3 weeks ago

joshka commented 3 weeks ago

This is behind the "palette" feature flag.

use palette::{LinSrgb, Srgb};
use ratatui::style::Color;

let color = Color::from(Srgb::new(1.0f32, 0.0, 0.0));
let color = Color::from(LinSrgb::new(1.0f32, 0.0, 0.0));
codecov[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.2%. Comparing base (e6871b9) to head (bde0bf4).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1172 +/- ## ======================================= - Coverage 94.2% 94.2% -0.1% ======================================= Files 60 60 Lines 14523 14521 -2 ======================================= - Hits 13684 13682 -2 Misses 839 839 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

EdJoPaTo commented 3 weeks ago

Given that the terminals are reexported, should this be reexported too (when the feature flag is given)?

joshka commented 3 weeks ago

Given that the terminals are reexported, should this be reexported too (when the feature flag is given)?

There's no public code to export - just trait impls.

EdJoPaTo commented 3 weeks ago

Given that the terminals are reexported, should this be reexported too (when the feature flag is given)?

There's no public code to export - just trait impls.

Srgb for example? Currently, this feature needs to be enabled and palette be added as dependency to your crate to use it?

joshka commented 3 weeks ago

Given that the terminals are reexported, should this be reexported too (when the feature flag is given)?

There's no public code to export - just trait impls.

Srgb for example? Currently, this feature needs to be enabled and palette be added as dependency to your crate to use it?

Ah, gotcha. I'd expect that the only people wanting to turn this on are probably people that are specifically using palette already. Also we have a palette module already (so this could easily cause confusion).