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

Ability to instantiate a new instance of the Color class with a HEX color as well as RGB. #1354

Open
futuremotiondev opened this issue Nov 5, 2023 · 0 comments · May be fixed by #1432
Open
Assignees
Labels
Milestone

Comments

@futuremotiondev
Copy link

futuremotiondev commented Nov 5, 2023

Is your feature request related to a problem? Please describe.
It's not a big problem, but as a web developer and designer, I work with hex color values much more often than RGB values.

Describe the solution you'd like
I really like that you can use hex in markup - but you can't actually create an instance of the Color class with a hex value. I have a helper function that automatically converts hex to RGB to fill this void, but it would be great to avoid that step entirely.

Describe alternatives you've considered
Just using a helper function to convert to HEX on the fly.

Additional context
Example (Note: I'm using a Powershell wrapper here, but the implementation is more or less the same)

This first example doesn't work, but would be awesome if it did.

using namespace Spectre.Console
$data = @(
    @{ Label = "Oranges"; Value = 10; Color = [Color]::new("#3E85ED")},
    @{ Label = "Apples"; Value = 7; Color = [Color]::new("#3EEDBF")},
    @{ Label = "Blueberries"; Value = 3; Color = [Color]::new("#ED6E3E")}
)
Format-SpectreBarChart -Data $data -Title "[white]Fruit Sales[/]" -Width 80

This, of course, works:

using namespace Spectre.Console
$data = @(
    @{ Label = "Oranges"; Value = 10; Color = [Color]::new(245,137,57)},
    @{ Label = "Apples"; Value = 7; Color = [Color]::new(255,75,138)},
    @{ Label = "Blueberries"; Value = 3; Color = [Color]::new(91,82,238)}
)
Format-SpectreBarChart -Data $data -Title "[white]Fruit Sales[/]" -Width 80

Code_T5qn7J1NlF

The way the BarChart is instantiated / created doesn't involve markup - so I can't use Hex. Hopefully all of this is clear.

Really appreciate the hard work, and any consideration on this improvement.


Please upvote 👍 this issue if you are interested in it.

@jsheely jsheely linked a pull request Jan 15, 2024 that will close this issue
@FrankRay78 FrankRay78 linked a pull request Mar 7, 2024 that will close this issue
@FrankRay78 FrankRay78 added this to the 0.49 milestone Mar 20, 2024
@FrankRay78 FrankRay78 self-assigned this Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: PR 📬
Development

Successfully merging a pull request may close this issue.

2 participants