studio-theme-glass-apple/src/lib.rs
flemming-it 50e2c4bb29 refactor: depend on renamed chain-plugin-sdk
Signed-off-by: flemming-it <sf@flemming.it>
2026-06-16 11:29:43 +02:00

94 lines
3.4 KiB
Rust

//! `studio.theme.glass-apple` — clean, neutral, frosted-glass
//! Studio theme inspired by Apple's macOS system palette.
//!
//! Cool grays, blue accent, indigo + green + red system
//! colours. Pairs cleanly with FaiEditorStyle.modern (frosted
//! panel + gradient backdrop) for the "Apple sidebar" feel.
//! Light mode reads as a sunlit studio; dark mode reads as
//! a quiet evening workspace.
#![allow(clippy::result_large_err)]
use chain_plugin_sdk::{bindings, export_plugin};
type ColorScheme = bindings::chain::studio_plugin::plugin_types::ColorScheme;
type PluginError = bindings::chain::studio_plugin::plugin_types::PluginError;
type RenderedOutput = bindings::chain::studio_plugin::plugin_types::RenderedOutput;
const GLASS_APPLE_LIGHT: [u32; 14] = [
0xFF007AFF, // primary — Apple system blue
0xFFFFFFFF, // on_primary
0xFF5856D6, // secondary — Apple system indigo
0xFFFFFFFF, // on_secondary
0xFF34C759, // tertiary — Apple system green
0xFFFFFFFF, // on_tertiary
0xFFFF3B30, // error — Apple system red
0xFFFFFFFF, // on_error
0xFFF2F2F7, // surface — Apple system gray 6 light
0xFF1C1C1E, // on_surface
0xFFE5E5EA, // surface_variant — Apple system gray 5 light
0xFF3A3A3C, // on_surface_variant
0xFFC7C7CC, // outline
0xFFD1D1D6, // outline_variant
];
const GLASS_APPLE_DARK: [u32; 14] = [
0xFF0A84FF, // primary — Apple system blue dark
0xFFFFFFFF, // on_primary
0xFF5E5CE6, // secondary — Apple system indigo dark
0xFFFFFFFF, // on_secondary
0xFF30D158, // tertiary — Apple system green dark
0xFF003800, // on_tertiary
0xFFFF453A, // error — Apple system red dark
0xFFFFFFFF, // on_error
0xFF1C1C1E, // surface — Apple system gray 6 dark
0xFFFFFFFF, // on_surface
0xFF2C2C2E, // surface_variant — Apple system gray 5 dark
0xFFEBEBF5, // on_surface_variant
0xFF48484A, // outline
0xFF3A3A3C, // outline_variant
];
struct GlassApplePlugin;
impl bindings::exports::chain::studio_plugin::theme::Guest for GlassApplePlugin {
fn theme_for(brightness: String) -> Result<ColorScheme, PluginError> {
let tokens = match brightness.as_str() {
"light" => GLASS_APPLE_LIGHT.to_vec(),
"dark" => GLASS_APPLE_DARK.to_vec(),
other => {
return Err(PluginError::Declined(format!(
"glass-apple has no scheme for brightness '{other}' \
(supported: light, dark)"
)));
}
};
Ok(ColorScheme { brightness, tokens })
}
}
impl bindings::exports::chain::studio_plugin::translate::Guest for GlassApplePlugin {
fn translate(
_text: String,
_from_locale: String,
_to_locale: String,
) -> Result<String, PluginError> {
Err(PluginError::Declined(
"glass-apple is a theme plugin and does not translate".to_string(),
))
}
}
impl bindings::exports::chain::studio_plugin::output_view::Guest for GlassApplePlugin {
fn render(
_mime_type: String,
_data: Vec<u8>,
) -> Result<RenderedOutput, PluginError> {
Err(PluginError::Declined(
"glass-apple is a theme plugin and does not render outputs"
.to_string(),
))
}
}
export_plugin!(GlassApplePlugin);