Skip to content

Commit

Permalink
🧱 Design some prototype for theme.
Browse files Browse the repository at this point in the history
  • Loading branch information
langyo committed Oct 30, 2024
1 parent c50c05b commit 4e7462c
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 38 deletions.
54 changes: 27 additions & 27 deletions packages/theme/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
)}
</style>

Expand Down
3 changes: 0 additions & 3 deletions packages/theme/src/prelude/element/designs/mod.rs

This file was deleted.

6 changes: 5 additions & 1 deletion packages/theme/src/prelude/element/mod.rs
Original file line number Diff line number Diff line change
@@ -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/
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use once_cell::sync::Lazy;

use crate::types::{Color, ColorMap};
use crate::types::{Color, Palette};

pub static COLOR_MAP: Lazy<ColorMap> = Lazy::new(|| ColorMap {
pub static COLOR_MAP: Lazy<Palette> = Lazy::new(|| Palette {
primary: Color::from_rgb_str_hex("#409EFF"),
secondary: Color::from_rgb_str_hex("#79bbff"),
success: Color::from_rgb_str_hex("#67C23A"),
Expand Down
Empty file.
Empty file.
File renamed without changes.
14 changes: 10 additions & 4 deletions packages/theme/src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Into<f64> for ColorLevel {
}

#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub struct ColorMap {
pub struct Palette {
pub primary: Color,
pub secondary: Color,
pub success: Color,
Expand Down
Empty file.
Empty file.
Empty file.

0 comments on commit 4e7462c

Please sign in to comment.