From 4e7462cb32b8422d90ce86b0baad5a3f9dfbd942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BC=8A=E6=AC=A7?= Date: Wed, 30 Oct 2024 21:20:45 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B1=20Design=20some=20prototype=20for?= =?UTF-8?q?=20theme.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/theme/src/context.rs | 54 +++++++++---------- .../theme/src/prelude/element/designs/mod.rs | 3 -- .../prelude/element/{designs => }/layout.rs | 0 packages/theme/src/prelude/element/mod.rs | 6 ++- .../element/{designs/color.rs => palette.rs} | 4 +- .../element/{designs/font.rs => skin.rs} | 0 .../theme/src/prelude/element/transition.rs | 0 .../theme/src/prelude/element/typography.rs | 0 .../theme/src/types/{size.rs => layout.rs} | 0 packages/theme/src/types/mod.rs | 14 +++-- .../theme/src/types/{color.rs => palette.rs} | 2 +- packages/theme/src/types/skin.rs | 0 packages/theme/src/types/transition.rs | 0 packages/theme/src/types/typography.rs | 0 14 files changed, 45 insertions(+), 38 deletions(-) delete mode 100644 packages/theme/src/prelude/element/designs/mod.rs rename packages/theme/src/prelude/element/{designs => }/layout.rs (100%) rename packages/theme/src/prelude/element/{designs/color.rs => palette.rs} (76%) rename packages/theme/src/prelude/element/{designs/font.rs => skin.rs} (100%) create mode 100644 packages/theme/src/prelude/element/transition.rs create mode 100644 packages/theme/src/prelude/element/typography.rs rename packages/theme/src/types/{size.rs => layout.rs} (100%) rename packages/theme/src/types/{color.rs => palette.rs} (99%) create mode 100644 packages/theme/src/types/skin.rs create mode 100644 packages/theme/src/types/transition.rs create mode 100644 packages/theme/src/types/typography.rs diff --git a/packages/theme/src/context.rs b/packages/theme/src/context.rs index bdacb0a..d901010 100644 --- a/packages/theme/src/context.rs +++ b/packages/theme/src/context.rs @@ -3,11 +3,11 @@ use yuuka::derive_struct; use yew::prelude::*; use crate::{ - prelude::element::designs::color::COLOR_MAP, - types::{ColorLevel, ColorMap}, + prelude::element::palette::COLOR_MAP, + types::{ColorLevel, Palette}, }; -derive_struct!(pub Theme { color: ColorMap = COLOR_MAP.clone() }); +derive_struct!(pub Theme { palette: Palette = COLOR_MAP.clone() }); #[derive(Properties, Debug, PartialEq)] pub struct ThemeContextProviderProps { @@ -78,30 +78,30 @@ pub fn ThemeContextShell(props: &ThemeContextProviderProps) -> Html { body {{ font-family: 'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei', sans-serif; }}"#, - props.context.color.primary.to_rgb_str(), - props.context.color.secondary.to_rgb_str(), - props.context.color.success.to_rgb_str(), - props.context.color.warning.to_rgb_str(), - props.context.color.error.to_rgb_str(), - props.context.color.info.to_rgb_str(), - props.context.color.primary.to_rgba_str(ColorLevel::Most), - props.context.color.secondary.to_rgba_str(ColorLevel::Most), - props.context.color.success.to_rgba_str(ColorLevel::Most), - props.context.color.warning.to_rgba_str(ColorLevel::Most), - props.context.color.error.to_rgba_str(ColorLevel::Most), - props.context.color.info.to_rgba_str(ColorLevel::Most), - props.context.color.primary.to_rgba_str(ColorLevel::Half), - props.context.color.secondary.to_rgba_str(ColorLevel::Half), - props.context.color.success.to_rgba_str(ColorLevel::Half), - props.context.color.warning.to_rgba_str(ColorLevel::Half), - props.context.color.error.to_rgba_str(ColorLevel::Half), - props.context.color.info.to_rgba_str(ColorLevel::Half), - props.context.color.primary.to_rgba_str(ColorLevel::Less), - props.context.color.secondary.to_rgba_str(ColorLevel::Less), - props.context.color.success.to_rgba_str(ColorLevel::Less), - props.context.color.warning.to_rgba_str(ColorLevel::Less), - props.context.color.error.to_rgba_str(ColorLevel::Less), - props.context.color.info.to_rgba_str(ColorLevel::Less) + props.context.palette.primary.to_rgb_str(), + props.context.palette.secondary.to_rgb_str(), + props.context.palette.success.to_rgb_str(), + props.context.palette.warning.to_rgb_str(), + props.context.palette.error.to_rgb_str(), + props.context.palette.info.to_rgb_str(), + props.context.palette.primary.to_rgba_str(ColorLevel::Most), + props.context.palette.secondary.to_rgba_str(ColorLevel::Most), + props.context.palette.success.to_rgba_str(ColorLevel::Most), + props.context.palette.warning.to_rgba_str(ColorLevel::Most), + props.context.palette.error.to_rgba_str(ColorLevel::Most), + props.context.palette.info.to_rgba_str(ColorLevel::Most), + props.context.palette.primary.to_rgba_str(ColorLevel::Half), + props.context.palette.secondary.to_rgba_str(ColorLevel::Half), + props.context.palette.success.to_rgba_str(ColorLevel::Half), + props.context.palette.warning.to_rgba_str(ColorLevel::Half), + props.context.palette.error.to_rgba_str(ColorLevel::Half), + props.context.palette.info.to_rgba_str(ColorLevel::Half), + props.context.palette.primary.to_rgba_str(ColorLevel::Less), + props.context.palette.secondary.to_rgba_str(ColorLevel::Less), + props.context.palette.success.to_rgba_str(ColorLevel::Less), + props.context.palette.warning.to_rgba_str(ColorLevel::Less), + props.context.palette.error.to_rgba_str(ColorLevel::Less), + props.context.palette.info.to_rgba_str(ColorLevel::Less) )} diff --git a/packages/theme/src/prelude/element/designs/mod.rs b/packages/theme/src/prelude/element/designs/mod.rs deleted file mode 100644 index ec9ee6d..0000000 --- a/packages/theme/src/prelude/element/designs/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod color; -pub mod font; -pub mod layout; diff --git a/packages/theme/src/prelude/element/designs/layout.rs b/packages/theme/src/prelude/element/layout.rs similarity index 100% rename from packages/theme/src/prelude/element/designs/layout.rs rename to packages/theme/src/prelude/element/layout.rs diff --git a/packages/theme/src/prelude/element/mod.rs b/packages/theme/src/prelude/element/mod.rs index 45c41fb..7c7066e 100644 --- a/packages/theme/src/prelude/element/mod.rs +++ b/packages/theme/src/prelude/element/mod.rs @@ -1,3 +1,7 @@ -pub mod designs; +pub mod layout; +pub mod palette; +pub mod skin; +pub mod transition; +pub mod typography; // https://element-plus.org/ diff --git a/packages/theme/src/prelude/element/designs/color.rs b/packages/theme/src/prelude/element/palette.rs similarity index 76% rename from packages/theme/src/prelude/element/designs/color.rs rename to packages/theme/src/prelude/element/palette.rs index 3dca7e2..f99daa1 100644 --- a/packages/theme/src/prelude/element/designs/color.rs +++ b/packages/theme/src/prelude/element/palette.rs @@ -1,8 +1,8 @@ use once_cell::sync::Lazy; -use crate::types::{Color, ColorMap}; +use crate::types::{Color, Palette}; -pub static COLOR_MAP: Lazy = Lazy::new(|| ColorMap { +pub static COLOR_MAP: Lazy = Lazy::new(|| Palette { primary: Color::from_rgb_str_hex("#409EFF"), secondary: Color::from_rgb_str_hex("#79bbff"), success: Color::from_rgb_str_hex("#67C23A"), diff --git a/packages/theme/src/prelude/element/designs/font.rs b/packages/theme/src/prelude/element/skin.rs similarity index 100% rename from packages/theme/src/prelude/element/designs/font.rs rename to packages/theme/src/prelude/element/skin.rs diff --git a/packages/theme/src/prelude/element/transition.rs b/packages/theme/src/prelude/element/transition.rs new file mode 100644 index 0000000..e69de29 diff --git a/packages/theme/src/prelude/element/typography.rs b/packages/theme/src/prelude/element/typography.rs new file mode 100644 index 0000000..e69de29 diff --git a/packages/theme/src/types/size.rs b/packages/theme/src/types/layout.rs similarity index 100% rename from packages/theme/src/types/size.rs rename to packages/theme/src/types/layout.rs diff --git a/packages/theme/src/types/mod.rs b/packages/theme/src/types/mod.rs index dbb42b9..610f84f 100644 --- a/packages/theme/src/types/mod.rs +++ b/packages/theme/src/types/mod.rs @@ -1,5 +1,11 @@ -mod color; -mod size; +mod layout; +mod palette; +mod skin; +mod transition; +mod typography; -pub use color::*; -pub use size::*; +pub use layout::*; +pub use palette::*; +pub use skin::*; +pub use transition::*; +pub use typography::*; diff --git a/packages/theme/src/types/color.rs b/packages/theme/src/types/palette.rs similarity index 99% rename from packages/theme/src/types/color.rs rename to packages/theme/src/types/palette.rs index dd93a68..707bdfb 100644 --- a/packages/theme/src/types/color.rs +++ b/packages/theme/src/types/palette.rs @@ -32,7 +32,7 @@ impl Into for ColorLevel { } #[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] -pub struct ColorMap { +pub struct Palette { pub primary: Color, pub secondary: Color, pub success: Color, diff --git a/packages/theme/src/types/skin.rs b/packages/theme/src/types/skin.rs new file mode 100644 index 0000000..e69de29 diff --git a/packages/theme/src/types/transition.rs b/packages/theme/src/types/transition.rs new file mode 100644 index 0000000..e69de29 diff --git a/packages/theme/src/types/typography.rs b/packages/theme/src/types/typography.rs new file mode 100644 index 0000000..e69de29