From a53ad6355f072cf4e9ade4e305204e2d0de17a12 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Fri, 14 Jul 2023 22:32:12 +0200 Subject: [PATCH 1/6] feat: Bumb dioxus --- Cargo.toml | 18 +++++++++--------- README.md | 2 +- book/src/guides/getting_started.md | 2 +- components/src/drag_drop.rs | 4 ++-- examples/drag_drop.rs | 4 ++-- examples/ui.rs | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a20da0e0a..c11df29c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,15 +26,15 @@ freya-dom = { path = "dom", version = "0.1.0" } freya-testing = { path = "testing", version = "0.1.0" } torin = { path = "torin", version = "0.1.0" } -dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev="11c9abcf7ce731ccb4a44c52de383c090ab319af" } -dioxus-native-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev="11c9abcf7ce731ccb4a44c52de383c090ab319af" } -dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", rev="11c9abcf7ce731ccb4a44c52de383c090ab319af" } -dioxus-native-core = { git = "https://github.com/DioxusLabs/dioxus", rev="11c9abcf7ce731ccb4a44c52de383c090ab319af", features=["dioxus"] } -dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev="11c9abcf7ce731ccb4a44c52de383c090ab319af" } -dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", rev="11c9abcf7ce731ccb4a44c52de383c090ab319af" } -dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", rev="11c9abcf7ce731ccb4a44c52de383c090ab319af" } -dioxus-hot-reload = { git = "https://github.com/DioxusLabs/dioxus", rev="11c9abcf7ce731ccb4a44c52de383c090ab319af" } -dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", rev="11c9abcf7ce731ccb4a44c52de383c090ab319af" } +dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } +dioxus-native-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } +dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } +dioxus-native-core = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9", features=["dioxus"] } +dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } +dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } +dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } +dioxus-hot-reload = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } +dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } gl = "0.14.0" glutin = "0.30.6" diff --git a/README.md b/README.md index 9782fc09a..018163499 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Add Freya as a dependency via git (it's not published on [crates.io](https://cra ```toml freya = { git = "https://github.com/marc2332/freya" } -dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev="11c9abcf7ce731ccb4a44c52de383c090ab319af", features = ["macro", "hooks"]} +dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9", features = ["macro", "hooks"]} ``` ### Features ✨ diff --git a/book/src/guides/getting_started.md b/book/src/guides/getting_started.md index 4e6997ac7..bc5b59264 100644 --- a/book/src/guides/getting_started.md +++ b/book/src/guides/getting_started.md @@ -24,7 +24,7 @@ edition = "2021" [dependencies] freya = { git = "https://github.com/marc2332/freya" } -dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev="11c9abcf7ce731ccb4a44c52de383c090ab319af", features = ["macro", "hooks"]} +dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9", features = ["macro", "hooks"]} ``` ### src/main.rs diff --git a/components/src/drag_drop.rs b/components/src/drag_drop.rs index 5b615e241..0380faebc 100644 --- a/components/src/drag_drop.rs +++ b/components/src/drag_drop.rs @@ -167,11 +167,11 @@ mod test { "Move" } } - } + }, DropZone { ondrop: move |data: bool| { state.set(data); - } + }, rect { height: "50%", width: "100%", diff --git a/examples/drag_drop.rs b/examples/drag_drop.rs index 9204efc43..fa2b7e2e2 100644 --- a/examples/drag_drop.rs +++ b/examples/drag_drop.rs @@ -36,7 +36,7 @@ fn app(cx: Scope) -> Element { } Column { data: data.clone(), - direction: SwapDirection::LeftToRight + direction: SwapDirection::LeftToRight, column: data.get().1.clone() } } @@ -79,7 +79,7 @@ fn Column( DropZone { ondrop: move |data: String| { swap(data, direction); - } + }, rect { width: "100%", height: "100%", diff --git a/examples/ui.rs b/examples/ui.rs index 4edd0c53f..8d7fea34f 100644 --- a/examples/ui.rs +++ b/examples/ui.rs @@ -17,10 +17,10 @@ fn app(cx: Scope) -> Element { Navbar { title: "Top navbar" } - ) + ), body: render!( ScrollView { - height: "calc(100% - 75 - 75)" + height: "calc(100% - 75 - 75)", show_scrollbar: true, Card { title: "Another title", From f8ca8c55982f5e5f7de623d2d212b71782b85c83 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Wed, 19 Jul 2023 18:52:48 +0200 Subject: [PATCH 2/6] updated dioxus --- Cargo.toml | 18 +++++++++--------- README.md | 2 +- book/src/guides/getting_started.md | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c11df29c7..326ee028d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,15 +26,15 @@ freya-dom = { path = "dom", version = "0.1.0" } freya-testing = { path = "testing", version = "0.1.0" } torin = { path = "torin", version = "0.1.0" } -dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } -dioxus-native-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } -dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } -dioxus-native-core = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9", features=["dioxus"] } -dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } -dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } -dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } -dioxus-hot-reload = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } -dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9" } +dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } +dioxus-native-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } +dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } +dioxus-native-core = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c", features=["dioxus"] } +dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } +dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } +dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } +dioxus-hot-reload = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } +dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } gl = "0.14.0" glutin = "0.30.6" diff --git a/README.md b/README.md index 018163499..8288b81ee 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Add Freya as a dependency via git (it's not published on [crates.io](https://cra ```toml freya = { git = "https://github.com/marc2332/freya" } -dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9", features = ["macro", "hooks"]} +dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c", features = ["macro", "hooks"]} ``` ### Features ✨ diff --git a/book/src/guides/getting_started.md b/book/src/guides/getting_started.md index bc5b59264..e178e4c45 100644 --- a/book/src/guides/getting_started.md +++ b/book/src/guides/getting_started.md @@ -24,7 +24,7 @@ edition = "2021" [dependencies] freya = { git = "https://github.com/marc2332/freya" } -dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev="8a9bf294b44e123927dc9a19ad2d4238aea6ccb9", features = ["macro", "hooks"]} +dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c", features = ["macro", "hooks"]} ``` ### src/main.rs From f8fbc28fbf88e88388d730619edbec002bbdf9ed Mon Sep 17 00:00:00 2001 From: marc2332 Date: Wed, 19 Jul 2023 21:11:53 +0200 Subject: [PATCH 3/6] update devtools routing --- devtools/src/hooks/mod.rs | 3 + devtools/src/hooks/use_selected_node.rs | 13 ++ devtools/src/lib.rs | 192 +++++++++++++++--------- devtools/src/node.rs | 4 +- devtools/src/property.rs | 6 +- devtools/src/tab.rs | 12 +- devtools/src/tabs/layout.rs | 11 +- devtools/src/tabs/style.rs | 22 ++- devtools/src/tabs/tree.rs | 19 +-- examples/ui.rs | 86 +++++------ 10 files changed, 218 insertions(+), 150 deletions(-) create mode 100644 devtools/src/hooks/mod.rs create mode 100644 devtools/src/hooks/use_selected_node.rs diff --git a/devtools/src/hooks/mod.rs b/devtools/src/hooks/mod.rs new file mode 100644 index 000000000..631855095 --- /dev/null +++ b/devtools/src/hooks/mod.rs @@ -0,0 +1,3 @@ +mod use_selected_node; + +pub use use_selected_node::*; diff --git a/devtools/src/hooks/use_selected_node.rs b/devtools/src/hooks/use_selected_node.rs new file mode 100644 index 000000000..072d6c6c0 --- /dev/null +++ b/devtools/src/hooks/use_selected_node.rs @@ -0,0 +1,13 @@ +use dioxus::prelude::*; +use dioxus_native_core::NodeId; + +use crate::TreeNode; + +pub fn use_selected_node(cx: &ScopeState, node_id: &NodeId) -> Option { + let children = use_shared_state::>(cx)?; + let children = children.read(); + + let node = children.iter().find(|node| &node.id == node_id)?; + + Some(node.clone()) +} diff --git a/devtools/src/lib.rs b/devtools/src/lib.rs index 6d1b048cc..62ae1813c 100644 --- a/devtools/src/lib.rs +++ b/devtools/src/lib.rs @@ -4,7 +4,7 @@ use dioxus_native_core::prelude::{ElementNode, TextNode}; use dioxus_native_core::real_dom::NodeImmutable; use dioxus_native_core::tree::TreeRef; use dioxus_native_core::NodeId; -use dioxus_router::*; +use dioxus_router::prelude::*; use freya_components::*; use freya_core::node::{get_node_state, NodeState}; use freya_dom::prelude::SafeDOM; @@ -16,6 +16,7 @@ use std::sync::Arc; use tokio::sync::Notify; use torin::prelude::NodeAreas; +mod hooks; mod node; mod property; mod tab; @@ -112,8 +113,10 @@ impl PartialEq for DevToolsProps { #[allow(non_snake_case)] pub fn DevTools(cx: Scope) -> Element { + use_shared_state_provider(cx, Vec::::new); + use_shared_state_provider::(cx, || cx.props.hovered_node.clone()); use_init_theme(cx, DARK_THEME); - let children = use_state(cx, Vec::::new); + let children = use_shared_state::>(cx).unwrap(); let theme = use_theme(cx); let theme = theme.read(); @@ -171,114 +174,153 @@ pub fn DevTools(cx: Scope) -> Element { } } }); - children.set(new_children); + *children.write() = new_children; } } }); - let selected_node_id = use_state::>(cx, || None); - - let selected_node = children.iter().find(|c| { - if let Some(n_id) = selected_node_id.get() { - n_id == &c.id - } else { - false - } - }); - render!( rect { width: "100%", height: "100%", color: theme.body.color, Router { - initial_url: "freya://freya/elements".to_string(), - DevtoolsBar {} - Route { - to: "/elements", - NodesTree { - nodes: children, - height: "calc(100% - 35)", - selected_node_id: &None, - onselected: |node: &TreeNode| { - if let Some(hovered_node) = &cx.props.hovered_node { - hovered_node.lock().unwrap().replace(node.id); - } - selected_node_id.set(Some(node.id)); - } - } - } - Route { - to: "/elements/style", - NodesTree { - nodes: children, - height: "calc(50% - 35)", - selected_node_id: selected_node_id.get(), - onselected: |node: &TreeNode| { - if let Some(hovered_node) = &cx.props.hovered_node { - hovered_node.lock().unwrap().replace(node.id); - } - selected_node_id.set(Some(node.id)); - } - } - selected_node.map(|selected_node| { - rsx!( - NodeInspectorStyle { - node: selected_node - } - ) - }) - } - Route { - to: "/elements/layout", - NodesTree { - nodes: children, - height: "calc(50% - 35)", - selected_node_id: selected_node_id.get(), - onselected: |node: &TreeNode| { - if let Some(hovered_node) = &cx.props.hovered_node { - hovered_node.lock().unwrap().replace(node.id); - } - selected_node_id.set(Some(node.id)); - } - } - selected_node.map(|selected_node| { - rsx!( - NodeInspectorLayout { - node: selected_node - } - ) - }) - } + } } ) } +#[inline_props] #[allow(non_snake_case)] pub fn DevtoolsBar(cx: Scope) -> Element { render!( TabsBar { TabButton { - to: "/elements", + to: Route::TreeTab { }, label: "Elements" } } + Outlet {} ) } #[allow(non_snake_case)] -pub fn NodeInspectorBar(cx: Scope) -> Element { +#[inline_props] +pub fn NodeInspectorBar(cx: Scope, node_id: NodeId) -> Element { render!( TabsBar { TabButton { - to: "/elements/style", + to: Route::TreeStyleTab { node_id: node_id.serialize() }, label: "Style" } TabButton { - to: "/elements/layout", + to: Route::TreeLayoutTab { node_id: node_id.serialize() }, label: "Layout" } } ) } + +#[derive(Routable, Clone)] +#[rustfmt::skip] +pub enum Route { + #[layout(DevtoolsBar)] + #[route("/")] + TreeTab {}, + + #[route("/elements/:node_id/style")] + TreeStyleTab { node_id: String }, + + #[route("/elements/:node_id/layout")] + TreeLayoutTab { node_id: String }, + #[end_layout] + #[route("/..route")] + PageNotFound { }, +} + +#[allow(non_snake_case)] +#[inline_props] +fn PageNotFound(cx: Scope) -> Element { + render!( + label { + "Page not found." + } + ) +} + +#[allow(non_snake_case)] +#[inline_props] +fn TreeTab(cx: Scope) -> Element { + let hovered_node = use_shared_state::(cx).unwrap(); + + render!(NodesTree { + height: "calc(100% - 35)", + onselected: |node: &TreeNode| { + if let Some(hovered_node) = &hovered_node.read().as_ref() { + hovered_node.lock().unwrap().replace(node.id); + } + } + }) +} + +#[allow(non_snake_case)] +#[inline_props] +fn TreeStyleTab(cx: Scope, node_id: String) -> Element { + let hovered_node = use_shared_state::(cx).unwrap(); + let node_id = NodeId::deserialize(&node_id); + + render!( + NodesTree { + height: "calc(50% - 35)", + selected_node_id: node_id, + onselected: |node: &TreeNode| { + if let Some(hovered_node) = &hovered_node.read().as_ref() { + hovered_node.lock().unwrap().replace(node.id); + } + } + } + NodeInspectorStyle { + node_id: node_id + } + ) +} + +#[allow(non_snake_case)] +#[inline_props] +fn TreeLayoutTab(cx: Scope, node_id: String) -> Element { + let hovered_node = use_shared_state::(cx).unwrap(); + let node_id = NodeId::deserialize(&node_id); + + render!( + NodesTree { + height: "calc(50% - 35)", + selected_node_id: node_id, + onselected: |node: &TreeNode| { + if let Some(hovered_node) = &hovered_node.read().as_ref() { + hovered_node.lock().unwrap().replace(node.id); + } + } + } + NodeInspectorLayout { + node_id: node_id + } + ) +} + +pub trait NodeIdSerializer { + fn serialize(&self) -> String; + + fn deserialize(node_id: &str) -> Self; +} + +impl NodeIdSerializer for NodeId { + fn serialize(&self) -> String { + format!("{}-{}", self.index(), self.gen()) + } + + fn deserialize(node_id: &str) -> Self { + let (index, gen) = node_id.split_once('-').unwrap(); + NodeId::new_from_index_and_gen(index.parse().unwrap(), gen.parse().unwrap()) + } +} diff --git a/devtools/src/node.rs b/devtools/src/node.rs index bb90b3c47..680f440c3 100644 --- a/devtools/src/node.rs +++ b/devtools/src/node.rs @@ -8,13 +8,13 @@ use crate::TreeNode; #[inline_props] pub fn NodeElement<'a>( cx: Scope<'a>, - node: &'a TreeNode, + node: TreeNode, is_selected: bool, onselected: EventHandler<'a, &'a TreeNode>, ) -> Element<'a> { let status = use_state(cx, ButtonStatus::default); - let onmousedown = move |_| onselected.call(node); + let onmousedown = move |_| onselected.call(&node); let onmouseover = move |_| { if *status.get() != ButtonStatus::Hovering { diff --git a/devtools/src/property.rs b/devtools/src/property.rs index f7d2b4aaa..3f36d5004 100644 --- a/devtools/src/property.rs +++ b/devtools/src/property.rs @@ -113,7 +113,7 @@ pub fn ColorProperty<'a>(cx: Scope<'a>, name: &'a str, fill: Fill) -> Element<'a #[allow(non_snake_case)] #[inline_props] -pub fn ShadowProperty<'a>(cx: Scope<'a>, name: &'a str, shadow: &'a Shadow) -> Element<'a> { +pub fn ShadowProperty<'a>(cx: Scope<'a>, name: &'a str, shadow: Shadow) -> Element<'a> { render!( rect { overflow: "clip", @@ -169,7 +169,7 @@ pub fn ShadowProperty<'a>(cx: Scope<'a>, name: &'a str, shadow: &'a Shadow) -> E #[allow(non_snake_case)] #[inline_props] -pub fn BorderProperty<'a>(cx: Scope<'a>, name: &'a str, border: &'a Border) -> Element<'a> { +pub fn BorderProperty<'a>(cx: Scope<'a>, name: &'a str, border: Border) -> Element<'a> { render!( rect { overflow: "clip", @@ -227,7 +227,7 @@ pub fn BorderProperty<'a>(cx: Scope<'a>, name: &'a str, border: &'a Border) -> E pub fn TextShadowProperty<'a>( cx: Scope<'a>, name: &'a str, - text_shadow: &'a TextShadow, + text_shadow: TextShadow, ) -> Element<'a> { let color = text_shadow.color.to_rgb(); render!( diff --git a/devtools/src/tab.rs b/devtools/src/tab.rs index ccbe85074..b70d0d635 100644 --- a/devtools/src/tab.rs +++ b/devtools/src/tab.rs @@ -1,9 +1,11 @@ use dioxus::prelude::*; -use dioxus_router::use_router; +use dioxus_router::prelude::*; use freya_components::{ButtonStatus, ScrollView}; use freya_elements::elements as dioxus_elements; use freya_hooks::use_get_theme; +use crate::Route; + #[derive(Props)] pub struct TabsBarProps<'a> { pub children: Element<'a>, @@ -23,18 +25,18 @@ pub fn TabsBar<'a>(cx: Scope<'a, TabsBarProps<'a>>) -> Element<'a> { #[derive(Props)] pub struct TabButtonProps<'a> { - pub to: &'a str, + pub to: Route, pub label: &'a str, } #[allow(non_snake_case)] pub fn TabButton<'a>(cx: Scope<'a, TabButtonProps<'a>>) -> Element<'a> { - let router = use_router(cx); + let router = use_generic_navigator::(cx); let theme = use_get_theme(cx); let status = use_state(cx, ButtonStatus::default); - let onclick = move |_| { - router.replace_route(cx.props.to, None, None); + let onclick = |_| { + router.replace(cx.props.to.clone()); }; let onmouseover = move |_| { diff --git a/devtools/src/tabs/layout.rs b/devtools/src/tabs/layout.rs index f47297150..12347e6c2 100644 --- a/devtools/src/tabs/layout.rs +++ b/devtools/src/tabs/layout.rs @@ -1,12 +1,15 @@ use dioxus::prelude::*; +use dioxus_native_core::NodeId; use freya_components::*; use freya_elements::elements as dioxus_elements; -use crate::{NodeInspectorBar, TreeNode}; +use crate::{hooks::use_selected_node, NodeInspectorBar}; #[allow(non_snake_case)] #[inline_props] -pub fn NodeInspectorLayout<'a>(cx: Scope<'a>, node: &'a TreeNode) -> Element<'a> { +pub fn NodeInspectorLayout(cx: Scope, node_id: NodeId) -> Element { + let node = use_selected_node(cx, &node_id).unwrap(); + let inner_area = format!( "{}x{}", node.areas.inner_area.width(), @@ -20,7 +23,9 @@ pub fn NodeInspectorLayout<'a>(cx: Scope<'a>, node: &'a TreeNode) -> Element<'a> overflow: "clip", width: "100%", height: "50%", - NodeInspectorBar { } + NodeInspectorBar { + node_id: *node_id + } ScrollView { show_scrollbar: true, height: "calc(100% - 35)", diff --git a/devtools/src/tabs/style.rs b/devtools/src/tabs/style.rs index 679aeb727..d40e034b4 100644 --- a/devtools/src/tabs/style.rs +++ b/devtools/src/tabs/style.rs @@ -1,25 +1,31 @@ use dioxus::prelude::*; +use dioxus_native_core::NodeId; use freya_components::*; use freya_core::prelude::*; use freya_elements::elements as dioxus_elements; use crate::{ + hooks::use_selected_node, property::{ BorderProperty, ColorProperty, LinearGradientProperty, Property, ShadowProperty, TextShadowProperty, }, - NodeInspectorBar, TreeNode, + NodeInspectorBar, }; #[allow(non_snake_case)] #[inline_props] -pub fn NodeInspectorStyle<'a>(cx: Scope<'a>, node: &'a TreeNode) -> Element<'a> { +pub fn NodeInspectorStyle(cx: Scope, node_id: NodeId) -> Element { + let node = use_selected_node(cx, &node_id).unwrap(); + render!( rect { overflow: "clip", width: "100%", height: "50%", - NodeInspectorBar { } + NodeInspectorBar { + node_id: *node_id + } ScrollView { show_scrollbar: true, height: "calc(100% - 35)", @@ -67,7 +73,7 @@ pub fn NodeInspectorStyle<'a>(cx: Scope<'a>, node: &'a TreeNode) -> Element<'a> ColorProperty { key: "{i}", name: "{name}", - fill: fill + fill: fill.clone() } } } @@ -76,7 +82,7 @@ pub fn NodeInspectorStyle<'a>(cx: Scope<'a>, node: &'a TreeNode) -> Element<'a> LinearGradientProperty { key: "{i}", name: "{name}", - fill: fill + fill: fill.clone() } } } @@ -85,7 +91,7 @@ pub fn NodeInspectorStyle<'a>(cx: Scope<'a>, node: &'a TreeNode) -> Element<'a> BorderProperty { key: "{i}", name: "{name}", - border: border + border: border.clone() } } } @@ -121,7 +127,7 @@ pub fn NodeInspectorStyle<'a>(cx: Scope<'a>, node: &'a TreeNode) -> Element<'a> ShadowProperty { key: "{i}", name: "{name}", - shadow: shadow + shadow: shadow.clone() } } } @@ -130,7 +136,7 @@ pub fn NodeInspectorStyle<'a>(cx: Scope<'a>, node: &'a TreeNode) -> Element<'a> TextShadowProperty { key: "{i}", name: "{name}", - text_shadow: text_shadow + text_shadow: text_shadow.clone() } } } diff --git a/devtools/src/tabs/tree.rs b/devtools/src/tabs/tree.rs index 469d29d90..d14a4a3d5 100644 --- a/devtools/src/tabs/tree.rs +++ b/devtools/src/tabs/tree.rs @@ -1,39 +1,40 @@ use dioxus::prelude::*; use dioxus_native_core::NodeId; -use dioxus_router::*; +use dioxus_router::prelude::use_generic_navigator; use freya_components::*; -use crate::{node::NodeElement, TreeNode}; +use crate::{node::NodeElement, NodeIdSerializer, Route, TreeNode}; #[allow(non_snake_case)] #[inline_props] pub fn NodesTree<'a>( cx: Scope<'a>, - nodes: &'a Vec, height: &'a str, - selected_node_id: &'a Option, + selected_node_id: Option, onselected: EventHandler<'a, &'a TreeNode>, ) -> Element<'a> { - let router = use_router(cx); + let router = use_generic_navigator::(cx); + let nodes = use_shared_state::>(cx).unwrap(); render!(VirtualScrollView { width: "100%", height: "{height}", padding: "15", show_scrollbar: true, - length: nodes.len(), + length: nodes.read().len(), item_size: 27.0, builder_values: (nodes, selected_node_id, onselected, router), builder: Box::new(move |(_k, i, _, values)| { let (nodes, selected_node_id, onselected, router) = values.unwrap(); - let node = nodes.get(i).unwrap(); + let nodes = nodes.read(); + let node = nodes.get(i).cloned().unwrap(); rsx! { NodeElement { key: "{node.id:?}", - is_selected: Some(node.id) == **selected_node_id, + is_selected: Some(node.id) == *selected_node_id, onselected: |node: &TreeNode| { onselected.call(node); - router.replace_route("/elements/style", None, None) + router.replace(Route::TreeStyleTab { node_id: node.id.serialize() }); }, node: node } diff --git a/examples/ui.rs b/examples/ui.rs index 8d7fea34f..d4722d9fa 100644 --- a/examples/ui.rs +++ b/examples/ui.rs @@ -10,65 +10,61 @@ fn main() { } fn app(cx: Scope) -> Element { - render!( - App { - title: "My App", - navbar: render!( - Navbar { - title: "Top navbar" + render!(App { + title: "My App", + navbar: render!(Navbar { + title: "Top navbar" + }), + body: render!( + ScrollView { + height: "calc(100% - 75 - 75)", + show_scrollbar: true, + Card { + title: "Another title", + content: "Some content", } - ), - body: render!( ScrollView { - height: "calc(100% - 75 - 75)", - show_scrollbar: true, + height: "200", + padding: "0 20", Card { - title: "Another title", - content: "Some content", - } - ScrollView { - height: "200", - padding: "0 20", - Card { - title: "Lalala", - content: "Wooow", - } - Card { - title: "Lalala", - content: "Wooow", - } - Card { - title: "Lalala", - content: "Wooow", - } - Card { - title: "Lalala", - content: "Wooow", - } - } - Card { - title: "Another title", - content: "Some content", + title: "Lalala", + content: "Wooow", } Card { - title: "Another title", - content: "Some content", + title: "Lalala", + content: "Wooow", } Card { title: "Lalala", content: "Wooow", } Card { - title: "Another title", - content: "Some content", + title: "Lalala", + content: "Wooow", } } - Navbar { - title: "Bottom bar" + Card { + title: "Another title", + content: "Some content", } - ) - } - ) + Card { + title: "Another title", + content: "Some content", + } + Card { + title: "Lalala", + content: "Wooow", + } + Card { + title: "Another title", + content: "Some content", + } + } + Navbar { + title: "Bottom bar" + } + ) + }) } #[derive(Props)] From 6faa6cf11b3468db5423cbcf9bbce1026f4438b6 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Tue, 1 Aug 2023 18:57:37 +0200 Subject: [PATCH 4/6] 0.4 --- Cargo.toml | 18 +++++++++--------- README.md | 2 +- book/src/guides/getting_started.md | 2 +- components/src/dropdown.rs | 3 ++- devtools/src/lib.rs | 6 ++---- devtools/src/tab.rs | 2 +- devtools/src/tabs/tree.rs | 4 ++-- elements/src/elements.rs | 13 ++++++------- 8 files changed, 24 insertions(+), 26 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 326ee028d..0369e072a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,15 +26,15 @@ freya-dom = { path = "dom", version = "0.1.0" } freya-testing = { path = "testing", version = "0.1.0" } torin = { path = "torin", version = "0.1.0" } -dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } -dioxus-native-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } -dioxus-rsx = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } -dioxus-native-core = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c", features=["dioxus"] } -dioxus-core-macro = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } -dioxus-hooks = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } -dioxus-core = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } -dioxus-hot-reload = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } -dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c" } +dioxus = { version = "0.4" } +dioxus-native-core-macro = { version = "0.4" } +dioxus-rsx = { version = "0.4", features=["hot_reload"] } +dioxus-native-core = { version = "0.4", features=["dioxus"] } +dioxus-core-macro = { version = "0.4" } +dioxus-hooks = { version = "0.4" } +dioxus-core = { version = "0.4" } +dioxus-hot-reload = { version = "0.4", features=["file_watcher"] } +dioxus-router = { version = "0.4" } gl = "0.14.0" glutin = "0.30.6" diff --git a/README.md b/README.md index 8288b81ee..f4e9828b6 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Add Freya as a dependency via git (it's not published on [crates.io](https://cra ```toml freya = { git = "https://github.com/marc2332/freya" } -dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c", features = ["macro", "hooks"]} +dioxus = { version = "0.4", features = ["macro", "hooks"]} ``` ### Features ✨ diff --git a/book/src/guides/getting_started.md b/book/src/guides/getting_started.md index e178e4c45..feb557792 100644 --- a/book/src/guides/getting_started.md +++ b/book/src/guides/getting_started.md @@ -24,7 +24,7 @@ edition = "2021" [dependencies] freya = { git = "https://github.com/marc2332/freya" } -dioxus = { git = "https://github.com/DioxusLabs/dioxus", rev="f69b84bf34114c68749e956f26ed61db38079f7c", features = ["macro", "hooks"]} +dioxus = { version = "0.4", features = ["macro", "hooks"]} ``` ### src/main.rs diff --git a/components/src/dropdown.rs b/components/src/dropdown.rs index 1618f2eb3..4b09127e7 100644 --- a/components/src/dropdown.rs +++ b/components/src/dropdown.rs @@ -222,6 +222,7 @@ where } ) } else { + let selected = selected.read().to_string(); render!( rect { margin: "5", @@ -237,7 +238,7 @@ where padding: "7", label { align: "center", - "{selected.read()}" + "{selected}" } rect { width: "100%", diff --git a/devtools/src/lib.rs b/devtools/src/lib.rs index 62ae1813c..90c50db4b 100644 --- a/devtools/src/lib.rs +++ b/devtools/src/lib.rs @@ -184,9 +184,7 @@ pub fn DevTools(cx: Scope) -> Element { width: "100%", height: "100%", color: theme.body.color, - Router { - - } + Router:: { } } ) } @@ -201,7 +199,7 @@ pub fn DevtoolsBar(cx: Scope) -> Element { label: "Elements" } } - Outlet {} + Outlet:: {} ) } diff --git a/devtools/src/tab.rs b/devtools/src/tab.rs index b70d0d635..f02a9465d 100644 --- a/devtools/src/tab.rs +++ b/devtools/src/tab.rs @@ -31,7 +31,7 @@ pub struct TabButtonProps<'a> { #[allow(non_snake_case)] pub fn TabButton<'a>(cx: Scope<'a, TabButtonProps<'a>>) -> Element<'a> { - let router = use_generic_navigator::(cx); + let router = use_navigator(cx); let theme = use_get_theme(cx); let status = use_state(cx, ButtonStatus::default); diff --git a/devtools/src/tabs/tree.rs b/devtools/src/tabs/tree.rs index d14a4a3d5..5e61b88c6 100644 --- a/devtools/src/tabs/tree.rs +++ b/devtools/src/tabs/tree.rs @@ -1,6 +1,6 @@ use dioxus::prelude::*; use dioxus_native_core::NodeId; -use dioxus_router::prelude::use_generic_navigator; +use dioxus_router::prelude::use_navigator; use freya_components::*; use crate::{node::NodeElement, NodeIdSerializer, Route, TreeNode}; @@ -13,7 +13,7 @@ pub fn NodesTree<'a>( selected_node_id: Option, onselected: EventHandler<'a, &'a TreeNode>, ) -> Element<'a> { - let router = use_generic_navigator::(cx); + let router = use_navigator(cx); let nodes = use_shared_state::>(cx).unwrap(); render!(VirtualScrollView { diff --git a/elements/src/elements.rs b/elements/src/elements.rs index 4b28b3581..95775b57d 100644 --- a/elements/src/elements.rs +++ b/elements/src/elements.rs @@ -307,13 +307,12 @@ pub mod events { $( $( #[$attr] )* pub fn $name<'a>(_cx: &'a ::dioxus_core::ScopeState, _f: impl FnMut(::dioxus_core::Event<$data>) + 'a) -> ::dioxus_core::Attribute<'a> { - ::dioxus_core::Attribute { - name: stringify!($name), - value: _cx.listener(_f), - namespace: None, - mounted_element: Default::default(), - volatile: false, - } + ::dioxus_core::Attribute::new( + stringify!($name), + _cx.listener(_f), + None, + false, + ) } )* }; From f436626dbf165e238368ab4b9fa19b00a51296f2 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Wed, 2 Aug 2023 10:36:42 +0200 Subject: [PATCH 5/6] fixes --- Cargo.toml | 6 +- devtools/src/lib.rs | 21 ++-- devtools/src/node.rs | 2 +- devtools/src/tabs/layout.rs | 154 ++++++++++++++------------- devtools/src/tabs/style.rs | 206 ++++++++++++++++++------------------ 5 files changed, 200 insertions(+), 189 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0369e072a..b45d94143 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,12 +28,12 @@ torin = { path = "torin", version = "0.1.0" } dioxus = { version = "0.4" } dioxus-native-core-macro = { version = "0.4" } -dioxus-rsx = { version = "0.4", features=["hot_reload"] } -dioxus-native-core = { version = "0.4", features=["dioxus"] } +dioxus-rsx = { version = "0.4", features = ["hot_reload"] } +dioxus-native-core = { version = "0.4", features = ["dioxus"] } dioxus-core-macro = { version = "0.4" } dioxus-hooks = { version = "0.4" } dioxus-core = { version = "0.4" } -dioxus-hot-reload = { version = "0.4", features=["file_watcher"] } +dioxus-hot-reload = { version = "0.4", features = ["file_watcher"] } dioxus-router = { version = "0.4" } gl = "0.14.0" diff --git a/devtools/src/lib.rs b/devtools/src/lib.rs index 90c50db4b..256560df2 100644 --- a/devtools/src/lib.rs +++ b/devtools/src/lib.rs @@ -195,7 +195,7 @@ pub fn DevtoolsBar(cx: Scope) -> Element { render!( TabsBar { TabButton { - to: Route::TreeTab { }, + to: Route::TreeElementsTab { }, label: "Elements" } } @@ -225,7 +225,7 @@ pub fn NodeInspectorBar(cx: Scope, node_id: NodeId) -> Element { pub enum Route { #[layout(DevtoolsBar)] #[route("/")] - TreeTab {}, + TreeElementsTab {}, #[route("/elements/:node_id/style")] TreeStyleTab { node_id: String }, @@ -249,7 +249,7 @@ fn PageNotFound(cx: Scope) -> Element { #[allow(non_snake_case)] #[inline_props] -fn TreeTab(cx: Scope) -> Element { +fn TreeElementsTab(cx: Scope) -> Element { let hovered_node = use_shared_state::(cx).unwrap(); render!(NodesTree { @@ -262,11 +262,15 @@ fn TreeTab(cx: Scope) -> Element { }) } +#[derive(Props, PartialEq)] +struct TreeTabProps { + node_id: String, +} + #[allow(non_snake_case)] -#[inline_props] -fn TreeStyleTab(cx: Scope, node_id: String) -> Element { +fn TreeStyleTab(cx: Scope) -> Element { let hovered_node = use_shared_state::(cx).unwrap(); - let node_id = NodeId::deserialize(&node_id); + let node_id = NodeId::deserialize(&cx.props.node_id); render!( NodesTree { @@ -285,10 +289,9 @@ fn TreeStyleTab(cx: Scope, node_id: String) -> Element { } #[allow(non_snake_case)] -#[inline_props] -fn TreeLayoutTab(cx: Scope, node_id: String) -> Element { +fn TreeLayoutTab(cx: Scope) -> Element { let hovered_node = use_shared_state::(cx).unwrap(); - let node_id = NodeId::deserialize(&node_id); + let node_id = NodeId::deserialize(&cx.props.node_id); render!( NodesTree { diff --git a/devtools/src/node.rs b/devtools/src/node.rs index 680f440c3..235930e3d 100644 --- a/devtools/src/node.rs +++ b/devtools/src/node.rs @@ -14,7 +14,7 @@ pub fn NodeElement<'a>( ) -> Element<'a> { let status = use_state(cx, ButtonStatus::default); - let onmousedown = move |_| onselected.call(&node); + let onmousedown = move |_| onselected.call(&cx.props.node); let onmouseover = move |_| { if *status.get() != ButtonStatus::Hovering { diff --git a/devtools/src/tabs/layout.rs b/devtools/src/tabs/layout.rs index 12347e6c2..636cfb7d3 100644 --- a/devtools/src/tabs/layout.rs +++ b/devtools/src/tabs/layout.rs @@ -8,111 +8,115 @@ use crate::{hooks::use_selected_node, NodeInspectorBar}; #[allow(non_snake_case)] #[inline_props] pub fn NodeInspectorLayout(cx: Scope, node_id: NodeId) -> Element { - let node = use_selected_node(cx, &node_id).unwrap(); + let node = use_selected_node(cx, &cx.props.node_id); - let inner_area = format!( - "{}x{}", - node.areas.inner_area.width(), - node.areas.inner_area.height() - ); - let area = format!("{}x{}", node.areas.area.width(), node.areas.area.height()); - let paddings = node.state.size.padding; + if let Some(node) = node { + let inner_area = format!( + "{}x{}", + node.areas.inner_area.width(), + node.areas.inner_area.height() + ); + let area = format!("{}x{}", node.areas.area.width(), node.areas.area.height()); + let paddings = node.state.size.padding; - render!( - rect { - overflow: "clip", - width: "100%", - height: "50%", - NodeInspectorBar { - node_id: *node_id - } - ScrollView { - show_scrollbar: true, - height: "calc(100% - 35)", + render!( + rect { + overflow: "clip", width: "100%", - rect { + height: "50%", + NodeInspectorBar { + node_id: *node_id + } + ScrollView { + show_scrollbar: true, + height: "calc(100% - 35)", width: "100%", - height: "200", - padding: "20", - label { - height: "25", - "Area: {area}" - } rect { width: "100%", - height: "calc(100% - 25)", - display: "center", - direction: "both", - background: "rgb(40, 40, 40)", + height: "200", + padding: "20", + label { + height: "25", + "Area: {area}" + } rect { width: "100%", - height: "100%", - background: "rgb(71, 180, 240)", - corner_radius: "5", - rect { - direction: "both", - display: "center", - width: "100%", - height: "25", - label { - width: "100%", - align: "center", - "{paddings.top()}" - } - } + height: "calc(100% - 25)", + display: "center", + direction: "both", + background: "rgb(40, 40, 40)", rect { width: "100%", - height: "calc(100% - 50)", - direction: "horizontal", + height: "100%", + background: "rgb(71, 180, 240)", + corner_radius: "5", rect { - direction: "vertical", + direction: "both", display: "center", - width: "25", - height: "100%", + width: "100%", + height: "25", label { width: "100%", align: "center", - "{paddings.left()}" + "{paddings.top()}" } } rect { - width: "calc(100% - 50)", - height: "100%", - display: "center", - direction: "both", - background: "rgb(40, 40, 40)", - corner_radius: "5", - label { - "{inner_area}" + width: "100%", + height: "calc(100% - 50)", + direction: "horizontal", + rect { + direction: "vertical", + display: "center", + width: "25", + height: "100%", + label { + width: "100%", + align: "center", + "{paddings.left()}" + } + } + rect { + width: "calc(100% - 50)", + height: "100%", + display: "center", + direction: "both", + background: "rgb(40, 40, 40)", + corner_radius: "5", + label { + "{inner_area}" + } + } + rect { + direction: "vertical", + display: "center", + width: "25", + height: "100%", + label { + width: "100%", + align: "center", + "{paddings.right()}" + } } } rect { - direction: "vertical", + direction: "both", display: "center", - width: "25", - height: "100%", + width: "100%", + height: "25", label { width: "100%", align: "center", - "{paddings.right()}" + "{paddings.bottom()}" } } } - rect { - direction: "both", - display: "center", - width: "100%", - height: "25", - label { - width: "100%", - align: "center", - "{paddings.bottom()}" - } - } } } } } - } - ) + ) + } else { + None + } } diff --git a/devtools/src/tabs/style.rs b/devtools/src/tabs/style.rs index d40e034b4..da54b1f50 100644 --- a/devtools/src/tabs/style.rs +++ b/devtools/src/tabs/style.rs @@ -16,133 +16,137 @@ use crate::{ #[allow(non_snake_case)] #[inline_props] pub fn NodeInspectorStyle(cx: Scope, node_id: NodeId) -> Element { - let node = use_selected_node(cx, &node_id).unwrap(); + let node = use_selected_node(cx, &cx.props.node_id); - render!( - rect { - overflow: "clip", - width: "100%", - height: "50%", - NodeInspectorBar { - node_id: *node_id - } - ScrollView { - show_scrollbar: true, - height: "calc(100% - 35)", + if let Some(node) = node { + render!( + rect { + overflow: "clip", width: "100%", - node.state.iter().enumerate().map(|(i, (name, attr))| { - match attr { - AttributeType::Measure(measure) => { - rsx!{ - Property { - key: "{i}", - name: "{name}", - value: measure.to_string() + height: "50%", + NodeInspectorBar { + node_id: *node_id + } + ScrollView { + show_scrollbar: true, + height: "calc(100% - 35)", + width: "100%", + node.state.iter().enumerate().map(|(i, (name, attr))| { + match attr { + AttributeType::Measure(measure) => { + rsx!{ + Property { + key: "{i}", + name: "{name}", + value: measure.to_string() + } } } - } - AttributeType::Measures(measures) => { - rsx!{ - Property { - key: "{i}", - name: "{name}", - value: measures.pretty() + AttributeType::Measures(measures) => { + rsx!{ + Property { + key: "{i}", + name: "{name}", + value: measures.pretty() + } } } - } - AttributeType::CornerRadius(radius) => { - rsx!{ - Property { - key: "{i}", - name: "{name}", - value: radius.pretty() + AttributeType::CornerRadius(radius) => { + rsx!{ + Property { + key: "{i}", + name: "{name}", + value: radius.pretty() + } } } - } - AttributeType::Size(size) => { - rsx!{ - Property { - key: "{i}", - name: "{name}", - value: size.pretty() + AttributeType::Size(size) => { + rsx!{ + Property { + key: "{i}", + name: "{name}", + value: size.pretty() + } } } - } - AttributeType::Color(fill) => { - rsx!{ - ColorProperty { - key: "{i}", - name: "{name}", - fill: fill.clone() + AttributeType::Color(fill) => { + rsx!{ + ColorProperty { + key: "{i}", + name: "{name}", + fill: fill.clone() + } } } - } - AttributeType::LinearGradient(fill) => { - rsx!{ - LinearGradientProperty { - key: "{i}", - name: "{name}", - fill: fill.clone() + AttributeType::LinearGradient(fill) => { + rsx!{ + LinearGradientProperty { + key: "{i}", + name: "{name}", + fill: fill.clone() + } } } - } - AttributeType::Border(border) => { - rsx!{ - BorderProperty { - key: "{i}", - name: "{name}", - border: border.clone() + AttributeType::Border(border) => { + rsx!{ + BorderProperty { + key: "{i}", + name: "{name}", + border: border.clone() + } } } - } - AttributeType::Text(text) => { - rsx!{ - Property { - key: "{i}", - name: "{name}", - value: text.to_string() + AttributeType::Text(text) => { + rsx!{ + Property { + key: "{i}", + name: "{name}", + value: text.to_string() + } } } - } - AttributeType::Direction(direction) => { - rsx!{ - Property { - key: "{i}", - name: "{name}", - value: direction.pretty() + AttributeType::Direction(direction) => { + rsx!{ + Property { + key: "{i}", + name: "{name}", + value: direction.pretty() + } } } - } - AttributeType::Display(display) => { - rsx!{ - Property { - key: "{i}", - name: "{name}", - value: display.pretty() + AttributeType::Display(display) => { + rsx!{ + Property { + key: "{i}", + name: "{name}", + value: display.pretty() + } } } - } - AttributeType::Shadow(shadow) => { - rsx!{ - ShadowProperty { - key: "{i}", - name: "{name}", - shadow: shadow.clone() + AttributeType::Shadow(shadow) => { + rsx!{ + ShadowProperty { + key: "{i}", + name: "{name}", + shadow: shadow.clone() + } } } - } - AttributeType::TextShadow(text_shadow) => { - rsx!{ - TextShadowProperty { - key: "{i}", - name: "{name}", - text_shadow: text_shadow.clone() + AttributeType::TextShadow(text_shadow) => { + rsx!{ + TextShadowProperty { + key: "{i}", + name: "{name}", + text_shadow: *text_shadow + } } } } - } - }) + }) + } } - } - ) + ) + } else { + None + } } From 479c801c31955257d32e58123d7dcbd08bdd90d7 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Wed, 2 Aug 2023 22:54:21 +0200 Subject: [PATCH 6/6] update std --- Cargo.toml | 2 +- README.md | 2 +- book/src/guides/getting_started.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b45d94143..9d6b04cab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,7 +66,7 @@ freya-node-state = { workspace = true } reqwest = { version = "0.11.13", features = ["json"] } serde = "1.0.152" tracing-subscriber = "0.2.25" -dioxus-std = { git = "https://github.com/marc2332/dioxus-std", rev = "4974f9e4e421b9036d9438ef33d4496559a76855", features = ["utils", "i18n"] } +dioxus-std = { version = "0.4", features = ["utils", "i18n"] } rand = "0.8.5" [profile.release] diff --git a/README.md b/README.md index f4e9828b6..8426ec831 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Add Freya as a dependency via git (it's not published on [crates.io](https://cra ```toml freya = { git = "https://github.com/marc2332/freya" } -dioxus = { version = "0.4", features = ["macro", "hooks"]} +dioxus = { version = "0.4", features = ["macro", "hooks"] } ``` ### Features ✨ diff --git a/book/src/guides/getting_started.md b/book/src/guides/getting_started.md index feb557792..d82533484 100644 --- a/book/src/guides/getting_started.md +++ b/book/src/guides/getting_started.md @@ -24,7 +24,7 @@ edition = "2021" [dependencies] freya = { git = "https://github.com/marc2332/freya" } -dioxus = { version = "0.4", features = ["macro", "hooks"]} +dioxus = { version = "0.4", features = ["macro", "hooks"] } ``` ### src/main.rs