Skip to content

Commit

Permalink
feat: remove Yew (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamilsan authored Oct 30, 2023
1 parent 1438fec commit 801e88f
Show file tree
Hide file tree
Showing 56 changed files with 1,086 additions and 3,185 deletions.
35 changes: 1 addition & 34 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.0.2"
edition = "2021"
license = "MIT"
description = "Lerni content framework"
repository = "https://github.com/lerni-edu/lerni"
repository = "https://github.com/noviga/lerni"
include = ["src/**/*.rs", "examples/**/*.rs"]

[dependencies]
Expand All @@ -15,7 +15,6 @@ gloo-utils = "0.2.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.21.0", features = ["csr"] }
wasm-bindgen = "0.2.84"

[dependencies.web-sys]
Expand Down Expand Up @@ -43,38 +42,6 @@ crate-type = ["cdylib"]
name = "hello_world"
crate-type = ["cdylib"]

[[example]]
name = "ng_blur"
crate-type = ["cdylib"]

[[example]]
name = "ng_buttons"
crate-type = ["cdylib"]

[[example]]
name = "ng_grid"
crate-type = ["cdylib"]

[[example]]
name = "ng_hello_world"
crate-type = ["cdylib"]

[[example]]
name = "ng_pointer"
crate-type = ["cdylib"]

[[example]]
name = "ng_rows_cols"
crate-type = ["cdylib"]

[[example]]
name = "ng_svg"
crate-type = ["cdylib"]

[[example]]
name = "ng_text"
crate-type = ["cdylib"]

[[example]]
name = "pointer"
crate-type = ["cdylib"]
Expand Down
37 changes: 0 additions & 37 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,43 +43,6 @@ <h1>Lerni Examples</h1>
(<a href="https://github.com/lerni-edu/lerni/blob/master/examples/svg.rs" target="_blank">source</a>)
</li>
</ul>

<h1>New Generation (Leptos-based) Lerni Examples</h1>
<h2>⚠️ Work in progress!</h2>
<ul>
<li>
<a href="/ng_hello_world/">Hello World</a>
(<a href="https://github.com/lerni-edu/lerni/blob/master/examples/ng_hello_world.rs" target="_blank">source</a>)
</li>
<li>
<a href="/ng_grid/">Grid</a>
(<a href="https://github.com/lerni-edu/lerni/blob/master/examples/ng_grid.rs" target="_blank">source</a>)
</li>
<li>
<a href="/ng_buttons/">Buttons</a>
(<a href="https://github.com/lerni-edu/lerni/blob/master/examples/ng_buttons.rs" target="_blank">source</a>)
</li>
<li>
<a href="/ng_pointer/">Pointer</a>
(<a href="https://github.com/lerni-edu/lerni/blob/master/examples/ng_pointer.rs" target="_blank">source</a>)
</li>
<li>
<a href="/ng_rows_cols/">Rows & Columns</a>
(<a href="https://github.com/lerni-edu/lerni/blob/master/examples/ng_rows_cols.rs" target="_blank">source</a>)
</li>
<li>
<a href="/ng_text/">Text</a>
(<a href="https://github.com/lerni-edu/lerni/blob/master/examples/ng_text.rs" target="_blank">source</a>)
</li>
<li>
<a href="/ng_blur/">Blur</a>
(<a href="https://github.com/lerni-edu/lerni/blob/master/examples/ng_blur.rs" target="_blank">source</a>)
</li>
<li>
<a href="/ng_svg/">SVG</a>
(<a href="https://github.com/lerni-edu/lerni/blob/master/examples/ng_svg.rs" target="_blank">source</a>)
</li>
</ul>
</div>
</body>
</html>
15 changes: 0 additions & 15 deletions dist/ng_blur/index.html

This file was deleted.

15 changes: 0 additions & 15 deletions dist/ng_buttons/index.html

This file was deleted.

15 changes: 0 additions & 15 deletions dist/ng_grid/index.html

This file was deleted.

15 changes: 0 additions & 15 deletions dist/ng_hello_world/index.html

This file was deleted.

15 changes: 0 additions & 15 deletions dist/ng_pointer/index.html

This file was deleted.

15 changes: 0 additions & 15 deletions dist/ng_rows_cols/index.html

This file was deleted.

15 changes: 0 additions & 15 deletions dist/ng_svg/index.html

This file was deleted.

15 changes: 0 additions & 15 deletions dist/ng_text/index.html

This file was deleted.

26 changes: 12 additions & 14 deletions examples/blur.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
use lerni::{properties::Color, widgets::*};
use wasm_bindgen::prelude::wasm_bindgen;
use yew::prelude::*;
use leptos::*;
use lerni::*;

