Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jun 8, 2024

Conversation

joshka
Copy link
Member

@joshka joshka commented Jun 7, 2024

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));

This is behind the "palette" feature flag.

```rust
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));
```
Copy link

codecov bot commented Jun 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@           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             

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@EdJoPaTo
Copy link
Contributor

EdJoPaTo commented Jun 7, 2024

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

@joshka joshka requested a review from EdJoPaTo June 7, 2024 13:31
@joshka
Copy link
Member Author

joshka commented Jun 7, 2024

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
Copy link
Contributor

EdJoPaTo commented Jun 7, 2024

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
Copy link
Member Author

joshka commented Jun 7, 2024

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).

Copy link
Member

@orhun orhun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I saw someone using palette colors in one of the videos before. So this will definitely be useful!

@joshka joshka merged commit 10d7788 into main Jun 8, 2024
33 checks passed
@joshka joshka deleted the jm/from-palette branch June 8, 2024 05:31
itsjunetime pushed a commit to itsjunetime/ratatui that referenced this pull request Jun 23, 2024
)

This is behind the "palette" feature flag.

```rust
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));
```
joshka added a commit to erak/ratatui that referenced this pull request Oct 14, 2024
)

This is behind the "palette" feature flag.

```rust
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));
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants