Merge branch 'master' into pr/atty303/1349
This commit is contained in:
commit
7033276c34
444 files changed
+2868
-14315
No files matched your search
@@ -18,7 +18,7 @@ serde_repr = { version = "0.1", optional = true }
|
||||
wasm-bindgen = { workspace = true, optional = true }
|
||||
euclid = "0.22.7"
|
||||
enumset = "1.0.11"
|
||||
keyboard-types = "0.6.2"
|
||||
keyboard-types = "0.7"
|
||||
async-trait = "0.1.58"
|
||||
serde-value = "0.7.0"
|
||||
tokio = { workspace = true, features = ["fs", "io-util"], optional = true }
|
||||
|
||||
+4
-11
@@ -1,6 +1,5 @@
|
||||
# `dioxus-html`: Html (and SVG) Namespace for Dioxus
|
||||
|
||||
|
||||
[![Crates.io][crates-badge]][crates-url]
|
||||
[![MIT licensed][mit-badge]][mit-url]
|
||||
[![Build Status][actions-badge]][actions-url]
|
||||
@@ -8,22 +7,18 @@
|
||||
|
||||
[crates-badge]: https://img.shields.io/crates/v/dioxus-html.svg
|
||||
[crates-url]: https://crates.io/crates/dioxus-html
|
||||
|
||||
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
|
||||
[mit-url]: https://github.com/dioxuslabs/dioxus/blob/master/LICENSE
|
||||
|
||||
[actions-badge]: https://github.com/dioxuslabs/dioxus/actions/workflows/main.yml/badge.svg
|
||||
[actions-url]: https://github.com/dioxuslabs/dioxus/actions?query=workflow%3ACI+branch%3Amaster
|
||||
|
||||
[discord-badge]: https://img.shields.io/discord/899851952891002890.svg?logo=discord&style=flat-square
|
||||
[discord-url]: https://discord.gg/XgGxMSkvUM
|
||||
|
||||
[Website](https://dioxuslabs.com) |
|
||||
[Guides](https://dioxuslabs.com/docs/0.3/guide/en/) |
|
||||
[Guides](https://dioxuslabs.com/learn/0.4/) |
|
||||
[API Docs](https://docs.rs/dioxus-html/latest/dioxus_html) |
|
||||
[Chat](https://discord.gg/XgGxMSkvUM)
|
||||
|
||||
|
||||
## Overview
|
||||
|
||||
The Dioxus `rsx!` and `html!` macros can accept any compile-time correct namespace on top of NodeFactory. This crate provides the HTML (and SVG) namespaces which get imported in the Dioxus prelude.
|
||||
@@ -64,6 +59,7 @@ All elements should be defined as a zero-sized-struct (also known as unit struct
|
||||
Attributes would then be implemented as constants on these unit structs.
|
||||
|
||||
The HTML namespace is defined mostly with macros. However, the expanded form would look something like this:
|
||||
|
||||
```rust
|
||||
struct base;
|
||||
impl DioxusElement for base {
|
||||
@@ -75,8 +71,8 @@ impl base {
|
||||
const target: (&'static str, Option<'static str>, bool) = ("target", None, false);
|
||||
}
|
||||
```
|
||||
Because attributes are defined as methods on the unit struct, they guard the attribute creation behind a compile-time correct interface.
|
||||
|
||||
Because attributes are defined as methods on the unit struct, they guard the attribute creation behind a compile-time correct interface.
|
||||
|
||||
## How to extend it:
|
||||
|
||||
@@ -93,16 +89,13 @@ mod dioxus_elements {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
- Report issues on our [issue tracker](https://github.com/dioxuslabs/dioxus/issues).
|
||||
- Join the discord and ask questions!
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the [MIT license].
|
||||
|
||||
[mit license]: https://github.com/DioxusLabs/dioxus/blob/master/LICENSE-MIT
|
||||
|
||||
@@ -1265,6 +1265,8 @@ builder_constructors! {
|
||||
spellcheck: BoolOrDefault DEFAULT,
|
||||
wrap: Wrap DEFAULT,
|
||||
value: String volatile,
|
||||
|
||||
initial_value: String DEFAULT,
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{collections::HashMap, fmt::Debug};
|
||||
use std::{any::Any, collections::HashMap, fmt::Debug};
|
||||
|
||||
use dioxus_core::Event;
|
||||
|
||||
@@ -45,6 +45,12 @@ impl FileEngine for SerializedFileEngine {
|
||||
.await
|
||||
.map(|bytes| String::from_utf8_lossy(&bytes).to_string())
|
||||
}
|
||||
|
||||
async fn get_native_file(&self, file: &str) -> Option<Box<dyn Any>> {
|
||||
self.read_file(file)
|
||||
.await
|
||||
.map(|val| Box::new(val) as Box<dyn Any>)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
@@ -89,6 +95,9 @@ pub trait FileEngine {
|
||||
|
||||
// read a file to string
|
||||
async fn read_file_to_string(&self, file: &str) -> Option<String>;
|
||||
|
||||
// returns a file in platform's native representation
|
||||
async fn get_native_file(&self, file: &str) -> Option<Box<dyn Any>>;
|
||||
}
|
||||
|
||||
impl_event! {
|
||||
|
||||
@@ -108,7 +108,7 @@ impl_event! {
|
||||
///
|
||||
/// ## Example
|
||||
/// ```rust, ignore
|
||||
/// rsx!( button { "click me", onclick: move |_| log::info!("Clicked!`") } )
|
||||
/// rsx!( button { "click me", onclick: move |_| tracing::info!("Clicked!`") } )
|
||||
/// ```
|
||||
///
|
||||
/// ## Reference
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use std::any::Any;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::FileEngine;
|
||||
@@ -40,4 +41,9 @@ impl FileEngine for NativeFileEngine {
|
||||
|
||||
Some(contents)
|
||||
}
|
||||
|
||||
async fn get_native_file(&self, file: &str) -> Option<Box<dyn Any>> {
|
||||
let file = File::open(file).await.ok()?;
|
||||
Some(Box::new(file))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user