fix: no text should use the steps array for transparent color

This commit is contained in:
Ashley Wulber 2026-07-08 19:34:10 -04:00 • committed by Ashley Wulber
parent 74b2407342
commit dc11d6a11f

View file

@ -11,7 +11,6 @@ use palette::color_difference::Wcag21RelativeContrast;
use palette::rgb::Rgb; use palette::rgb::Rgb;
use palette::{IntoColor, Oklcha, Srgb, Srgba, WithAlpha}; use palette::{IntoColor, Oklcha, Srgb, Srgba, WithAlpha};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::default;
use std::num::NonZeroUsize; use std::num::NonZeroUsize;
/// ID for the current dark `ThemeBuilder` config /// ID for the current dark `ThemeBuilder` config
@ -1190,7 +1189,7 @@ impl ThemeBuilder {
); );
let on_transparent_bg_component = get_text( let on_transparent_bg_component = get_text(
color_index(transparent_bg_component, transparent_bg_steps_array.len()), color_index(transparent_bg_component, transparent_bg_steps_array.len()),
&transparent_bg_steps_array, &step_array,
&control_steps_array[8], &control_steps_array[8],
text_steps_array.as_deref(), text_steps_array.as_deref(),
actual_alpha, actual_alpha,
@ -1254,17 +1253,22 @@ impl ThemeBuilder {
}; };
container_bg.alpha = (container_alpha + if is_dark { 0.3 } else { 0.25 }).min(1.0); container_bg.alpha = (container_alpha + if is_dark { 0.3 } else { 0.25 }).min(1.0);
let step_array = steps(container_bg, NonZeroUsize::new(100).unwrap()); let t_step_array = steps(container_bg, NonZeroUsize::new(100).unwrap());
let base_index: usize = color_index(container_bg, step_array.len()); let base_index: usize = color_index(container_bg, t_step_array.len());
let component_base = let component_base = get_surface_color(
get_surface_color(base_index, 6, &step_array, is_dark, &control_steps_array[3]); base_index,
6,
&t_step_array,
is_dark,
&control_steps_array[3],
);
Container::new( Container::new(
Component::component( Component::component(
component_base, component_base,
accent, accent,
get_text( get_text(
color_index(component_base, step_array.len()), color_index(component_base, t_step_array.len()),
&step_array, &step_array,
&control_steps_array[8], &control_steps_array[8],
text_steps_array.as_deref(), text_steps_array.as_deref(),
@ -1368,10 +1372,15 @@ impl ThemeBuilder {
get_surface_color(bg_index, 10, &step_array, is_dark, &control_steps_array[2]) get_surface_color(bg_index, 10, &step_array, is_dark, &control_steps_array[2])
}; };
let step_array = steps(container_bg, NonZeroUsize::new(100).unwrap()); let t_step_array = steps(container_bg, NonZeroUsize::new(100).unwrap());
let base_index = color_index(container_bg, step_array.len()); let base_index = color_index(container_bg, t_step_array.len());
let secondary_component = let secondary_component = get_surface_color(
get_surface_color(base_index, 3, &step_array, is_dark, &control_steps_array[4]); base_index,
3,
&t_step_array,
is_dark,
&control_steps_array[4],
);
component_hovered_overlay = if base_index < 91 { component_hovered_overlay = if base_index < 91 {
control_steps_array[10] control_steps_array[10]
@ -1388,7 +1397,7 @@ impl ThemeBuilder {
secondary_component, secondary_component,
accent, accent,
get_text( get_text(
color_index(secondary_component, step_array.len()), color_index(secondary_component, t_step_array.len()),
&step_array, &step_array,
&control_steps_array[8], &control_steps_array[8],
text_steps_array.as_deref(), text_steps_array.as_deref(),
@ -1561,7 +1570,7 @@ impl ThemeBuilder {
transparent_bg, transparent_bg,
get_text( get_text(
bg_index, bg_index,
&transparent_bg_steps_array, &step_array,
&control_steps_array[8], &control_steps_array[8],
text_steps_array.as_deref(), text_steps_array.as_deref(),
actual_alpha, actual_alpha,