From ca0e1fb9ab61466d61dbff1671612852e6a06497 Mon Sep 17 00:00:00 2001 From: bluekey Date: Sun, 23 Apr 2023 17:15:06 +0200 Subject: [PATCH 01/10] added select element example --- examples/inputs.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/examples/inputs.rs b/examples/inputs.rs index cf848d99e..311afc1f0 100644 --- a/examples/inputs.rs +++ b/examples/inputs.rs @@ -37,6 +37,7 @@ const FIELDS: &[(&str, &str)] = &[ fn app(cx: Scope) -> Element { cx.render(rsx! { div { margin_left: "30px", + select_example(cx), div { // handling inputs on divs will catch all input events below // so the value of our input event will be either huey, dewey, louie, or true/false (because of the checkboxe) @@ -134,3 +135,34 @@ fn app(cx: Scope) -> Element { } }) } + +fn select_example(cx: Scope) -> Element { + cx.render(rsx! { + div { + select { + id: "selection", + name: "selection", + multiple: true, + oninput: move |evt| { + println!("{evt:?}"); + }, + option { + value : "Option 1", + label : "Option 1", + } + option { + value : "Option 2", + label : "Option 2", + selected : true, + }, + option { + value : "Option 3", + label : "Option 3", + } + } + label { + r#for: "selection", + "select element" + } + }}) +} From 3317dc3e177e80ff62ba1b3a5f66e942d222f051 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Sat, 29 Apr 2023 07:58:43 -0500 Subject: [PATCH 02/10] fix the link to tui widgets in the guide --- docs/guide/src/en/custom_renderer/index.md | 2 +- docs/guide/src/en/getting_started/tui.md | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/guide/src/en/custom_renderer/index.md b/docs/guide/src/en/custom_renderer/index.md index 2d4ddb759..b531593dc 100644 --- a/docs/guide/src/en/custom_renderer/index.md +++ b/docs/guide/src/en/custom_renderer/index.md @@ -15,7 +15,7 @@ Essentially, your renderer needs to process edits and generate events to update Internally, Dioxus handles the tree relationship, diffing, memory management, and the event system, leaving as little as possible required for renderers to implement themselves. -For reference, check out the [javascript interpreter](https://github.com/DioxusLabs/dioxus/tree/master/packages/interpreter) or [tui renderer](https://github.com/DioxusLabs/dioxus/tree/master/packages/tui) as a starting point for your custom renderer. +For reference, check out the [javascript interpreter](https://github.com/DioxusLabs/dioxus/tree/master/packages/interpreter) or [tui renderer](https://github.com/DioxusLabs/dioxus/tree/master/packages/dioxus-tui) as a starting point for your custom renderer. ## Templates diff --git a/docs/guide/src/en/getting_started/tui.md b/docs/guide/src/en/getting_started/tui.md index e49cb84a8..4e8d36cf9 100644 --- a/docs/guide/src/en/getting_started/tui.md +++ b/docs/guide/src/en/getting_started/tui.md @@ -12,14 +12,12 @@ TUI support is currently quite experimental. But, if you're willing to venture i - It uses flexbox for the layout - It only supports a subset of the attributes and elements -- Regular widgets will not work in the tui render, but the tui renderer has its own widget components that start with a capital letter. See the [widgets example](https://github.com/DioxusLabs/dioxus/blob/master/packages/tui/examples/widgets.rs) +- Regular widgets will not work in the tui render, but the tui renderer has its own widget components that start with a capital letter. See the [widgets example](https://github.com/DioxusLabs/dioxus/blob/master/packages/dioxus-tui/examples/widgets.rs) - 1px is one character line height. Your regular CSS px does not translate - If your app panics, your terminal is wrecked. This will be fixed eventually - ## Getting Set up - Start by making a new package and adding Dioxus and the TUI renderer as dependancies. ```shell From 74cb70590c1b50d8f9bbaf82411e6c3c8a8223e0 Mon Sep 17 00:00:00 2001 From: stephenandary Date: Sat, 29 Apr 2023 11:44:28 -0400 Subject: [PATCH 03/10] WIP - Initial commit of devcontainer --- .devcontainer/devcontainer.json | 28 +++++++++++++++++++ .../linux/devcontainer-feature.json | 4 +++ .devcontainer/local-features/linux/install.sh | 6 ++++ 3 files changed, 38 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/local-features/linux/devcontainer-feature.json create mode 100644 .devcontainer/local-features/linux/install.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..1c5278332 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,28 @@ +{ + "name": "dioxus", + "image": "mcr.microsoft.com/devcontainers/rust:latest", + "features": { + "ghcr.io/devcontainers/features/common-utils:2": {}, + "./local-features/linux": {} + }, + "containerEnv": { + "RUST_LOG": "INFO" + }, + "customizations": { + "vscode": { + "settings": { + "files.watcherExclude": { + "**/target/**": true + }, + "[rust]": { + "editor.formatOnSave": true + } + }, + "extensions": [ + "rust-lang.rust-analyzer", + "tamasfe.even-better-toml", + "serayuzgur.crates" + ] + } + } +} \ No newline at end of file diff --git a/.devcontainer/local-features/linux/devcontainer-feature.json b/.devcontainer/local-features/linux/devcontainer-feature.json new file mode 100644 index 000000000..daba5bc1f --- /dev/null +++ b/.devcontainer/local-features/linux/devcontainer-feature.json @@ -0,0 +1,4 @@ +{ + "id": "linux", + "version": "0.0.1" +} \ No newline at end of file diff --git a/.devcontainer/local-features/linux/install.sh b/.devcontainer/local-features/linux/install.sh new file mode 100644 index 000000000..8f9ad5e1a --- /dev/null +++ b/.devcontainer/local-features/linux/install.sh @@ -0,0 +1,6 @@ +#!/bin/bash +echo "Update Apt Database" +sudo apt-get update + +echo "Install Webkit Dependencies" +sudo apt-get -qq install build-essential libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev From a78ee4ffe77ad68a2b6e677446853bef3b086584 Mon Sep 17 00:00:00 2001 From: stephenandary Date: Mon, 1 May 2023 14:12:08 -0400 Subject: [PATCH 04/10] WIP - Update devcontainer to use debian bookworm --- .devcontainer/Dockerfile | 9 +++++++++ .devcontainer/devcontainer.json | 15 ++++++++++++--- .../linux/devcontainer-feature.json | 4 ---- .devcontainer/local-features/linux/install.sh | 6 ------ 4 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 .devcontainer/Dockerfile delete mode 100644 .devcontainer/local-features/linux/devcontainer-feature.json delete mode 100644 .devcontainer/local-features/linux/install.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..b20e962b9 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,9 @@ +# [Choice] Debian OS version (use bullseye on local arm64/Apple Silicon): buster, bullseye +ARG VARIANT="slim-bookworm" +FROM rust:${VARIANT} +ENV DEBIAN_FRONTEND noninteractive +RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections + +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive + +RUN apt-get -qq install build-essential libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1c5278332..aa536ab53 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,9 +1,18 @@ { "name": "dioxus", - "image": "mcr.microsoft.com/devcontainers/rust:latest", + "remoteUser": "vscode", + "build": { + "dockerfile": "./Dockerfile", + "context": "." + }, "features": { - "ghcr.io/devcontainers/features/common-utils:2": {}, - "./local-features/linux": {} + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": "true", + "username": "vscode", + "uid": "1000", + "gid": "1000", + "upgradePackages": "true" + } }, "containerEnv": { "RUST_LOG": "INFO" diff --git a/.devcontainer/local-features/linux/devcontainer-feature.json b/.devcontainer/local-features/linux/devcontainer-feature.json deleted file mode 100644 index daba5bc1f..000000000 --- a/.devcontainer/local-features/linux/devcontainer-feature.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "linux", - "version": "0.0.1" -} \ No newline at end of file diff --git a/.devcontainer/local-features/linux/install.sh b/.devcontainer/local-features/linux/install.sh deleted file mode 100644 index 8f9ad5e1a..000000000 --- a/.devcontainer/local-features/linux/install.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -echo "Update Apt Database" -sudo apt-get update - -echo "Install Webkit Dependencies" -sudo apt-get -qq install build-essential libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev From 856650eb4d4c898af323fa4750e0a1bf2db9ac6a Mon Sep 17 00:00:00 2001 From: stephenandary Date: Mon, 1 May 2023 14:25:54 -0400 Subject: [PATCH 05/10] WIP - Add README --- .devcontainer/README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .devcontainer/README.md diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 000000000..74dbbe8c5 --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,26 @@ +# Dev Container + +A dev container in the most simple context allows one to create a consistent development environment within a docker container that can easily be opened locally or remotely via codespaces such that contributors don't need to install anything to contribute. + +## Useful Links + +- +- +- +- + +## Using A Dev Container + +### Locally + +To use this dev container locally, make sure Docker is installed and in VSCode install the `ms-vscode-remote.remote-containers` extension. Then from the root of Dioxus you can type `Ctrl + Shift + P`, then choose `Dev Containers: Rebuild and Reopen in Devcontainer`. + +### Codespaces + +TBD + +## Troubleshooting + +If having difficulty commiting with github, and you use ssh or gpg keys, you may need to ensure that the keys are being shared properly between your host and VSCode. + +Though VSCode does a pretty good job sharing credentials between host and devcontainer, to save some time you can always just reopen the container locally to commit with `Ctrl + Shift + P`, then choose `Dev Containers: Reopen Folder Locally` From e68c806f8ce294cc855c116db3a2ba0d26cc6bd3 Mon Sep 17 00:00:00 2001 From: stephenandary Date: Mon, 1 May 2023 14:27:47 -0400 Subject: [PATCH 06/10] WIP - Update Readme Codespaces section with setup link --- .devcontainer/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/README.md b/.devcontainer/README.md index 74dbbe8c5..570435663 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -17,7 +17,7 @@ To use this dev container locally, make sure Docker is installed and in VSCode i ### Codespaces -TBD +[Codespaces Setup](https://docs.github.com/en/codespaces/developing-in-codespaces/creating-a-codespace-for-a-repository#creating-a-codespace-for-a-repository) ## Troubleshooting From 5f3c3d3f04217fcd1d58b5a182ee19dfba369037 Mon Sep 17 00:00:00 2001 From: stephenandary Date: Mon, 1 May 2023 14:49:38 -0400 Subject: [PATCH 07/10] WIP - Update base image to nightly so format on save works --- .devcontainer/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index b20e962b9..c0e58fab8 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,6 +1,6 @@ # [Choice] Debian OS version (use bullseye on local arm64/Apple Silicon): buster, bullseye -ARG VARIANT="slim-bookworm" -FROM rust:${VARIANT} +ARG VARIANT="nightly-bookworm-slim" +FROM rustlang/rust:${VARIANT} ENV DEBIAN_FRONTEND noninteractive RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections From d3cf9f728c6d501944c143baa1e39d77ac9b0f45 Mon Sep 17 00:00:00 2001 From: stephenandary Date: Mon, 1 May 2023 14:54:21 -0400 Subject: [PATCH 08/10] WIP - remove comment in Dockerfile --- .devcontainer/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index c0e58fab8..e2fd03ad8 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,3 @@ -# [Choice] Debian OS version (use bullseye on local arm64/Apple Silicon): buster, bullseye ARG VARIANT="nightly-bookworm-slim" FROM rustlang/rust:${VARIANT} ENV DEBIAN_FRONTEND noninteractive From ed4709101c681b15de7d6ef5f290277f04daf059 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Tue, 2 May 2023 09:38:58 -0500 Subject: [PATCH 09/10] fix duplicate example names --- .../{all_events.rs => all_terminal_events.rs} | 0 packages/dioxus-tui/examples/components.rs | 67 ----------------- .../{stress.rs => many_small_edit_stress.rs} | 0 packages/dioxus-tui/examples/quadrants.rs | 71 ++++++++++--------- .../{readme.rs => readme_hello_world.rs} | 0 packages/native-core/src/tree.rs | 2 +- .../{counter.rs => counter_button.rs} | 0 packages/rink/src/widget.rs | 2 +- .../examples/{simple.rs => simple_routes.rs} | 0 9 files changed, 41 insertions(+), 101 deletions(-) rename packages/dioxus-tui/examples/{all_events.rs => all_terminal_events.rs} (100%) delete mode 100644 packages/dioxus-tui/examples/components.rs rename packages/dioxus-tui/examples/{stress.rs => many_small_edit_stress.rs} (100%) rename packages/dioxus-tui/examples/{readme.rs => readme_hello_world.rs} (100%) rename packages/rink/examples/{counter.rs => counter_button.rs} (100%) rename packages/router/examples/{simple.rs => simple_routes.rs} (100%) diff --git a/packages/dioxus-tui/examples/all_events.rs b/packages/dioxus-tui/examples/all_terminal_events.rs similarity index 100% rename from packages/dioxus-tui/examples/all_events.rs rename to packages/dioxus-tui/examples/all_terminal_events.rs diff --git a/packages/dioxus-tui/examples/components.rs b/packages/dioxus-tui/examples/components.rs deleted file mode 100644 index 45ed56338..000000000 --- a/packages/dioxus-tui/examples/components.rs +++ /dev/null @@ -1,67 +0,0 @@ -#![allow(non_snake_case)] - -use dioxus::prelude::*; -use dioxus_tui::Config; - -fn main() { - dioxus_tui::launch_cfg(app, Config::default()); -} - -#[derive(Props, PartialEq)] -struct QuadrentProps { - color: String, - text: String, -} - -fn Quadrant(cx: Scope) -> Element { - cx.render(rsx! { - div { - border_width: "1px", - width: "50%", - height: "100%", - background_color: "{cx.props.color}", - justify_content: "center", - align_items: "center", - - "{cx.props.text}" - } - }) -} - -fn app(cx: Scope) -> Element { - cx.render(rsx! { - div { - width: "100%", - height: "100%", - flex_direction: "column", - - div { - width: "100%", - height: "50%", - flex_direction: "row", - Quadrant{ - color: "red".to_string(), - text: "[A]".to_string() - }, - Quadrant{ - color: "black".to_string(), - text: "[B]".to_string() - } - } - - div { - width: "100%", - height: "50%", - flex_direction: "row", - Quadrant{ - color: "green".to_string(), - text: "[C]".to_string() - }, - Quadrant{ - color: "blue".to_string(), - text: "[D]".to_string() - } - } - } - }) -} diff --git a/packages/dioxus-tui/examples/stress.rs b/packages/dioxus-tui/examples/many_small_edit_stress.rs similarity index 100% rename from packages/dioxus-tui/examples/stress.rs rename to packages/dioxus-tui/examples/many_small_edit_stress.rs diff --git a/packages/dioxus-tui/examples/quadrants.rs b/packages/dioxus-tui/examples/quadrants.rs index d9da5dcb5..45ed56338 100644 --- a/packages/dioxus-tui/examples/quadrants.rs +++ b/packages/dioxus-tui/examples/quadrants.rs @@ -1,7 +1,31 @@ +#![allow(non_snake_case)] + use dioxus::prelude::*; +use dioxus_tui::Config; fn main() { - dioxus_tui::launch(app); + dioxus_tui::launch_cfg(app, Config::default()); +} + +#[derive(Props, PartialEq)] +struct QuadrentProps { + color: String, + text: String, +} + +fn Quadrant(cx: Scope) -> Element { + cx.render(rsx! { + div { + border_width: "1px", + width: "50%", + height: "100%", + background_color: "{cx.props.color}", + justify_content: "center", + align_items: "center", + + "{cx.props.text}" + } + }) } fn app(cx: Scope) -> Element { @@ -15,22 +39,13 @@ fn app(cx: Scope) -> Element { width: "100%", height: "50%", flex_direction: "row", - div { - border_width: "1px", - width: "50%", - height: "100%", - background_color: "red", - justify_content: "center", - align_items: "center", - "[A]" - } - div { - width: "50%", - height: "100%", - background_color: "black", - justify_content: "center", - align_items: "center", - "[B]" + Quadrant{ + color: "red".to_string(), + text: "[A]".to_string() + }, + Quadrant{ + color: "black".to_string(), + text: "[B]".to_string() } } @@ -38,21 +53,13 @@ fn app(cx: Scope) -> Element { width: "100%", height: "50%", flex_direction: "row", - div { - width: "50%", - height: "100%", - background_color: "green", - justify_content: "center", - align_items: "center", - "[C]" - } - div { - width: "50%", - height: "100%", - background_color: "blue", - justify_content: "center", - align_items: "center", - "[D]" + Quadrant{ + color: "green".to_string(), + text: "[C]".to_string() + }, + Quadrant{ + color: "blue".to_string(), + text: "[D]".to_string() } } } diff --git a/packages/dioxus-tui/examples/readme.rs b/packages/dioxus-tui/examples/readme_hello_world.rs similarity index 100% rename from packages/dioxus-tui/examples/readme.rs rename to packages/dioxus-tui/examples/readme_hello_world.rs diff --git a/packages/native-core/src/tree.rs b/packages/native-core/src/tree.rs index df25deac3..e0c55eece 100644 --- a/packages/native-core/src/tree.rs +++ b/packages/native-core/src/tree.rs @@ -178,7 +178,7 @@ impl<'a> TreeMut for TreeMutView<'a> { fn set_height(tree: &mut TreeMutView<'_>, node: NodeId, height: u16) { let children = { let mut node_data_mut = &mut tree.1; - let mut node = (&mut node_data_mut).get(node).unwrap(); + let node = (&mut node_data_mut).get(node).unwrap(); node.height = height; node.children.clone() }; diff --git a/packages/rink/examples/counter.rs b/packages/rink/examples/counter_button.rs similarity index 100% rename from packages/rink/examples/counter.rs rename to packages/rink/examples/counter_button.rs diff --git a/packages/rink/src/widget.rs b/packages/rink/src/widget.rs index 7c6645692..ab9044998 100644 --- a/packages/rink/src/widget.rs +++ b/packages/rink/src/widget.rs @@ -26,7 +26,7 @@ impl<'a> RinkBuffer<'a> { // panic!("({x}, {y}) is not in {area:?}"); return; } - let mut cell = self.buf.get_mut(x, y); + let cell = self.buf.get_mut(x, y); cell.bg = convert(self.cfg.rendering_mode, new.bg.blend(cell.bg)); if new.symbol.is_empty() { if !cell.symbol.is_empty() { diff --git a/packages/router/examples/simple.rs b/packages/router/examples/simple_routes.rs similarity index 100% rename from packages/router/examples/simple.rs rename to packages/router/examples/simple_routes.rs From b6463e4b27ff1a178c5269535fae4f015ab76ed4 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Thu, 4 May 2023 12:04:21 -0700 Subject: [PATCH 10/10] bump core --- packages/core/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index b86466692..af0feba9c 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-core" -version = "0.3.2" +version = "0.3.3" authors = ["Jonathan Kelley"] edition = "2018" description = "Core functionality for Dioxus - a concurrent renderer-agnostic Virtual DOM for interactive user experiences"