diff --git a/demo/src/assets/css/index.css b/demo/src/assets/css/index.css index c59be3e..0e03a75 100644 --- a/demo/src/assets/css/index.css +++ b/demo/src/assets/css/index.css @@ -1,9 +1,5 @@ body { margin: 0; - font-family: Inter, ui-sans-serif, system-ui, -apple-system, - BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, - sans-serif, "Apple Color Emoji", "Segoe UI Emoji", Segoe UI Symbol, - "Noto Color Emoji"; } .components-page-box { @@ -17,3 +13,7 @@ body { .components-page-box main { flex: 1; } + +.token.operator { + background: hsla(0, 0%, 100%, 0) !important; +} diff --git a/demo/src/assets/svg/grid_dot.svg b/demo/src/assets/svg/grid_dot.svg index 30c7ffe..bc909a3 100644 --- a/demo/src/assets/svg/grid_dot.svg +++ b/demo/src/assets/svg/grid_dot.svg @@ -1,4 +1,4 @@ - - - + + + \ No newline at end of file diff --git a/demo/src/components/demo.rs b/demo/src/components/demo.rs index ee4d18a..88fd860 100644 --- a/demo/src/components/demo.rs +++ b/demo/src/components/demo.rs @@ -1,5 +1,5 @@ use leptos::*; -use melt_ui::{mount_style, Code}; +use melt_ui::*; #[slot] pub struct DemoCode { @@ -11,11 +11,39 @@ pub struct DemoCode { #[component] pub fn Demo(demo_code: DemoCode, children: Children) -> impl IntoView { mount_style("demo", prisms::prism_css!()); + let theme = use_theme(Theme::light); + let style = create_memo(move |_| { + let mut style = String::from("background-image: url(/melt-ui/grid_dot.svg); background-repeat: repeat; background-size: 1.5rem; margin-top: 1rem; padding: 1rem; border-top-left-radius: 0.5rem; border-top-right-radius: 0.5rem;"); + theme.with(|theme| { + if theme.common.color_scheme == "dark" { + style.push_str("border: 1px solid #383f52;"); + } else { + style.push_str(&format!("border: 1px solid {};", theme.common.border_color)); + } + }); + style + }); + let code_style = create_memo(move |_| { + let mut style = String::from("font-weight: 400; font-size: 0.875em; line-height: 1.7142857;margin-bottom: 1rem; padding: 1rem; border-bottom-left-radius: 0.5rem; border-bottom-right-radius: 0.5rem;"); + theme.with(|theme| { + if theme.common.color_scheme == "dark" { + style.push_str("border: 1px solid #383f52; border-top-width: 0;"); + style.push_str("background-color: #242832;"); + } else { + style.push_str(&format!( + "border: 1px solid {}; border-top-width: 0;", + theme.common.border_color + )); + style.push_str("background-color: #f9fafb;"); + } + }); + style + }); view! { -
+
{children()}
-
+
                     {(demo_code.children)()}
diff --git a/demo/src/components/site_header.rs b/demo/src/components/site_header.rs
index 10eb76a..a7109f5 100644
--- a/demo/src/components/site_header.rs
+++ b/demo/src/components/site_header.rs
@@ -13,8 +13,13 @@ pub fn SiteHeader() -> impl IntoView {
             theme.set(Theme::dark())
         }
     };
+    let style = create_memo(move |_| {
+        theme.with(|theme| {
+            format!("height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid {}", theme.common.border_color)
+        })
+    });
     view! {
-        
+        
              impl IntoView {
                 _ = body
                     .style()
                     .set_property("font-size", &theme.common.font_size);
+                _ = body
+                    .style()
+                    .set_property("color-scheme", &theme.common.color_scheme);
             }
         });
     });
diff --git a/src/theme/common.rs b/src/theme/common.rs
index a2a21c3..b9df919 100644
--- a/src/theme/common.rs
+++ b/src/theme/common.rs
@@ -5,6 +5,8 @@ pub struct CommonTheme {
     pub font_family: String,
     pub font_color: String,
     pub background_color: String,
+    pub border_color: String,
+    pub color_scheme: String,
 
     pub color_primary: String,
     pub color_primary_hover: String,
@@ -43,6 +45,8 @@ impl CommonTheme {
             font_family: r#"Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", Segoe UI Symbol, "Noto Color Emoji""#.into(),
             font_color: "".into(),
             background_color: "".into(),
+            border_color: "".into(),
+            color_scheme: "".into(),
             color_primary: "".into(),
             color_primary_hover: "".into(),
             color_primary_active: "".into(),
@@ -78,6 +82,7 @@ impl ThemeMethod for CommonTheme {
         Self {
             font_color: "#11181c".into(),
             background_color: "#fff".into(),
+            color_scheme: "light".into(),
             color_primary: "#f5222d".into(),
             color_primary_hover: "#ff4d4f".into(),
             color_primary_active: "#cf1322".into(),
@@ -90,6 +95,7 @@ impl ThemeMethod for CommonTheme {
             color_error: "#d03050".into(),
             color_error_hover: "#de576d".into(),
             color_error_active: "#ab1f3f".into(),
+            border_color: "#e5e8eb".into(),
             ..CommonTheme::common()
         }
     }
@@ -97,11 +103,14 @@ impl ThemeMethod for CommonTheme {
         Self {
             font_color: "#ecedee".into(),
             background_color: "#1a1d1e".into(),
+            color_scheme: "dark".into(),
             color_primary: "#d32029".into(),
             color_primary_hover: "#e04648".into(),
             color_primary_active: "#ad111e".into(),
-            color_success: "#63e2b7".into(),
-            color_success_hover: "#7fe7c4".into(),
+            // color_success: "#63e2b7".into(),
+            // color_success_hover: "#7fe7c4".into(),
+            color_success: "#18a058".into(),
+            color_success_hover: "#36ad6a".into(),
             color_success_active: "#5acea7".into(),
             color_warning: "#f0a020".into(),
             color_warning_hover: "#fcb040".into(),
@@ -109,6 +118,7 @@ impl ThemeMethod for CommonTheme {
             color_error: "#d03050".into(),
             color_error_hover: "#de576d".into(),
             color_error_active: "#e57272".into(),
+            border_color: "#1f2537".into(),
             ..CommonTheme::common()
         }
     }