fix: readme and examples syntax

This commit is contained in:
Jonathan Kelley committed 2021-12-28 23:48:25 -05:00
1 parent f24aae8787
commit 3dc0e59876
102 files changed
+213 -1222

No files matched your search

+7 -7
View File
@@ -7,7 +7,7 @@ fn main() {
dioxus::desktop::launch(App)
}
static App: Component<()> = |cx| {
static App: Component = |cx| {
let (count, set_count) = use_state(&cx, || 0);
cx.render(rsx!(
@@ -34,7 +34,7 @@ Window management, system trays, notifications, and other desktop-related functi
Managing windows is done by simply rendering content into a `WebviewWindow` component.
```rust
static App: Component<()> = |cx| {
static App: Component = |cx| {
rsx!(cx, WebviewWindow { "hello world" } )
}
```
@@ -46,7 +46,7 @@ Notifications also use a declarative approach. Sending a notification has never
The api has been somewhat modeled after https://github.com/mikaelbr/node-notifier
```rust
static Notifications: Component<()> = |cx| {
static Notifications: Component = |cx| {
cx.render(rsx!(
Notification {
title: "title"
@@ -78,7 +78,7 @@ static Notifications: Component<()> = |cx| {
Dioxus Desktop supports app trays, which can be built with native menu groups or with a custom window.
```rust
static Tray: Component<()> = |cx| {
static Tray: Component = |cx| {
cx.render(rsx!(
GlobalTray {
MenuGroup {
@@ -90,7 +90,7 @@ static Tray: Component<()> = |cx| {
};
// using a builder
static Tray: Component<()> = |cx| {
static Tray: Component = |cx| {
let menu = MenuGroup::builder(cx)
.with_items([
MenuGroupItem::builder()
@@ -107,7 +107,7 @@ static Tray: Component<()> = |cx| {
}
// or with a custom window
static Tray: Component<()> = |cx| {
static Tray: Component = |cx| {
rsx!(cx, GlobalTray { div { "custom buttons here" } })
};
```
@@ -116,7 +116,7 @@ static Tray: Component<()> = |cx| {
Declaring menus is convenient and cross-platform.
```rust
static Menu: Component<()> = |cx| {
static Menu: Component = |cx| {
cx.render(rsx!(
MenuBarMajorItem { title: "File"
MenuGroup {
+3 -3
View File
@@ -56,7 +56,7 @@ pub struct WebviewWindowProps<'a> {
///
///
///
pub fn WebviewWindow(cx: Context, props: &WebviewWindowProps) -> Element {
pub fn WebviewWindow(cx: Scope<WebviewWindowProps>) -> Element {
let dtcx = cx.consume_state::<RefCell<DesktopContext>>()?;
cx.use_hook(
@@ -78,7 +78,7 @@ pub fn WebviewWindow(cx: Context, props: &WebviewWindowProps) -> Element {
pub struct WindowHandle {}
/// Get a handle to the current window from inside a component
pub fn use_current_window(cx: Context) -> Option<WindowHandle> {
pub fn use_current_window(cx: Scope) -> Option<WindowHandle> {
todo!()
}
@@ -90,7 +90,7 @@ fn syntax_works() {
use dioxus_hooks::*;
use dioxus_html as dioxus_elements;
static App: Component<()> = |cx| {
static App: Component = |cx| {
cx.render(rsx! {
// left window
WebviewWindow {
+2 -2
View File
@@ -28,11 +28,11 @@ use wry::{
webview::{WebView, WebViewBuilder},
};
pub fn launch(root: Component<()>) {
pub fn launch(root: Component) {
launch_with_props(root, (), |c| c)
}
pub fn launch_cfg(
root: Component<()>,
root: Component,
config_builder: impl for<'a, 'b> FnOnce(&'b mut DesktopConfig<'a>) -> &'b mut DesktopConfig<'a>,
) {
launch_with_props(root, (), config_builder)