iced_code_editor/theme.rs
1//! Theming support for the code editor widget.
2//!
3//! Defines the [`Style`] appearance record, the [`Catalog`] trait used to
4//! derive a `Style` from an `iced::Theme`, and helpers to build a default
5//! style from any Iced theme's palette.
6
7use iced::Color;
8
9/// The appearance of a code editor.
10///
11/// Build one with [`from_iced_theme`] to follow the application's Iced theme,
12/// then override individual fields for anything that needs to differ.
13///
14/// # Examples
15///
16/// ```
17/// use iced_code_editor::{CodeEditor, theme};
18///
19/// let mut style = theme::from_iced_theme(&iced::Theme::TokyoNightStorm);
20///
21/// // Tweak one color while keeping the rest of the derived palette.
22/// style.current_line_highlight = iced::Color::from_rgba(1.0, 1.0, 1.0, 0.05);
23///
24/// let mut editor = CodeEditor::new("fn main() {}", "rs");
25/// editor.set_theme(style);
26/// ```
27#[derive(Debug, Clone, Copy)]
28pub struct Style {
29 /// Main editor background color
30 pub background: Color,
31 /// Text content color
32 pub text_color: Color,
33 /// Line numbers gutter background color
34 pub gutter_background: Color,
35 /// Border color for the gutter
36 pub gutter_border: Color,
37 /// Color for line numbers text
38 pub line_number_color: Color,
39 /// Scrollbar background color
40 pub scrollbar_background: Color,
41 /// Scrollbar scroller (thumb) color
42 pub scroller_color: Color,
43 /// Highlight color for the current line where cursor is located
44 pub current_line_highlight: Color,
45 /// Color for visible whitespace characters (spaces as `·`, tabs as `→`)
46 pub whitespace_color: Color,
47 /// Color of the vertical indentation guides drawn behind the text
48 pub indent_guide_color: Color,
49 /// Highlight fill color for non-current search matches
50 pub search_match_color: Color,
51 /// Highlight fill color for the currently active search match
52 pub search_match_current_color: Color,
53 /// Fill color for text selection ranges
54 pub selection_color: Color,
55 /// Fill color used to highlight a matching bracket pair
56 pub bracket_match_color: Color,
57 /// Background fill color for the IME preedit (composition) region
58 pub ime_preedit_background_color: Color,
59 /// Name of the syntect theme that colors the code tokens.
60 ///
61 /// Any theme bundled with syntect works: `"base16-ocean.dark"`,
62 /// `"base16-eighties.dark"`, `"base16-mocha.dark"`, `"base16-ocean.light"`,
63 /// `"InspiredGitHub"`, `"Solarized (dark)"` and `"Solarized (light)"`.
64 /// `None`, or an unknown name, picks `base16-ocean` in its dark or light
65 /// variant from the lightness of [`Style::background`].
66 pub syntax_theme_name: Option<&'static str>,
67 /// Colors drawn over the syntax theme for common token kinds, matched by
68 /// TextMate scope. The default overrides nothing.
69 pub token_colors: TokenColors,
70 /// Underline color for error diagnostics
71 pub diagnostic_error_color: Color,
72 /// Underline color for warning diagnostics
73 pub diagnostic_warning_color: Color,
74 /// Underline color for information diagnostics
75 pub diagnostic_information_color: Color,
76 /// Underline color for hint diagnostics
77 pub diagnostic_hint_color: Color,
78}
79
80/// Colors that replace the syntax theme's for common token kinds.
81///
82/// Tokens are matched by TextMate scope name, so one set of colors applies to
83/// every grammar that uses the usual names (JSON, YAML, TOML, JavaScript,
84/// Rust, ...). A `None` field keeps the syntax theme's color.
85///
86/// # Example
87///
88/// ```
89/// use iced::Color;
90/// use iced_code_editor::{CodeEditor, TokenColors, theme};
91///
92/// let mut style = theme::from_iced_theme(&iced::Theme::Dark);
93/// style.token_colors = TokenColors {
94/// key: Some(Color::from_rgb(0.5, 0.8, 1.0)),
95/// string: Some(Color::from_rgb(0.6, 0.9, 0.5)),
96/// ..TokenColors::default()
97/// };
98///
99/// let mut editor = CodeEditor::new("{\"name\": \"value\"}", "json");
100/// editor.set_theme(style);
101/// ```
102#[derive(Debug, Clone, Copy, Default, PartialEq)]
103pub struct TokenColors {
104 /// Object keys and property names (JSON and YAML keys, object-literal
105 /// keys). Takes precedence over [`TokenColors::string`] for quoted keys.
106 pub key: Option<Color>,
107 /// Strings, quotes included (`string` scopes).
108 pub string: Option<Color>,
109 /// Numbers (`constant.numeric` scopes).
110 pub number: Option<Color>,
111 /// `true`, `false`, `null` and other `constant.language` values.
112 pub literal: Option<Color>,
113 /// Comments, delimiters included (`comment` scopes).
114 pub comment: Option<Color>,
115 /// Brackets, separators and other `punctuation` that does not delimit a
116 /// string or comment.
117 pub punctuation: Option<Color>,
118}
119
120impl TokenColors {
121 /// Whether no token kind is overridden.
122 ///
123 /// # Example
124 ///
125 /// ```
126 /// use iced_code_editor::TokenColors;
127 ///
128 /// assert!(TokenColors::default().is_empty());
129 /// ```
130 pub fn is_empty(&self) -> bool {
131 *self == Self::default()
132 }
133}
134
135/// The theme catalog of a code editor.
136///
137/// Implemented for [`iced::Theme`] out of the box, following the same catalog
138/// pattern Iced's own widgets use. Implement it for a custom theme type to
139/// make this editor themable alongside the rest of an application.
140///
141/// # Examples
142///
143/// ```
144/// use iced_code_editor::theme::{Catalog, Style};
145///
146/// // `iced::Theme` implements `Catalog`, so a style comes from the theme
147/// // itself rather than being hardcoded.
148/// let class = <iced::Theme as Catalog>::default();
149/// let style: Style = Catalog::style(&iced::Theme::Dracula, &class);
150///
151/// // A dark theme yields a dark editor background.
152/// assert!(style.background.r < 0.5);
153/// ```
154pub trait Catalog {
155 /// The item class of the [`Catalog`].
156 type Class<'a>;
157
158 /// The default class produced by the [`Catalog`].
159 fn default<'a>() -> Self::Class<'a>;
160
161 /// The [`Style`] of a class with the given status.
162 fn style(&self, class: &Self::Class<'_>) -> Style;
163}
164
165/// A styling function for a code editor.
166///
167/// This is a shorthand for a function that takes a reference to a
168/// [`Theme`](iced::Theme) and returns a [`Style`].
169///
170/// # Examples
171///
172/// ```
173/// use iced_code_editor::theme::{self, Style, StyleFn};
174///
175/// // A styling function that derives from the theme, then dims the gutter.
176/// let styling: StyleFn<'_, iced::Theme> = Box::new(|theme| {
177/// let mut style = theme::from_iced_theme(theme);
178/// style.line_number_color.a *= 0.5;
179/// style
180/// });
181///
182/// let style: Style = styling(&iced::Theme::Dracula);
183/// assert!(style.line_number_color.a < 1.0);
184/// ```
185pub type StyleFn<'a, Theme> = Box<dyn Fn(&Theme) -> Style + 'a>;
186
187impl Catalog for iced::Theme {
188 type Class<'a> = StyleFn<'a, Self>;
189
190 fn default<'a>() -> Self::Class<'a> {
191 Box::new(from_iced_theme)
192 }
193
194 fn style(&self, class: &Self::Class<'_>) -> Style {
195 class(self)
196 }
197}
198
199/// Creates a theme style automatically from any Iced theme.
200///
201/// This is the default styling function that adapts to all native Iced themes including:
202/// - Basic themes: Light, Dark
203/// - Popular themes: Dracula, Nord, Solarized, Gruvbox
204/// - Catppuccin variants: Latte, Frappé, Macchiato, Mocha
205/// - Tokyo Night variants: Tokyo Night, Storm, Light
206/// - Kanagawa variants: Wave, Dragon, Lotus
207/// - And more: Moonfly, Nightfly, Oxocarbon, Ferra
208///
209/// The function automatically detects if the theme is dark or light and adjusts
210/// colors accordingly for optimal contrast and readability in code editing.
211///
212/// # Color Mapping
213///
214/// - `background`: Uses the theme's base background color
215/// - `text_color`: Uses the theme's base text color
216/// - `gutter_background`: Slightly darker/lighter than background
217/// - `gutter_border`: Border between gutter and editor
218/// - `line_number_color`: Dimmed text color for subtle line numbers
219/// - `scrollbar_background`: Matches editor background
220/// - `scroller_color`: Uses secondary color for visibility
221/// - `current_line_highlight`: Subtle highlight using primary color
222///
223/// # Example
224///
225/// ```
226/// use iced_code_editor::theme;
227///
228/// let tokyo_night = iced::Theme::TokyoNightStorm;
229/// let style = theme::from_iced_theme(&tokyo_night);
230///
231/// // Or use with any theme variant
232/// let dracula = iced::Theme::Dracula;
233/// let style = theme::from_iced_theme(&dracula);
234/// ```
235pub fn from_iced_theme(theme: &iced::Theme) -> Style {
236 let palette = theme.extended_palette();
237 let is_dark = palette.is_dark;
238
239 // Base colors from theme palette
240 let background = palette.background.base.color;
241 let text_color = palette.background.base.text;
242
243 // Gutter colors: slightly offset from background for subtle distinction
244 let gutter_background = palette.background.weak.color;
245 let gutter_border = if is_dark {
246 darken(palette.background.strong.color, 0.1)
247 } else {
248 lighten(palette.background.strong.color, 0.1)
249 };
250
251 // Line numbers: dimmed text color for subtlety
252 // For dark themes: dim the bright text (make it darker)
253 // For light themes: blend text towards background (make it lighter/grayer)
254 let line_number_color = if is_dark {
255 dim_color(text_color, 0.5)
256 } else {
257 // For light themes, blend text color towards background
258 blend_colors(text_color, background, 0.5)
259 };
260
261 // Scrollbar colors: blend with background
262 let scrollbar_background = background;
263 let scroller_color = palette.secondary.weak.color;
264
265 // Current line highlight: very subtle with primary color
266 let current_line_highlight = with_alpha(
267 palette.primary.weak.color,
268 if is_dark { 0.15 } else { 0.25 },
269 );
270
271 let whitespace_color = if is_dark {
272 dim_color(text_color, 0.65)
273 } else {
274 blend_colors(text_color, background, 0.65)
275 };
276
277 // Indentation guides: fainter than visible whitespace, since a guide spans
278 // the full line height and would otherwise compete with the code itself.
279 let indent_guide_color =
280 with_alpha(text_color, if is_dark { 0.18 } else { 0.22 });
281
282 // Search matches: orange for the current match, yellow for the rest.
283 // Fixed values (not palette-derived) to preserve the conventional
284 // search-highlight look regardless of the active theme.
285 let search_match_color = Color { r: 1.0, g: 1.0, b: 0.0, a: 0.3 };
286 let search_match_current_color = Color { r: 1.0, g: 0.6, b: 0.0, a: 0.4 };
287
288 // Text selection fill.
289 let selection_color = Color { r: 0.3, g: 0.5, b: 0.8, a: 0.3 };
290
291 // Matching bracket/quote pair highlight.
292 let bracket_match_color = Color { r: 0.5, g: 0.5, b: 0.5, a: 0.4 };
293
294 // IME preedit (composition) background.
295 let ime_preedit_background_color =
296 Color { r: 1.0, g: 1.0, b: 1.0, a: 0.08 };
297
298 Style {
299 background,
300 text_color,
301 gutter_background,
302 gutter_border,
303 line_number_color,
304 scrollbar_background,
305 scroller_color,
306 current_line_highlight,
307 whitespace_color,
308 indent_guide_color,
309 search_match_color,
310 search_match_current_color,
311 selection_color,
312 bracket_match_color,
313 ime_preedit_background_color,
314 syntax_theme_name: None,
315 token_colors: TokenColors::default(),
316 diagnostic_error_color: palette.danger.base.color,
317 diagnostic_warning_color: palette.warning.base.color,
318 diagnostic_information_color: palette.primary.base.color,
319 diagnostic_hint_color: palette.secondary.base.color,
320 }
321}
322
323/// Returns whether `color` is dark enough to need a dark-tuned palette on top
324/// of it.
325///
326/// [`Style`] keeps only the resolved colors, not the `is_dark` flag of the
327/// Iced palette it was derived from, so consumers that must branch on
328/// light/dark -- notably the syntect theme picked by the syntax highlighter --
329/// recover it from the background here. The threshold is applied to the
330/// relative luminance (ITU-R BT.709 coefficients), so a mid-tone yellow reads
331/// as light and a mid-tone blue as dark, the way the eye sees them.
332///
333/// # Arguments
334///
335/// * `color` - The background color to classify
336///
337/// # Returns
338///
339/// `true` when the color is dark, `false` when it is light.
340pub(crate) fn is_dark_background(color: Color) -> bool {
341 let luminance = 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
342 luminance < 0.5
343}
344
345/// Darkens a color by a given factor (0.0 to 1.0).
346fn darken(color: Color, factor: f32) -> Color {
347 Color {
348 r: color.r * (1.0 - factor),
349 g: color.g * (1.0 - factor),
350 b: color.b * (1.0 - factor),
351 a: color.a,
352 }
353}
354
355/// Lightens a color by a given factor (0.0 to 1.0).
356fn lighten(color: Color, factor: f32) -> Color {
357 Color {
358 r: color.r + (1.0 - color.r) * factor,
359 g: color.g + (1.0 - color.g) * factor,
360 b: color.b + (1.0 - color.b) * factor,
361 a: color.a,
362 }
363}
364
365/// Dims a color by reducing its intensity.
366fn dim_color(color: Color, factor: f32) -> Color {
367 Color {
368 r: color.r * factor,
369 g: color.g * factor,
370 b: color.b * factor,
371 a: color.a,
372 }
373}
374
375/// Blends two colors together by a given factor (0.0 = first color, 1.0 = second color).
376fn blend_colors(color1: Color, color2: Color, factor: f32) -> Color {
377 Color {
378 r: color1.r + (color2.r - color1.r) * factor,
379 g: color1.g + (color2.g - color1.g) * factor,
380 b: color1.b + (color2.b - color1.b) * factor,
381 a: color1.a + (color2.a - color1.a) * factor,
382 }
383}
384
385/// Applies an alpha transparency to a color.
386fn with_alpha(color: Color, alpha: f32) -> Color {
387 Color { r: color.r, g: color.g, b: color.b, a: alpha }
388}
389
390#[cfg(test)]
391mod tests {
392 use super::*;
393
394 #[test]
395 fn test_is_dark_background_classifies_dark_and_light() {
396 // TokyoNightStorm's background.
397 assert!(is_dark_background(Color::from_rgb(0.141, 0.157, 0.231)));
398 assert!(is_dark_background(Color::BLACK));
399
400 // base16-ocean.light's background.
401 assert!(!is_dark_background(Color::from_rgb(0.937, 0.945, 0.961)));
402 assert!(!is_dark_background(Color::WHITE));
403 }
404
405 #[test]
406 fn test_is_dark_background_weights_channels_by_luminance() {
407 // Same numeric intensity in every channel, but green dominates the
408 // luminance formula: pure green reads light, pure blue reads dark.
409 assert!(!is_dark_background(Color::from_rgb(0.0, 1.0, 0.0)));
410 assert!(is_dark_background(Color::from_rgb(0.0, 0.0, 1.0)));
411 }
412
413 #[test]
414 fn test_from_iced_theme_dark() {
415 let theme = iced::Theme::Dark;
416 let style = from_iced_theme(&theme);
417
418 // Dark theme should have dark background
419 let brightness =
420 (style.background.r + style.background.g + style.background.b)
421 / 3.0;
422 assert!(brightness < 0.5, "Dark theme should have dark background");
423
424 // Text should be bright for contrast
425 let text_brightness =
426 (style.text_color.r + style.text_color.g + style.text_color.b)
427 / 3.0;
428 assert!(text_brightness > 0.5, "Dark theme should have bright text");
429 }
430
431 #[test]
432 fn test_from_iced_theme_light() {
433 let theme = iced::Theme::Light;
434 let style = from_iced_theme(&theme);
435
436 // Light theme should have bright background
437 let brightness =
438 (style.background.r + style.background.g + style.background.b)
439 / 3.0;
440 assert!(brightness > 0.5, "Light theme should have bright background");
441
442 // Text should be dark for contrast
443 let text_brightness =
444 (style.text_color.r + style.text_color.g + style.text_color.b)
445 / 3.0;
446 assert!(text_brightness < 0.5, "Light theme should have dark text");
447 }
448
449 #[test]
450 fn test_all_iced_themes_produce_valid_styles() {
451 // Test all native Iced themes
452 for theme in iced::Theme::ALL {
453 let style = from_iced_theme(theme);
454
455 // All color components should be valid (0.0 to 1.0)
456 assert!(style.background.r >= 0.0 && style.background.r <= 1.0);
457 assert!(style.text_color.r >= 0.0 && style.text_color.r <= 1.0);
458 assert!(
459 style.gutter_background.r >= 0.0
460 && style.gutter_background.r <= 1.0
461 );
462 assert!(
463 style.line_number_color.r >= 0.0
464 && style.line_number_color.r <= 1.0
465 );
466
467 // Current line highlight should have transparency
468 assert!(
469 style.current_line_highlight.a < 1.0,
470 "Current line highlight should be semi-transparent for theme: {:?}",
471 theme
472 );
473
474 // New overlay colors should have valid components and visible
475 // (but not opaque) alpha for every theme.
476 for (name, color) in [
477 ("search_match_color", style.search_match_color),
478 (
479 "search_match_current_color",
480 style.search_match_current_color,
481 ),
482 ("selection_color", style.selection_color),
483 ("bracket_match_color", style.bracket_match_color),
484 (
485 "ime_preedit_background_color",
486 style.ime_preedit_background_color,
487 ),
488 ] {
489 assert!(
490 color.r >= 0.0 && color.r <= 1.0,
491 "{name}.r out of range for theme: {theme:?}"
492 );
493 assert!(
494 color.g >= 0.0 && color.g <= 1.0,
495 "{name}.g out of range for theme: {theme:?}"
496 );
497 assert!(
498 color.b >= 0.0 && color.b <= 1.0,
499 "{name}.b out of range for theme: {theme:?}"
500 );
501 assert!(
502 color.a > 0.0 && color.a < 1.0,
503 "{name} should be semi-transparent for theme: {theme:?}"
504 );
505 }
506 }
507 }
508
509 #[test]
510 fn test_overlay_colors_are_theme_independent() {
511 // The 5 overlay colors are fixed constants (not palette-derived), so
512 // they must be identical across very different themes.
513 let light = from_iced_theme(&iced::Theme::Light);
514 let dark = from_iced_theme(&iced::Theme::Dark);
515
516 for (light_color, dark_color) in [
517 (light.search_match_color, dark.search_match_color),
518 (light.search_match_current_color, dark.search_match_current_color),
519 (light.selection_color, dark.selection_color),
520 (light.bracket_match_color, dark.bracket_match_color),
521 (
522 light.ime_preedit_background_color,
523 dark.ime_preedit_background_color,
524 ),
525 ] {
526 assert!((light_color.r - dark_color.r).abs() < f32::EPSILON);
527 assert!((light_color.g - dark_color.g).abs() < f32::EPSILON);
528 assert!((light_color.b - dark_color.b).abs() < f32::EPSILON);
529 assert!((light_color.a - dark_color.a).abs() < f32::EPSILON);
530 }
531 }
532
533 #[test]
534 fn test_tokyo_night_themes() {
535 // Test Tokyo Night variants specifically
536 let tokyo_night = iced::Theme::TokyoNight;
537 let style = from_iced_theme(&tokyo_night);
538 assert!(style.background.r >= 0.0 && style.background.r <= 1.0);
539
540 let tokyo_storm = iced::Theme::TokyoNightStorm;
541 let style = from_iced_theme(&tokyo_storm);
542 assert!(style.background.r >= 0.0 && style.background.r <= 1.0);
543
544 let tokyo_light = iced::Theme::TokyoNightLight;
545 let style = from_iced_theme(&tokyo_light);
546 let brightness =
547 (style.background.r + style.background.g + style.background.b)
548 / 3.0;
549 assert!(
550 brightness > 0.5,
551 "Tokyo Night Light should have bright background"
552 );
553 }
554
555 #[test]
556 fn test_catppuccin_themes() {
557 // Test Catppuccin variants
558 let themes = [
559 iced::Theme::CatppuccinLatte,
560 iced::Theme::CatppuccinFrappe,
561 iced::Theme::CatppuccinMacchiato,
562 iced::Theme::CatppuccinMocha,
563 ];
564
565 for theme in themes {
566 let style = from_iced_theme(&theme);
567 // All should produce valid styles
568 assert!(style.background.r >= 0.0 && style.background.r <= 1.0);
569 assert!(style.text_color.r >= 0.0 && style.text_color.r <= 1.0);
570 }
571 }
572
573 #[test]
574 fn test_gutter_colors_distinct_from_background() {
575 let theme = iced::Theme::Dark;
576 let style = from_iced_theme(&theme);
577
578 // Gutter background should be different from editor background
579 let gutter_diff = (style.gutter_background.r - style.background.r)
580 .abs()
581 + (style.gutter_background.g - style.background.g).abs()
582 + (style.gutter_background.b - style.background.b).abs();
583
584 assert!(
585 gutter_diff > 0.0,
586 "Gutter should be visually distinct from background"
587 );
588 }
589
590 #[test]
591 fn test_line_numbers_visible_but_subtle() {
592 for theme in [iced::Theme::Dark, iced::Theme::Light] {
593 let style = from_iced_theme(&theme);
594 let palette = theme.extended_palette();
595
596 // Line numbers should be dimmed compared to text
597 let line_num_brightness = (style.line_number_color.r
598 + style.line_number_color.g
599 + style.line_number_color.b)
600 / 3.0;
601
602 let text_brightness =
603 (style.text_color.r + style.text_color.g + style.text_color.b)
604 / 3.0;
605
606 let bg_brightness =
607 (style.background.r + style.background.g + style.background.b)
608 / 3.0;
609
610 // Line numbers should be between text and background (more subtle than text)
611 // For dark themes: text is bright, line numbers dimmer, background dark
612 // For light themes: text is dark, line numbers lighter (gray), background bright
613 if palette.is_dark {
614 // Dark theme: line numbers should be less bright than text
615 assert!(
616 line_num_brightness < text_brightness,
617 "Dark theme line numbers should be dimmer than text. Line num: {}, Text: {}",
618 line_num_brightness,
619 text_brightness
620 );
621 } else {
622 // Light theme: line numbers should be between text (dark) and background (bright)
623 assert!(
624 line_num_brightness > text_brightness
625 && line_num_brightness < bg_brightness,
626 "Light theme line numbers should be between text and background. Text: {}, Line num: {}, Bg: {}",
627 text_brightness,
628 line_num_brightness,
629 bg_brightness
630 );
631 }
632 }
633 }
634
635 #[test]
636 fn test_color_helper_functions() {
637 let color = Color::from_rgb(0.5, 0.5, 0.5);
638
639 // Test darken
640 let darker = darken(color, 0.5);
641 assert!(darker.r < color.r);
642 assert!(darker.g < color.g);
643 assert!(darker.b < color.b);
644
645 // Test lighten
646 let lighter = lighten(color, 0.5);
647 assert!(lighter.r > color.r);
648 assert!(lighter.g > color.g);
649 assert!(lighter.b > color.b);
650
651 // Test dim_color
652 let dimmed = dim_color(color, 0.5);
653 assert!(dimmed.r < color.r);
654
655 // Test with_alpha
656 let transparent = with_alpha(color, 0.3);
657 assert!((transparent.a - 0.3).abs() < f32::EPSILON);
658 assert!((transparent.r - color.r).abs() < f32::EPSILON);
659 }
660
661 #[test]
662 fn test_style_copy() {
663 let theme = iced::Theme::Dark;
664 let style1 = from_iced_theme(&theme);
665 let style2 = style1;
666
667 // Verify colors are approximately equal (using epsilon for float comparison)
668 assert!(
669 (style1.background.r - style2.background.r).abs() < f32::EPSILON
670 );
671 assert!(
672 (style1.text_color.r - style2.text_color.r).abs() < f32::EPSILON
673 );
674 assert!(
675 (style1.gutter_background.r - style2.gutter_background.r).abs()
676 < f32::EPSILON
677 );
678 assert!(
679 (style1.selection_color.r - style2.selection_color.r).abs()
680 < f32::EPSILON
681 );
682 }
683
684 #[test]
685 fn test_catalog_default() {
686 let theme = iced::Theme::Dark;
687 let class = <iced::Theme as Catalog>::default();
688 let style = theme.style(&class);
689
690 // Should produce a valid style
691 assert!(style.background.r >= 0.0 && style.background.r <= 1.0);
692 assert!(style.text_color.r >= 0.0 && style.text_color.r <= 1.0);
693 }
694}