From d79a014916c17001eb5e2d56cac1c3b4b5eb8aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Thu, 15 Jan 2026 09:42:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(color-module):=20=E6=B7=BB=E5=8A=A0=20q=5F?= =?UTF-8?q?scheme=5Fselect=5Foptions=20=E6=96=B9=E6=B3=95=E4=BB=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20SchemeSelect=20=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- color-module/src/schemes/q_style/mod.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/color-module/src/schemes/q_style/mod.rs b/color-module/src/schemes/q_style/mod.rs index df027ca..f204a45 100644 --- a/color-module/src/schemes/q_style/mod.rs +++ b/color-module/src/schemes/q_style/mod.rs @@ -4,7 +4,7 @@ use baseline::Baseline; use linked_hash_set::LinkedHashSet; use palette::FromColor; use serde::Serialize; -use wasm_bindgen::{prelude::wasm_bindgen, JsValue}; +use wasm_bindgen::{JsValue, prelude::wasm_bindgen}; use crate::{errors, parse_option_to_oklch, parse_to_oklch}; @@ -16,7 +16,7 @@ mod neutral_swatch; mod scheme_setting; pub use neutral_swatch::NeutralSwatch; -pub use scheme_setting::{ColorExpand, ColorShifting, SchemeSetting, WACGSetting}; +pub use scheme_setting::{ColorExpand, ColorShifting, SchemeSelect, SchemeSetting, WACGSetting}; #[derive(Debug, Clone, Serialize)] pub struct QScheme { @@ -221,6 +221,20 @@ pub fn q_scheme_wacg_settings() -> Result { serde_wasm_bindgen::to_value(&settings).map_err(|e| e.to_string()) } +#[wasm_bindgen] +pub fn q_scheme_select_options() -> Result { + let options = enum_iterator::all::() + .map(|option| { + serde_json::json!({ + "label": option.label(), + "value": option as u8, + }) + }) + .collect::>(); + + serde_wasm_bindgen::to_value(&options).map_err(|e| e.to_string()) +} + #[wasm_bindgen] pub fn q_scheme_default_settings() -> SchemeSetting { SchemeSetting::default()