fix: sync website color scheme
This commit is contained in:
@@ -19,6 +19,24 @@ pub enum ThemeMode {
|
||||
Dark,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum ColorScheme {
|
||||
#[default]
|
||||
Light,
|
||||
Dark,
|
||||
}
|
||||
|
||||
impl ThemeMode {
|
||||
pub fn resolve(self, system: ColorScheme) -> ColorScheme {
|
||||
match self {
|
||||
Self::System => system,
|
||||
Self::Light => ColorScheme::Light,
|
||||
Self::Dark => ColorScheme::Dark,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const DEFAULT_TRANSLUCENCY_PCT: u8 = 40;
|
||||
pub const MAX_TRANSLUCENCY_PCT: u8 = 100;
|
||||
|
||||
@@ -77,7 +95,7 @@ impl AppearanceSettings {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{AppearanceSettings, ThemeMode, WallpaperTheme};
|
||||
use super::{AppearanceSettings, ColorScheme, ThemeMode, WallpaperTheme};
|
||||
|
||||
#[test]
|
||||
fn default_settings_use_dawn_and_system_mode() {
|
||||
@@ -103,6 +121,13 @@ mod tests {
|
||||
assert_eq!(settings.translucency_pct(), 75);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn theme_mode_resolves_explicit_and_system_color_schemes() {
|
||||
assert_eq!(ThemeMode::System.resolve(ColorScheme::Dark), ColorScheme::Dark);
|
||||
assert_eq!(ThemeMode::Light.resolve(ColorScheme::Dark), ColorScheme::Light);
|
||||
assert_eq!(ThemeMode::Dark.resolve(ColorScheme::Light), ColorScheme::Dark);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn translucency_setter_clamps_above_max() {
|
||||
let mut settings = AppearanceSettings::default();
|
||||
|
||||
@@ -24,7 +24,8 @@ mod tab_group;
|
||||
mod url_text;
|
||||
|
||||
pub use appearance::{
|
||||
AppearanceSettings, DEFAULT_TRANSLUCENCY_PCT, MAX_TRANSLUCENCY_PCT, ThemeMode, WallpaperTheme,
|
||||
AppearanceSettings, ColorScheme, DEFAULT_TRANSLUCENCY_PCT, MAX_TRANSLUCENCY_PCT, ThemeMode,
|
||||
WallpaperTheme,
|
||||
};
|
||||
pub use archive::{ArchiveSource, ArchivedTab};
|
||||
pub use bookmark::BookmarkEntry;
|
||||
|
||||
Reference in New Issue
Block a user