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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! iced adapter — apply Opaline themes to iced GUIs.
//!
//! Provides `From` conversions for [`Color`] and helpers that map theme
//! tokens onto iced's [`Palette`] and [`Custom`] theme.
//!
//! ```rust,ignore
//! use iced::Theme;
//! use std::sync::Arc;
//!
//! let theme = opaline::Theme::default();
//! let custom = opaline::adapters::iced::to_iced_custom(&theme);
//! let iced_theme = Theme::Custom(Arc::new(custom));
//! ```
use Color;
use Extended;
use ;
use crateOpalineColor;
use cratetokens;
use crateTheme;
// ═══════════════════════════════════════════════════════════════════════════════
// Color conversion
// ═══════════════════════════════════════════════════════════════════════════════
// ═══════════════════════════════════════════════════════════════════════════════
// Theme → Palette / Custom
// ═══════════════════════════════════════════════════════════════════════════════
/// Convert an Opaline [`Theme`] to an iced [`Palette`].
///
/// Maps the six required iced palette slots from the standard Opaline token
/// contract:
///
/// | iced field | Opaline token |
/// |--------------|-------------------|
/// | `background` | `bg.base` |
/// | `text` | `text.primary` |
/// | `primary` | `accent.primary` |
/// | `success` | `success` |
/// | `warning` | `warning` |
/// | `danger` | `error` |
/// Convert an Opaline [`Theme`] to an iced [`Extended`] palette.
///
/// Builds a [`Palette`] via [`to_iced_palette`] and lets iced derive the
/// extended tints via [`Extended::generate`].
/// Convert an Opaline [`Theme`] to an iced [`Custom`] theme.
///
/// Uses [`Theme::meta.name`](crate::schema::ThemeMeta) as the iced theme
/// name and derives the extended palette via iced's default generator.
/// Drop the result into [`iced::Theme::Custom`](https://docs.rs/iced/latest/iced/enum.Theme.html#variant.Custom)
/// (wrapped in `Arc`) to use it.