改变QScheme设置内容的导出方式。
This commit is contained in:
parent
c78a2f0183
commit
3ad637e1fa
|
@ -10,6 +10,7 @@ use crate::errors;
|
|||
pub mod material_design_2;
|
||||
pub mod material_design_3;
|
||||
pub mod q_style;
|
||||
pub mod swatch_style;
|
||||
|
||||
pub trait SchemeExport {
|
||||
fn output_css_variables(&self) -> String;
|
||||
|
@ -69,10 +70,8 @@ pub fn generate_q_scheme_automatically(
|
|||
info_color: &str,
|
||||
fg_color: &str,
|
||||
bg_color: &str,
|
||||
setting: JsValue,
|
||||
setting: SchemeSetting,
|
||||
) -> Result<JsValue, errors::ColorError> {
|
||||
let settings: SchemeSetting = serde_wasm_bindgen::from_value(setting)
|
||||
.map_err(|_| errors::ColorError::UnableToParseArgument)?;
|
||||
let scheme = QScheme::new(
|
||||
primary_color,
|
||||
danger_color,
|
||||
|
@ -81,7 +80,7 @@ pub fn generate_q_scheme_automatically(
|
|||
info_color,
|
||||
fg_color,
|
||||
bg_color,
|
||||
settings,
|
||||
setting,
|
||||
)?;
|
||||
Ok(serde_wasm_bindgen::to_value(&(
|
||||
scheme.clone(),
|
||||
|
@ -104,10 +103,8 @@ pub fn generate_q_scheme_manually(
|
|||
info_color: &str,
|
||||
fg_color: &str,
|
||||
bg_color: &str,
|
||||
setting: JsValue,
|
||||
setting: SchemeSetting,
|
||||
) -> Result<JsValue, errors::ColorError> {
|
||||
let settings: SchemeSetting = serde_wasm_bindgen::from_value(setting)
|
||||
.map_err(|_| errors::ColorError::UnableToParseArgument)?;
|
||||
let scheme = QScheme::custom(
|
||||
primary_color,
|
||||
secondary_color.as_deref(),
|
||||
|
@ -119,7 +116,7 @@ pub fn generate_q_scheme_manually(
|
|||
info_color,
|
||||
fg_color,
|
||||
bg_color,
|
||||
settings,
|
||||
setting,
|
||||
)?;
|
||||
Ok(serde_wasm_bindgen::to_value(&(
|
||||
scheme.clone(),
|
||||
|
|
|
@ -16,7 +16,7 @@ mod color_set;
|
|||
mod neutral_swatch;
|
||||
mod scheme_setting;
|
||||
|
||||
pub use scheme_setting::SchemeSetting;
|
||||
pub use scheme_setting::{ColorShifting, SchemeSetting};
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct QScheme {
|
||||
|
|
|
@ -3,8 +3,10 @@ use std::ops::Mul;
|
|||
use palette::Oklch;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use strum::{Display, EnumIter, EnumString};
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||
#[wasm_bindgen]
|
||||
pub struct ColorShifting {
|
||||
pub chroma: f32,
|
||||
pub lightness: f32,
|
||||
|
@ -55,6 +57,7 @@ impl Mul<ColorShifting> for &Oklch<f32> {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||
#[wasm_bindgen]
|
||||
pub struct SchemeSetting {
|
||||
pub hover: ColorShifting,
|
||||
pub active: ColorShifting,
|
||||
|
@ -67,6 +70,7 @@ pub struct SchemeSetting {
|
|||
|
||||
#[derive(Debug, Clone, Copy, Display, EnumString, EnumIter, Serialize, Deserialize)]
|
||||
#[strum(serialize_all = "lowercase")]
|
||||
#[wasm_bindgen]
|
||||
pub enum ColorExpand {
|
||||
Complementary,
|
||||
Analogous,
|
||||
|
@ -93,6 +97,7 @@ impl ColorExpand {
|
|||
|
||||
#[derive(Debug, Clone, Copy, Display, EnumString, EnumIter, Serialize, Deserialize)]
|
||||
#[strum(serialize_all = "lowercase")]
|
||||
#[wasm_bindgen]
|
||||
pub enum WACGSetting {
|
||||
Fixed,
|
||||
AutomaticAA,
|
||||
|
|
Loading…
Reference in New Issue
Block a user