#[function_component]
pub fn Blur() -> Html {
let blur = use_state(|| false);
let onclick = {
let blur = blur.clone();
Callback::from(move |_| blur.set(!*blur))
};
#[component]
pub fn Blur() -> impl IntoView {
let (blur, set_blur) = create_signal(false);
let on_click = move |_| set_blur.set(!blur.get());

html! {
<Slide blur={ *blur } background_color={ Color::MistyRose }>
<Button text="Blur ON/OFF" { onclick } />
view! {
<Slide blur=blur.into() background_color=Color::MistyRose>
<Button on_click=on_click>
"Blur " {move || if blur.get() { "ON" } else { "OFF" }}
</Button>
</Slide>
}
}

#[wasm_bindgen(start)]
pub fn main() {
lerni::start::<Blur>();
lerni::start(Blur);
}
43 changes: 22 additions & 21 deletions examples/buttons.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
use lerni::{properties::*, widgets::*};
use wasm_bindgen::prelude::wasm_bindgen;
use yew::prelude::*;
use leptos::*;
use lerni::*;

#[function_component]
pub fn Buttons() -> Html {
let counter = use_state(|| 0);
let onclick = {
let counter = counter.clone();
Callback::from(move |_| counter.set(*counter + 1))
#[component]
pub fn Buttons() -> impl IntoView {
let (counter, set_counter) = create_signal(0);
let on_click = move |_| {
logging::log!("Clicked");
set_counter.set(counter.get() + 1);
};

html! {
view! {
<Slide>
<Grid cols=3 rows=3>
<Button text="Alice" onclick={ onclick.clone() } />
<Button text="Bob" width=300 height=300 radius=150 onclick={ onclick.clone() } />
<Button text="Charlie" font_size=72 text_color={ Color::DarkCyan } onclick={ onclick.clone() } />
<Button html={ html!(<><tspan font-size="96" fill="red">{ "Da" }</tspan><tspan font-size="80">{ "ve" }</tspan></>) }
onclick={ onclick.clone() } />
<Label text={ format!("Clicked: {}", *counter) }/>
<Button text="Eve" text_bold=true align={ Align::Right } onclick={ onclick.clone() } />
<Button text="Ferdie" align={ Align::Right } valign={ VAlign::Bottom } onclick={ onclick.clone() } />
<Button text="George" color={ Color::Honeydew } border_color={ Color::ForestGreen } onclick={ onclick.clone() } />
<Button text="Harry" align={ Align::Fill } valign={ VAlign::Fill } { onclick } />
<Button on_click=on_click>"Alice"</Button>
<Button width=300 height=300 radius=150 on_click=on_click>"Bob"</Button>
<Button font_size=72 text_color=Color::DarkCyan on_click=on_click>"Charlie"</Button>
<Button on_click=on_click>
<tspan font-size="96" fill="red" alignment-baseline="central">"Da"</tspan>
<tspan font-size="80" alignment-baseline="central">"ve"</tspan>
</Button>
<Label>{counter}</Label>
<Button text_bold=true align=Align::Right on_click=on_click>"Eve"</Button>
<Button align=Align::Right valign=VAlign::Bottom on_click=on_click>"Ferdie"</Button>
<Button color=Color::Honeydew border_color=Color::ForestGreen on_click=on_click>"George"</Button>
<Button align=Align::Fill valign=VAlign::Fill on_click=on_click>"Harry"</Button>
</Grid>
</Slide>
}
}

#[wasm_bindgen(start)]
pub fn main() {
lerni::start::<Buttons>();
lerni::start(Buttons);
}
66 changes: 40 additions & 26 deletions examples/grid.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
use lerni::{
properties::{Align, Color, VAlign},
widgets::*,
};
use wasm_bindgen::prelude::wasm_bindgen;
use yew::prelude::*;
use leptos::*;
use lerni::*;

#[function_component]
pub fn GridExample() -> Html {
html! {
#[component]
pub fn GridExample() -> impl IntoView {
view! {
<Slide>
<Grid cols=3 rows=3 border_width=4 padding=20>
<Label html={ html!(<><tspan>{ "00" }</tspan><tspan font-size="96">{ "1" }</tspan></>) } />
<Label text="2" />
<Label html={ html!(<><tspan>{ "00" }</tspan><tspan fill="red">{ "3" }</tspan></>) } />
<Label text="4" font_size=96 color={ Color::Blue } />
<Button text="5" align={ Align::Fill } valign={ VAlign::Fill } />
<Label text="6" align={ Align::Right } />
<Label text="7" align={ Align::Left } />
<Label text="8" />
<Label>
<tspan>"00"</tspan>
<tspan font-size=96>"1"</tspan>
</Label>
<Label>2</Label>
<Label>
<tspan>"00"</tspan>
<tspan fill="red">"3"</tspan>
</Label>
<Label font_size=96 color=Color::Blue>"4"</Label>
<Button
align=Align::Fill
valign=VAlign::Fill
on_click=move |_| logging::log!("5: Clicked")
>
"5"
</Button>
<Label align=Align::Right>"6"</Label>
<Label align=Align::Left>"7"</Label>
<Label>8</Label>
<Grid cols=4 rows=2 border_width=4 spacing=20>
<Label text="9" valign={ VAlign::Top } />
<Label text="10" valign={ VAlign::Bottom } />
<Label text="11" />
<Button text="12" align={ Align::Fill } valign={ VAlign::Fill } />
<Label text="13" />
<Label text="14" align={ Align::Left } valign={ VAlign::Top } />
<Label text="15" />
<Label text="16" align={ Align::Right } valign={ VAlign::Bottom } />
<Label valign=VAlign::Top>"9"</Label>
<Label valign=VAlign::Bottom>"10"</Label>
<Label>11</Label>
<Button
align=Align::Fill
valign=VAlign::Fill
on_click=move |_| logging::log!("12: Clicked")
>
"12"
</Button>
<Label>"13"</Label>
<Label align=Align::Left valign=VAlign::Top>"14"</Label>
<Label>"15"</Label>
<Label align=Align::Right valign=VAlign::Bottom>"16"</Label>
</Grid>
</Grid>
</Slide>
Expand All @@ -35,5 +49,5 @@ pub fn GridExample() -> Html {

#[wasm_bindgen(start)]
pub fn main() {
lerni::start::<GridExample>();
lerni::start(GridExample);
}
Loading

0 comments on commit 801e88f

Please sign in to comment.