Skip to content

Commit

Permalink
Update leptos requirement from 0.4.3 to 0.5.1 (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Oct 25, 2023
1 parent dcc03e8 commit 98398c9
Show file tree
Hide file tree
Showing 20 changed files with 89 additions and 98 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ derive_more = "0.99.17"
getrandom = { version = "0.2.8", features = ["js"] }
gloo-events = "0.2.0"
gloo-utils = "0.2.0"
leptos = { version = "0.4.3", features = ["csr"] }
leptos-use = "0.6.0"
leptos = { version = "0.5.1", features = ["csr"] }
leptos-use = "0.8.0"
rand = { version = "0.8.5", default-features = false, features = ["getrandom"] }
yew = { version = "0.20.0", features = ["csr"] }
yew = { version = "0.21.0", features = ["csr"] }
wasm-bindgen = "0.2.84"

[dependencies.web-sys]
Expand Down
2 changes: 1 addition & 1 deletion examples/logo-ng.svg-rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
view! { cx, <g stroke-width=".265"><path d="M9.822 58.779q-3.129 0-4.511-2.183Q4 54.486 4 51.283q0-3.493 1.31-8.296t3.42-10.115q2.183-5.312 4.73-10.334 2.547-5.094 5.094-9.242t4.657-6.623Q25.396 4.2 26.632 4.2q.801 0 1.31.946.51.873.801 2.183.291 1.237.291 2.256 0 1.965-1.018 5.167-.947 3.13-2.766 7.06-1.746 3.856-4.22 7.859-2.402 3.93-5.313 7.568-2.838 3.639-6.04 6.258-.437 1.965-.728 3.857-.218 1.82-.218 3.493 0 2.838.8 4.221t2.402 1.383q1.965 0 3.856-1.747 1.965-1.746 3.64-4.366 1.746-2.693 2.983-5.53l1.091.581q-2.91 6.186-6.331 9.825-3.42 3.566-7.35 3.566zm.51-17.757q2.547-2.547 4.948-5.822 2.402-3.347 4.44-6.913 2.11-3.566 3.71-6.914t2.475-5.967q.873-2.693.873-4.148 0-.728-.218-.946-.145-.219-.291-.219-.582 0-2.038 1.893-1.382 1.819-3.274 4.948T17.1 24.066t-3.784 8.369q-1.747 4.366-2.984 8.587z"/><path d="M28.816 59.799q-4.439 0-6.695-2.475-2.183-2.401-2.183-5.967 0-3.275 1.6-6.914 1.674-3.638 4.367-6.84 2.765-3.202 6.04-5.167 3.275-2.038 6.477-2.038 1.674 0 3.056.873 1.456.874 1.456 3.566 0 2.766-1.674 5.24-1.6 2.401-4.294 4.293-2.62 1.892-5.821 3.13-3.13 1.164-6.259 1.455-.145.728-.218 1.383t-.073 1.237q0 1.091.218 2.183.291 1.092.946 2.038.655.873 1.747 1.382 1.164.51 2.838.51 3.13 0 6.186-1.747 3.056-1.82 5.676-4.73t4.439-6.404l.873.655q-1.965 4.366-5.021 7.568-2.984 3.202-6.55 4.949-3.493 1.82-7.131 1.82zM25.25 47.573q1.965-.655 4.44-1.892 2.473-1.31 4.73-3.057 2.328-1.746 3.783-3.856 1.529-2.11 1.529-4.44 0-.8-.292-1.237t-1.237-.436q-1.746 0-3.711 1.382-1.965 1.31-3.784 3.494t-3.275 4.803-2.183 5.24z"/><path d="M57.776 58.488q-2.474 0-3.93-1.31-1.382-1.31-1.382-3.42 0-2.183 1.019-4.585t1.964-4.73q1.02-2.401 1.02-4.293 0-2.329-1.383-3.42-1.31-1.165-2.693-2.11-1.674 4.293-3.493 8.15t-2.984 5.821l-.655-1.237q1.02-1.892 2.62-5.53 1.674-3.639 3.275-8.297-.728-.727-.728-1.746 0-2.183 1.237-3.566t1.82-1.383q.8 0 .873.728.145.655.145 1.019t-.436 1.455q-.364 1.02-.364 1.238 0 1.018 1.092 1.892 1.164.8 2.62 1.892 1.455 1.019 2.546 2.547 1.165 1.455 1.165 3.784 0 2.183-.946 4.439-.874 2.256-1.82 4.294-.873 2.037-.873 3.566 0 1.31.655 1.746t1.528.437q1.747 0 3.566-1.092 1.892-1.091 3.639-2.765t3.129-3.493q1.383-1.892 2.038-3.493l.946.727q-1.383 3.057-3.784 6.04-2.402 2.912-5.386 4.804-2.91 1.892-6.04 1.892z"/><path d="M94.017 58.05q-2.547 0-3.856-1.31-1.237-1.31-1.237-3.348 0-1.529.509-3.202.582-1.674 1.092-3.42.509-1.82.509-3.494 0-2.037-.873-2.765-.8-.8-2.038-.8-2.256 0-4.585 1.891-2.329 1.82-4.512 4.73-2.183 2.839-4.075 5.895t-3.348 5.458q-1.164 0-2.183-.437-1.091-.363-1.674-1.164 0-.364.801-2.256.728-1.892 1.747-4.657t1.819-5.677.8-5.312q.437-.51 1.383-1.019t1.965-.51q1.965 0 1.965 1.893 0 1.164-.655 3.93-.655 2.692-1.674 5.676 1.965-2.984 4.366-5.894 2.475-2.984 5.24-4.949t5.53-1.965q2.839 0 4.076 2.038 1.31 2.037 1.31 4.512 0 2.256-.728 4.22-.727 1.893-1.528 3.712-.728 1.747-.728 3.566 0 1.528.582 2.183.655.582 1.601.582 1.82 0 3.64-1.674 1.818-1.746 3.492-4.366 1.747-2.62 3.057-5.312l.8.946q-1.528 3.566-3.42 6.331t-4.148 4.367-5.021 1.6z"/><path fill="red" d="M52.177 50.828q-.305 0-.552-.152-.23-.153-.23-.477 0-.4.458-.685.476-.305.934-.305.285 0 .457.133t.171.457q0 .362-.4.705-.38.324-.838.324z" style="-inkscape-stroke:none;font-variation-settings:normal" transform="translate(-80.924 -169.01) scale(3.8201)"/><path d="M109.665 58.488q-2.839 0-4.221-1.819-1.383-1.746-1.383-4.294 0-1.673.582-4.22.655-2.548 1.674-5.313 1.019-2.838 2.329-5.312 1.382-2.474 2.91-4.003 1.529-1.6 2.984-1.6.655 0 1.092.436.51.364.51 1.164 0 .874-1.165 2.838-1.092 1.965-2.62 4.512t-2.692 5.386q-1.092 2.765-1.092 5.312 0 2.62.873 3.493t2.693.873q2.474 0 5.24-2.474 2.838-2.474 5.967-8.66l.655.727q-2.11 6.259-6.113 9.606-3.93 3.348-8.223 3.348z"/><path fill="red" d="M31.54 50.828q-.305 0-.552-.152-.23-.153-.23-.477 0-.4.458-.685.476-.305.934-.305.285 0 .457.133t.171.457q0 .362-.4.705-.38.324-.838.324z" transform="translate(-80.924 -169.01) scale(3.8201)"/></g> }
view! { <g stroke-width=".265"><path d="M9.822 58.779q-3.129 0-4.511-2.183Q4 54.486 4 51.283q0-3.493 1.31-8.296t3.42-10.115q2.183-5.312 4.73-10.334 2.547-5.094 5.094-9.242t4.657-6.623Q25.396 4.2 26.632 4.2q.801 0 1.31.946.51.873.801 2.183.291 1.237.291 2.256 0 1.965-1.018 5.167-.947 3.13-2.766 7.06-1.746 3.856-4.22 7.859-2.402 3.93-5.313 7.568-2.838 3.639-6.04 6.258-.437 1.965-.728 3.857-.218 1.82-.218 3.493 0 2.838.8 4.221t2.402 1.383q1.965 0 3.856-1.747 1.965-1.746 3.64-4.366 1.746-2.693 2.983-5.53l1.091.581q-2.91 6.186-6.331 9.825-3.42 3.566-7.35 3.566zm.51-17.757q2.547-2.547 4.948-5.822 2.402-3.347 4.44-6.913 2.11-3.566 3.71-6.914t2.475-5.967q.873-2.693.873-4.148 0-.728-.218-.946-.145-.219-.291-.219-.582 0-2.038 1.893-1.382 1.819-3.274 4.948T17.1 24.066t-3.784 8.369q-1.747 4.366-2.984 8.587z"/><path d="M28.816 59.799q-4.439 0-6.695-2.475-2.183-2.401-2.183-5.967 0-3.275 1.6-6.914 1.674-3.638 4.367-6.84 2.765-3.202 6.04-5.167 3.275-2.038 6.477-2.038 1.674 0 3.056.873 1.456.874 1.456 3.566 0 2.766-1.674 5.24-1.6 2.401-4.294 4.293-2.62 1.892-5.821 3.13-3.13 1.164-6.259 1.455-.145.728-.218 1.383t-.073 1.237q0 1.091.218 2.183.291 1.092.946 2.038.655.873 1.747 1.382 1.164.51 2.838.51 3.13 0 6.186-1.747 3.056-1.82 5.676-4.73t4.439-6.404l.873.655q-1.965 4.366-5.021 7.568-2.984 3.202-6.55 4.949-3.493 1.82-7.131 1.82zM25.25 47.573q1.965-.655 4.44-1.892 2.473-1.31 4.73-3.057 2.328-1.746 3.783-3.856 1.529-2.11 1.529-4.44 0-.8-.292-1.237t-1.237-.436q-1.746 0-3.711 1.382-1.965 1.31-3.784 3.494t-3.275 4.803-2.183 5.24z"/><path d="M57.776 58.488q-2.474 0-3.93-1.31-1.382-1.31-1.382-3.42 0-2.183 1.019-4.585t1.964-4.73q1.02-2.401 1.02-4.293 0-2.329-1.383-3.42-1.31-1.165-2.693-2.11-1.674 4.293-3.493 8.15t-2.984 5.821l-.655-1.237q1.02-1.892 2.62-5.53 1.674-3.639 3.275-8.297-.728-.727-.728-1.746 0-2.183 1.237-3.566t1.82-1.383q.8 0 .873.728.145.655.145 1.019t-.436 1.455q-.364 1.02-.364 1.238 0 1.018 1.092 1.892 1.164.8 2.62 1.892 1.455 1.019 2.546 2.547 1.165 1.455 1.165 3.784 0 2.183-.946 4.439-.874 2.256-1.82 4.294-.873 2.037-.873 3.566 0 1.31.655 1.746t1.528.437q1.747 0 3.566-1.092 1.892-1.091 3.639-2.765t3.129-3.493q1.383-1.892 2.038-3.493l.946.727q-1.383 3.057-3.784 6.04-2.402 2.912-5.386 4.804-2.91 1.892-6.04 1.892z"/><path d="M94.017 58.05q-2.547 0-3.856-1.31-1.237-1.31-1.237-3.348 0-1.529.509-3.202.582-1.674 1.092-3.42.509-1.82.509-3.494 0-2.037-.873-2.765-.8-.8-2.038-.8-2.256 0-4.585 1.891-2.329 1.82-4.512 4.73-2.183 2.839-4.075 5.895t-3.348 5.458q-1.164 0-2.183-.437-1.091-.363-1.674-1.164 0-.364.801-2.256.728-1.892 1.747-4.657t1.819-5.677.8-5.312q.437-.51 1.383-1.019t1.965-.51q1.965 0 1.965 1.893 0 1.164-.655 3.93-.655 2.692-1.674 5.676 1.965-2.984 4.366-5.894 2.475-2.984 5.24-4.949t5.53-1.965q2.839 0 4.076 2.038 1.31 2.037 1.31 4.512 0 2.256-.728 4.22-.727 1.893-1.528 3.712-.728 1.747-.728 3.566 0 1.528.582 2.183.655.582 1.601.582 1.82 0 3.64-1.674 1.818-1.746 3.492-4.366 1.747-2.62 3.057-5.312l.8.946q-1.528 3.566-3.42 6.331t-4.148 4.367-5.021 1.6z"/><path fill="red" d="M52.177 50.828q-.305 0-.552-.152-.23-.153-.23-.477 0-.4.458-.685.476-.305.934-.305.285 0 .457.133t.171.457q0 .362-.4.705-.38.324-.838.324z" style="-inkscape-stroke:none;font-variation-settings:normal" transform="translate(-80.924 -169.01) scale(3.8201)"/><path d="M109.665 58.488q-2.839 0-4.221-1.819-1.383-1.746-1.383-4.294 0-1.673.582-4.22.655-2.548 1.674-5.313 1.019-2.838 2.329-5.312 1.382-2.474 2.91-4.003 1.529-1.6 2.984-1.6.655 0 1.092.436.51.364.51 1.164 0 .874-1.165 2.838-1.092 1.965-2.62 4.512t-2.692 5.386q-1.092 2.765-1.092 5.312 0 2.62.873 3.493t2.693.873q2.474 0 5.24-2.474 2.838-2.474 5.967-8.66l.655.727q-2.11 6.259-6.113 9.606-3.93 3.348-8.223 3.348z"/><path fill="red" d="M31.54 50.828q-.305 0-.552-.152-.23-.153-.23-.477 0-.4.458-.685.476-.305.934-.305.285 0 .457.133t.171.457q0 .362-.4.705-.38.324-.838.324z" transform="translate(-80.924 -169.01) scale(3.8201)"/></g> }
6 changes: 3 additions & 3 deletions examples/ng_blur.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use leptos::*;
use lerni::ng::*;

#[component]
pub fn Blur(cx: Scope) -> impl IntoView {
let (blur, set_blur) = create_signal(cx, false);
pub fn Blur() -> impl IntoView {
let (blur, set_blur) = create_signal(false);
let on_click = move |_| set_blur.set(!blur.get());

view! { cx,
view! {
<Slide blur=blur.into() background_color=Color::MistyRose>
<Button on_click=on_click>
"Blur " {move || if blur.get() { "ON" } else { "OFF" }}
Expand Down
8 changes: 4 additions & 4 deletions examples/ng_buttons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use leptos::*;
use lerni::ng::*;

#[component]
pub fn Buttons(cx: Scope) -> impl IntoView {
let (counter, set_counter) = create_signal(cx, 0);
pub fn Buttons() -> impl IntoView {
let (counter, set_counter) = create_signal(0);
let on_click = move |_| {
log!("Clicked");
logging::log!("Clicked");
set_counter.set(counter.get() + 1);
};

view! { cx,
view! {
<Slide>
<Grid cols=3 rows=3>
<Button on_click=on_click>"Alice"</Button>
Expand Down
8 changes: 4 additions & 4 deletions examples/ng_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use leptos::*;
use lerni::ng::*;

#[component]
pub fn GridExample(cx: Scope) -> impl IntoView {
view! { cx,
pub fn GridExample() -> impl IntoView {
view! {
<Slide>
<Grid cols=3 rows=3 border_width=4 padding=20>
<Label>
Expand All @@ -19,7 +19,7 @@ pub fn GridExample(cx: Scope) -> impl IntoView {
<Button
align=Align::Fill
valign=VAlign::Fill
on_click=move |_| log!("5: Clicked")
on_click=move |_| logging::log!("5: Clicked")
>
"5"
</Button>
Expand All @@ -33,7 +33,7 @@ pub fn GridExample(cx: Scope) -> impl IntoView {
<Button
align=Align::Fill
valign=VAlign::Fill
on_click=move |_| log!("12: Clicked")
on_click=move |_| logging::log!("12: Clicked")
>
"12"
</Button>
Expand Down
4 changes: 2 additions & 2 deletions examples/ng_hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use leptos::*;
use lerni::ng::*;

#[component]
pub fn HelloWorld(cx: Scope) -> impl IntoView {
view! { cx,
pub fn HelloWorld() -> impl IntoView {
view! {
<SlideShow>
<Slide background_color=Color::MistyRose>
<Label>"Hello →"</Label>
Expand Down
6 changes: 3 additions & 3 deletions examples/ng_pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use leptos::*;
use lerni::ng::*;

#[component]
pub fn Pointer(cx: Scope) -> impl IntoView {
let (pointer, set_pointer) = create_signal(cx, true);
pub fn Pointer() -> impl IntoView {
let (pointer, set_pointer) = create_signal(true);
let on_click = move |_| set_pointer.set(!pointer.get());

view! { cx,
view! {
<Slide pointer=pointer.into()>
<Button on_click=on_click>
"Pointer " {move || if pointer.get() { "ON" } else { "OFF" }}
Expand Down
4 changes: 2 additions & 2 deletions examples/ng_rows_cols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use leptos::*;
use lerni::ng::*;

#[component]
pub fn RowsCols(cx: Scope) -> impl IntoView {
view! { cx,
pub fn RowsCols() -> impl IntoView {
view! {
<Slide>
<Row border_width=4 stretch=vec![1, 1, 4, 1, 1] padding=20>
<Label>"1"</Label>
Expand Down
4 changes: 2 additions & 2 deletions examples/ng_svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use leptos::*;
use lerni::ng::*;

#[component]
pub fn SvgExample(cx: Scope) -> impl IntoView {
view! { cx,
pub fn SvgExample() -> impl IntoView {
view! {
<Slide background_image="/img/lerni-bg.svg".into()>
<Grid cols=3 rows=3 border_width=4 padding=20>
<Svg width=128 height=64>{include!("logo-ng.svg-rs")}</Svg>
Expand Down
2 changes: 1 addition & 1 deletion src/ng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn calc_width(margin: i32) -> i32 {
/// The main entry point.
pub fn start<F, N>(f: F)
where
F: FnOnce(Scope) -> N + 'static,
F: Fn() -> N + 'static,
N: IntoView,
{
leptos::mount_to_body(f);
Expand Down
11 changes: 5 additions & 6 deletions src/ng/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const HEIGHT: i32 = 150;

#[component]
pub fn Button<CB>(
cx: Scope,
on_click: CB,
#[prop(optional)] text_bold: bool,
#[prop(default = WIDTH)] width: i32,
Expand All @@ -27,7 +26,7 @@ pub fn Button<CB>(
where
CB: FnMut(MouseEvent) + 'static,
{
let f = use_frame(cx);
let f = use_frame();

let width = if align == Align::Fill { f.width } else { width };
let height = if valign == VAlign::Fill {
Expand All @@ -53,18 +52,18 @@ where
width,
height,
};
provide_frame(cx, frame);
provide_frame(frame);

let x = x + border_width / 2;
let y = y + border_width / 2;
let width = width - border_width;
let height = height - border_width;

let (border, set_border) = create_signal(cx, border_width);
let (border, set_border) = create_signal(border_width);
let on_mousedown = move |_| set_border.set(border_width + 6);
let on_mouseup = move |_| set_border.set(border_width);

view! { cx,
view! {
<rect
on:click=on_click
on:mousedown=on_mousedown
Expand All @@ -82,7 +81,7 @@ where
style="cursor: pointer;"
></rect>
<Label bold=text_bold color=text_color font=font font_size=font_size>
{children(cx)}
{children()}
</Label>
}
}
8 changes: 4 additions & 4 deletions src/ng/color.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use derive_more::Display;
use leptos::{Attribute, IntoAttribute, Scope};
use leptos::{Attribute, IntoAttribute};

// TODO: Define all colors

Expand Down Expand Up @@ -311,11 +311,11 @@ pub enum Color {
}

impl IntoAttribute for Color {
fn into_attribute(self, _: Scope) -> Attribute {
fn into_attribute(self) -> Attribute {
Attribute::String(self.to_string().into())
}

fn into_attribute_boxed(self: Box<Self>, cx: leptos::Scope) -> leptos::Attribute {
self.into_attribute(cx)
fn into_attribute_boxed(self: Box<Self>) -> leptos::Attribute {
self.into_attribute()
}
}
13 changes: 6 additions & 7 deletions src/ng/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::ng::{use_frame, use_frames, Color, Frame};
/// Column of widgets.
#[component]
pub fn Column(
cx: Scope,
#[prop(optional)] rows: Option<usize>,
#[prop(optional)] border_width: i32,
#[prop(default = Color::Black)] border_color: Color,
Expand All @@ -15,7 +14,7 @@ pub fn Column(
children: Children,
) -> impl IntoView {
if rows.is_none() && stretch.is_empty() {
warn!("Column: either `rows` or `stretch` must be specified");
logging::warn!("Column: either `rows` or `stretch` must be specified");
}

let stretch = if let Some(rows) = rows {
Expand All @@ -26,7 +25,7 @@ pub fn Column(
let denominator: i32 = stretch.iter().sum();
let rows = stretch.len();

let f = use_frame(cx);
let f = use_frame();

let s = spacing * (rows as i32 - 1);
let x = f.x + border_width / 2;
Expand All @@ -48,7 +47,7 @@ pub fn Column(
.collect();

{
let frames = use_frames(cx);
let frames = use_frames();
let mut frames = frames.borrow_mut();
for i in (0..rows).rev() {
let Frame {
Expand All @@ -67,7 +66,7 @@ pub fn Column(
}
}

children(cx)
children()
.nodes
.into_iter()
.take(rows)
Expand All @@ -79,7 +78,7 @@ pub fn Column(
width,
height,
} = cells[i];
view! { cx,
view! {
<rect
x=x
y=y
Expand All @@ -92,5 +91,5 @@ pub fn Column(
{child}
}
})
.collect_view(cx)
.collect_view()
}
16 changes: 8 additions & 8 deletions src/ng/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate alloc;

use alloc::{collections::VecDeque, rc::Rc};
use core::cell::RefCell;
use leptos::{expect_context, provide_context, use_context, Scope};
use leptos::{expect_context, provide_context, use_context};

/// Frame within which the widget will be rendered.
#[derive(Clone, Default, Debug)]
Expand Down Expand Up @@ -47,24 +47,24 @@ impl Frames {
}

/// Provides frame to the context.
pub fn provide_frame(cx: Scope, frame: Frame) {
let frames: Option<FramesRef> = use_context(cx);
pub fn provide_frame(frame: Frame) {
let frames: Option<FramesRef> = use_context();
if let Some(frames) = frames {
frames.borrow_mut().0.push_back(frame);
} else {
let frames = Frames([frame].into());
provide_context(cx, Rc::new(RefCell::new(frames)));
provide_context(Rc::new(RefCell::new(frames)));
}
}

/// Returns the current frame.
pub fn use_frame(cx: Scope) -> Frame {
let frames: FramesRef = expect_context(cx);
pub fn use_frame() -> Frame {
let frames: FramesRef = expect_context();
let mut frames = frames.borrow_mut();
frames.pop()
}

/// Returns frames stack from context.
pub fn use_frames(cx: Scope) -> FramesRef {
expect_context(cx)
pub fn use_frames() -> FramesRef {
expect_context()
}
11 changes: 5 additions & 6 deletions src/ng/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::ng::{use_frame, use_frames, Color, Frame};
/// Grid layout widget.
#[component]
pub fn Grid(
cx: Scope,
#[prop(default = 1)] rows: usize,
#[prop(default = 1)] cols: usize,
#[prop(optional)] border_width: i32,
Expand All @@ -14,7 +13,7 @@ pub fn Grid(
#[prop(optional)] padding: i32,
children: Children,
) -> impl IntoView {
let f = use_frame(cx);
let f = use_frame();

let max = cols * rows;

Expand All @@ -26,7 +25,7 @@ pub fn Grid(
let height = (f.height - border_width - vspacing) / rows;

{
let frames = use_frames(cx);
let frames = use_frames();
let mut frames = frames.borrow_mut();
for i in (0..max).rev() {
let x = f.x + border_width / 2 + (width + spacing) * (i as i32 % cols);
Expand All @@ -41,15 +40,15 @@ pub fn Grid(
}
}

children(cx)
children()
.nodes
.into_iter()
.take(max)
.enumerate()
.map(|(i, child)| {
let x = f.x + border_width / 2 + (width + spacing) * (i as i32 % cols);
let y = f.y + border_width / 2 + (height + spacing) * (i as i32 / cols);
view! { cx,
view! {
<rect
x=x
y=y
Expand All @@ -62,5 +61,5 @@ pub fn Grid(
{child}
}
})
.collect_view(cx)
.collect_view()
}
7 changes: 3 additions & 4 deletions src/ng/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::ng::{use_frame, Align, Color, VAlign};

#[component]
pub fn Label(
cx: Scope,
#[prop(optional)] bold: bool,
#[prop(optional)] font: String,
#[prop(default = 48)] font_size: i32,
Expand All @@ -13,7 +12,7 @@ pub fn Label(
#[prop(default = Color::Black)] color: Color,
children: Children,
) -> impl IntoView {
let f = use_frame(cx);
let f = use_frame();

let (x, anchor) = match align {
Align::Left => (f.x, "start"),
Expand All @@ -26,7 +25,7 @@ pub fn Label(
VAlign::Bottom => (f.y + f.height, "text-top"),
};

view! { cx,
view! {
<text
class:has-text-weight-bold=bold
style:font-family=font
Expand All @@ -39,7 +38,7 @@ pub fn Label(
pointer-events="none"
style="user-select: none; -webkit-user-select: none;"
>
{children(cx)}
{children()}
</text>
}
}
Loading

0 comments on commit 98398c9

Please sign in to comment.