#![allow(non_snake_case)]
#![allow(deprecated)]
#[cfg(feature = "demo-islands")]
use krab_core::signal::*;
#[cfg(feature = "demo-islands")]
use krab_core::{IntoNode, Node};
#[cfg(feature = "demo-islands")]
use krab_macros::{island, view};
#[cfg(feature = "demo-islands")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "demo-islands")]
#[derive(Serialize, Deserialize, Clone)]
#[deprecated(
since = "0.4.0",
note = "demo island, removed in 0.6.0: `Counter` is `inventory::submit`ed into every consumer's binary, so defining your own `Counter` island puts two entries under one name in the registry and `hydrate()`'s `find()` resolves them by link order. Define the island in your own crate with `#[island]`, or disable the `demo-islands` feature."
)]
pub struct CounterProps {
pub initial: i32,
}
#[cfg(feature = "demo-islands")]
#[island]
#[allow(non_snake_case)]
pub fn Counter(props: CounterProps) -> Node {
let (count, _set_count) = create_signal(props.initial);
view! {
<button on:click={ move |_| _set_count.update(|c| *c += 1) }>
"Count: " <span>{ move || count.get().into_node() }</span>
</button>
}
}
#[cfg(feature = "demo-islands")]
#[derive(Serialize, Deserialize, Clone)]
#[deprecated(
since = "0.4.0",
note = "demo island, removed in 0.6.0: `Toggle` is `inventory::submit`ed into every consumer's binary, so defining your own `Toggle` island puts two entries under one name in the registry and `hydrate()`'s `find()` resolves them by link order. Define the island in your own crate with `#[island]`, or disable the `demo-islands` feature."
)]
pub struct ToggleProps {
pub initial: bool,
}
#[cfg(feature = "demo-islands")]
#[island]
#[allow(non_snake_case)]
pub fn Toggle(props: ToggleProps) -> Node {
let (on, _set_on) = create_signal(props.initial);
view! {
<div>
<button on:click={ move |_| _set_on.update(|v| *v = !*v) }>
"Toggle"
</button>
<span>{ move || if on.get() { " ON" } else { " OFF" }.into_node() }</span>
</div>
}
}
#[cfg(feature = "demo-islands")]
#[derive(Serialize, Deserialize, Clone)]
#[deprecated(
since = "0.4.0",
note = "demo island, removed in 0.6.0: `Likes` is `inventory::submit`ed into every consumer's binary, so defining your own `Likes` island puts two entries under one name in the registry and `hydrate()`'s `find()` resolves them by link order. Define the island in your own crate with `#[island]`, or disable the `demo-islands` feature."
)]
pub struct LikesProps {
pub initial: i32,
}
#[cfg(feature = "demo-islands")]
#[island]
#[allow(non_snake_case)]
pub fn Likes(props: LikesProps) -> Node {
let (likes, _set_likes) = create_signal(props.initial);
view! {
<div>
<button on:click={ move |_| _set_likes.update(|v| *v += 1) }>
"Like"
</button>
<span>{ move || likes.get().into_node() }</span>
</div>
}
}