wip: more examples

This commit is contained in:
Jonathan Kelley committed 2021-07-11 19:31:07 -04:00
1 parent 304259d818
commit 56e7eb83a9
21 files changed
+162 -236

No files matched your search

+4 -13
View File
@@ -1,24 +1,15 @@
fn main() {}
use dioxus::*;
use dioxus_core as dioxus;
use dioxus_core::prelude::*;
mod dioxus_elements {
use super::*;
pub struct div;
impl DioxusElement for div {
const TAG_NAME: &'static str = "str";
const NAME_SPACE: Option<&'static str> = None;
}
}
static Example: FC<()> = |cx| {
let list = (0..10).map(|f| {
//
LazyNodes::new(move |f: NodeFactory| todo!())
});
let list = (0..10).map(|f| LazyNodes::new(move |f| todo!()));
cx.render(LazyNodes::new(move |cx| {
let bump = cx.bump();
dioxus_core::builder::ElementBuilder::new(&cx, "h1")
cx.raw_element("div")
.children([
cx.text(format_args!("hello")),
cx.text(format_args!("hello")),
+1
View File
@@ -7,6 +7,7 @@
fn main() {}
use dioxus_core::prelude::*;
use dioxus_core::*;
use std::rc::Rc;
struct AppProps {
+4 -1
View File
@@ -44,6 +44,7 @@ pub fn fc_to_builder<T: Properties>(_: FC<T>) -> T::Builder {
T::builder()
}
use crate::nodebuilder::LazyNodes;
/// Create inline fragments
///
/// Fragments capture a series of children without rendering extra nodes.
@@ -53,5 +54,7 @@ pub fn fc_to_builder<T: Properties>(_: FC<T>) -> T::Builder {
use crate::prelude::*;
#[allow(non_upper_case_globals, non_snake_case)]
pub fn Fragment<'a>(cx: Context<'a, ()>) -> VNode<'a> {
cx.render(LazyNodes::new(move |f| f.fragment_from_iter(cx.children())))
cx.render(LazyNodes::new(move |f| {
f.fragment_from_iter(cx.children())
}))
}
+2 -2
View File
@@ -125,8 +125,8 @@ pub mod on {
use std::{fmt::Debug, ops::Deref, rc::Rc};
use crate::{
builder::ElementBuilder,
builder::NodeFactory,
innerlude::ElementBuilder,
innerlude::NodeFactory,
innerlude::{Attribute, Listener, RealDomNode, VNode},
};
use std::cell::Cell;
+15 -30
View File
@@ -28,10 +28,6 @@ pub mod tasks;
pub mod util;
pub mod virtual_dom;
pub mod builder {
pub use super::nodebuilder::*;
}
// types used internally that are important
pub(crate) mod innerlude {
pub use crate::bumpframe::*;
@@ -43,6 +39,7 @@ pub(crate) mod innerlude {
pub use crate::nodebuilder::*;
pub use crate::nodes::*;
pub use crate::scope::*;
pub use crate::serialize::*;
pub use crate::tasks::*;
pub use crate::util::*;
pub use crate::virtual_dom::*;
@@ -54,35 +51,23 @@ pub(crate) mod innerlude {
pub use dioxus_core_macro::{html, rsx};
}
/// Re-export common types for ease of development use.
/// Essential when working with the html! macro
pub use crate::{
innerlude::{
DioxusElement, DomEdit, LazyNodes, NodeFactory, RealDom, RealDomNode, ScopeIdx, FC,
},
virtual_dom::VirtualDom,
};
pub mod prelude {
pub use crate::component::{fc_to_builder, Fragment, Properties};
pub use crate::context::Context;
use crate::nodes;
pub use crate::styles::{AsAttr, StyleBuilder};
pub use crate::util::RealDomNode;
pub use crate::virtual_dom::VirtualDom;
pub use nodes::*;
pub use crate::nodebuilder::LazyNodes;
pub use crate::nodebuilder::{DioxusElement, NodeFactory};
// pub use nodes::iterables::IterableNodes;
/// This type alias is an internal way of abstracting over the static functions that represent components.
pub use crate::innerlude::FC;
// expose our bumpalo type
pub use bumpalo;
pub use bumpalo::Bump;
// Re-export the FC macro
pub use crate::nodebuilder as builder;
// pub use dioxus_core_macro::fc;
pub use crate::innerlude::{LazyNodes, NodeFactory, FC};
pub use crate::nodebuilder::DioxusElement;
pub use crate::nodes::VNode;
pub use crate::VirtualDom;
pub use dioxus_core_macro::{format_args_f, html, rsx, Props};
}
pub use crate::diff::DiffMachine;
pub use crate::virtual_dom::ScopeIdx;
pub mod exports {
// export important things here
}
+15 -2
View File
@@ -14,9 +14,8 @@ use bumpalo::Bump;
use crate::{
events::VirtualEvent,
innerlude::{Properties, RealDomNode, Scope, VComponent, VText, FC},
innerlude::{Properties, RealDomNode, Scope, VComponent, VFragment, VText, FC},
nodes::{Attribute, Listener, NodeKey, VNode},
prelude::{VElement, VFragment},
};
/// A virtual DOM element builder.
@@ -647,6 +646,20 @@ impl<'a> NodeFactory<'a> {
VNode::text(self.bump(), args)
}
/// Create an element builder
pub fn raw_element<'b>(
&'b self,
tag: &'static str,
) -> ElementBuilder<
'a,
'b,
bumpalo::collections::Vec<'a, Listener<'a>>,
bumpalo::collections::Vec<'a, Attribute<'a>>,
bumpalo::collections::Vec<'a, VNode<'a>>,
> {
ElementBuilder::new(self, tag)
}
/// Create an element builder
pub fn element<'b>(
&'b self,
+1 -1
View File
@@ -7,7 +7,7 @@
//!
//!
use crate::prelude::ScopeIdx;
use crate::innerlude::ScopeIdx;
use serde::{Deserialize, Serialize};
/// A `DomEdit` represents a serialzied form of the VirtualDom's trait-based API. This allows streaming edits across the
+1 -1
View File
@@ -19,7 +19,7 @@ use std::{
use futures_util::{Future, Stream, StreamExt};
use slotmap::{DefaultKey, SlotMap};
use crate::{events::EventTrigger, prelude::ScopeIdx};
use crate::{events::EventTrigger, innerlude::ScopeIdx};
pub type TaskSubmitter = Arc<dyn Fn(DTask)>;