Skip to content

Commit e118648

Browse files
authored
Merge pull request #59 from DioxusLabs/fix-dioxus-updates
Update blitz to the git version of dioxus
2 parents 75a8389 + eb2e74d commit e118648

File tree

7 files changed

+61
-62
lines changed

7 files changed

+61
-62
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ dioxus-native-core = { path = "packages/native-core", version = "0.5.0-alpha.2"
1919
dioxus-native-core-macro = { path = "packages/native-core-macro", version = "0.5.0-alpha.2" }
2020
plasmo = { path = "packages/plasmo", version = "0.5.0-alpha.2" }
2121

22-
dioxus = { version = "0.5.0-alpha.2" }
23-
dioxus-core = { version = "0.5.0-alpha.2" }
24-
dioxus-hot-reload = { version = "0.5.0-alpha.2" }
25-
dioxus-html = { version = "0.5.0-alpha.2" }
22+
dioxus = { git = "https://github.com/DioxusLabs/dioxus" }
23+
dioxus-core = { git = "https://github.com/DioxusLabs/dioxus" }
24+
dioxus-hot-reload = { git = "https://github.com/DioxusLabs/dioxus" }
25+
dioxus-html = { git = "https://github.com/DioxusLabs/dioxus" }
2626

2727
tracing = "0.1.37"
2828
tracing-futures = "0.2.5"

packages/blitz-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dioxus-native-core = { workspace = true, features = [
1414
"layout-attributes",
1515
] }
1616
dioxus-native-core-macro = { workspace = true }
17-
dioxus-html = { version = "0.5.0-alpha.2" }
17+
dioxus-html = { git = "https://github.com/DioxusLabs/dioxus" }
1818
taffy = "0.3.12"
1919
tokio = { version = "1.25.0", features = ["full"] }
2020
lightningcss = "1.0.0-alpha.39"

packages/blitz-core/src/events.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use tao::event::MouseButton;
1212
use vello::kurbo::Point;
1313

1414
use dioxus_html::{
15-
geometry::{euclid::Point2D, ClientPoint, Coordinates, ElementPoint, PagePoint, ScreenPoint}, input_data::{self, keyboard_types::Modifiers, MouseButtonSet}, SerializedFocusData, SerializedKeyboardData, SerializedMouseData, SerializedWheelData
15+
geometry::{euclid::Point2D, ClientPoint, Coordinates, ElementPoint, PagePoint, ScreenPoint}, input_data::{self, keyboard_types::Modifiers, MouseButtonSet}, PlatformEventData, SerializedFocusData, SerializedKeyboardData, SerializedMouseData, SerializedWheelData
1616
};
1717
use dioxus_native_core::prelude::*;
1818

@@ -101,12 +101,12 @@ pub enum EventData {
101101

102102
impl EventData {
103103
pub fn into_any(self) -> Rc<dyn Any> {
104-
match self {
105-
EventData::Mouse(data) => Rc::new(data),
106-
EventData::Keyboard(data) => Rc::new(data),
107-
EventData::Focus(data) => Rc::new(data),
108-
EventData::Wheel(data) => Rc::new(data),
109-
}
104+
Rc::new(PlatformEventData::new(match self {
105+
EventData::Mouse(data) => Box::new(data) as Box<dyn Any>,
106+
EventData::Keyboard(data) => Box::new(data),
107+
EventData::Focus(data) => Box::new(data),
108+
EventData::Wheel(data) => Box::new(data),
109+
}))
110110
}
111111
}
112112

packages/blitz/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ repository = "https://github.com/DioxusLabs/blitz"
1111
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1212

1313
[dependencies]
14-
dioxus = { version = "0.5.0-alpha.2" }
14+
dioxus = { git = "https://github.com/DioxusLabs/dioxus" }
1515
dioxus-native-core = { workspace = true, features = [
1616
"dioxus",
1717
] }
18-
dioxus-html = { version = "0.5.0-alpha.2" }
19-
dioxus-hot-reload = { version = "0.5.0-alpha.2" }
18+
dioxus-html = { git = "https://github.com/DioxusLabs/dioxus" }
19+
dioxus-hot-reload = { git = "https://github.com/DioxusLabs/dioxus" }
2020
blitz-core = { path = "../blitz-core" }
2121
tokio = { version = "1.26.0", features = ["full"] }
2222
keyboard-types = "0.7.0"

packages/blitz/examples/buttons.rs

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,41 @@ async fn main() {
55
blitz::launch(app).await;
66
}
77

8-
#[derive(PartialEq, Props)]
8+
#[derive(PartialEq, Props, Clone)]
99
struct ButtonProps {
1010
color_offset: u32,
1111
layer: u16,
1212
}
1313

1414
#[allow(non_snake_case)]
15-
fn Button(cx: Scope<ButtonProps>) -> Element {
16-
let toggle = use_state(cx, || false);
17-
let hovered = use_state(cx, || false);
15+
fn Button(props: ButtonProps) -> Element {
16+
let mut toggle = use_signal(|| false);
17+
let mut hovered = use_signal( || false);
1818

19-
let hue = cx.props.color_offset % 255;
20-
let saturation = if *toggle.get() { 50 } else { 25 } + if *hovered.get() { 50 } else { 25 };
19+
let hue = props.color_offset % 255;
20+
let saturation = if toggle() { 50 } else { 25 } + if hovered() { 50 } else { 25 };
2121
let brightness = saturation / 2;
2222
let color = format!("hsl({hue}, {saturation}%, {brightness}%)");
2323

24-
cx.render(rsx! {
24+
rsx! {
2525
div {
2626
border_width: "0px",
2727
width: "100%",
2828
height: "100%",
2929
background_color: "{color}",
30-
tabindex: "{cx.props.layer}",
31-
onkeydown: |e| {
30+
tabindex: "{props.layer}",
31+
onkeydown: move |e| {
3232
if e.code() == keyboard_types::Code::Space {
33-
toggle.modify(|f| !f);
33+
toggle.toggle();
3434
}
3535
},
36-
onmouseup: |_| {
37-
toggle.modify(|f| !f);
36+
onmouseup: move |_| {
37+
toggle.toggle();
3838
},
39-
onmouseenter: |_| {
39+
onmouseenter: move |_| {
4040
hovered.set(true);
4141
},
42-
onmouseleave: |_| {
42+
onmouseleave: move |_| {
4343
hovered.set(false);
4444
},
4545
justify_content: "center",
@@ -48,15 +48,15 @@ fn Button(cx: Scope<ButtonProps>) -> Element {
4848
display: "flex",
4949
flex_direction: "column",
5050

51-
p { "{cx.props.layer}" }
51+
p { "{props.layer}" }
5252
}
53-
})
53+
}
5454
}
5555

56-
fn app(cx: Scope) -> Element {
57-
let count = use_state(cx, || 10);
58-
let current_count = **count;
59-
cx.render(rsx! {
56+
fn app(_: ()) -> Element {
57+
let mut count = use_signal(|| 10);
58+
let current_count = count();
59+
rsx! {
6060
div { display: "flex", flex_direction: "column", width: "100%", height: "100%",
6161
div {
6262
display: "flex",
@@ -68,8 +68,8 @@ fn app(cx: Scope) -> Element {
6868
height: "10%",
6969
background_color: "green",
7070
tabindex: "0",
71-
onmouseup: |_| {
72-
count.modify(|c| *c + 10);
71+
onmouseup: move |_| {
72+
count += 10;
7373
},
7474
"grid: {current_count}x{current_count} = {current_count*current_count} tiles - Click to add more"
7575
}
@@ -81,32 +81,27 @@ fn app(cx: Scope) -> Element {
8181
text_align: "center",
8282
width: "100%",
8383
height: "90%",
84-
(0..current_count).map(|y|
85-
rsx! {
86-
div { display: "flex", flex_direction: "row", width: "100%", height: "100%",
87-
(0..current_count).map(|x| {
88-
if (x + y) % 2 == 0 {
89-
rsx! {
90-
div {
91-
border_width: "0px",
92-
width: "100%",
93-
height: "100%",
94-
background_color: "rgb(100, 100, 100)"
95-
}
96-
}
97-
} else {
98-
rsx! {
99-
Button {
100-
color_offset: x * y,
101-
layer: ((x + y) % 3) as u16
102-
}
103-
}
84+
for y in (0..current_count) {
85+
86+
div { display: "flex", flex_direction: "row", width: "100%", height: "100%",
87+
for x in (0..current_count) {
88+
if (x + y) % 2 == 0 {
89+
div {
90+
border_width: "0px",
91+
width: "100%",
92+
height: "100%",
93+
background_color: "rgb(100, 100, 100)"
94+
}
95+
} else {
96+
Button {
97+
color_offset: x * y,
98+
layer: ((x + y) % 3) as u16
10499
}
105-
})
100+
}
106101
}
107102
}
108-
)
103+
}
109104
}
110105
}
111-
})
106+
}
112107
}

packages/blitz/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::ops::Deref;
22
use std::sync::Arc;
33

44
use dioxus::dioxus_core::{Component, VirtualDom};
5+
use dioxus_html::SerializedHtmlEventConverter;
56
use dioxus_native_core::prelude::*;
67

78
use blitz_core::EventData;
@@ -20,6 +21,9 @@ pub async fn launch_cfg_with_props<Props: 'static +Clone+ Send>(
2021
props: Props,
2122
cfg: Config,
2223
) {
24+
// Set the event converter
25+
dioxus_html::set_event_converter(Box::new(SerializedHtmlEventConverter));
26+
2327
render(
2428
move |rdom, _| {
2529
let mut vdom = VirtualDom::new_with_props(app, props);

packages/plasmo/src/hooks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl EventData {
6666
pub struct FormData {
6767
pub(crate) value: String,
6868

69-
pub values: HashMap<String, String>,
69+
pub values: HashMap<String, FormValue>,
7070

7171
pub(crate) files: Option<Files>,
7272
}
@@ -76,7 +76,7 @@ impl HasFormData for FormData {
7676
self.value.clone()
7777
}
7878

79-
fn values(&self) -> HashMap<String, String> {
79+
fn values(&self) -> HashMap<String,FormValue> {
8080
self.values.clone()
8181
}
8282

0 commit comments

Comments
 (0)