Extend RGBA hex color parsing to support 3-value and 4-value variants (#3295)
This PR extends our support for parsing hex color codes to `Rgba` to additionally support 3-value (`#rgb`) and 4-value (`#rgba`) formats. See [here](https://developer.mozilla.org/en-US/docs/Web/CSS/hex-color) for more details on these hex color variants. Release Notes: - N/A
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
use std::num::ParseIntError;
|
||||
|
||||
use gpui::{hsla, Hsla, Rgba};
|
||||
|
||||
use crate::colors::{StatusColors, SystemColors, ThemeColors};
|
||||
@@ -413,10 +411,10 @@ struct StaticColorScaleSet {
|
||||
}
|
||||
|
||||
impl TryFrom<StaticColorScaleSet> for ColorScaleSet {
|
||||
type Error = ParseIntError;
|
||||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(value: StaticColorScaleSet) -> Result<Self, Self::Error> {
|
||||
fn to_color_scale(scale: StaticColorScale) -> Result<ColorScale, ParseIntError> {
|
||||
fn to_color_scale(scale: StaticColorScale) -> Result<ColorScale, anyhow::Error> {
|
||||
scale
|
||||
.into_iter()
|
||||
.map(|color| Rgba::try_from(color).map(Hsla::from))
|
||||
|
||||
Reference in New Issue
Block a user