mirror of
https://github.com/adoyle0/thaw.git
synced 2025-01-23 06:19:22 -05:00
fix: Icon attr
This commit is contained in:
parent
f33c012364
commit
8b122d0986
13 changed files with 36 additions and 39 deletions
|
@ -24,9 +24,7 @@ pub fn Demo(demo_code: DemoCode, #[prop(optional)] children: Option<Children>) -
|
||||||
} else {
|
} else {
|
||||||
css_vars.push_str("--demo-color: #00000060;");
|
css_vars.push_str("--demo-color: #00000060;");
|
||||||
css_vars.push_str("--demo-color-hover: #000000e0;");
|
css_vars.push_str("--demo-color-hover: #000000e0;");
|
||||||
css_vars.push_str(&format!(
|
css_vars.push_str(&format!("--demo-border-color: var(--colorNeutralStroke2);",));
|
||||||
"--demo-border-color: var(--colorNeutralStroke2);",
|
|
||||||
));
|
|
||||||
css_vars.push_str("--demo-background-color: #f9fafb;");
|
css_vars.push_str("--demo-background-color: #f9fafb;");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::AccordionInjection;
|
use crate::AccordionInjection;
|
||||||
use leptos::{prelude::*, html};
|
use leptos::{html, prelude::*};
|
||||||
use thaw_components::CSSTransition;
|
use thaw_components::CSSTransition;
|
||||||
use thaw_utils::{mount_style, update, with, StoredMaybeSignal};
|
use thaw_utils::{mount_style, update, with, StoredMaybeSignal};
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ pub fn Icon(
|
||||||
let svg = view! {
|
let svg = view! {
|
||||||
<svg
|
<svg
|
||||||
class=class_list!["thaw-icon", class.map(|c| move || c.get())]
|
class=class_list!["thaw-icon", class.map(|c| move || c.get())]
|
||||||
style=move || take_signal(icon_style)
|
style=move || take_signal(icon_style).unwrap_or_default()
|
||||||
x=move || take(icon_x)
|
x=move || take(icon_x)
|
||||||
y=move || take(icon_y)
|
y=move || take(icon_y)
|
||||||
width=move || take_signal(icon_width)
|
width=move || take_signal(icon_width)
|
||||||
|
@ -102,18 +102,15 @@ pub fn Icon(
|
||||||
svg.inner_html(move || take(icon_data))
|
svg.inner_html(move || take(icon_data))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn take_signal(signal: RwSignal<Option<MaybeSignal<String>>>) -> String {
|
fn take_signal(signal: RwSignal<Option<MaybeSignal<String>>>) -> Option<String> {
|
||||||
signal.with(|s| match s {
|
signal.with(|s| match s {
|
||||||
Some(MaybeSignal::Static(value)) => value.clone(),
|
Some(MaybeSignal::Static(value)) => Some(value.clone()),
|
||||||
Some(MaybeSignal::Dynamic(signal)) => signal.get(),
|
Some(MaybeSignal::Dynamic(signal)) => Some(signal.get()),
|
||||||
_ => String::new(),
|
_ => None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn take(signal: RwSignal<Option<String>>) -> String {
|
fn take(signal: RwSignal<Option<String>>) -> Option<String> {
|
||||||
signal.track();
|
signal.track();
|
||||||
signal
|
signal.try_update_untracked(|value| value.take()).flatten()
|
||||||
.try_update_untracked(|value| value.take())
|
|
||||||
.flatten()
|
|
||||||
.unwrap_or_default()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,8 +107,8 @@ impl SpaceJustify {
|
||||||
mod test {
|
mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn main() {
|
fn main() {
|
||||||
use leptos::prelude::*;
|
|
||||||
use super::Space;
|
use super::Space;
|
||||||
|
use leptos::prelude::*;
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<Space>
|
<Space>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
// use cfg_if::cfg_if;
|
||||||
use cfg_if::cfg_if;
|
|
||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
|
|
||||||
/// https://github.com/solidjs/solid/blob/main/packages/solid/web/src/index.ts#L56
|
/// https://github.com/solidjs/solid/blob/main/packages/solid/web/src/index.ts#L56
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
use leptos::{
|
use leptos::{
|
||||||
logging::debug_warn,
|
logging::debug_warn,
|
||||||
reactive_graph::{
|
reactive_graph::{
|
||||||
effect::RenderEffect,
|
|
||||||
signal::RwSignal,
|
signal::RwSignal,
|
||||||
traits::{Get, GetUntracked, Update},
|
traits::{Get, GetUntracked, Update},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use std::cell::Cell;
|
|
||||||
|
|
||||||
pub struct ComponentRef<T: 'static>(RwSignal<Option<T>>);
|
pub struct ComponentRef<T: 'static>(RwSignal<Option<T>>);
|
||||||
|
|
||||||
|
@ -58,17 +56,17 @@ impl<T> ComponentRef<T> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_load<F>(self, f: F)
|
// pub fn on_load<F>(self, f: F)
|
||||||
where
|
// where
|
||||||
T: Clone,
|
// T: Clone,
|
||||||
F: FnOnce(T) + 'static,
|
// F: FnOnce(T) + 'static,
|
||||||
{
|
// {
|
||||||
let f = Cell::new(Some(f));
|
// let f = Cell::new(Some(f));
|
||||||
|
|
||||||
RenderEffect::new(move |_| {
|
// RenderEffect::new(move |_| {
|
||||||
if let Some(comp) = self.get() {
|
// if let Some(comp) = self.get() {
|
||||||
f.take().unwrap()(comp);
|
// f.take().unwrap()(comp);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
use leptos::reactive_graph::{effect::Effect, signal::RwSignal, traits::{Dispose, With}, untrack};
|
use leptos::reactive_graph::{
|
||||||
|
effect::Effect,
|
||||||
|
signal::RwSignal,
|
||||||
|
traits::{Dispose, With},
|
||||||
|
untrack,
|
||||||
|
};
|
||||||
|
|
||||||
pub trait SignalWatch {
|
pub trait SignalWatch {
|
||||||
type Value;
|
type Value;
|
||||||
|
|
Loading…
Add table
Reference in a new issue