| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
use makeover::{Rgb, ThemeColors}; |
| 34 |
use ratatui::style::Color; |
| 35 |
|
| 36 |
|
| 37 |
#[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 38 |
pub enum Mode { |
| 39 |
Light, |
| 40 |
Dark, |
| 41 |
HighContrast, |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
#[derive(Debug, Clone, Copy)] |
| 52 |
#[non_exhaustive] |
| 53 |
pub struct Theme { |
| 54 |
pub mode: Mode, |
| 55 |
|
| 56 |
pub surface_page: Color, |
| 57 |
pub surface_raised: Color, |
| 58 |
pub surface_sunken: Color, |
| 59 |
pub surface_overlay: Color, |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
pub surface_well: Option<Color>, |
| 75 |
|
| 76 |
pub content_primary: Color, |
| 77 |
pub content_secondary: Color, |
| 78 |
pub content_muted: Color, |
| 79 |
|
| 80 |
pub action_primary: Color, |
| 81 |
|
| 82 |
pub status_danger: Color, |
| 83 |
pub status_success: Color, |
| 84 |
pub status_warning: Color, |
| 85 |
pub status_info: Color, |
| 86 |
|
| 87 |
|
| 88 |
pub line_border: Color, |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
pub border_strong: Color, |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
pub selection_on: Color, |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
pub focus_ring: Color, |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
pub bevel_light: Color, |
| 136 |
pub bevel_dark: Color, |
| 137 |
|
| 138 |
pub category: [Color; 6], |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
#[derive(Debug, Clone)] |
| 146 |
pub enum ThemeError { |
| 147 |
MissingKey(&'static str), |
| 148 |
InvalidHex { key: &'static str, value: String }, |
| 149 |
} |
| 150 |
|
| 151 |
impl std::fmt::Display for ThemeError { |
| 152 |
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 153 |
match self { |
| 154 |
Self::MissingKey(k) => write!(f, "theme missing required key `{k}`"), |
| 155 |
Self::InvalidHex { key, value } => { |
| 156 |
write!(f, "theme key `{key}` has invalid hex value `{value}`") |
| 157 |
} |
| 158 |
} |
| 159 |
} |
| 160 |
} |
| 161 |
|
| 162 |
impl std::error::Error for ThemeError {} |
| 163 |
|
| 164 |
impl Theme { |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
pub fn from_theme(theme: &ThemeColors) -> Result<Self, ThemeError> { |
| 173 |
let authored = |key: &'static str| -> Result<Rgb, ThemeError> { |
| 174 |
let hex = theme.colors.get(key).ok_or(ThemeError::MissingKey(key))?; |
| 175 |
Rgb::from_hex(hex).ok_or_else(|| ThemeError::InvalidHex { |
| 176 |
key, |
| 177 |
value: hex.clone(), |
| 178 |
}) |
| 179 |
}; |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
let resolved = makeover::resolve(theme); |
| 186 |
let derived = |key: &'static str| -> Result<Rgb, ThemeError> { |
| 187 |
let hex = resolved.hex(key).ok_or(ThemeError::MissingKey(key))?; |
| 188 |
Rgb::from_hex(hex).ok_or_else(|| ThemeError::InvalidHex { |
| 189 |
key, |
| 190 |
value: hex.to_string(), |
| 191 |
}) |
| 192 |
}; |
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
let accent = authored("action.primary")?; |
| 200 |
let page = authored("surface.page")?; |
| 201 |
let selection_on = on_accent(accent, page, authored("content.primary")?); |
| 202 |
|
| 203 |
let mode = match theme.meta.variant.as_str() { |
| 204 |
"dark" => Mode::Dark, |
| 205 |
"high-contrast" => Mode::HighContrast, |
| 206 |
_ => Mode::Light, |
| 207 |
}; |
| 208 |
|
| 209 |
Ok(Self { |
| 210 |
mode, |
| 211 |
|
| 212 |
surface_page: rgb(authored("surface.page")?), |
| 213 |
surface_raised: rgb(authored("surface.raised")?), |
| 214 |
surface_sunken: rgb(authored("surface.sunken")?), |
| 215 |
surface_overlay: rgb(authored("surface.overlay")?), |
| 216 |
surface_well: resolved |
| 217 |
.hex("surface-well") |
| 218 |
.and_then(Rgb::from_hex) |
| 219 |
.map(rgb), |
| 220 |
|
| 221 |
content_primary: rgb(authored("content.primary")?), |
| 222 |
content_secondary: rgb(authored("content.secondary")?), |
| 223 |
content_muted: rgb(authored("content.muted")?), |
| 224 |
|
| 225 |
action_primary: rgb(accent), |
| 226 |
selection_on: rgb(selection_on), |
| 227 |
focus_ring: rgb(focus_ring(accent, page)), |
| 228 |
|
| 229 |
status_danger: rgb(authored("status.danger")?), |
| 230 |
status_success: rgb(authored("status.success")?), |
| 231 |
status_warning: rgb(authored("status.warning")?), |
| 232 |
status_info: rgb(authored("status.info")?), |
| 233 |
|
| 234 |
line_border: rgb(authored("line.border")?), |
| 235 |
border_strong: rgb(derived("border-strong")?), |
| 236 |
|
| 237 |
bevel_light: rgb(derived("bevel-light")?), |
| 238 |
bevel_dark: rgb(derived("bevel-dark")?), |
| 239 |
|
| 240 |
category: [ |
| 241 |
rgb(authored("category.one")?), |
| 242 |
rgb(authored("category.two")?), |
| 243 |
rgb(authored("category.three")?), |
| 244 |
rgb(authored("category.four")?), |
| 245 |
rgb(authored("category.five")?), |
| 246 |
rgb(authored("category.six")?), |
| 247 |
], |
| 248 |
}) |
| 249 |
} |
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
#[must_use] |
| 278 |
pub fn for_terminal(self, fidelity: crate::Fidelity) -> Self { |
| 279 |
let Some(q) = Quantize::for_fidelity(fidelity) else { |
| 280 |
return self; |
| 281 |
}; |
| 282 |
|
| 283 |
let plain = |c: Color| q.plain(c); |
| 284 |
let on_page = |c: Color| q.against(c, self.surface_page); |
| 285 |
|
| 286 |
Self { |
| 287 |
mode: self.mode, |
| 288 |
|
| 289 |
surface_page: plain(self.surface_page), |
| 290 |
surface_raised: plain(self.surface_raised), |
| 291 |
surface_sunken: plain(self.surface_sunken), |
| 292 |
surface_overlay: plain(self.surface_overlay), |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
surface_well: self.surface_well.map(plain), |
| 298 |
|
| 299 |
content_primary: on_page(self.content_primary), |
| 300 |
content_secondary: on_page(self.content_secondary), |
| 301 |
content_muted: on_page(self.content_muted), |
| 302 |
|
| 303 |
action_primary: on_page(self.action_primary), |
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
selection_on: q.against(self.selection_on, self.action_primary), |
| 309 |
focus_ring: on_page(self.focus_ring), |
| 310 |
|
| 311 |
status_danger: on_page(self.status_danger), |
| 312 |
status_success: on_page(self.status_success), |
| 313 |
status_warning: on_page(self.status_warning), |
| 314 |
status_info: on_page(self.status_info), |
| 315 |
|
| 316 |
line_border: on_page(self.line_border), |
| 317 |
border_strong: on_page(self.border_strong), |
| 318 |
|
| 319 |
bevel_light: plain(self.bevel_light), |
| 320 |
bevel_dark: plain(self.bevel_dark), |
| 321 |
|
| 322 |
category: self.category.map(on_page), |
| 323 |
} |
| 324 |
} |
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
#[must_use] |
| 334 |
pub const fn palette(&self, fidelity: crate::Fidelity) -> crate::Palette { |
| 335 |
crate::Palette { |
| 336 |
page: self.surface_page, |
| 337 |
raised: self.surface_raised, |
| 338 |
overlay: self.surface_overlay, |
| 339 |
well: self.surface_well, |
| 340 |
bevel_light: self.bevel_light, |
| 341 |
bevel_dark: self.bevel_dark, |
| 342 |
fidelity, |
| 343 |
} |
| 344 |
} |
| 345 |
} |
| 346 |
|
| 347 |
fn rgb(c: Rgb) -> Color { |
| 348 |
Color::Rgb(c.r, c.g, c.b) |
| 349 |
} |
| 350 |
|
| 351 |
|
| 352 |
const TEXT_FLOOR: f32 = 4.5; |
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
const UI_FLOOR: f32 = 3.0; |
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
fn on_accent(accent: Rgb, page: Rgb, content: Rgb) -> Rgb { |
| 374 |
let best = if makeover::wcag_contrast(page, accent) >= makeover::wcag_contrast(content, accent) |
| 375 |
{ |
| 376 |
page |
| 377 |
} else { |
| 378 |
content |
| 379 |
}; |
| 380 |
if makeover::wcag_contrast(best, accent) >= TEXT_FLOOR { |
| 381 |
best |
| 382 |
} else { |
| 383 |
makeover::readable_on(accent) |
| 384 |
} |
| 385 |
} |
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
fn focus_ring(accent: Rgb, page: Rgb) -> Rgb { |
| 399 |
if makeover::wcag_contrast(accent, page) >= UI_FLOOR { |
| 400 |
return accent; |
| 401 |
} |
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
let page_is_dark = makeover::wcag_contrast( |
| 406 |
Rgb { |
| 407 |
r: 255, |
| 408 |
g: 255, |
| 409 |
b: 255, |
| 410 |
}, |
| 411 |
page, |
| 412 |
) > makeover::wcag_contrast(Rgb { r: 0, g: 0, b: 0 }, page); |
| 413 |
|
| 414 |
let mut candidate = accent; |
| 415 |
for _ in 0..20 { |
| 416 |
candidate = if page_is_dark { |
| 417 |
makeover::lighten(candidate, 0.05) |
| 418 |
} else { |
| 419 |
makeover::darken(candidate, 0.05) |
| 420 |
}; |
| 421 |
if makeover::wcag_contrast(candidate, page) >= UI_FLOOR { |
| 422 |
return candidate; |
| 423 |
} |
| 424 |
} |
| 425 |
candidate |
| 426 |
} |
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
#[derive(Debug, Clone, Copy)] |
| 437 |
pub struct Quantize { |
| 438 |
palette: &'static [Rgb], |
| 439 |
offset: usize, |
| 440 |
} |
| 441 |
|
| 442 |
impl Quantize { |
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
#[must_use] |
| 450 |
pub const fn for_fidelity(fidelity: crate::Fidelity) -> Option<Self> { |
| 451 |
match fidelity { |
| 452 |
crate::Fidelity::TrueColor => None, |
| 453 |
crate::Fidelity::Ansi256 => Some(Self { |
| 454 |
palette: makeover::ANSI_240, |
| 455 |
offset: makeover::ANSI_240_OFFSET, |
| 456 |
}), |
| 457 |
crate::Fidelity::Ansi16 => Some(Self { |
| 458 |
palette: &makeover::ANSI_16, |
| 459 |
offset: 0, |
| 460 |
}), |
| 461 |
} |
| 462 |
} |
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
#[must_use] |
| 469 |
pub fn plain(&self, c: Color) -> Color { |
| 470 |
match c { |
| 471 |
Color::Rgb(r, g, b) => Color::Indexed( |
| 472 |
(makeover::quantize(Rgb { r, g, b }, self.palette) + self.offset) as u8, |
| 473 |
), |
| 474 |
other => other, |
| 475 |
} |
| 476 |
} |
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
#[must_use] |
| 487 |
pub fn against(&self, c: Color, on: Color) -> Color { |
| 488 |
match (c, on) { |
| 489 |
(Color::Rgb(r, g, b), Color::Rgb(br, bg, bb)) => Color::Indexed( |
| 490 |
(makeover::quantize_against( |
| 491 |
Rgb { r, g, b }, |
| 492 |
Rgb { |
| 493 |
r: br, |
| 494 |
g: bg, |
| 495 |
b: bb, |
| 496 |
}, |
| 497 |
self.palette, |
| 498 |
) + self.offset) as u8, |
| 499 |
), |
| 500 |
_ => self.plain(c), |
| 501 |
} |
| 502 |
} |
| 503 |
} |
| 504 |
|
| 505 |
#[cfg(test)] |
| 506 |
mod tests { |
| 507 |
use super::*; |
| 508 |
|
| 509 |
fn bundled(id: &str) -> ThemeColors { |
| 510 |
let dir = makeover::bundled_themes_dir().expect("makeover ships themes"); |
| 511 |
makeover::load_theme(&[(dir, false)], id).expect("bundled theme loads") |
| 512 |
} |
| 513 |
|
| 514 |
#[test] |
| 515 |
fn every_bundled_theme_resolves() { |
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
let dir = makeover::bundled_themes_dir().expect("makeover ships themes"); |
| 520 |
let metas = makeover::list_themes_from_dirs(&[(dir, false)]); |
| 521 |
assert!( |
| 522 |
!metas.is_empty(), |
| 523 |
"makeover shipped no themes to test against" |
| 524 |
); |
| 525 |
for meta in &metas { |
| 526 |
let colors = bundled(&meta.id); |
| 527 |
assert!( |
| 528 |
Theme::from_theme(&colors).is_ok(), |
| 529 |
"bundled theme `{}` failed to resolve", |
| 530 |
meta.id |
| 531 |
); |
| 532 |
} |
| 533 |
} |
| 534 |
|
| 535 |
fn to_rgb(c: Color) -> Rgb { |
| 536 |
match c { |
| 537 |
Color::Rgb(r, g, b) => Rgb { r, g, b }, |
| 538 |
other => panic!("expected a resolved colour, got {other:?}"), |
| 539 |
} |
| 540 |
} |
| 541 |
|
| 542 |
#[test] |
| 543 |
fn the_two_derived_cues_are_legible_in_every_bundled_theme() { |
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
let dir = makeover::bundled_themes_dir().expect("makeover ships themes"); |
| 549 |
for meta in makeover::list_themes_from_dirs(&[(dir, false)]) { |
| 550 |
let theme = Theme::from_theme(&bundled(&meta.id)).expect("resolves"); |
| 551 |
|
| 552 |
|
| 553 |
let selection = |
| 554 |
makeover::wcag_contrast(to_rgb(theme.selection_on), to_rgb(theme.action_primary)); |
| 555 |
assert!( |
| 556 |
selection >= TEXT_FLOOR, |
| 557 |
"{}: selection_on is {selection:.2} on the accent", |
| 558 |
meta.id |
| 559 |
); |
| 560 |
|
| 561 |
|
| 562 |
let ring = |
| 563 |
makeover::wcag_contrast(to_rgb(theme.focus_ring), to_rgb(theme.surface_page)); |
| 564 |
assert!( |
| 565 |
ring >= UI_FLOOR, |
| 566 |
"{}: focus_ring is {ring:.2} on the page", |
| 567 |
meta.id |
| 568 |
); |
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
assert_ne!(theme.focus_ring, theme.border_strong, "{}", meta.id); |
| 573 |
} |
| 574 |
} |
| 575 |
|
| 576 |
#[test] |
| 577 |
fn the_derived_cues_are_quantised_for_the_surface_each_sits_on() { |
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
let theme = Theme::from_theme(&bundled("goingson")).expect("resolves"); |
| 582 |
let ansi16 = theme.for_terminal(crate::Fidelity::Ansi16); |
| 583 |
let q = Quantize::for_fidelity(crate::Fidelity::Ansi16).expect("Ansi16 quantises"); |
| 584 |
|
| 585 |
assert_eq!( |
| 586 |
ansi16.selection_on, |
| 587 |
q.against(theme.selection_on, theme.action_primary) |
| 588 |
); |
| 589 |
assert_eq!( |
| 590 |
ansi16.focus_ring, |
| 591 |
q.against(theme.focus_ring, theme.surface_page) |
| 592 |
); |
| 593 |
} |
| 594 |
|
| 595 |
#[test] |
| 596 |
fn a_missing_intent_names_the_key_it_wanted() { |
| 597 |
let mut colors = bundled("goingson"); |
| 598 |
colors.colors.remove("content.muted"); |
| 599 |
match Theme::from_theme(&colors) { |
| 600 |
Err(ThemeError::MissingKey(k)) => assert_eq!(k, "content.muted"), |
| 601 |
other => panic!("expected MissingKey(content.muted), got {other:?}"), |
| 602 |
} |
| 603 |
} |
| 604 |
|
| 605 |
#[test] |
| 606 |
fn an_unparseable_hex_names_the_key_and_the_value() { |
| 607 |
let mut colors = bundled("goingson"); |
| 608 |
colors |
| 609 |
.colors |
| 610 |
.insert("content.muted".into(), "not-a-colour".into()); |
| 611 |
match Theme::from_theme(&colors) { |
| 612 |
Err(ThemeError::InvalidHex { key, value }) => { |
| 613 |
assert_eq!(key, "content.muted"); |
| 614 |
assert_eq!(value, "not-a-colour"); |
| 615 |
} |
| 616 |
other => panic!("expected InvalidHex, got {other:?}"), |
| 617 |
} |
| 618 |
} |
| 619 |
|
| 620 |
#[test] |
| 621 |
fn a_capable_terminal_gets_the_theme_as_authored() { |
| 622 |
let theme = Theme::from_theme(&bundled("goingson")).expect("resolves"); |
| 623 |
let same = theme.for_terminal(crate::Fidelity::TrueColor); |
| 624 |
assert_eq!(same.surface_page, theme.surface_page); |
| 625 |
assert_eq!(same.content_primary, theme.content_primary); |
| 626 |
assert!(matches!(same.surface_page, Color::Rgb(..))); |
| 627 |
} |
| 628 |
|
| 629 |
#[test] |
| 630 |
fn a_limited_terminal_gets_indices_rather_than_rgb() { |
| 631 |
let theme = Theme::from_theme(&bundled("goingson")).expect("resolves"); |
| 632 |
for fidelity in [crate::Fidelity::Ansi16, crate::Fidelity::Ansi256] { |
| 633 |
let q = theme.for_terminal(fidelity); |
| 634 |
assert!( |
| 635 |
matches!(q.surface_page, Color::Indexed(_)), |
| 636 |
"{fidelity:?} left a surface as rgb" |
| 637 |
); |
| 638 |
assert!( |
| 639 |
matches!(q.content_primary, Color::Indexed(_)), |
| 640 |
"{fidelity:?} left content as rgb" |
| 641 |
); |
| 642 |
} |
| 643 |
} |
| 644 |
|
| 645 |
#[test] |
| 646 |
fn the_256_indices_land_outside_the_repaintable_low_sixteen() { |
| 647 |
|
| 648 |
|
| 649 |
let theme = Theme::from_theme(&bundled("goingson")).expect("resolves"); |
| 650 |
let q = theme.for_terminal(crate::Fidelity::Ansi256); |
| 651 |
for (name, c) in [ |
| 652 |
("surface_page", q.surface_page), |
| 653 |
("content_primary", q.content_primary), |
| 654 |
("bevel_light", q.bevel_light), |
| 655 |
("bevel_dark", q.bevel_dark), |
| 656 |
] { |
| 657 |
match c { |
| 658 |
Color::Indexed(i) => assert!(i >= 16, "{name} landed on repaintable index {i}"), |
| 659 |
other => panic!("{name} was not quantised: {other:?}"), |
| 660 |
} |
| 661 |
} |
| 662 |
} |
| 663 |
|
| 664 |
#[test] |
| 665 |
fn the_bevel_pair_stays_two_tones_at_256() { |
| 666 |
|
| 667 |
|
| 668 |
let theme = Theme::from_theme(&bundled("goingson")).expect("resolves"); |
| 669 |
let q = theme.for_terminal(crate::Fidelity::Ansi256); |
| 670 |
assert_ne!(q.bevel_light, q.bevel_dark); |
| 671 |
} |
| 672 |
|
| 673 |
#[test] |
| 674 |
fn the_palette_takes_the_well_and_not_the_sunken_surface() { |
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
let colors = bundled("goingson"); |
| 679 |
let theme = Theme::from_theme(&colors).expect("resolves"); |
| 680 |
let palette = theme.palette(crate::Fidelity::TrueColor); |
| 681 |
assert_eq!(palette.well, theme.surface_well); |
| 682 |
assert_ne!(palette.well, Some(theme.surface_sunken)); |
| 683 |
} |
| 684 |
} |
| 685 |
|